Skip to content

Commit d67bd60

Browse files
committed
E2E: drop the prime-logins project and AUTHENTICATE_ACCOUNTS
The setup project logged in as a per-build-type list of accounts before the suite, so the specs would find cookies rather than all log in at once. The list is hand written per test group: it drifts from what the specs use, an account missing from it got no priming at all, and a build type running the wrong list paid for logins no spec needs. The login lock covers the same ground without a list. Removes the project, the env var behind it, the resolver and the reporting script that read it, the 25 TeamCity parameters setting it and the semicolon form EXTRA_ENV_VARS grew to carry one. Also the priming half of the legacy Jest global setup, which has had no specs to prime since the last one moved to Playwright Test.
1 parent 16634f7 commit d67bd60

12 files changed

Lines changed: 31 additions & 215 deletions

File tree

.teamcity/_self/CalypsoE2ETestsBuildTemplate.kt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ object CalypsoE2ETestsBuildTemplate : Template({
2323
param("env.NODE_CONFIG_ENV", "test")
2424
param("env.PLAYWRIGHT_BROWSERS_PATH", "0")
2525
param("env.LOCALE", "en")
26-
// No AUTHENTICATE_ACCOUNTS here on purpose: it names the accounts the prime-logins
27-
// setup project logs in as beyond the one the environment resolves to, and that is per
28-
// test group, not per template. A build type running a group should set it; leaving it
29-
// unset primes every account any group uses, which is safe but slower. See
30-
// test/e2e/setup/prime-logins.setup.ts.
3126
// required in the CTRF report
3227
param("env.BRANCH_NAME", "%teamcity.build.branch%")
3328
param("PROJECT", "desktop")
@@ -165,14 +160,9 @@ object CalypsoE2ETestsBuildTemplate : Template({
165160
name = "Set extra environment variables"
166161
id = "set_extra_env_vars"
167162
scriptContent = """
168-
# Parse EXTRA_ENV_VARS param (KEY=value pairs) and set as TeamCity env params.
169-
# Pairs are separated by semicolons so that a value can hold a comma, as
170-
# AUTHENTICATE_ACCOUNTS does; a value with no semicolon keeps the older
171-
# comma-separated form, so a saved custom run still parses.
163+
# Parse EXTRA_ENV_VARS param (comma-separated KEY=value pairs) and set as TeamCity env params
172164
if [[ -n "%EXTRA_ENV_VARS%" ]]; then
173-
SEPARATOR=','
174-
[[ "%EXTRA_ENV_VARS%" == *";"* ]] && SEPARATOR=';'
175-
IFS="${'$'}SEPARATOR" read -ra ENV_PAIRS <<< "%EXTRA_ENV_VARS%"
165+
IFS=',' read -ra ENV_PAIRS <<< "%EXTRA_ENV_VARS%"
176166
for pair in "${'$'}{ENV_PAIRS[@]}"; do
177167
KEY="${'$'}{pair%%=*}"
178168
VALUE="${'$'}{pair#*=}"
@@ -200,16 +190,6 @@ object CalypsoE2ETestsBuildTemplate : Template({
200190
fi
201191
echo "Playwright grep flag: ${'$'}{GREP_FLAG:-(none, running all tests)}"
202192
203-
# AUTHENTICATE_ACCOUNTS names the accounts this build's group logs in as, so it
204-
# is wrong for a build type whose group was adapted away to run everything: hand
205-
# priming back its own default list instead. Only that adaptation clears the
206-
# flag; a build type selecting its specs through PROJECT leaves TEST_GROUP empty
207-
# on purpose and keeps its list.
208-
if [[ "%IGNORE_TEST_GROUP_FOR_E2E_CHANGES%" == "true" && -z "${'$'}GREP_FLAG" ]]; then
209-
echo "No test group: priming the default accounts instead of AUTHENTICATE_ACCOUNTS"
210-
unset AUTHENTICATE_ACCOUNTS
211-
fi
212-
213193
cd test/e2e
214194
# Clear any stale teardown-leak markers from a reused checkout before this run.
215195
# Recursive over output/: markers should land in output/teardown-leaks, but a

.teamcity/_self/projects/MarTech.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ object ToSAcceptanceTracking : BuildType({
3838
param("TEST_GROUP", "@legal")
3939
param("CALYPSO_BASE_URL", "https://wordpress.com")
4040
param("DASHBOARD_BASE_URL", "https://my.wordpress.com")
41-
param("env.AUTHENTICATE_ACCOUNTS", "")
4241
}
4342

4443
steps {

.teamcity/_self/projects/WPComTests.kt

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.exec
2323
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.ScriptBuildStep
2424
import jetbrains.buildServer.configs.kotlin.v2019_2.matrix
2525

26-
// Accounts the @jetpack-wpcom-integration specs log in as on top of the one the run's own
27-
// environment resolves to, which the prime-logins setup project adds by itself. On Simple
28-
// that is the Blaze spec's free plan site plus the site editor's own staging site; on Atomic
29-
// both of those resolve to the account the environment already gives us.
30-
const val jetpackWpcomIntegrationSimpleAccounts = "simpleSiteFreePlanUser,jetpackStagingFseUser"
31-
const val jetpackWpcomIntegrationAtomicAccounts = ""
32-
3326
object WPComTests : Project({
3427
id("WPComTests")
3528
name = "WPCom Tests"
@@ -116,17 +109,6 @@ fun gutenbergPlaywrightBuildType( targetDevice: String, buildUuid: String, atomi
116109
checked = "true",
117110
unchecked = "false"
118111
)
119-
// The account this build runs against is added by the prime-logins project itself.
120-
// On top of it the @gutenberg specs log in as defaultUser to read a published post
121-
// as a second user, as the site editor account for this leg (the environment key
122-
// carries no variant, so that one is never derived), and, on stable Gutenberg on a
123-
// Simple site only, resolve their criteria overrides to simpleSitePersonalPlanUser.
124-
param("env.AUTHENTICATE_ACCOUNTS", when {
125-
atomic && (edge || nightly) -> "defaultUser,siteEditorAtomicSiteEdgeUser"
126-
atomic -> "defaultUser,siteEditorAtomicSiteUser"
127-
edge || nightly -> "defaultUser,siteEditorSimpleSiteEdgeUser"
128-
else -> "defaultUser,simpleSitePersonalPlanUser,siteEditorSimpleSiteUser"
129-
})
130112
if (atomic) {
131113
param("env.TEST_ON_ATOMIC", "true")
132114
// Overrides the inherited max workers settings and sets it to not run any tests in parallel.
@@ -217,7 +199,6 @@ fun jetpackSimpleDeploymentE2eBuildType( targetDevice: String, buildUuid: String
217199
calypsoBaseUrlParam()
218200
param("env.VIEWPORT_NAME", "$targetDevice")
219201
param("env.JETPACK_TARGET", "wpcom-deployment")
220-
param("env.AUTHENTICATE_ACCOUNTS", jetpackWpcomIntegrationSimpleAccounts)
221202
}
222203

223204
steps {
@@ -281,7 +262,6 @@ fun jetpackAtomicDeploymentE2eBuildType( targetDevice: String, buildUuid: String
281262
param("env.VIEWPORT_NAME", "$targetDevice")
282263
param("env.JETPACK_TARGET", "wpcom-deployment")
283264
param("env.TEST_ON_ATOMIC", "true")
284-
param("env.AUTHENTICATE_ACCOUNTS", jetpackWpcomIntegrationAtomicAccounts)
285265
}
286266

287267
steps {
@@ -357,7 +337,6 @@ fun jetpackAtomicBuildSmokeE2eBuildType( targetDevice: String, buildUuid: String
357337
param("env.JETPACK_TARGET", "wpcom-deployment")
358338
param("env.TEST_ON_ATOMIC", "true")
359339
param("env.ATOMIC_VARIATION", "mixed")
360-
param("env.AUTHENTICATE_ACCOUNTS", jetpackWpcomIntegrationAtomicAccounts)
361340
}
362341

363342
steps {
@@ -411,7 +390,6 @@ private object I18NTests : BuildType({
411390
param("CALYPSO_BASE_URL", "https://wordpress.com")
412391
param("DASHBOARD_BASE_URL", "https://my.wordpress.com")
413392
param("env.E2E_CTRF_APP_NAME", "i18n (calypso)")
414-
param("env.AUTHENTICATE_ACCOUNTS", "i18nUser")
415393
}
416394

417395
features {
@@ -456,7 +434,6 @@ private object P2E2ETests : BuildType({
456434
param("CALYPSO_BASE_URL", "https://wpcalypso.wordpress.com")
457435
param("DASHBOARD_BASE_URL", "https://my.wordpress.com")
458436
param("env.E2E_CTRF_APP_NAME", "p2 (calypso)")
459-
param("env.AUTHENTICATE_ACCOUNTS", "p2User")
460437
}
461438

462439
features {
@@ -508,11 +485,6 @@ private object GutenbergPlaywrightTests : BuildType({
508485
param("CALYPSO_BASE_URL", "https://wordpress.com")
509486
param("DASHBOARD_BASE_URL", "https://my.wordpress.com")
510487
param("env.E2E_CTRF_APP_NAME", "gutenberg (calypso)")
511-
// The Simple Production leg; the others override this through EXTRA_ENV_VARS below.
512-
param(
513-
"env.AUTHENTICATE_ACCOUNTS",
514-
"defaultUser,simpleSitePersonalPlanUser,siteEditorSimpleSiteUser"
515-
)
516488
password("GB_E2E_ANNOUNCEMENT_SLACK_API_TOKEN", "credentialsJSON:8196e9b8-cf0a-4ab5-9547-95145134f04a", display = ParameterDisplay.HIDDEN);
517489
// Uncomment the following to route it to the test channel, don't forget to change the reference in the exec() calls below, too.
518490
// Ask someone from the Team Calypso Platform to know what these channels are. They are also available in the source for `announce.sh` (par of Gutenbot).
@@ -545,15 +517,12 @@ private object GutenbergPlaywrightTests : BuildType({
545517
value("desktop", label = "Desktop"),
546518
value("mobile", label = "Mobile"),
547519
))
548-
// Each leg carries the site editor account its own environment resolves to, which
549-
// the prime-logins project cannot derive: the environment key holds no variant.
550-
// The Simple Production leg takes the build's own AUTHENTICATE_ACCOUNTS above.
551520
param("EXTRA_ENV_VARS", listOf(
552521
value("", label = "Simple Production"),
553-
value("GUTENBERG_EDGE=true;AUTHENTICATE_ACCOUNTS=defaultUser,siteEditorSimpleSiteEdgeUser", label = "Simple Edge"),
554-
value("TEST_ON_ATOMIC=true;PW_WORKERS=1;AUTHENTICATE_ACCOUNTS=defaultUser,siteEditorAtomicSiteUser", label = "Atomic Production"),
555-
value("TEST_ON_ATOMIC=true;GUTENBERG_EDGE=true;PW_WORKERS=1;AUTHENTICATE_ACCOUNTS=defaultUser,siteEditorAtomicSiteEdgeUser", label = "Atomic Edge"),
556-
value("TEST_ON_ATOMIC=true;GUTENBERG_NIGHTLY=true;PW_WORKERS=1;AUTHENTICATE_ACCOUNTS=defaultUser,siteEditorAtomicSiteEdgeUser", label = "Atomic Nightly"),
522+
value("GUTENBERG_EDGE=true", label = "Simple Edge"),
523+
value("TEST_ON_ATOMIC=true,PW_WORKERS=1", label = "Atomic Production"),
524+
value("TEST_ON_ATOMIC=true,GUTENBERG_EDGE=true,PW_WORKERS=1", label = "Atomic Edge"),
525+
value("TEST_ON_ATOMIC=true,GUTENBERG_NIGHTLY=true,PW_WORKERS=1", label = "Atomic Nightly"),
557526
))
558527
}
559528
notifyAllFailuresAndFirstSuccess("#gutenberg-e2e")
@@ -580,7 +549,6 @@ private object JetpackE2ETestsBuildTemplate : Template({
580549
param("CALYPSO_BASE_URL", "https://wordpress.com")
581550
param("env.E2E_CTRF_APP_NAME", "jetpack (calypso)")
582551
param("env.JETPACK_TARGET", "wpcom-deployment")
583-
param("env.AUTHENTICATE_ACCOUNTS", jetpackWpcomIntegrationSimpleAccounts)
584552
}
585553

586554
features {
@@ -629,7 +597,6 @@ private object JetpackAtomicE2ETests : BuildType({
629597
param("PROJECT", "desktop")
630598
param("env.TEST_ON_ATOMIC", "true")
631599
param("env.PW_WORKERS", "5")
632-
param("env.AUTHENTICATE_ACCOUNTS", jetpackWpcomIntegrationAtomicAccounts)
633600
}
634601

635602
features {
@@ -659,6 +626,5 @@ private object JetpackAtomicSmokeE2ETests : BuildType({
659626
param("env.TEST_ON_ATOMIC", "true")
660627
param("env.PW_WORKERS", "14")
661628
param("env.ATOMIC_VARIATION", "mixed")
662-
param("env.AUTHENTICATE_ACCOUNTS", jetpackWpcomIntegrationAtomicAccounts)
663629
}
664630
})

.teamcity/_self/projects/WebApp.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,6 @@ object PlaywrightTestPRMatrix : BuildType({
984984
param("TEST_GROUP", "@calypso-pr")
985985
param("DOCKER_IMAGE_BUILD_NUMBER", "${BuildDockerImage.depParamRefs.buildNumber}")
986986
param("IGNORE_TEST_GROUP_FOR_E2E_CHANGES", "true")
987-
// calypsoPreReleaseUser is left out: the only @calypso-pr spec that logs in as it runs
988-
// on trunk alone, and this build type never builds trunk.
989-
param("env.AUTHENTICATE_ACCOUNTS", "atomicUser,commentingUser,defaultUser,gutenbergSimpleSiteUser,notificationsUser,siteEditorSimpleSiteUser,simpleSiteFreePlanUser,simpleSitePersonalPlanUser")
990987
}
991988

992989
features {
@@ -1039,7 +1036,6 @@ object PlaywrightTestPreReleaseMatrix : BuildType({
10391036
text("TEST_GROUP", "@calypso-release")
10401037
param("CALYPSO_BASE_URL", "https://wpcalypso.wordpress.com")
10411038
param("DASHBOARD_BASE_URL", "https://my.wordpress.com")
1042-
param("env.AUTHENTICATE_ACCOUNTS", "atomicUser,calypsoPreReleaseUser,defaultUser,simpleSiteFreePlanUser,simpleSitePersonalPlanUser")
10431039
}
10441040

10451041
features {
@@ -1076,10 +1072,6 @@ object PlaywrightTestDashboardPRMatrix : BuildType({
10761072
params {
10771073
param("TEST_GROUP", "@dashboard-pr")
10781074
param("DOCKER_IMAGE_BUILD_NUMBER", "${BuildDockerImage.depParamRefs.buildNumber}")
1079-
// Every @dashboard-pr spec takes the account this environment resolves to, and
1080-
// nothing else. Naming it costs no extra login: prime-logins adds the resolved
1081-
// account to whatever is listed here and logs in as each account once.
1082-
param("env.AUTHENTICATE_ACCOUNTS", "gutenbergSimpleSiteUser")
10831075
}
10841076

10851077
features {
@@ -1134,8 +1126,6 @@ object PlaywrightTestA4APRMatrix : BuildType({
11341126
params {
11351127
param("TEST_GROUP", "@a8c-for-agencies")
11361128
param("DOCKER_IMAGE_BUILD_NUMBER", "${BuildDockerImage.depParamRefs.buildNumber}")
1137-
// The @a8c-for-agencies specs sign up their own users and log in as no test account.
1138-
param("env.AUTHENTICATE_ACCOUNTS", "")
11391129
}
11401130

11411131
features {

packages/calypso-e2e/src/env-variables.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
import crypto from 'crypto';
33
import path from 'path';
44
import { getMag16Locales, getViewports } from './data-helper';
5-
import { TEST_ACCOUNT_NAMES } from './secrets';
65
import { SupportedEnvVariables, JetpackTarget, AtomicVariation } from './types/env-variables.types';
7-
import { TestAccountName } from '.';
86

97
class EnvVariables implements SupportedEnvVariables {
108
private _defaultEnvVariables: SupportedEnvVariables = {
119
A8C_FOR_AGENCIES_URL: 'https://agencies.automattic.com',
1210
ALLURE_RESULTS_PATH: '',
1311
ARTIFACTS_PATH: path.join( process.cwd(), 'results' ),
1412
ATOMIC_VARIATION: 'default',
15-
AUTHENTICATE_ACCOUNTS: [],
1613
BROWSER_NAME: 'chromium',
1714
CALYPSO_BASE_URL: `http://calypso.localhost:${ process.env.PORT || 3000 }`,
1815
COBLOCKS_EDGE: false,
@@ -111,22 +108,6 @@ class EnvVariables implements SupportedEnvVariables {
111108
: this._defaultEnvVariables.COBLOCKS_EDGE;
112109
}
113110

114-
get AUTHENTICATE_ACCOUNTS(): TestAccountName[] {
115-
const value = process.env.AUTHENTICATE_ACCOUNTS;
116-
if ( ! value ) {
117-
return this._defaultEnvVariables.AUTHENTICATE_ACCOUNTS;
118-
}
119-
120-
const parsedAccounts: TestAccountName[] = value.split( ',' ) as TestAccountName[];
121-
const supportedValues = new Set< TestAccountName >( TEST_ACCOUNT_NAMES );
122-
if ( ! parsedAccounts.every( ( account ) => supportedValues.has( account ) ) ) {
123-
throw new Error(
124-
`Unknown AUTHENTICATE_ACCOUNTS value: ${ value }.\nSupported values: ${ TEST_ACCOUNT_NAMES }`
125-
);
126-
}
127-
return parsedAccounts;
128-
}
129-
130111
get COOKIES_PATH(): string {
131112
const value = process.env.COOKIES_PATH;
132113
return value ? value : this._defaultEnvVariables.COOKIES_PATH;
Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
/* eslint-disable require-jsdoc */
2-
import { Browser, chromium } from 'playwright';
31
import envVariables from '../env-variables';
4-
import { TestAccount } from '../lib/test-account';
5-
import pwConfig from './playwright-config';
62

73
export default async (): Promise< void > => {
8-
const { AUTHENTICATE_ACCOUNTS, CALYPSO_BASE_URL } = envVariables;
4+
const { CALYPSO_BASE_URL } = envVariables;
95

106
// Checks whether the Calypso server is running so we can exit early with a help message.
117
// Don't run in CI because there seems to be a timing issue about whether calypso.live will be ready in time.
@@ -32,62 +28,4 @@ export default async (): Promise< void > => {
3228
process.exit( 1 );
3329
}
3430
}
35-
36-
// If PWDEBUG mode is enabled (stepping through each step)
37-
// don't execute the cookie refresh.
38-
if ( process.env.PWDEBUG ) {
39-
return;
40-
}
41-
42-
// If the list of accounts for which to pre-authenticate and save cookies
43-
// for is empty, then don't run.
44-
if ( AUTHENTICATE_ACCOUNTS.length === 0 ) {
45-
return;
46-
}
47-
48-
const browser = await chromium.launch( {
49-
...pwConfig.launchOptions,
50-
headless: true,
51-
} );
52-
53-
await Promise.all(
54-
AUTHENTICATE_ACCOUNTS.map( async ( accountName ) => {
55-
const testAccount = new TestAccount( accountName );
56-
if ( await testAccount.hasFreshAuthCookies() ) {
57-
return;
58-
}
59-
60-
await loginAndSaveCookiesWithRetry( testAccount, browser );
61-
} )
62-
);
63-
64-
await browser.close();
6531
};
66-
67-
async function loginAndSaveCookiesWithRetry( testAccount: TestAccount, browser: Browser ) {
68-
const MAX_ATTEMPTS = 2;
69-
let numberOfAttempts = 0;
70-
71-
let error: Error | undefined;
72-
while ( numberOfAttempts < MAX_ATTEMPTS ) {
73-
try {
74-
return await loginAndSaveCookies( testAccount, browser );
75-
} catch ( err ) {
76-
numberOfAttempts++;
77-
error = err as Error;
78-
}
79-
}
80-
81-
throw error;
82-
}
83-
84-
async function loginAndSaveCookies( testAccount: TestAccount, browser: Browser ) {
85-
const page = await browser.newPage( pwConfig.contextOptions );
86-
page.setDefaultTimeout( envVariables.TIMEOUT );
87-
try {
88-
await testAccount.logInViaLoginPage( page );
89-
await testAccount.saveAuthCookies( page.context() );
90-
} finally {
91-
await page.close();
92-
}
93-
}

packages/calypso-e2e/src/lib/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* Utilities */
22
export * from './validate-translations';
33
export * from './get-test-account-by-feature';
4-
export * from './accounts-to-prime';
54
export * from './translate';
65
export * from './social-connections-manager';
76

packages/calypso-e2e/src/types/env-variables.types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { TestAccountName } from '../';
2-
31
export type ViewportName = string;
42
export type TestLocales = string[];
53
export type JetpackTarget = 'remote-site' | 'wpcom-production' | 'wpcom-deployment';
@@ -18,7 +16,6 @@ export interface SupportedEnvVariables {
1816
readonly ALLURE_RESULTS_PATH: string;
1917
readonly ARTIFACTS_PATH: string;
2018
readonly ATOMIC_VARIATION: AtomicVariation;
21-
readonly AUTHENTICATE_ACCOUNTS: TestAccountName[];
2219
readonly BROWSER_NAME: string;
2320
readonly CALYPSO_BASE_URL: string;
2421
readonly COBLOCKS_EDGE: boolean;

test/e2e/AGENTS.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,7 @@ test( 'Test', async ( { pageLogin, componentSidebar } ) => {
141141

142142
### Available Fixtures
143143

144-
**Accounts**: one fixture per key of `fixtureAccounts` in [`lib/pw-base.ts`](lib/pw-base.ts), plus `accountGivenByEnvironment` and `accountSMS`. Declaring an account fixture logs in as it, whether or not the test body uses it, so take only the ones the test needs. To have a build log in as an account before the suite instead of during it, add it to that build type's `AUTHENTICATE_ACCOUNTS` parameter; see [`setup/prime-logins.setup.ts`](setup/prime-logins.setup.ts).
145-
146-
To see what every build type logs in as before its suite, without starting a build:
147-
148-
```bash
149-
# From the repository root. Regenerate only after a .teamcity change; the DSL needs JDK 17.
150-
( cd .teamcity && JAVA_HOME=$(/usr/libexec/java_home -v 17) mvn -q teamcity-configs:generate )
151-
yarn workspace @automattic/calypso-e2e build
152-
( cd test/e2e && node bin/primed-accounts.js )
153-
```
144+
**Accounts**: one fixture per key of `fixtureAccounts` in [`lib/pw-base.ts`](lib/pw-base.ts), plus `accountGivenByEnvironment` and `accountSMS`. Declaring an account fixture logs in as it, whether or not the test body uses it, so take only the ones the test needs. A run logs in as each account once: the first worker to reach it logs in and saves the cookies the rest load.
154145

155146
**Pages/Components**: Follow naming conventions:
156147

0 commit comments

Comments
 (0)