|
| 1 | +// @ts-check |
| 2 | +import { test, expect } from '@playwright/test'; |
| 3 | +import {ProjectPage} from "./pages/project"; |
| 4 | + |
| 5 | +test.describe('Header', |
| 6 | + { |
| 7 | + tag: ['@readonly'], |
| 8 | + }, |
| 9 | + () => { |
| 10 | + |
| 11 | + test('Login info as user A on the landing page', async ({ browser }) => { |
| 12 | + const userA = await browser.newContext({ storageState: 'playwright/.auth/user_in_group_a.json' }); |
| 13 | + const page = await userA.newPage(); |
| 14 | + await page.goto('index.php'); |
| 15 | + |
| 16 | + // Fixme, class "hide" but visible ? |
| 17 | + await expect(page.locator("#info-user-login")).toHaveText("user_in_group_a"); |
| 18 | + await expect(page.locator("#info-user-firstname")).toHaveText("User A"); |
| 19 | + await expect(page.locator("#info-user-firstname")).toHaveClass("hide"); |
| 20 | + await expect(page.locator("#info-user-firstname")).toBeVisible(); |
| 21 | + await expect(page.locator("#info-user-lastname")).toHaveText("Testadiferro"); |
| 22 | + await expect(page.locator("#info-user-lastname")).toHaveClass("hide"); |
| 23 | + await expect(page.locator("#info-user-lastname")).toBeVisible(); |
| 24 | + await expect(page.locator("#info-user-organization")).toHaveText("Make it KISS"); |
| 25 | + await expect(page.locator("#info-user-organization")).toHaveClass("hide"); |
| 26 | + await expect(page.locator("#info-user-organization")).toBeVisible(); |
| 27 | + }); |
| 28 | + |
| 29 | + test('Login info as user A on project page', async ({ browser }) => { |
| 30 | + const userA = await browser.newContext({ storageState: 'playwright/.auth/user_in_group_a.json' }); |
| 31 | + const userPage = await userA.newPage(); |
| 32 | + const projectPage = new ProjectPage(userPage, 'world-3857'); |
| 33 | + await projectPage.open(); |
| 34 | + |
| 35 | + await expect(userPage.locator("#info-user-login")).toHaveText("user_in_group_a"); |
| 36 | + await expect(userPage.locator("#info-user-firstname")).toHaveText("User A"); |
| 37 | + await expect(userPage.locator("#info-user-firstname")).toHaveClass("hide"); |
| 38 | + await expect(userPage.locator("#info-user-firstname")).not.toBeVisible(); |
| 39 | + await expect(userPage.locator("#info-user-lastname")).toHaveText("Testadiferro"); |
| 40 | + await expect(userPage.locator("#info-user-lastname")).toHaveClass("hide"); |
| 41 | + await expect(userPage.locator("#info-user-lastname")).not.toBeVisible(); |
| 42 | + await expect(userPage.locator("#info-user-organization")).toHaveText("Make it KISS"); |
| 43 | + await expect(userPage.locator("#info-user-organization")).toHaveClass("hide"); |
| 44 | + await expect(userPage.locator("#info-user-organization")).not.toBeVisible(); |
| 45 | + }); |
| 46 | + |
| 47 | + test('Login info as anonymous on the landing page', async ({ page }) => { |
| 48 | + await page.goto('index.php'); |
| 49 | + await expect(page.locator("#headermenu .login")).toHaveText("Connect"); |
| 50 | + }); |
| 51 | + |
| 52 | + test('Login info as anonymous on project page', async ({ page }) => { |
| 53 | + const projectPage = new ProjectPage(page, 'world-3857'); |
| 54 | + await projectPage.open(); |
| 55 | + await expect(page.locator("#headermenu .login")).toHaveText("Connect"); |
| 56 | + }); |
| 57 | +}); |
0 commit comments