Skip to content

Commit

Permalink
docs: updated comments in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalinDe committed Nov 27, 2023
1 parent c541772 commit 5760291
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions web/frontend/tests/integration/homepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
});
Expand All @@ -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');
});

0 comments on commit 5760291

Please sign in to comment.