diff --git a/web/frontend/tests/integration/homepage.spec.ts b/web/frontend/tests/integration/homepage.spec.ts index a2e405a79..f7e5ba213 100644 --- a/web/frontend/tests/integration/homepage.spec.ts +++ b/web/frontend/tests/integration/homepage.spec.ts @@ -30,14 +30,14 @@ async function logOut (page: any) { await page.getByRole('button', { name: i18n.t('continue') }).dispatchEvent('click'); } -// assert unauthenticated view +// unauthenticated view -test('Assert homepage title', async({ page }) => { +test('Assert homepage has correct title', async({ page }) => { await page.goto(process.env.FRONT_END_URL); await expect(page).toHaveTitle(/D-Voting/); }); -test('Assert login button', async({ page }) => { +test('Assert login button sets cookie', async({ page }) => { await page.goto(process.env.FRONT_END_URL); const login = page.getByRole('button', { name: i18n.t('login') }); await login.click(); @@ -46,16 +46,16 @@ test('Assert login button', async({ page }) => { }); -// assert authenticated non-admin view +// authenticated non-admin view async function assertOnlyVisibleToAuthenticated(page: any, role: string, key: string) { const element = page.getByRole(role, { name: i18n.t(key) }); - await expect(element).toBeHidden(); + await expect(element).toBeHidden(); // assert is hidden to unauthenticated user await logInNonAdmin(page); - await expect(element).toBeVisible(); + await expect(element).toBeVisible(); // assert is visible to authenticated non-admin user } -test('Assert profile button', async({ page }) => { +test('Assert profile button is visible to any user', async({ page }) => { await page.goto(process.env.FRONT_END_URL); await assertOnlyVisibleToAuthenticated(page, 'button', 'Profile'); }); @@ -65,20 +65,20 @@ test('Assert profile button', async({ page }) => { async function assertOnlyVisibleToAdmin(page: any, role: string, key: string) { const element = page.getByRole(role, { name: i18n.t(key) }); - await expect(element).toBeHidden(); + await expect(element).toBeHidden(); // assert is hidden to unauthenticated user await logInNonAdmin(page); - await expect(element).toBeHidden(); + await expect(element).toBeHidden(); // assert is hidden to non-admin user await logOut(page); await logIn(page); - await expect(element).toBeVisible(); + await expect(element).toBeVisible(); // assert is visible to admin user } -test('Assert create form button', async({ page }) => { +test('Assert form creation button is only visible to admin', async({ page }) => { await page.goto(process.env.FRONT_END_URL); await assertOnlyVisibleToAdmin(page, 'link', 'navBarCreateForm'); }); -test('Assert admin button', async({ page }) => { +test('Assert administration button is only visible to admin', async({ page }) => { await page.goto(process.env.FRONT_END_URL); await assertOnlyVisibleToAdmin(page, 'link', 'navBarAdmin'); });