From 9d3281466827b0df922ee41f00e1df9ee1ec374c Mon Sep 17 00:00:00 2001 From: David Wallace Date: Fri, 5 Apr 2024 17:56:50 +0200 Subject: [PATCH] tests: refactor frontend import options test --- rdmo/management/tests/test_frontend_import_options.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rdmo/management/tests/test_frontend_import_options.py b/rdmo/management/tests/test_frontend_import_options.py index 773a32a664..1a5048a7cf 100644 --- a/rdmo/management/tests/test_frontend_import_options.py +++ b/rdmo/management/tests/test_frontend_import_options.py @@ -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: @@ -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() @@ -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()