Skip to content

Commit

Permalink
fix: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalinDe committed Dec 14, 2023
1 parent 628cf71 commit d6c136a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
18 changes: 13 additions & 5 deletions web/frontend/tests/formIndex.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import { default as i18n } from 'i18next';
import { assertHasFooter, assertHasNavBar, initI18n, setUp } from './shared';
import { mockPersonalInfo, mockEvoting } from './mocks';
import { mockEvoting, mockPersonalInfo } from './mocks';

initI18n();

Expand Down Expand Up @@ -31,7 +31,9 @@ test('Assert pagination bar is present', async ({ page }) => {
});

test('Assert pagination works correctly for empty list', async ({ page }) => {
await expect(page.getByTestId('navPaginationMessage')).toHaveText(i18n.t('showingNOverMOfXResults', { n: 1, m: 1, x: 0 }));
await expect(page.getByTestId('navPaginationMessage')).toHaveText(
i18n.t('showingNOverMOfXResults', { n: 1, m: 1, x: 0 })
);
for (let key of ['next', 'previous']) {
await expect(page.getByRole('button', { name: i18n.t(key) })).toBeDisabled();
}
Expand All @@ -44,17 +46,23 @@ test('Assert pagination works correctly for non-empty list', async ({ page }) =>
const next = await page.getByRole('button', { name: i18n.t('next') });
const previous = await page.getByRole('button', { name: i18n.t('previous') });
// 1st page
await expect(page.getByTestId('navPaginationMessage')).toHaveText(i18n.t('showingNOverMOfXResults', { n: 1, m: 2, x: 11 }));
await expect(page.getByTestId('navPaginationMessage')).toHaveText(
i18n.t('showingNOverMOfXResults', { n: 1, m: 2, x: 11 })
);
await expect(previous).toBeDisabled();
await expect(next).toBeEnabled();
await next.click();
// 2nd page
await expect(page.getByTestId('navPaginationMessage')).toHaveText(i18n.t('showingNOverMOfXResults', { n: 2, m: 2, x: 11 }));
await expect(page.getByTestId('navPaginationMessage')).toHaveText(
i18n.t('showingNOverMOfXResults', { n: 2, m: 2, x: 11 })
);
await expect(next).toBeDisabled();
await expect(previous).toBeEnabled();
await previous.click();
// back to 1st page
await expect(page.getByTestId('navPaginationMessage')).toHaveText(i18n.t('showingNOverMOfXResults', { n: 1, m: 2, x: 11 }));
await expect(page.getByTestId('navPaginationMessage')).toHaveText(
i18n.t('showingNOverMOfXResults', { n: 1, m: 2, x: 11 })
);
await expect(previous).toBeDisabled();
await expect(next).toBeEnabled();
});
5 changes: 2 additions & 3 deletions web/frontend/tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ export async function mockPersonalInfo(page: any, sciper?: string) {
await page.route('/api/personal_info', async (route) => {
if (sciper) {
route.fulfill({ path: `./tests/json/personal_info/${sciper}.json` });
}
else {
route.fulfill({ status: 401, contentType: 'text/html', body: 'Unauthenticated'})
} else {
route.fulfill({ status: 401, contentType: 'text/html', body: 'Unauthenticated' });
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion web/frontend/tests/navbar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
logIn,
setUp,
} from './shared';
import { SCIPER_ADMIN, SCIPER_USER, mockLogout, mockPersonalInfo } from './mocks';
import { SCIPER_USER, mockLogout, mockPersonalInfo } from './mocks';

initI18n();

Expand Down

0 comments on commit d6c136a

Please sign in to comment.