mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-10876] ACA e2e playwright automated test for Firefox Edge and Safari (#4952)
* [ACS-10876] playwright config changes to support multi browser * [ACS-10876]workflow temp changes to enable all browser run * [ACS-10876]workflow issue fix * [ACS-10876]workflow issue fix * [ACS-10876]workflow issue fix * [ACS-10876]workflow issue fix * [ACS-10876]fix report issue and webkit dep issue * [ACS-10876]fix report issue and exclude test logic * [ACS-10876]playwright browser setup change * [ACS-10876]small fixes * [ACS-10876]restore only run on pull request schedule job * [ACS-10876]sonar cloud issue fix * [ACS-10876]make chromium for pr run and chrome browser for scheduled run * [ACS-10876]sonar cloud issue fix * [ACS-10876]sonar cloud issue fix and small improvement
This commit is contained in:
@@ -22,13 +22,121 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PlaywrightTestConfig, devices } from '@playwright/test';
|
||||
import { PlaywrightTestConfig, devices, chromium } from '@playwright/test';
|
||||
import { timeouts } from '../utils';
|
||||
import { getReporter } from './report-portal.config';
|
||||
|
||||
type LaunchOptions = Parameters<typeof chromium.launch>[0];
|
||||
|
||||
require('@alfresco/adf-cli/tooling').dotenvConfig();
|
||||
const { env } = process;
|
||||
|
||||
interface BrowserConfig {
|
||||
device: any;
|
||||
launchOptions: LaunchOptions;
|
||||
name: string;
|
||||
}
|
||||
|
||||
function getBrowsersToUse(): string[] {
|
||||
const browserEnv = (env.PLAYWRIGHT_BROWSER || 'chromium').toLowerCase();
|
||||
const allBrowsers = ['chrome', 'firefox', 'webkit', 'msedge'];
|
||||
|
||||
if (browserEnv === 'all') {
|
||||
return allBrowsers;
|
||||
} else if (allBrowsers.includes(browserEnv) || browserEnv === 'chromium') {
|
||||
return [browserEnv];
|
||||
} else {
|
||||
return ['chromium'];
|
||||
}
|
||||
}
|
||||
|
||||
function getBrowserConfig(browser: string): BrowserConfig {
|
||||
const launchOptions: LaunchOptions = {
|
||||
devtools: false,
|
||||
slowMo: 300
|
||||
};
|
||||
|
||||
const chromiumArgs = ['--no-sandbox', '--disable-site-isolation-trials'];
|
||||
|
||||
switch (browser) {
|
||||
case 'firefox':
|
||||
return {
|
||||
device: devices['Desktop Firefox'],
|
||||
launchOptions,
|
||||
name: 'firefox'
|
||||
};
|
||||
case 'webkit':
|
||||
return {
|
||||
device: devices['Desktop Safari'],
|
||||
launchOptions,
|
||||
name: 'webkit'
|
||||
};
|
||||
case 'msedge':
|
||||
launchOptions.args = chromiumArgs;
|
||||
return {
|
||||
device: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||
launchOptions,
|
||||
name: 'msedge'
|
||||
};
|
||||
case 'chrome':
|
||||
launchOptions.args = chromiumArgs;
|
||||
return {
|
||||
device: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
launchOptions,
|
||||
name: 'chrome'
|
||||
};
|
||||
case 'chromium':
|
||||
default:
|
||||
launchOptions.args = chromiumArgs;
|
||||
return {
|
||||
device: devices['Desktop Chrome'],
|
||||
launchOptions,
|
||||
name: 'chromium'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createSuiteProjects(
|
||||
suiteName: string,
|
||||
testDir: string,
|
||||
useConfig: Record<string, any> = {},
|
||||
projectConfig: Record<string, any> = {}
|
||||
) {
|
||||
const browsersToUse = getBrowsersToUse();
|
||||
const browserEnv = (env.PLAYWRIGHT_BROWSER || 'chrome').toLowerCase();
|
||||
|
||||
return browsersToUse.map((browser) => {
|
||||
const { device, launchOptions } = getBrowserConfig(browser);
|
||||
|
||||
return {
|
||||
name: browserEnv === 'all' ? `${suiteName} - ${browser}` : suiteName,
|
||||
testDir,
|
||||
use: {
|
||||
...device,
|
||||
launchOptions,
|
||||
...useConfig
|
||||
},
|
||||
...projectConfig
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function getBrowserProjects() {
|
||||
const browsersToUse = getBrowsersToUse();
|
||||
|
||||
return browsersToUse.map((browser) => {
|
||||
const { device, launchOptions, name } = getBrowserConfig(browser);
|
||||
|
||||
return {
|
||||
name,
|
||||
use: {
|
||||
...device,
|
||||
launchOptions
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export const getGlobalConfig: PlaywrightTestConfig = {
|
||||
timeout: timeouts.globalTest,
|
||||
globalTimeout: timeouts.globalSpec,
|
||||
@@ -62,21 +170,9 @@ export const getGlobalConfig: PlaywrightTestConfig = {
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'retain-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
screenshot: 'only-on-failure',
|
||||
launchOptions: {
|
||||
devtools: false,
|
||||
args: ['--no-sandbox', '--disable-site-isolation-trials'],
|
||||
slowMo: 300
|
||||
}
|
||||
screenshot: 'only-on-failure'
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome']
|
||||
}
|
||||
}
|
||||
]
|
||||
projects: getBrowserProjects()
|
||||
};
|
||||
|
||||
@@ -28,14 +28,16 @@ import { timeouts } from '../utils';
|
||||
const { env } = process;
|
||||
|
||||
export const getReportPortalConfig = () => {
|
||||
const browser = (env.PLAYWRIGHT_BROWSER || 'chrome').toLowerCase();
|
||||
const attributes = [
|
||||
{ key: 'Job', value: `${env.GITHUB_JOB}` },
|
||||
{ key: 'Build_type', value: `${env.GITHUB_EVENT_NAME}` },
|
||||
{ key: 'Repository', value: `${env.GITHUB_REPOSITORY}` },
|
||||
{ key: 'Branch', value: `${env.GITHUB_HEAD_REF || env.GITHUB_REF}` }
|
||||
{ key: 'Branch', value: `${env.GITHUB_HEAD_REF || env.GITHUB_REF}` },
|
||||
{ key: 'Browser', value: browser }
|
||||
];
|
||||
|
||||
const launch = `GitHub Actions - ACA`;
|
||||
const launch = `GitHub Actions - ACA - ${browser}`;
|
||||
|
||||
return {
|
||||
endpoint: env.REPORT_PORTAL_URL,
|
||||
@@ -43,13 +45,19 @@ export const getReportPortalConfig = () => {
|
||||
project: 'alfresco-content-app',
|
||||
launch,
|
||||
includeTestSteps: true,
|
||||
skipPassed: true,
|
||||
restClientConfig: {
|
||||
timeout: timeouts.extendedTest
|
||||
},
|
||||
attributes,
|
||||
description: `[Run on GitHub Actions ${env.GITHUB_RUN_ID}](${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID})`
|
||||
description: `[Run ${env.GITHUB_RUN_ID}](${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}) - ${browser} - Failures only`
|
||||
};
|
||||
};
|
||||
|
||||
export const getReporter = (): ReporterDescription[] =>
|
||||
env.CI ? [['@reportportal/agent-js-playwright', getReportPortalConfig()], ['github']] : [['html']];
|
||||
export const getReporter = (): ReporterDescription[] => {
|
||||
if (!env.CI) {
|
||||
return [['html']];
|
||||
}
|
||||
|
||||
return [['@reportportal/agent-js-playwright', getReportPortalConfig()], ['github']];
|
||||
};
|
||||
|
||||
@@ -22,15 +22,39 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const getCurrentBrowser = (): string => (process.env.PLAYWRIGHT_BROWSER || 'chrome').toLowerCase();
|
||||
|
||||
export const getExcludedTestsRegExpArray = (excludedJson: any, projectName: string) => {
|
||||
const prefix = `[ 🎭 Playwright Excludes - ${projectName} ]`;
|
||||
const objectKeys = Object.keys(excludedJson);
|
||||
const currentBrowser = getCurrentBrowser();
|
||||
const browserKeys = ['all', 'firefox', 'chromium', 'webkit', 'msedge'];
|
||||
const relevantKeys: string[] = [];
|
||||
const testIdsToExclude: string[] = [];
|
||||
|
||||
if (!objectKeys.length) {
|
||||
console.info(`${prefix} ✅ No excluded tests 🎉 `);
|
||||
} else {
|
||||
console.warn(`${prefix} ❌ Tests excluded because of 🐛 : ${objectKeys}`);
|
||||
// Always include 'all' if it exists
|
||||
if (excludedJson.all && typeof excludedJson.all === 'object') {
|
||||
const allTestIds = Object.keys(excludedJson.all);
|
||||
testIdsToExclude.push(...allTestIds);
|
||||
relevantKeys.push('all');
|
||||
}
|
||||
|
||||
return objectKeys.map((key) => new RegExp(key));
|
||||
// Include current browser-specific exclusions
|
||||
const browserKey = browserKeys.find((key) => key.toLowerCase() === currentBrowser);
|
||||
if (browserKey && excludedJson[browserKey] && typeof excludedJson[browserKey] === 'object') {
|
||||
const browserTestIds = Object.keys(excludedJson[browserKey]);
|
||||
testIdsToExclude.push(...browserTestIds);
|
||||
if (!relevantKeys.includes(browserKey)) {
|
||||
relevantKeys.push(browserKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (testIdsToExclude.length > 0) {
|
||||
console.warn(
|
||||
`${prefix} ❌ Tests excluded for browser '${currentBrowser}' because of 🐛 : ${testIdsToExclude.join(', ')} (from keys: ${relevantKeys.join(', ')})`
|
||||
);
|
||||
} else {
|
||||
console.info(`${prefix} ✅ No excluded tests for browser '${currentBrowser}' 🎉`);
|
||||
}
|
||||
|
||||
return testIdsToExclude.map((key) => new RegExp(key));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user