-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from c4dt/playwright
Smaller changes, also undo of breaking change in PR #69
- Loading branch information
Showing
7 changed files
with
140 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,52 @@ | ||
import { default as i18n } from 'i18next'; | ||
import { test, expect } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
import en from './../src/language/en.json'; | ||
import fr from './../src/language/fr.json'; | ||
import de from './../src/language/de.json'; | ||
import { SCIPER_ADMIN, SCIPER_USER, UPDATE, mockPersonalInfo, mockGetDevLogin, mockLogout } from './mocks'; | ||
import { | ||
SCIPER_ADMIN, | ||
SCIPER_USER, | ||
mockGetDevLogin, | ||
mockLogout, | ||
mockPersonalInfo, | ||
mockProxy, | ||
} from './mocks'; | ||
|
||
export function initI18n () { | ||
export function initI18n() { | ||
i18n.init({ | ||
resources: { en, fr, de }, | ||
fallbackLng: ['en', 'fr', 'de'], | ||
}); | ||
} | ||
|
||
export async function setUp(page: any, url: string) { | ||
if (UPDATE === true) { | ||
return; | ||
} | ||
await mockPersonalInfo(page); | ||
await mockProxy(page); | ||
await mockGetDevLogin(page); | ||
await mockLogout(page); | ||
await page.goto(url); | ||
await expect(page).toHaveURL(url); // make sure that page is loaded | ||
await expect(page).toHaveURL(url); // make sure that page is loaded | ||
} | ||
|
||
export async function logIn (page: any, sciper: string) { | ||
export async function logIn(page: any, sciper: string) { | ||
await mockPersonalInfo(page, sciper); | ||
await page.reload(); | ||
await expect(page).toHaveURL(page.url()); // make sure that page is loaded | ||
await expect(page).toHaveURL(page.url()); // make sure that page is loaded | ||
} | ||
|
||
export async function assertOnlyVisibleToAuthenticated (page: any, locator: any) { | ||
await expect(locator).toBeHidden(); // assert is hidden to unauthenticated user | ||
export async function assertOnlyVisibleToAuthenticated(page: any, locator: any) { | ||
await expect(locator).toBeHidden(); // assert is hidden to unauthenticated user | ||
await logIn(page, SCIPER_USER); | ||
await expect(locator).toBeVisible(); // assert is visible to authenticated user | ||
await expect(locator).toBeVisible(); // assert is visible to authenticated user | ||
} | ||
|
||
export async function assertOnlyVisibleToAdmin (page: any, locator: any) { | ||
await expect(locator).toBeHidden(); // assert is hidden to unauthenticated user | ||
export async function assertOnlyVisibleToAdmin(page: any, locator: any) { | ||
await expect(locator).toBeHidden(); // assert is hidden to unauthenticated user | ||
await logIn(page, SCIPER_USER); | ||
await expect(locator).toBeHidden(); // assert is hidden to authenticated non-admin user | ||
await expect(locator).toBeHidden(); // assert is hidden to authenticated non-admin user | ||
await logIn(page, SCIPER_ADMIN); | ||
await expect(locator).toBeVisible(); // assert is visible to admin user | ||
await expect(locator).toBeVisible(); // assert is visible to admin user | ||
} | ||
|
||
export async function getFooter (page: any) { | ||
return await page.getByTestId('footer'); | ||
export async function getFooter(page: any) { | ||
return page.getByTestId('footer'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
"paths": { | ||
"*": [ | ||
"*" | ||
] | ||
}, | ||
}, | ||
} | ||
|