Skip to content

Commit

Permalink
tests(e2e): fix header info assertions in import options
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Jul 12, 2024
1 parent 208ee04 commit c4a1eb6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions rdmo/management/tests/test_frontend_import_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
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
OPTIONSETS_COUNTS = {
"total": 13,
"updated": 13,
"changed": 5,
"warnings": 1
}
OPTIONSETS_COUNTS_HEADER_INFOS = [f"{k.capitalize()}: {v}" for k,v in OPTIONSETS_COUNTS.items()]

@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 @@ -36,15 +42,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(f"Created: {OPTIONS_TOTAL_COUNT}")).to_be_visible(timeout=30_000)
expect(page.get_by_text(f"Created: {OPTIONSETS_COUNTS['total']}")).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(OPTIONS_TOTAL_COUNT)
expect(rows_displayed_in_ui).to_have_count(OPTIONSETS_COUNTS['total'])
# click the import button to start saving the instances to the db
page.get_by_role("button", name=f"Import {OPTIONS_TOTAL_COUNT} elements").click()
page.get_by_role("button", name=f"Import {OPTIONSETS_COUNTS['total']} elements").click()
expect(page.get_by_role("heading", name="Import successful")).to_be_visible()
page.screenshot(path="screenshots/management-import-optionsets-post-import.png", full_page=True)
page.get_by_text("Created:").click()
Expand All @@ -62,7 +68,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(f"Total: {OPTIONS_TOTAL_COUNT} Updated: {OPTIONS_TOTAL_COUNT} (Changed: 5) Warnings: 1")).to_be_visible(timeout=30_000) # noqa: E501
for text in OPTIONSETS_COUNTS_HEADER_INFOS:
expect(page.locator("#main")).to_contain_text(text)
expect(page.get_by_text("Filter changed (5)")).to_be_visible()
page.get_by_role("link", name="Show changes").click()
expect(page.locator(".col-sm-6 > .form-group").first).to_be_visible(timeout=30_000)
Expand Down

0 comments on commit c4a1eb6

Please sign in to comment.