Skip to content
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
4 changes: 2 additions & 2 deletions fixtures/auth-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ async function authenticatedUserFixture(
await use(credentials);

// Clean up, deactivate user
await deactivateMasUser(userId);
console.log(`Cleaned up MAS user: ${user.username}`);
// await deactivateMasUser(userId);
// console.log(`Cleaned up MAS user: ${user.username}`);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO : clean up the users only after the tests finish running. Will be good to delete also room creation

}

/**
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"test:room:dev01": "ENV=dev01 playwright test ./tests/integration/room-access-rules/",
"test:room:dev02": "ENV=dev02 playwright test ./tests/integration/room-access-rules/",
"test:room:int01": "ENV=int01 playwright test ./tests/integration/room-access-rules/",
"test:web:local": "ENV=local playwright test ./tests/web/",
"test:web:dev01": "ENV=dev01 playwright test ./tests/web/",
"test:web:int01": "ENV=int01 playwright test ./tests/web/",
"test:all": "playwright test",
"lint": "biome lint .",
"lint:fix": "biome lint . --fix",
Expand Down
96 changes: 96 additions & 0 deletions playwright.ci.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
The new file playwright.ci.config.ts only add a webserver config to start during a web CI action run.
It will replace the standard playwirght config during the trigger of the action
*/

import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
import { BROWSER_LOCALE } from './utils/config';
import path from 'path';

// Determine which environment to use
const env = process.env.ENV || 'local';
console.log(`Loading environment configuration for: ${env}`);

// Load environment variables from the appropriate .env file
dotenv.config({ path: path.resolve(__dirname, `.env.${env}`) });

console.log('[playwright conf] process.env', process.env);
/**
* See https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: './tests',
/* Maximum time one test can run for */
timeout: 15 * 1000,
/* Run tests in files in parallel */
fullyParallel: process.env.TEST_IN_PARALLEL === 'true',

/* Define how many workers */
// Limit the number of workers on CI, use default locally
workers: process.env.CI ? 2 : 1,

/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,

retries: process.env.CI ? 2 : 2,
/* Reporter to use */
reporter: 'html',
/* Shared settings for all the projects below */
use: {
/* Base URL to use in actions like `await page.goto('/')` */
baseURL: process.env.MAS_URL || 'https://auth.tchapgouv.com',

/* Set locale to French */
locale: BROWSER_LOCALE,

/* Collect trace when retrying the failed test */
trace: 'on-first-retry',

/* Take screenshot on failure */
screenshot: 'only-on-failure',

/* Record video on failure */
video: 'on-first-retry',

/* Ignore HTTPS errors */
ignoreHTTPSErrors: true,
},

/* Configure projects for major browsers */
projects: [
/* e2e tests do not work well on firefox nor webkit (bit flaky)
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Edge'] },
},
*/

/* when using archlinux to use ui testing, bundled browser are not correctly installed
Directly use the installed chromium
{
name: "chromium",
use: { ...devices["Desktop Chrome"],
launchOptions: {
executablePath: "/usr/bin/chromium",
},
},
},
},

*/
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: {
// use the dist folder to start devserver in CI
command: 'npx serve dist -l 8088',
port: 8088,
},
});
24 changes: 22 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
import { BROWSER_LOCALE } from './utils/config';
import path from 'path';

// Load environment variables from .env file
dotenv.config();
// Determine which environment to use
const env = process.env.ENV || 'local';
console.log(`Loading environment configuration for: ${env}`);

// Load environment variables from the appropriate .env file
dotenv.config({ path: path.resolve(__dirname, `.env.${env}`) });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move initialization of dotenv config on one place only (at the higher call)

console.log('[playwright conf] process.env', process.env);
/**
* See https://playwright.dev/docs/test-configuration
*/
Expand Down Expand Up @@ -57,6 +63,20 @@ export default defineConfig({
use: { ...devices['Desktop Edge'] },
},
*/

/* when using archlinux to use ui testing, bundled browser are not correctly installed
Directly use the installed chromium
{
name: "chromium",
use: { ...devices["Desktop Chrome"],
launchOptions: {
executablePath: "/usr/bin/chromium",
},
},
},
},

*/
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
Expand Down
4 changes: 3 additions & 1 deletion tests/auth/logout/tchap-logout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ test.describe('Tchap : logout', () => {
await page.getByRole('button').filter({ hasText: 'Continuer' }).click();

// Success - Confirm identity
await expect(page.getByRole('button').filter({hasText: 'Vérification impossible ?'})).toBeVisible({ timeout: 20000 });
await expect(
page.getByRole('button').filter({ hasText: 'Vérification impossible ?' })
).toBeVisible({ timeout: 20000 });
await screenChecker(page, `/`);
});
});
6 changes: 3 additions & 3 deletions tests/integration/minimal/minimal-scenario.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { Page } from '@playwright/test';
//this scenario is one big test to cover all the scenario on a not MAS synapse (dev02 - a) and one MAS synapse (ext01 - e)

// Helper function to create a public room
async function createPublicRoom(page: Page, roomName: string): Promise<string> {
export async function createPublicRoom(page: Page, roomName: string): Promise<string> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expose the room creation fonction, since it will be used in lot of places

const appPage = new TchapAppPage(page);
await page.getByRole('button', { name: 'Ajouter', exact: true }).click();
await page.getByRole('menuitem', { name: 'Nouveau salon', exact: true }).click();
Expand All @@ -33,7 +33,7 @@ async function createPublicRoom(page: Page, roomName: string): Promise<string> {
}

// Helper function to create an encrypted private room
async function createEncryptedPrivateRoom(page: Page, roomName: string): Promise<string> {
export async function createEncryptedPrivateRoom(page: Page, roomName: string): Promise<string> {
const appPage = new TchapAppPage(page);
await page.getByRole('button', { name: 'Ajouter', exact: true }).click();
await page.getByText('Nouveau salon').click();
Expand All @@ -57,7 +57,7 @@ async function createEncryptedPrivateRoom(page: Page, roomName: string): Promise
}

// Helper function to create an unencrypted private room
async function createUnencryptedPrivateRoom(page: Page, roomName: string): Promise<string> {
export async function createUnencryptedPrivateRoom(page: Page, roomName: string): Promise<string> {
const appPage = new TchapAppPage(page);
await page.getByRole('button', { name: 'Ajouter', exact: true }).click();
await page.getByText('Nouveau salon').click();
Expand Down
Loading