Skip to content

Commit

Permalink
test: add navigation bar tests for authenticated/admin users
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalinDe committed Dec 1, 2023
1 parent 260175d commit 801ca6a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions web/frontend/tests/navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -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') })
);
});

0 comments on commit 801ca6a

Please sign in to comment.