Skip to content

Commit

Permalink
Tests - Add E2E for header info login
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Feb 4, 2025
1 parent ec92890 commit 0513e4e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
57 changes: 57 additions & 0 deletions tests/end2end/playwright/header.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// @ts-check
import { test, expect } from '@playwright/test';
import {ProjectPage} from "./pages/project";

test.describe('Header',
{
tag: ['@readonly'],
},
() => {

test('Login info as user A on the landing page', async ({ browser }) => {
const userA = await browser.newContext({ storageState: 'playwright/.auth/user_in_group_a.json' });
const page = await userA.newPage();
await page.goto('index.php');

// Fixme, class "hide" but visible ?
await expect(page.locator("#info-user-login")).toHaveText("user_in_group_a");
await expect(page.locator("#info-user-firstname")).toHaveText("User A");
await expect(page.locator("#info-user-firstname")).toHaveClass("hide");
await expect(page.locator("#info-user-firstname")).toBeVisible();
await expect(page.locator("#info-user-lastname")).toHaveText("Testadiferro");
await expect(page.locator("#info-user-lastname")).toHaveClass("hide");
await expect(page.locator("#info-user-lastname")).toBeVisible();
await expect(page.locator("#info-user-organization")).toHaveText("Make it KISS");
await expect(page.locator("#info-user-organization")).toHaveClass("hide");
await expect(page.locator("#info-user-organization")).toBeVisible();
});

test('Login info as user A on project page', async ({ browser }) => {
const userA = await browser.newContext({ storageState: 'playwright/.auth/user_in_group_a.json' });
const userPage = await userA.newPage();
const projectPage = new ProjectPage(userPage, 'world-3857');
await projectPage.open();

await expect(userPage.locator("#info-user-login")).toHaveText("user_in_group_a");
await expect(userPage.locator("#info-user-firstname")).toHaveText("User A");
await expect(userPage.locator("#info-user-firstname")).toHaveClass("hide");
await expect(userPage.locator("#info-user-firstname")).not.toBeVisible();
await expect(userPage.locator("#info-user-lastname")).toHaveText("Testadiferro");
await expect(userPage.locator("#info-user-lastname")).toHaveClass("hide");
await expect(userPage.locator("#info-user-lastname")).not.toBeVisible();
await expect(userPage.locator("#info-user-organization")).toHaveText("Make it KISS");
await expect(userPage.locator("#info-user-organization")).toHaveClass("hide");
await expect(userPage.locator("#info-user-organization")).not.toBeVisible();
});

test('Login info as anonymous on the landing page', async ({ page }) => {
await page.goto('index.php');
await expect(page.locator("#headermenu .login")).toHaveText("Connect");
});

test('Login info as anonymous on project page', async ({ page }) => {
const projectPage = new ProjectPage(page, 'world-3857');
await projectPage.open();
await expect(page.locator("#headermenu .login")).toHaveText("Connect");
});
});
8 changes: 4 additions & 4 deletions tests/qgis-projects/tests/set_tests_respository_rights.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ INSERT INTO lizmap.jacl2_group(

-- Users
INSERT INTO lizmap.jlx_user(
usr_login, usr_email, usr_password, status, create_date)
usr_login, usr_email, usr_password, status, create_date, firstname, lastname, organization)
VALUES
('user_in_group_a', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW()),
('user_in_group_b', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW()),
('publisher', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW())
('user_in_group_a', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW(), 'User A', 'Testadiferro', 'Make it KISS'),
('user_in_group_b', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW(), 'User B', 'Testillano', 'Make it KISS'),
('publisher', '[email protected]', '$2y$10$d2KZfxeYJP0l3YbNyDMZYe2vGSA3JWa8kFJSdecmSEIqInjnunTJ.', 1, NOW(), 'Publisher', 'Testla', 'Make it KISS')
ON CONFLICT DO NOTHING
;

Expand Down

0 comments on commit 0513e4e

Please sign in to comment.