Mono repo -> Master (#22553)
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
Этот коммит содержится в:
38
e2e/playwright/support/visual/index.ts
Обычный файл
38
e2e/playwright/support/visual/index.ts
Обычный файл
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import os from 'node:os';
|
||||
|
||||
import chalk from 'chalk';
|
||||
import {expect, TestInfo} from '@playwright/test';
|
||||
|
||||
import {illegalRe} from '@e2e-support/util';
|
||||
import testConfig, {TestArgs} from '@e2e-test.config';
|
||||
|
||||
import snapshotWithPercy from './percy';
|
||||
|
||||
export async function matchSnapshot(testInfo: TestInfo, testArgs: TestArgs) {
|
||||
if (os.platform() !== 'linux') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
`^ Warning: No visual test performed. Run in Linux or Playwright docker image to match snapshot.`
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (testConfig.snapshotEnabled) {
|
||||
// Visual test with built-in snapshot
|
||||
const filename = testInfo.title.replace(illegalRe, '').replace(/\s/g, '-').trim().toLowerCase();
|
||||
expect(await testArgs.page.screenshot({fullPage: true})).toMatchSnapshot(`${filename}.png`);
|
||||
}
|
||||
|
||||
if (testConfig.percyEnabled) {
|
||||
// Used to easily identify the screenshot when viewing from third-party service provider.
|
||||
const name = `[${testInfo.project.name}, ${testArgs?.viewport?.width}px] > ${testInfo.file} > ${testInfo.title}`;
|
||||
|
||||
// Visual test with Percy
|
||||
await snapshotWithPercy(name, testArgs);
|
||||
}
|
||||
}
|
||||
22
e2e/playwright/support/visual/percy.ts
Обычный файл
22
e2e/playwright/support/visual/percy.ts
Обычный файл
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import percySnapshot from '@percy/playwright';
|
||||
|
||||
import testConfig, {TestArgs} from '@e2e-test.config';
|
||||
|
||||
export default async function snapshotWithPercy(name: string, testArgs: TestArgs) {
|
||||
if (testArgs.browserName === 'chromium' && testConfig.percyEnabled && testArgs.viewport) {
|
||||
if (!testConfig.percyToken) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Error: Token is missing! Please set using: "export PERCY_TOKEN=<change_me>"');
|
||||
}
|
||||
|
||||
const {page, viewport} = testArgs;
|
||||
|
||||
// Ignore since percy is using Playwright.Page
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
await percySnapshot(page, name, {widths: [viewport.width], minHeight: viewport.height});
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user