Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header - Add authenticated user organization in hidden fields #5288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lizmap/modules/lizmap/templates/user_menu.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<span id="info-user-login" title="{$user->firstname} {$user->lastname}">{$user->login|eschtml}</span>
<span class="hide" id="info-user-firstname">{$user->firstname}</span>
<span class="hide" id="info-user-lastname">{$user->lastname}</span>
<span class="hide" id="info-user-organization">{$user->organization}</span>
</span>
</a>
<ul class="dropdown-menu dropdown-menu-end">
Expand Down
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
Loading