Skip to content

Commit

Permalink
tests: refactor frontend import options test
Browse files Browse the repository at this point in the history
  • Loading branch information
MyPyDavid committed Apr 5, 2024
1 parent db2471e commit 9d32814
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rdmo/management/tests/test_frontend_import_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
test_users = [('editor', 'editor')]
import_xml = "./testing/xml/elements/optionsets.xml"
import_xml_1 = "./testing/xml/elements/updated-and-changed/optionsets-1.xml"
OPTIONS_TOTAL_COUNT = 13

@pytest.mark.parametrize("username, password", test_users) # consumed by fixture
def test_import_and_update_optionsets_in_management(logged_in_user: Page) -> None:
Expand All @@ -35,15 +36,15 @@ def test_import_and_update_optionsets_in_management(logged_in_user: Page) -> Non
expect(page.get_by_text("Import from: optionsets.xml")).to_be_visible(timeout=30_000)
## TODO test if ImportInfo numbers are correct
# test the components of the import-before-import staging page
expect(page.get_by_text("Created: 13")).to_be_visible(timeout=30_000)
expect(page.get_by_text(f"Created: {OPTIONS_TOTAL_COUNT}")).to_be_visible(timeout=30_000)
page.locator(".element-link").first.click()
page.get_by_role("link", name="Unselect all").click()
page.get_by_role("link", name="Select all", exact=True).click()
page.get_by_role("link", name="Show all", exact=True).click()
rows_displayed_in_ui = page.locator(".list-group > .list-group-item > .row.mt-10")
expect(rows_displayed_in_ui).to_have_count(13)
expect(rows_displayed_in_ui).to_have_count(OPTIONS_TOTAL_COUNT)
# click the import button to start saving the instances to the db
page.get_by_role("button", name="Import 13 elements").click()
page.get_by_role("button", name=f"Import {OPTIONS_TOTAL_COUNT} elements").click()
expect(page.get_by_role("heading", name="Import successful")).to_be_visible()
page.screenshot(path="screenshots/management-import-post-import.png", full_page=True)
page.get_by_text("Created:").click()
Expand All @@ -61,7 +62,8 @@ def test_import_and_update_optionsets_in_management(logged_in_user: Page) -> Non
page.locator('#sidebar div.elements-sidebar form.upload-form.sidebar-form div.sidebar-form-button button.btn.btn-primary').click() # noqa: E501
expect(page.get_by_text("Import from: optionsets-1.xml")).to_be_visible(timeout=40_000)
# assert changed elements
expect(page.get_by_text("Total: 13 Updated: 13 (Changed: 5) Warnings: 1")).to_be_visible(timeout=30_000)
expect(page.get_by_text(f"Total: {OPTIONS_TOTAL_COUNT} Updated: {OPTIONS_TOTAL_COUNT} (Changed: 5) Warnings: 1")).to_be_visible(timeout=30_000) # noqa: E501

expect(page.get_by_text("Filter changed (5)")).to_be_visible()
page.get_by_text("Filter changed (5)").click()
page.get_by_role("link", name="Show changes").click()
Expand Down

0 comments on commit 9d32814

Please sign in to comment.