Skip to content

Commit 4dd2f74

Browse files
authored
fix(cc-widgets): End 2 End Tests stabilised (#517)
1 parent e6b953d commit 4dd2f74

35 files changed

Lines changed: 4178 additions & 3695 deletions

playwright.config.ts

Lines changed: 38 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,66 @@
1-
import { defineConfig, devices } from '@playwright/test';
1+
import {defineConfig, devices} from '@playwright/test';
22
import dotenv from 'dotenv';
33
import path from 'path';
4+
import {USER_SETS} from './playwright/test-data';
45

5-
// Alternatively, read from "../my.env" file.
6-
dotenv.config({ path: path.resolve(__dirname, '.env') });
6+
dotenv.config({path: path.resolve(__dirname, '.env')});
77

8-
/**
9-
* See https://playwright.dev/docs/test-configuration.
10-
*/
118
const dummyAudioPath = path.resolve(__dirname, './playwright/wav/dummyAudio.wav');
9+
1210
export default defineConfig({
1311
testDir: './playwright',
14-
/* Maximum time one test can run for. */
1512
timeout: 180000,
16-
/* Run your local dev server before starting the tests */
1713
webServer: {
1814
command: 'yarn workspace samples-cc-react-app serve',
1915
url: 'http://localhost:3000',
2016
reuseExistingServer: !process.env.CI,
2117
stdout: 'ignore',
2218
stderr: 'pipe',
2319
},
24-
fullyParallel: false,
25-
/* Retry on CI only */
2620
retries: 0,
27-
/* Opt out of parallel tests on CI. */
28-
workers: 1,
29-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
21+
fullyParallel: true,
22+
workers: Object.keys(USER_SETS).length, // Dynamic worker count based on USER_SETS
3023
reporter: 'html',
31-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3224
use: {
33-
/* Base URL to use in actions like `await page.goto('/')`. */
34-
// baseURL: 'http://127.0.0.1:3000',
3525
baseURL: 'http://localhost:3000',
36-
37-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3826
trace: 'retain-on-failure',
3927
},
40-
41-
/* Configure projects for major browsers */
4228
projects: [
4329
{
4430
name: 'OAuth: Get Access Token',
4531
testMatch: /global\.setup\.ts/,
4632
},
47-
{
48-
name: 'Test: Chrome',
49-
// Run all tests except advanced tests and transfer/consult tests on Chrome
50-
testIgnore: [/advanced-task-controls-test\.spec\.ts/],
51-
use: {
52-
...devices['Desktop Chrome'],
53-
launchOptions: {
54-
args: [
55-
`--disable-site-isolation-trials`,
56-
`--disable-web-security`,
57-
`--no-sandbox`,
58-
`--disable-features=WebRtcHideLocalIpsWithMdns`,
59-
`--allow-file-access-from-files`,
60-
`--use-fake-ui-for-media-stream`,
61-
`--use-fake-device-for-media-stream`,
62-
`--use-file-for-fake-audio-capture=${dummyAudioPath}`,
63-
],
64-
}
65-
},
66-
// dependencies: ['OAuth: Get Access Token'],
67-
},
68-
{
69-
name: 'Test: Firefox - Advanced Tests',
70-
// Run only advanced tests and transfer/consult tests on Firefox
71-
testMatch: [/advanced-task-controls-test\.spec\.ts/],
72-
use: {
73-
...devices['Desktop Firefox'],
74-
launchOptions: {
75-
// Firefox-specific preferences for fake media
76-
firefoxUserPrefs: {
77-
// Essential media preferences for testing
78-
'media.navigator.streams.fake': true,
79-
'media.navigator.permission.disabled': true,
80-
'media.getusermedia.insecure.enabled': true,
81-
'media.peerconnection.enabled': true,
82-
'permissions.default.microphone': 1,
83-
'permissions.default.camera': 1,
84-
85-
// Automation-friendly settings
86-
'media.autoplay.default': 0,
87-
'media.autoplay.blocking_policy': 0,
88-
'privacy.webrtc.legacyGlobalIndicator': false,
89-
}
33+
// Dynamically generate test projects from USER_SETS
34+
...Object.entries(USER_SETS).map(([setName, setData], index) => {
35+
return {
36+
name: setName,
37+
dependencies: ['OAuth: Get Access Token'],
38+
fullyParallel: false,
39+
retries: 1,
40+
testMatch: [`**/suites/${setData.TEST_SUITE}`],
41+
use: {
42+
...devices['Desktop Chrome'],
43+
channel: 'chrome',
44+
storageState: undefined,
45+
launchOptions: {
46+
args: [
47+
`--disable-site-isolation-trials`,
48+
`--disable-web-security`,
49+
`--no-sandbox`,
50+
`--disable-features=WebRtcHideLocalIpsWithMdns`,
51+
`--allow-file-access-from-files`,
52+
`--use-fake-ui-for-media-stream`,
53+
`--use-fake-device-for-media-stream`,
54+
`--use-file-for-fake-audio-capture=${dummyAudioPath}`,
55+
`--remote-debugging-port=${9221 + index}`,
56+
`--disable-extensions`,
57+
`--disable-plugins`,
58+
`--window-position=${index * 1300},0`,
59+
`--window-size=1280,720`,
60+
],
61+
},
9062
},
91-
// Remove permissions - Firefox handles this differently
92-
},
93-
// dependencies: ['OAuth: Get Access Token'],
94-
},
95-
96-
// {
97-
// name: 'Test: Webkit',
98-
// use: {...devices['Desktop Safari']},
99-
// dependencies: ['firefox'],
100-
// },
63+
};
64+
}),
10165
],
102-
});
66+
});

0 commit comments

Comments
 (0)