Skip to content

Commit

Permalink
Fix invalid id value
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkohei13 committed Aug 9, 2024
1 parent 50818f3 commit d279ae2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ phpMyAdmin admin UI will be at http://localhost:8080

- Run the app with `docker-compose up; docker-compose down;`
- Login to playwright container with `docker exec -ti species-challenge-playwright-1 bash`
- Run tests with `python -m pytest -v`. Add `-s` option to the end to see print outputs.
- Run tests with `python -m pytest -v -s`. The `-s` option enables print outputs.

## OpenShift setup

Expand Down Expand Up @@ -77,6 +77,7 @@ Note that in order to create MariaDB database on Rahti, PHPMyAdmin data dump doe

### Next

* Fix autocomplete-added species min/max dates being 2022-??
* If user removes name and then trashes the participation, saving fails, and some data disappears.
* Should removal be completely different procedure, that only UPDATES trashed = 1, and does not UPDATE anything else?
* Trim whitespace from MX codes, both on read and write
Expand All @@ -100,6 +101,7 @@ Note that in order to create MariaDB database on Rahti, PHPMyAdmin data dump doe
- Accessibility
- Challenge sort order (int) for the front page - larger number shown on top
- Later / nice:
- Todo if simple form fullness verification field is not enough: Calculate taxon count on frontend, make backend validate this is same as taxa with dates.
- Show challenge days also on participation form (in case challenge is open, but challenge period has not yet started)
- If today is not within date begin and end, don't update taxon datw by clicking taxon name (now updates, but browser validation then prevents saving)
- Move login_url, api_url, target id yms. konfiguraatiotiedostoon
Expand Down
8 changes: 6 additions & 2 deletions app/templates/form_challenge100.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,14 @@
}

// Todo: comma between fin and swe only when both exist

// Replace . with _ in id, to be valid CSS selector
const id_underscore = id.replace(/\./g, '_');

newLi.innerHTML = `
<span class='taxon_name' title='Merkitse havaintopäivä tälle lajille'>${fin}, ${swe} (<em>${sci}</em>)</span>
<input title='Valitse havaintopäivä tälle lajille' type="date" id="${id}" name='taxa:${id}' value="" min="${min}" max="${max}">
<span class='clear_date' data-clear-for="${id}" title='Poista havaintopäivä'>❌</span>
<input title='Valitse havaintopäivä tälle lajille' type="date" id="${id_underscore}" name='taxa:${id}' value="" min="${min}" max="${max}">
<span class='clear_date' data-clear-for="${id_underscore}" title='Poista havaintopäivä'>❌</span>
<a href='https://laji.fi/taxon/${id}' target='_blank' class='taxon_info' title='Lisätietoa: ${fin}'>i</a>
`
// taxaList.appendChild(newLi); // Append to end of list
Expand Down
3 changes: 1 addition & 2 deletions tests-playwright/test_anon_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_anon_public_pages(browser):
# Access a challenge that doesn't exist, which should redirect to front page
page.goto("http://web:8081/haaste/99")
assert front_page_text in page.content()


# Access pages that require login
def test_anon_restricted_pages(browser):
Expand Down Expand Up @@ -50,6 +50,5 @@ def test_anon_restricted_pages(browser):
assert "Kirjaudu ensin sisään" in page.content()
assert front_page_text in page.content()


page.close()

8 changes: 6 additions & 2 deletions tests-playwright/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ def test_add_edit_participation(browser):

# Add taxa in different ways
page.fill("#MX_71896", "2024-01-01") # Add by filling in the field
page.fill("#MX_71663", "2024-06-01") # Add by filling in the field
page.click("#MX_73304_id") # Add by clicking the taxon name

# Add taxon by autocomplete
page.fill('input#autocomplete-input', 'valko')
page.click('#autocomplete-results > :first-child')
page.fill("#MX_66563", "2024-06-01") # Add by filling in the field

# Submit the form
page.click("#submit_button")

Expand All @@ -138,7 +142,7 @@ def test_add_edit_participation(browser):

# Remove taxon in different ways
page.fill("#MX_71896", "") # Editing field directly
page.click('span.clear_date[data-clear-for="MX_71663"]') # Clicking the clear button
page.click('span.clear_date[data-clear-for="MX_66563"]') # Clicking the clear button

# Submit the form
page.click("#submit_button")
Expand Down

0 comments on commit d279ae2

Please sign in to comment.