woocommerce/plugins/woocommerce-blocks/tests/e2e/playwright.config.ts

63 lines
1.8 KiB
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { defineConfig, PlaywrightTestConfig } from '@playwright/test';
import { BASE_URL, STORAGE_STATE_PATH } from '@woocommerce/e2e-utils';
import { fileURLToPath } from 'url';
// eslint-disable-next-line @typescript-eslint/no-var-requires
require( 'dotenv' ).config();
interface ExtendedPlaywrightTestConfig extends PlaywrightTestConfig {
use: {
stateDir?: string;
} & PlaywrightTestConfig[ 'use' ];
}
const { CI, DEFAULT_TIMEOUT_OVERRIDE, E2E_MAX_FAILURES } = process.env;
const config: ExtendedPlaywrightTestConfig = {
timeout: parseInt( DEFAULT_TIMEOUT_OVERRIDE || '', 10 ) || 100_000, // Defaults to 100s.
outputDir: 'artifacts/test-results',
globalSetup: fileURLToPath(
new URL( 'global-setup.ts', 'file:' + __filename ).href
),
globalTeardown: require.resolve( './global-teardown' ),
testDir: 'tests',
retries: CI ? 2 : 0,
workers: 1,
// Don't report slow test "files", as we're running our tests in serial.
reportSlowTests: null,
reporter: process.env.CI
? [ [ 'github' ], [ 'list' ], [ 'html' ] ]
: 'list',
maxFailures: E2E_MAX_FAILURES ? Number( E2E_MAX_FAILURES ) : 0,
snapshotPathTemplate:
'{testDir}/{testFileDir}/__screenshots__/{arg}{testName}{ext}',
use: {
baseURL: BASE_URL,
screenshot: 'only-on-failure',
stateDir: 'tests/e2e/test-results/storage/',
trace: 'retain-on-failure',
video: 'on-first-retry',
viewport: { width: 1280, height: 720 },
storageState: STORAGE_STATE_PATH,
actionTimeout: 10_000,
Fix E2E tests for WordPress 6.5 (#44593) * Add sharding to Blocks e2e tests * Changelog * Push a change to Blocks README to trigger tests * Fix syntax * Fixed again * Try again * Trying to get the shard number * Shard names * fix E2E test * use wordpress 6.5 as test env * update util * fix Mini Cart Block E2E test * add editor dependency * fix E2E tests * fix E2E tests * fix E2E tests * restore global setup file * fix E2E tests * fix global setup * try now * try now * fix E2E test * fix E2E test * fix mini cart E2E test * add changelog * complete all the jobs * update playwright * fix E2E tests * fix E2E test * try now * fix E2E test * not show welcome guide for the post editor * update configuration * fix guest storage state * fix E2E tests * check now * fix E2E tests * fix command * improve selector * use WordPress 6.5 beta 2 * use WordPress 6.5 beta 3 * fix canvas use * wait for button * fix E2E test * fix E2E test * fix product button * fix product collection tests * fix wp build link * use beforeEach * fix E2E tests * use WordPress RC2 * Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce * trigger CI * fix E2E tests * fix E2E tests * fix E2E test * fix E2E tests * add timeout * Fix flaky locator assertions ...by replacing them with dedicaed auto-waiting ones. * Apply correct use of waitForRequest/Response and remove where unnecessary * Remove obsolete waitUntils * Fix accidentally isolated test * Replace saveTemplate with core's saveSiteEditorEntities * Fix findProductRow util * Restore necessary request waiters * Use activateTheme util instead of cli call * Remove unused import * Fix request destructured call Request properties cannot be destructured (todo: create upstream issue) * Revert some waitForRequest changes These need to be investigated for heavy bleeding from side-effects * Fix failing cart checkout test * Set navigation timeout to 10s We need this so that API like page.goto or page.waitForURL doesn't take 100 seconds (global timeout) to throw. * Do not close the page in the page fixture override The page will be closed anyway, and by closing it explicitly in the teardown phase of the fixture we create a flaky race condition where the page might be closed before the action/navigation timeout is reached, resulting in "page closed!" error instead of, e.g. "locator.fill timed out". * Revert product collection tests due to conflicts * Try fixing E2E test * Remove some random change * Revert to programmatic blur :shrug: * Fix additional checkout fields test * Add a waitForRequest safety check in case it's debounced * Fix price filter test * Fix flaky visitTemplateEditor util * Remove obsolete code from global setup * Revert "Fix flaky visitTemplateEditor util" This reverts commit 227336f2653eb17b37ade45634374d69ef221c50. * update to WordPress RC3 * Add waitForCustomerDataUpdate function * Don't wait for requests and use data store instead * Try with new wait condition * Re-add wait condition * Wait for customer update in guest checkout test * Add changelog * fix lint error * fix some E2E tests * disable welcome guide * remove beforeAll * add timeout * add another timeout * increase timeout * Add call to waitForSiteEditorFinishLoading when editing the theme template * remove timeout * remove not necessary comment * clean changelog * Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce * remove changelog --------- Co-authored-by: Jon Lane <jon.lane@automattic.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com> Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2024-03-27 09:54:44 +00:00
navigationTimeout: 10_000,
},
projects: [
{
name: 'blockThemeConfiguration',
testDir: '.',
testMatch: /block-theme.setup.ts/,
},
{
name: 'blockTheme',
testMatch: /.*.block_theme.spec.ts/,
dependencies: [ 'blockThemeConfiguration' ],
},
],
};
export default defineConfig( config );