From 801ca6aa6bf9da1830b1494c142eabd8c0f4c7f6 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Fri, 1 Dec 2023 17:57:40 +0100 Subject: [PATCH] test: add navigation bar tests for authenticated/admin users --- web/frontend/tests/navigation.spec.ts | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 web/frontend/tests/navigation.spec.ts diff --git a/web/frontend/tests/navigation.spec.ts b/web/frontend/tests/navigation.spec.ts new file mode 100644 index 000000000..1359ad7dc --- /dev/null +++ b/web/frontend/tests/navigation.spec.ts @@ -0,0 +1,36 @@ +import { default as i18n } from 'i18next'; +import { test, expect } from '@playwright/test'; +import { + initI18n, + logIn, + logOut, + assertOnlyVisibleToAuthenticated, + assertOnlyVisibleToAdmin, +} from './shared'; + +initI18n(); + +// authenticated non-admin + +test('Assert "Profile" button is visible upon logging in', async({ page }) => { + await page.goto(process.env.FRONT_END_URL); + await assertOnlyVisibleToAuthenticated( + page, page.getByRole('button', { name: i18n.t('Profile') }) + ); +}); + +// admin + +test('Assert "Create form" button is (only) visible to admin', async({ page }) => { + await page.goto(process.env.FRONT_END_URL); + await assertOnlyVisibleToAdmin( + page, page.getByRole('link', { name: i18n.t('navBarCreateForm')}) + ); +}); + +test('Assert "Admin" button is (only) visible to admin', async({ page }) => { + await page.goto(process.env.FRONT_END_URL); + await assertOnlyVisibleToAdmin( + page, page.getByRole('link', { name: i18n.t('navBarAdmin') }) + ); +});