diff --git a/package.json b/package.json index 52fa13a51..cf94d88ce 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,8 @@ "clean:dist": "yarn workspaces foreach --all --topological --parallel run clean:dist", "test:unit": "yarn run test:tooling && yarn run test:cc-widgets && yarn run test:meetings-widget", "test:e2e": "yarn playwright test", + "test:e2e:cc": "yarn workspace @webex/cc-widgets run test:e2e", + "test:e2e:meetings": "yarn workspace @webex/widgets run test:e2e", "test:styles": "yarn workspaces foreach --all --exclude webex-widgets run test:styles", "test:tooling": "NODE_ENV=test jest --coverage", "test:cc-widgets": "yarn workspaces foreach --all --exclude webex-widgets --exclude samples-cc-wc-app --exclude samples-cc-react-app run test:unit", diff --git a/packages/contact-center/cc-widgets/package.json b/packages/contact-center/cc-widgets/package.json index a64fb5984..a22276234 100644 --- a/packages/contact-center/cc-widgets/package.json +++ b/packages/contact-center/cc-widgets/package.json @@ -31,6 +31,7 @@ "build:src": "yarn run clean:dist && webpack", "build:watch": "webpack --watch", "test:unit": "NODE_ENV=test jest --coverage", + "test:e2e": "yarn run -T playwright test --config ../../../playwright.config.ts", "test:styles": "eslint", "deploy:npm": "yarn npm publish" }, diff --git a/playwright.config.ts b/playwright.config.ts index 378f47490..7cde685b8 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -19,7 +19,9 @@ export default defineConfig({ }, retries: 0, fullyParallel: true, - workers: Object.keys(USER_SETS).length, // Dynamic worker count based on USER_SETS + // Match CI concurrency to the runner's available resources while preserving + // one worker per user set for local runs. + workers: process.env.CI ? 4 : Object.keys(USER_SETS).length, reporter: 'html', use: { baseURL: 'http://localhost:3000', diff --git a/playwright/global.setup.ts b/playwright/global.setup.ts index 8a4a51c84..bf39f94fb 100644 --- a/playwright/global.setup.ts +++ b/playwright/global.setup.ts @@ -6,7 +6,6 @@ const path = require('path'); const ENV_PATH = path.resolve(__dirname, '../.env'); const OAUTH_BATCH_SIZE = 4; -const OAUTH_SET_GROUP_SIZE = 2; type EnvUpdateMap = Record; @@ -65,18 +64,6 @@ const buildOAuthTasksForSetGroup = (setKeys: UserSetKey[]): OAuthTask[] => { return setKeys.flatMap((setKey) => buildOAuthTasksForSet(setKey)); }; -const buildSetGroups = (setKeys: UserSetKey[], groupSize: number): UserSetKey[][] => { - if (groupSize <= 0) { - throw new Error('groupSize must be greater than 0'); - } - - const groups: UserSetKey[][] = []; - for (let index = 0; index < setKeys.length; index += groupSize) { - groups.push(setKeys.slice(index, index + groupSize)); - } - return groups; -}; - const buildDialNumberTask = (): OAuthTask | null => { const dialNumberUsername = process.env.PW_DIAL_NUMBER_LOGIN_USERNAME; const dialNumberPassword = process.env.PW_DIAL_NUMBER_LOGIN_PASSWORD; @@ -149,19 +136,14 @@ export const UpdateENVWithUserSets = () => { return updates; }; -const runOAuthSetGroup = async (browser: Browser, setGroup: UserSetKey[]) => { - const tasks = buildOAuthTasksForSetGroup(setGroup); - return collectTokensInBatches(browser, tasks); -}; - setup('OAuth', async ({browser}) => { const userSetKeys = Object.keys(USER_SETS) as UserSetKey[]; - const oauthSetGroups = buildSetGroups(userSetKeys, OAUTH_SET_GROUP_SIZE); // Collect all environment updates const userSetUpdates = UpdateENVWithUserSets(); - const groupedTokenUpdates = await Promise.all(oauthSetGroups.map((setGroup) => runOAuthSetGroup(browser, setGroup))); - const tokenUpdates = groupedTokenUpdates.reduce((acc, groupTokens) => ({...acc, ...groupTokens}), {}); + const oauthTasks = buildOAuthTasksForSetGroup(userSetKeys); + // Use one batch loop so OAUTH_BATCH_SIZE is the global browser-context limit. + const tokenUpdates = await collectTokensInBatches(browser, oauthTasks); // Fetch dial number token (if configured) const dialNumberTask = buildDialNumberTask();