From b9909be4e9505375d0a397b194e83687b162cc47 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Fri, 15 Dec 2023 14:13:49 +0100 Subject: [PATCH 01/10] style: prettify JSON --- .../tests/json/personal_info/123456.json | 22 ++++++++++++++++++- .../tests/json/personal_info/789012.json | 8 ++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/web/frontend/tests/json/personal_info/123456.json b/web/frontend/tests/json/personal_info/123456.json index 18abd32b4..0b98c591f 100644 --- a/web/frontend/tests/json/personal_info/123456.json +++ b/web/frontend/tests/json/personal_info/123456.json @@ -1 +1,21 @@ -{"sciper":123456,"lastName":"123456","firstName":"sciper-#","isLoggedIn":true,"authorization":{"roles":["add","list","remove"],"proxies":["post","put","delete"],"election":["create"]}} \ No newline at end of file +{ + "sciper": 123456, + "lastName": "123456", + "firstName": "sciper-#", + "isLoggedIn": true, + "authorization": { + "roles": [ + "add", + "list", + "remove" + ], + "proxies": [ + "post", + "put", + "delete" + ], + "election": [ + "create" + ] + } +} diff --git a/web/frontend/tests/json/personal_info/789012.json b/web/frontend/tests/json/personal_info/789012.json index fbbb5fb20..22aebd42c 100644 --- a/web/frontend/tests/json/personal_info/789012.json +++ b/web/frontend/tests/json/personal_info/789012.json @@ -1 +1,7 @@ -{"sciper":789012,"lastName":"789012","firstName":"sciper-#","isLoggedIn":true,"authorization":{}} \ No newline at end of file +{ + "sciper": 789012, + "lastName": "789012", + "firstName": "sciper-#", + "isLoggedIn": true, + "authorization": {} +} From 6b8a4203727af56a644ce6c59ddfea312df95d99 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Fri, 15 Dec 2023 14:23:17 +0100 Subject: [PATCH 02/10] test: add form list display tests --- .../src/pages/form/components/QuickAction.tsx | 2 +- web/frontend/tests/formIndex.spec.ts | 11 ++++++++++- web/frontend/tests/json/personal_info/123456.json | 5 ++++- web/frontend/tests/json/personal_info/789012.json | 4 +++- web/frontend/tests/shared.ts | 13 +++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/web/frontend/src/pages/form/components/QuickAction.tsx b/web/frontend/src/pages/form/components/QuickAction.tsx index d05594cc2..fc363f93b 100644 --- a/web/frontend/src/pages/form/components/QuickAction.tsx +++ b/web/frontend/src/pages/form/components/QuickAction.tsx @@ -11,7 +11,7 @@ type QuickActionProps = { const QuickAction: FC = ({ status, formID }) => { return ( -
+
{status === Status.Open && } {status === Status.ResultAvailable && }
diff --git a/web/frontend/tests/formIndex.spec.ts b/web/frontend/tests/formIndex.spec.ts index f041f6527..be7f3a68b 100644 --- a/web/frontend/tests/formIndex.spec.ts +++ b/web/frontend/tests/formIndex.spec.ts @@ -1,10 +1,19 @@ import { expect, test } from '@playwright/test'; import { default as i18n } from 'i18next'; -import { assertHasFooter, assertHasNavBar, initI18n, setUp } from './shared'; +import { assertHasFooter, assertHasNavBar, initI18n, setUp, translate } from './shared'; import { mockEvoting, mockPersonalInfo } from './mocks'; +import Forms from './json/formList.json'; initI18n(); +async function goForward(page: page) { + await page.getByRole('button', { name: i18n.t('next') }).click(); +} + +async function goBackward(page: page) { + await page.getByRole('button', { name: i18n.t('previous') }).click(); +} + test.beforeEach(async ({ page }) => { // mock empty list per default await mockEvoting(page); diff --git a/web/frontend/tests/json/personal_info/123456.json b/web/frontend/tests/json/personal_info/123456.json index 0b98c591f..aaaa59759 100644 --- a/web/frontend/tests/json/personal_info/123456.json +++ b/web/frontend/tests/json/personal_info/123456.json @@ -17,5 +17,8 @@ "election": [ "create" ] - } + }, + "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote", "own"], + "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"], + "9f50ad723805a6419ba1a9f83dd0aa582f3e13b94f14727cd0c8c01744e0dba2": ["own"] } diff --git a/web/frontend/tests/json/personal_info/789012.json b/web/frontend/tests/json/personal_info/789012.json index 22aebd42c..ed9f81347 100644 --- a/web/frontend/tests/json/personal_info/789012.json +++ b/web/frontend/tests/json/personal_info/789012.json @@ -3,5 +3,7 @@ "lastName": "789012", "firstName": "sciper-#", "isLoggedIn": true, - "authorization": {} + "authorization": {}, + "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote"], + "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"] } diff --git a/web/frontend/tests/shared.ts b/web/frontend/tests/shared.ts index f48994adc..4839f164f 100644 --- a/web/frontend/tests/shared.ts +++ b/web/frontend/tests/shared.ts @@ -54,3 +54,16 @@ export async function assertHasNavBar(page: page) { export async function assertHasFooter(page: page) { await expect(page.getByTestId('footer')).toBeVisible(); } + +export function translate(internationalizable: object) { + switch(i18n.language) { + case 'en': + return internationalizable.En; + case 'fr': + return internationalizable.Fr || internationalizable.En; + case 'de': + return internationalizable.De || internationalizable.En; + default: + return internationalizable.En; + } +} From f6605791c2276f6d05534545394fc04503202f4b Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Mon, 8 Jan 2024 20:49:24 +0100 Subject: [PATCH 03/10] test: do not actually load page to check URL --- web/frontend/src/layout/NavBar.tsx | 4 ++-- web/frontend/tests/navbar.spec.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/web/frontend/src/layout/NavBar.tsx b/web/frontend/src/layout/NavBar.tsx index 0ced61ff2..56ccf2fcf 100644 --- a/web/frontend/src/layout/NavBar.tsx +++ b/web/frontend/src/layout/NavBar.tsx @@ -60,7 +60,7 @@ const MobileMenu = ({ authCtx, handleLogout, fctx, t }) => (
-
+
Workflow
@@ -177,7 +177,7 @@ const RightSideNavBar = ({ authCtx, handleLogout, handleChangeId, fctx, t }) => const LeftSideNavBar = ({ authCtx, t }) => (
-
+
Workflow diff --git a/web/frontend/tests/navbar.spec.ts b/web/frontend/tests/navbar.spec.ts index e20f4038a..5ea38700d 100644 --- a/web/frontend/tests/navbar.spec.ts +++ b/web/frontend/tests/navbar.spec.ts @@ -24,10 +24,9 @@ test('Assert cookie is set', async ({ page }) => { }); test('Assert D-Voting logo is present', async ({ page }) => { - const logo = await page.getByAltText(i18n.t('Workflow')); + const logo = await page.getByTestId('leftSideNavBarLogo'); await expect(logo).toBeVisible(); - await logo.click(); - await expect(page).toHaveURL('/'); + await expect(await logo.getByRole('link')).toHaveAttribute('href', '/'); }); test('Assert link to form table is present', async ({ page }) => { From 7c62d809fd8688e9c691032da9292266848484a6 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Mon, 8 Jan 2024 21:04:04 +0100 Subject: [PATCH 04/10] test: assert unauthenticated form list views are correct --- web/frontend/tests/formIndex.spec.ts | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/web/frontend/tests/formIndex.spec.ts b/web/frontend/tests/formIndex.spec.ts index be7f3a68b..f0cb5ddec 100644 --- a/web/frontend/tests/formIndex.spec.ts +++ b/web/frontend/tests/formIndex.spec.ts @@ -75,3 +75,38 @@ test('Assert pagination works correctly for non-empty list', async ({ page }) => await expect(previous).toBeDisabled(); await expect(next).toBeEnabled(); }); + + +test('Assert no forms are displayed for empty list', async ({ page }) => { + // 1 header row + await expect.poll(async () => { + const rows = await page.getByRole('table').getByRole('row'); + return rows.all(); + }).toHaveLength(1); +}); + +test('Assert forms are displayed correctly for unauthenticated user', async ({ page, baseURL }) => { + await mockEvoting(page, false); + await page.reload(); + const table = await page.getByRole('table'); + for (let form of Forms.Forms.slice(0, -1)) { + let name = translate(form.Title); + let row = await table.getByRole('row', { name: name }); + await expect(row).toBeVisible(); + // row entry leads to form view + let link = await row.getByRole('link', { name: name }); + await expect(link).toBeVisible(); + await expect(link).toHaveAttribute('href', `/forms/${form.FormID}`); + const quickAction = row.getByTestId('quickAction'); + // any user can see the results of a past election + if (form.Status === 5) { + await expect(quickAction).toHaveText(i18n.t('seeResult')); + await expect(await quickAction.getByRole('link')).toHaveAttribute('href', `/forms/${form.FormID}/result`); + } + else { + await expect(quickAction).toBeHidden(); + } + } + await goForward(page); + await expect(await table.getByRole('row', { name: translate(Forms.Forms.at(-1).Title) })).toBeVisible(); +}); From 96dcb5a9ed18f93ec5a205e7f318e05ed80c3d1b Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Thu, 11 Jan 2024 14:42:57 +0100 Subject: [PATCH 05/10] test: fix malformatted test data --- web/frontend/tests/json/personal_info/123456.json | 10 +++++----- web/frontend/tests/json/personal_info/789012.json | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/frontend/tests/json/personal_info/123456.json b/web/frontend/tests/json/personal_info/123456.json index aaaa59759..25f0b0d43 100644 --- a/web/frontend/tests/json/personal_info/123456.json +++ b/web/frontend/tests/json/personal_info/123456.json @@ -16,9 +16,9 @@ ], "election": [ "create" - ] - }, - "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote", "own"], - "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"], - "9f50ad723805a6419ba1a9f83dd0aa582f3e13b94f14727cd0c8c01744e0dba2": ["own"] + ], + "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote", "own"], + "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"], + "9f50ad723805a6419ba1a9f83dd0aa582f3e13b94f14727cd0c8c01744e0dba2": ["own"] + } } diff --git a/web/frontend/tests/json/personal_info/789012.json b/web/frontend/tests/json/personal_info/789012.json index ed9f81347..dd341520e 100644 --- a/web/frontend/tests/json/personal_info/789012.json +++ b/web/frontend/tests/json/personal_info/789012.json @@ -3,7 +3,8 @@ "lastName": "789012", "firstName": "sciper-#", "isLoggedIn": true, - "authorization": {}, - "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote"], - "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"] + "authorization": { + "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote"], + "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"] + } } From 380b15795d5cfdf4fd772229c4af6490a30bf359 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Thu, 11 Jan 2024 14:54:51 +0100 Subject: [PATCH 06/10] test: admin cannot vote on same form as non-admin --- web/frontend/tests/json/formList.json | 4 ++-- web/frontend/tests/json/personal_info/123456.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/frontend/tests/json/formList.json b/web/frontend/tests/json/formList.json index 5c237fb5c..1ddd282be 100644 --- a/web/frontend/tests/json/formList.json +++ b/web/frontend/tests/json/formList.json @@ -57,8 +57,8 @@ "Fr": "", "De": "" }, - "Status": 0, - "Pubkey": "" + "Status": 1, + "Pubkey": "348f56a444e1b75214a9c675587222099007ce739a04651667c054d9be626e07" }, { "FormID": "1269a8507dc316a9ec983ede527705078bfef2b151a49f7ffae6e903ef1bb38f", diff --git a/web/frontend/tests/json/personal_info/123456.json b/web/frontend/tests/json/personal_info/123456.json index 25f0b0d43..2f6de9a7b 100644 --- a/web/frontend/tests/json/personal_info/123456.json +++ b/web/frontend/tests/json/personal_info/123456.json @@ -17,8 +17,8 @@ "election": [ "create" ], - "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["vote", "own"], + "fdf8bfb702e8883e330a2b303b24212b6fc16df5a53a097998b77ba74632dc72": ["own"], "ed26713245824d44ee46ec90507ef521962f2313706934cdfe76ff1823738109": ["vote"], - "9f50ad723805a6419ba1a9f83dd0aa582f3e13b94f14727cd0c8c01744e0dba2": ["own"] + "9f50ad723805a6419ba1a9f83dd0aa582f3e13b94f14727cd0c8c01744e0dba2": ["vote", "own"] } } From ee64e2b3c0cf6f8402f97a8d88490754dc40755d Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Thu, 11 Jan 2024 15:01:05 +0100 Subject: [PATCH 07/10] test: add form list display tests --- web/frontend/tests/formIndex.spec.ts | 62 ++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/web/frontend/tests/formIndex.spec.ts b/web/frontend/tests/formIndex.spec.ts index f0cb5ddec..87b6f6df2 100644 --- a/web/frontend/tests/formIndex.spec.ts +++ b/web/frontend/tests/formIndex.spec.ts @@ -1,8 +1,10 @@ import { expect, test } from '@playwright/test'; import { default as i18n } from 'i18next'; -import { assertHasFooter, assertHasNavBar, initI18n, setUp, translate } from './shared'; -import { mockEvoting, mockPersonalInfo } from './mocks'; +import { assertHasFooter, assertHasNavBar, initI18n, setUp, translate, logIn } from './shared'; +import { mockEvoting, mockPersonalInfo, SCIPER_USER, SCIPER_ADMIN } from './mocks'; import Forms from './json/formList.json'; +import User from './json/personal_info/789012.json'; +import Admin from './json/personal_info/123456.json'; initI18n(); @@ -85,6 +87,33 @@ test('Assert no forms are displayed for empty list', async ({ page }) => { }).toHaveLength(1); }); +async function assertQuickAction(row: locator, form: object, sciper?: string) { + const user = sciper === SCIPER_USER ? User + : sciper === SCIPER_ADMIN ? Admin + : undefined; + const quickAction = row.getByTestId('quickAction'); + switch(form.Status) { + case 1: + // only authenticated user w/ right to vote sees 'vote' button + if ((user) && (form.FormID in user.authorization) && (user.authorization[form.FormID].includes('vote'))) { + await expect(quickAction).toHaveText(i18n.t('vote')); + await expect(await quickAction.getByRole('link')).toHaveAttribute('href', `/ballot/show/${form.FormID}`); + await expect(quickAction).toBeVisible(); + } + else { + await expect(quickAction).toBeHidden(); + } + break; + case 5: + // any user can see the results of a past election + await expect(quickAction).toHaveText(i18n.t('seeResult')); + await expect(await quickAction.getByRole('link')).toHaveAttribute('href', `/forms/${form.FormID}/result`); + break; + default: + await expect(quickAction).toBeHidden(); + } +} + test('Assert forms are displayed correctly for unauthenticated user', async ({ page, baseURL }) => { await mockEvoting(page, false); await page.reload(); @@ -97,16 +126,25 @@ test('Assert forms are displayed correctly for unauthenticated user', async ({ p let link = await row.getByRole('link', { name: name }); await expect(link).toBeVisible(); await expect(link).toHaveAttribute('href', `/forms/${form.FormID}`); - const quickAction = row.getByTestId('quickAction'); - // any user can see the results of a past election - if (form.Status === 5) { - await expect(quickAction).toHaveText(i18n.t('seeResult')); - await expect(await quickAction.getByRole('link')).toHaveAttribute('href', `/forms/${form.FormID}/result`); - } - else { - await expect(quickAction).toBeHidden(); - } + await assertQuickAction(row, form); } await goForward(page); - await expect(await table.getByRole('row', { name: translate(Forms.Forms.at(-1).Title) })).toBeVisible(); + let row = await table.getByRole('row', { name: translate(Forms.Forms.at(-1).Title) }); + await expect(row).toBeVisible(); + await assertQuickAction(row, Forms.Forms.at(-1)); +}); + +test('Assert quick actions are displayed correctly for authenticated users', async ({ page, baseURL }) => { + for (let sciper of [SCIPER_USER, SCIPER_ADMIN]) { + await logIn(page, sciper); + await mockEvoting(page, false); + await page.reload(); + const table = await page.getByRole('table'); + for (let form of Forms.Forms.slice(0, -1)) { + let row = await table.getByRole('row', { name: translate(form.Title) }); + await assertQuickAction(row, form, sciper); + } + await goForward(page); + await assertQuickAction(await table.getByRole('row', { name: translate(Forms.Forms.at(-1).Title) }), Forms.Forms.at(-1)); + } }); From 5956f1dcebf841f6a76da1a168b7c289cf124f67 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Thu, 11 Jan 2024 15:09:36 +0100 Subject: [PATCH 08/10] style: fix linting --- web/frontend/tests/formIndex.spec.ts | 55 ++++++++++++++++------------ web/frontend/tests/shared.ts | 2 +- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/web/frontend/tests/formIndex.spec.ts b/web/frontend/tests/formIndex.spec.ts index 87b6f6df2..4d22fcd53 100644 --- a/web/frontend/tests/formIndex.spec.ts +++ b/web/frontend/tests/formIndex.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from '@playwright/test'; import { default as i18n } from 'i18next'; -import { assertHasFooter, assertHasNavBar, initI18n, setUp, translate, logIn } from './shared'; -import { mockEvoting, mockPersonalInfo, SCIPER_USER, SCIPER_ADMIN } from './mocks'; +import { assertHasFooter, assertHasNavBar, initI18n, logIn, setUp, translate } from './shared'; +import { SCIPER_ADMIN, SCIPER_USER, mockEvoting, mockPersonalInfo } from './mocks'; import Forms from './json/formList.json'; import User from './json/personal_info/789012.json'; import Admin from './json/personal_info/123456.json'; @@ -12,10 +12,6 @@ async function goForward(page: page) { await page.getByRole('button', { name: i18n.t('next') }).click(); } -async function goBackward(page: page) { - await page.getByRole('button', { name: i18n.t('previous') }).click(); -} - test.beforeEach(async ({ page }) => { // mock empty list per default await mockEvoting(page); @@ -78,43 +74,51 @@ test('Assert pagination works correctly for non-empty list', async ({ page }) => await expect(next).toBeEnabled(); }); - test('Assert no forms are displayed for empty list', async ({ page }) => { // 1 header row - await expect.poll(async () => { - const rows = await page.getByRole('table').getByRole('row'); - return rows.all(); - }).toHaveLength(1); + await expect + .poll(async () => { + const rows = await page.getByRole('table').getByRole('row'); + return rows.all(); + }) + .toHaveLength(1); }); async function assertQuickAction(row: locator, form: object, sciper?: string) { - const user = sciper === SCIPER_USER ? User - : sciper === SCIPER_ADMIN ? Admin - : undefined; + const user = sciper === SCIPER_USER ? User : sciper === SCIPER_ADMIN ? Admin : undefined; const quickAction = row.getByTestId('quickAction'); - switch(form.Status) { + switch (form.Status) { case 1: // only authenticated user w/ right to vote sees 'vote' button - if ((user) && (form.FormID in user.authorization) && (user.authorization[form.FormID].includes('vote'))) { + if ( + user && + form.FormID in user.authorization && + user.authorization[form.FormID].includes('vote') + ) { await expect(quickAction).toHaveText(i18n.t('vote')); - await expect(await quickAction.getByRole('link')).toHaveAttribute('href', `/ballot/show/${form.FormID}`); + await expect(await quickAction.getByRole('link')).toHaveAttribute( + 'href', + `/ballot/show/${form.FormID}` + ); await expect(quickAction).toBeVisible(); - } - else { + } else { await expect(quickAction).toBeHidden(); } break; case 5: // any user can see the results of a past election await expect(quickAction).toHaveText(i18n.t('seeResult')); - await expect(await quickAction.getByRole('link')).toHaveAttribute('href', `/forms/${form.FormID}/result`); + await expect(await quickAction.getByRole('link')).toHaveAttribute( + 'href', + `/forms/${form.FormID}/result` + ); break; - default: + default: await expect(quickAction).toBeHidden(); } } -test('Assert forms are displayed correctly for unauthenticated user', async ({ page, baseURL }) => { +test('Assert forms are displayed correctly for unauthenticated user', async ({ page }) => { await mockEvoting(page, false); await page.reload(); const table = await page.getByRole('table'); @@ -134,7 +138,7 @@ test('Assert forms are displayed correctly for unauthenticated user', async ({ p await assertQuickAction(row, Forms.Forms.at(-1)); }); -test('Assert quick actions are displayed correctly for authenticated users', async ({ page, baseURL }) => { +test('Assert quick actions are displayed correctly for authenticated users', async ({ page }) => { for (let sciper of [SCIPER_USER, SCIPER_ADMIN]) { await logIn(page, sciper); await mockEvoting(page, false); @@ -145,6 +149,9 @@ test('Assert quick actions are displayed correctly for authenticated users', asy await assertQuickAction(row, form, sciper); } await goForward(page); - await assertQuickAction(await table.getByRole('row', { name: translate(Forms.Forms.at(-1).Title) }), Forms.Forms.at(-1)); + await assertQuickAction( + await table.getByRole('row', { name: translate(Forms.Forms.at(-1).Title) }), + Forms.Forms.at(-1) + ); } }); diff --git a/web/frontend/tests/shared.ts b/web/frontend/tests/shared.ts index 4839f164f..a17581897 100644 --- a/web/frontend/tests/shared.ts +++ b/web/frontend/tests/shared.ts @@ -56,7 +56,7 @@ export async function assertHasFooter(page: page) { } export function translate(internationalizable: object) { - switch(i18n.language) { + switch (i18n.language) { case 'en': return internationalizable.En; case 'fr': From 1b03a2fa827f4e990af277908bce62eb27c663d6 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Wed, 17 Jan 2024 13:04:07 +0100 Subject: [PATCH 09/10] test: apply code review suggestions --- web/frontend/tests/formIndex.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/frontend/tests/formIndex.spec.ts b/web/frontend/tests/formIndex.spec.ts index 4d22fcd53..bd82464c2 100644 --- a/web/frontend/tests/formIndex.spec.ts +++ b/web/frontend/tests/formIndex.spec.ts @@ -91,7 +91,7 @@ async function assertQuickAction(row: locator, form: object, sciper?: string) { case 1: // only authenticated user w/ right to vote sees 'vote' button if ( - user && + user !== undefined && form.FormID in user.authorization && user.authorization[form.FormID].includes('vote') ) { From d28bec3897bfbc11714a4df0cd4cb8336d8e1420 Mon Sep 17 00:00:00 2001 From: Carine Dengler Date: Wed, 17 Jan 2024 13:09:36 +0100 Subject: [PATCH 10/10] test: disable lint to make code more readable --- web/frontend/tests/formIndex.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/frontend/tests/formIndex.spec.ts b/web/frontend/tests/formIndex.spec.ts index bd82464c2..56f83d3d4 100644 --- a/web/frontend/tests/formIndex.spec.ts +++ b/web/frontend/tests/formIndex.spec.ts @@ -85,7 +85,7 @@ test('Assert no forms are displayed for empty list', async ({ page }) => { }); async function assertQuickAction(row: locator, form: object, sciper?: string) { - const user = sciper === SCIPER_USER ? User : sciper === SCIPER_ADMIN ? Admin : undefined; + const user = sciper === SCIPER_USER ? User : (sciper === SCIPER_ADMIN ? Admin : undefined); // eslint-disable-line const quickAction = row.getByTestId('quickAction'); switch (form.Status) { case 1: