Refactor login tests (#2337)

Co-authored-by: Omar López <[email protected]>
This commit is contained in:
Demian CaldelasandOmar López authored and GitHub committed 2022-04-06 08:13:09 -07:00
1 parent 7fd65ceb8a
commit 551892fa30
7 files changed
+128 -61

No files matched your search

+2 -5
View File
@@ -1,17 +1,14 @@
import { test as base } from "@playwright/test";
import { createUsersFixture } from "../fixtures/users";
import type { UsersFixture } from "../fixtures/users";
interface Fixtures {
users: UsersFixture;
users: ReturnType<typeof createUsersFixture>;
}
export const test = base.extend<Fixtures>({
users: async ({ page }, use, testInfo) => {
// instantiate the fixture
users: async ({ page }, use) => {
const usersFixture = createUsersFixture(page);
// use the fixture within the test
await use(usersFixture);
},
});
+10
View File
@@ -86,3 +86,13 @@ export async function selectSecondAvailableTimeSlotNextMonth(page: Page) {
await page.click('[data-testid="day"][data-disabled="false"]');
await page.locator('[data-testid="time"]').nth(1).click();
}
// Provide an standalone localize utility not managed by next-i18n
export async function localize(locale: string) {
const localeModule = `../../public/static/locales/${locale}/common.json`;
const localeMap = await import(localeModule);
return (message: string) => {
if (message in localeMap) return localeMap[message];
throw "No locale found for the given entry message";
};
}