From 1b1b26e8b2dc82dca498699bd1f66a0211c4daf1 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Wed, 9 Oct 2024 10:38:09 +0200 Subject: [PATCH] :white_check_mark: [#390] Add test for OIDC login in frontend --- .../api/tests/test_oidc_auth.py | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/backend/src/openarchiefbeheer/api/tests/test_oidc_auth.py b/backend/src/openarchiefbeheer/api/tests/test_oidc_auth.py index 6db311c74..773fd075d 100644 --- a/backend/src/openarchiefbeheer/api/tests/test_oidc_auth.py +++ b/backend/src/openarchiefbeheer/api/tests/test_oidc_auth.py @@ -62,26 +62,29 @@ async def test_login_admin_staff_with_oidc(self): page_text = page.get_by_text("You don't have permission to") await expect(page_text).to_be_visible() - # async def test_login_app_with_oidc(self): - # async with browser_page() as page: - # await page.goto(self.live_server_url) - # await page.wait_for_url( - # f"{self.live_server_url}/login?next=/destruction-lists" - # ) + async def test_login_app_with_oidc(self): + async with browser_page() as page: + await page.goto(self.live_server_url) + await page.wait_for_url( + f"{self.live_server_url}/login?next=/destruction-lists" + ) + + login_button = page.get_by_text("Organisatie login") - # login_button = page.get_by_text("Organisatie login") + await login_button.click() - # await login_button.click() + username_field = page.get_by_role("textbox", name="username") + await username_field.fill( + "alice_doe" + ) # configured in the Keycloak fixture as record manager - # username_field = page.get_by_role("textbox", name="username") - # await username_field.fill( - # "alice_doe" - # ) # configured in the Keycloak fixture as record manager + password_field = page.get_by_role("textbox", name="password") + await password_field.fill("aNic3Passw0rd") - # password_field = page.get_by_role("textbox", name="password") - # await password_field.fill("aNic3Passw0rd") + login_button = page.get_by_role("button", name="Sign In") + await login_button.click() - # await page.wait_for_url(f"{self.live_server_url}/destruction-lists") + await page.wait_for_url(f"{self.live_server_url}/destruction-lists") - # page_text = page.get_by_text("Vernietigingslijsten") - # await expect(page_text).to_be_visible() + page_text = page.get_by_role("heading", name="Vernietigingslijsten") + await expect(page_text).to_be_visible()