@trackunit/iris-app-playwright 0.2.120-alpha-f04589101e3.0 → 0.2.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/migrations.json +1 -7
- package/package.json +1 -1
- package/src/fixtures/acceptTerms.d.ts +33 -0
- package/src/fixtures/acceptTerms.js +109 -0
- package/src/fixtures/baseTest.d.ts +1 -2
- package/src/fixtures/baseTest.js +1 -3
- package/src/fixtures/irisApp.fixture.d.ts +2 -52
- package/src/fixtures/irisApp.fixture.js +3 -61
- package/src/fixtures/login.fixture.d.ts +63 -7
- package/src/fixtures/login.fixture.js +173 -48
- package/src/generators/playwright-configuration/files/root/playwright/tests/app.spec.ts__tmpl__ +1 -1
- package/migrations/entry.js.map +0 -1
- package/migrations/v1-0-0/await-iris-app.js +0 -223
- package/migrations/v1-0-0/await-iris-app.js.map +0 -1
- package/src/credentials/guards.js.map +0 -1
- package/src/credentials/keys.js.map +0 -1
- package/src/credentials/resolveE2EPassword.js.map +0 -1
- package/src/fixtures/baseTest.js.map +0 -1
- package/src/fixtures/describe.js.map +0 -1
- package/src/fixtures/featureFlags.fixture.js.map +0 -1
- package/src/fixtures/harRecording.fixture.js.map +0 -1
- package/src/fixtures/hostReadiness.js.map +0 -1
- package/src/fixtures/hydrateStorageState.js.map +0 -1
- package/src/fixtures/irisApp.fixture.js.map +0 -1
- package/src/fixtures/localDevMode.fixture.js.map +0 -1
- package/src/fixtures/login.fixture.js.map +0 -1
- package/src/fixtures/loginCacheKey.js.map +0 -1
- package/src/fixtures/resolveCredentials.js.map +0 -1
- package/src/fixtures/withTimeout.js.map +0 -1
- package/src/generators/playwright-configuration/generator.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/plugins/createLogFile.js.map +0 -1
- package/src/plugins/defaultPlaywrightConfig.js.map +0 -1
- package/src/plugins/harRecordingPath.js.map +0 -1
- package/src/plugins/logsReporter.js.map +0 -1
- package/src/plugins/nxPreset.js.map +0 -1
- package/src/plugins/redactHar.js.map +0 -1
- package/src/plugins/redactPatterns.js.map +0 -1
- package/src/plugins/redactSensitive.js.map +0 -1
- package/src/plugins/redactTrace.js.map +0 -1
- package/src/plugins/scanArtifactsForSecrets.js.map +0 -1
- package/src/plugins/setupPlugins.js.map +0 -1
- package/src/plugins/writeFileWithPrettier.js.map +0 -1
- package/src/support.js.map +0 -1
- package/src/utils/Codeowner.js.map +0 -1
- package/src/utils/fileNameBuilder.js.map +0 -1
- package/src/utils/fileUpdater.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expect = exports.performOktaLogin = exports.test = exports.waitForEnvReady = exports.EnvReadyTimeoutError = exports.waitForMainMenuReady = exports.isMainMenuReady = exports.reserveFeatureBranchLoginBudget = exports.extendTestTimeout = exports.MAIN_MENU_READY_SELECTOR = exports.SESSION_DOCUMENT_RETRY_DELAY_MS = exports.ENV_READY_POLL_INTERVAL_MS = exports.ENV_READY_TIMEOUT_ENV_VAR = exports.ENV_READY_TIMEOUT_MS = exports.MAIN_MENU_READY_TIMEOUT_MS = exports.HIDE_MENU_URL_FRAGMENTS = void 0;
|
|
3
|
+
exports.expect = exports.signIn = exports.performOktaLogin = exports.test = exports.waitForEnvReady = exports.EnvReadyTimeoutError = exports.waitForMainMenuReady = exports.isMainMenuReady = exports.reserveFeatureBranchLoginBudget = exports.extendTestTimeout = exports.MAIN_MENU_READY_SELECTOR = exports.SESSION_DOCUMENT_RETRY_DELAY_MS = exports.ENV_READY_POLL_INTERVAL_MS = exports.ENV_READY_TIMEOUT_ENV_VAR = exports.ENV_READY_TIMEOUT_MS = exports.MAIN_MENU_READY_TIMEOUT_MS = exports.HIDE_MENU_URL_FRAGMENTS = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
|
+
const acceptTerms_1 = require("./acceptTerms");
|
|
5
6
|
const hostReadiness_1 = require("./hostReadiness");
|
|
6
7
|
const hydrateStorageState_1 = require("./hydrateStorageState");
|
|
7
8
|
const loginCacheKey_1 = require("./loginCacheKey");
|
|
@@ -69,22 +70,52 @@ const reserveFeatureBranchLoginBudget = (testInfo) => {
|
|
|
69
70
|
(0, exports.extendTestTimeout)(testInfo, exports.MAIN_MENU_READY_TIMEOUT_MS);
|
|
70
71
|
};
|
|
71
72
|
exports.reserveFeatureBranchLoginBudget = reserveFeatureBranchLoginBudget;
|
|
72
|
-
/**
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Returns whether the main menu is ready or intentionally hidden for the current route.
|
|
75
|
+
*
|
|
76
|
+
* Root cause (GLU-2632): `/terms` is in {@link HIDE_MENU_URL_FRAGMENTS}, so every
|
|
77
|
+
* host treated the unfinished prompt as a finished login. `termsRoute` gives
|
|
78
|
+
* that route exact-match semantics, and callers decide whether it is an
|
|
79
|
+
* intermediate ready state or must keep waiting for the final shell.
|
|
80
|
+
*/
|
|
81
|
+
const isMainMenuReady = ({ selector, fragments, termsRoute, termsCountsAsReady = true, }) => {
|
|
82
|
+
const pathname = window.location.pathname;
|
|
83
|
+
if (termsRoute !== undefined && pathname === termsRoute) {
|
|
84
|
+
return termsCountsAsReady;
|
|
85
|
+
}
|
|
74
86
|
if (document.querySelector(selector) !== null) {
|
|
75
87
|
return true;
|
|
76
88
|
}
|
|
77
|
-
return fragments.some(fragment =>
|
|
89
|
+
return fragments.some(fragment => fragment !== termsRoute && pathname.includes(fragment));
|
|
78
90
|
};
|
|
79
91
|
exports.isMainMenuReady = isMainMenuReady;
|
|
80
92
|
/**
|
|
81
93
|
* Waits until Manager's main menu is rendered without a loading skeleton, or
|
|
82
94
|
* until the browser is on a HostLayout hide-menu route (marketplace / auth /
|
|
83
95
|
* terms) where the menu is intentionally absent.
|
|
96
|
+
*
|
|
97
|
+
* On a feature-branch host, `/terms` is excluded: the prompt is not a finished
|
|
98
|
+
* login (GLU-2632). The flag is computed here, in Node, and passed in because
|
|
99
|
+
* {@link isMainMenuReady} is evaluated in the page.
|
|
84
100
|
*/
|
|
85
101
|
const waitForMainMenuReady = async (page, testInfo) => {
|
|
86
102
|
(0, exports.extendTestTimeout)(testInfo, exports.MAIN_MENU_READY_TIMEOUT_MS);
|
|
87
|
-
|
|
103
|
+
try {
|
|
104
|
+
await page.waitForFunction(exports.isMainMenuReady, {
|
|
105
|
+
selector: exports.MAIN_MENU_READY_SELECTOR,
|
|
106
|
+
fragments: exports.HIDE_MENU_URL_FRAGMENTS,
|
|
107
|
+
termsRoute: acceptTerms_1.TERMS_ROUTE,
|
|
108
|
+
termsCountsAsReady: !(0, hostReadiness_1.isFeatureBranchHost)(),
|
|
109
|
+
}, { timeout: exports.MAIN_MENU_READY_TIMEOUT_MS });
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
// On a feature-branch host this means the final shell never became ready,
|
|
113
|
+
// before any page assertion. Other hosts keep Playwright's timeout.
|
|
114
|
+
if ((0, hostReadiness_1.isFeatureBranchHost)() && error instanceof test_1.errors.TimeoutError) {
|
|
115
|
+
throw new hostReadiness_1.HostNeverBecameReadyError(error);
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
88
119
|
};
|
|
89
120
|
exports.waitForMainMenuReady = waitForMainMenuReady;
|
|
90
121
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -164,44 +195,62 @@ exports.test = test_1.test.extend({
|
|
|
164
195
|
{ scope: "worker" },
|
|
165
196
|
],
|
|
166
197
|
login: async ({ page, baseURL, _loginCache }, provide, testInfo) => {
|
|
167
|
-
|
|
168
|
-
const credentials = await (0, resolveCredentials_1.resolveCredentials)(options);
|
|
169
|
-
const cacheKey = (0, loginCacheKey_1.buildLoginCacheKey)(baseURL, credentials);
|
|
170
|
-
const cached = _loginCache.get(cacheKey);
|
|
171
|
-
if (cached !== undefined) {
|
|
172
|
-
let cachedSessionRestored = false;
|
|
173
|
-
try {
|
|
174
|
-
await (0, hydrateStorageState_1.hydrateStorageState)(page.context(), cached);
|
|
175
|
-
await page.goto("/");
|
|
176
|
-
await page.locator("#host-layout-content").waitFor({ state: "visible", timeout: 15000 });
|
|
177
|
-
cachedSessionRestored = true;
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
_loginCache.delete(cacheKey);
|
|
181
|
-
}
|
|
182
|
-
if (cachedSessionRestored) {
|
|
183
|
-
await (0, exports.waitForMainMenuReady)(page, testInfo);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
(0, exports.reserveFeatureBranchLoginBudget)(testInfo);
|
|
188
|
-
await (0, exports.performOktaLogin)({ page, baseURL, credentials, testInfo });
|
|
189
|
-
// Capture the fully-authenticated state for reuse by later tests in
|
|
190
|
-
// this worker. Errors here would mask the actual login success, so we
|
|
191
|
-
// never let snapshot capture throw — at worst we'll re-hit Okta next
|
|
192
|
-
// time, which is the pre-cache behaviour.
|
|
193
|
-
try {
|
|
194
|
-
const snapshot = await page.context().storageState();
|
|
195
|
-
_loginCache.set(cacheKey, snapshot);
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
/* Snapshot capture is best-effort; failing here is non-fatal. */
|
|
199
|
-
}
|
|
200
|
-
await (0, exports.waitForMainMenuReady)(page, testInfo);
|
|
201
|
-
};
|
|
202
|
-
await provide(loginFn);
|
|
198
|
+
await provide(options => (0, exports.signIn)({ page, baseURL, cache: _loginCache, testInfo, options }));
|
|
203
199
|
},
|
|
204
200
|
});
|
|
201
|
+
/**
|
|
202
|
+
* Waits for the terms route or the final shell inside the shared login budget.
|
|
203
|
+
*
|
|
204
|
+
* `TermsGate` wraps `HostLayout`, so the main menu cannot render before the terms
|
|
205
|
+
* decision is complete. The first wait can therefore treat `/terms` as ready. If that
|
|
206
|
+
* route wins, the prompt is completed and one final wait requires the real shell.
|
|
207
|
+
*/
|
|
208
|
+
const finishFeatureBranchTerms = async ({ page, now, sleep: pause, deadline, }) => {
|
|
209
|
+
if (!(0, hostReadiness_1.isFeatureBranchHost)()) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const pageUrl = page.url;
|
|
213
|
+
const getByTestId = page.getByTestId;
|
|
214
|
+
const waitForFunction = page.waitForFunction;
|
|
215
|
+
if (pageUrl === undefined || getByTestId === undefined || waitForFunction === undefined) {
|
|
216
|
+
throw new TypeError("Feature-branch terms readiness requires page.url, page.getByTestId, and page.waitForFunction");
|
|
217
|
+
}
|
|
218
|
+
const waitUntilReady = async (termsCountsAsReady) => {
|
|
219
|
+
const remaining = deadline - now();
|
|
220
|
+
if (remaining <= 0) {
|
|
221
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
await waitForFunction.call(page, exports.isMainMenuReady, {
|
|
225
|
+
selector: exports.MAIN_MENU_READY_SELECTOR,
|
|
226
|
+
fragments: [],
|
|
227
|
+
termsRoute: acceptTerms_1.TERMS_ROUTE,
|
|
228
|
+
termsCountsAsReady,
|
|
229
|
+
}, { timeout: remaining });
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (!isPlaywrightTimeout(error)) {
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
throw new hostReadiness_1.HostNeverBecameReadyError(error);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
await waitUntilReady(true);
|
|
239
|
+
if (!(0, acceptTerms_1.isTermsRoute)(pageUrl.call(page))) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
await (0, acceptTerms_1.acceptTermsWithinBudget)({
|
|
243
|
+
page: {
|
|
244
|
+
url: pageUrl.bind(page),
|
|
245
|
+
getByTestId: getByTestId.bind(page),
|
|
246
|
+
waitForURL: (predicate, options) => page.waitForURL(predicate, options),
|
|
247
|
+
},
|
|
248
|
+
now,
|
|
249
|
+
sleep: pause,
|
|
250
|
+
deadline,
|
|
251
|
+
});
|
|
252
|
+
await waitUntilReady(false);
|
|
253
|
+
};
|
|
205
254
|
const openDefaultRequestContext = async (baseURL) => {
|
|
206
255
|
const context = await test_1.request.newContext({ baseURL });
|
|
207
256
|
return {
|
|
@@ -318,11 +367,13 @@ const gotoSessionDocument = async (page, url, now, deadline, pause) => {
|
|
|
318
367
|
/**
|
|
319
368
|
* Performs the slow path: wait for the branch host to serve `/env`, hit Okta's
|
|
320
369
|
* `/api/v1/authn`, redeem the `sessionToken` via the manager-classic redirect,
|
|
321
|
-
* and wait for the host layout to render.
|
|
322
|
-
*
|
|
370
|
+
* and wait for the host layout to render. On a feature-branch host it then
|
|
371
|
+
* finishes the terms prompt and waits for the main shell inside the same
|
|
372
|
+
* budget. Factored out so the cache hit/miss branches read clearly.
|
|
323
373
|
*
|
|
324
374
|
* `createRequestContext`, `now`, and `sleep` are injectable so a unit test can
|
|
325
|
-
* drive the session handoff without a browser or a real
|
|
375
|
+
* drive the session handoff and the terms prompt without a browser or a real
|
|
376
|
+
* three-minute wait.
|
|
326
377
|
*/
|
|
327
378
|
const performOktaLogin = async ({ page, baseURL, credentials, testInfo, createRequestContext = openDefaultRequestContext, now = Date.now, sleep: pause = sleep, }) => {
|
|
328
379
|
const context = await createRequestContext(baseURL);
|
|
@@ -333,9 +384,10 @@ const performOktaLogin = async ({ page, baseURL, credentials, testInfo, createRe
|
|
|
333
384
|
throw new Error(`No domain found from servers /env found env: ${JSON.stringify(env)}`);
|
|
334
385
|
}
|
|
335
386
|
const domain = domainValue;
|
|
336
|
-
// Started once `/env` is ready. The Okta post, the session document
|
|
337
|
-
// handoff
|
|
338
|
-
//
|
|
387
|
+
// Started once `/env` is ready. The Okta post, the session document, the
|
|
388
|
+
// handoff, the terms prompt and the shell wait share this window. Only the
|
|
389
|
+
// document, the handoff and the prompt are retried against it; the post keeps
|
|
390
|
+
// its own fixed timeout (GLU-2631, GLU-2632).
|
|
339
391
|
const readyDeadline = (0, hostReadiness_1.isFeatureBranchHost)() ? now() + exports.MAIN_MENU_READY_TIMEOUT_MS : undefined;
|
|
340
392
|
const authResponse = await context.post(`${domain}/api/v1/authn`, {
|
|
341
393
|
data: {
|
|
@@ -356,13 +408,86 @@ const performOktaLogin = async ({ page, baseURL, credentials, testInfo, createRe
|
|
|
356
408
|
const { sessionToken } = await authResponse.json();
|
|
357
409
|
await gotoSessionDocument(page, `/auth/manager-classic#session_token=${sessionToken}&userProfile=true`, now, readyDeadline, pause);
|
|
358
410
|
await waitForSessionHandoff(page, now, readyDeadline);
|
|
359
|
-
|
|
411
|
+
if (readyDeadline !== undefined) {
|
|
412
|
+
await finishFeatureBranchTerms({
|
|
413
|
+
page,
|
|
414
|
+
now,
|
|
415
|
+
sleep: pause,
|
|
416
|
+
deadline: readyDeadline,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
await page.locator("#host-layout-content").waitFor({ state: "visible", timeout: 15000 });
|
|
421
|
+
}
|
|
360
422
|
}
|
|
361
423
|
finally {
|
|
362
424
|
await context.dispose();
|
|
363
425
|
}
|
|
364
426
|
};
|
|
365
427
|
exports.performOktaLogin = performOktaLogin;
|
|
428
|
+
/**
|
|
429
|
+
* Signs in, reusing this worker's cached session when one exists.
|
|
430
|
+
*
|
|
431
|
+
* `now` and `sleep` are injectable so a unit test can drive the restored
|
|
432
|
+
* feature-branch terms wait without a browser or a real three-minute clock.
|
|
433
|
+
* Production uses `Date.now` and the event loop.
|
|
434
|
+
*/
|
|
435
|
+
const signIn = async ({ page, baseURL, cache, testInfo, options, now = Date.now, sleep: pause = sleep, createRequestContext, }) => {
|
|
436
|
+
const credentials = await (0, resolveCredentials_1.resolveCredentials)(options);
|
|
437
|
+
const cacheKey = (0, loginCacheKey_1.buildLoginCacheKey)(baseURL, credentials);
|
|
438
|
+
const cached = cache.get(cacheKey);
|
|
439
|
+
const featureBranchHost = (0, hostReadiness_1.isFeatureBranchHost)();
|
|
440
|
+
if (cached !== undefined) {
|
|
441
|
+
let cachedSessionRestored = false;
|
|
442
|
+
try {
|
|
443
|
+
await (0, hydrateStorageState_1.hydrateStorageState)(page.context(), cached);
|
|
444
|
+
await page.goto("/");
|
|
445
|
+
if (featureBranchHost) {
|
|
446
|
+
// Reserve the single shared handoff/terms/shell budget before waiting.
|
|
447
|
+
(0, exports.reserveFeatureBranchLoginBudget)(testInfo);
|
|
448
|
+
const deadline = now() + exports.MAIN_MENU_READY_TIMEOUT_MS;
|
|
449
|
+
await finishFeatureBranchTerms({
|
|
450
|
+
page,
|
|
451
|
+
now,
|
|
452
|
+
sleep: pause,
|
|
453
|
+
deadline,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
await page.locator("#host-layout-content").waitFor({ state: "visible", timeout: 15000 });
|
|
458
|
+
}
|
|
459
|
+
cachedSessionRestored = true;
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
if (error instanceof hostReadiness_1.HostNeverBecameReadyError) {
|
|
463
|
+
throw error;
|
|
464
|
+
}
|
|
465
|
+
cache.delete(cacheKey);
|
|
466
|
+
}
|
|
467
|
+
if (cachedSessionRestored) {
|
|
468
|
+
if (!featureBranchHost) {
|
|
469
|
+
await (0, exports.waitForMainMenuReady)(page, testInfo);
|
|
470
|
+
}
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
(0, exports.reserveFeatureBranchLoginBudget)(testInfo);
|
|
475
|
+
await (0, exports.performOktaLogin)({ page, baseURL, credentials, testInfo, now, sleep: pause, createRequestContext });
|
|
476
|
+
if (!featureBranchHost) {
|
|
477
|
+
await (0, exports.waitForMainMenuReady)(page, testInfo);
|
|
478
|
+
}
|
|
479
|
+
// Capture only after the shell is ready. Errors here would mask the actual
|
|
480
|
+
// login success, so snapshot capture never throws — at
|
|
481
|
+
// worst we'll re-hit Okta next time, which is the pre-cache behaviour.
|
|
482
|
+
try {
|
|
483
|
+
const snapshot = await page.context().storageState();
|
|
484
|
+
cache.set(cacheKey, snapshot);
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
/* Snapshot capture is best-effort; failing here is non-fatal. */
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
exports.signIn = signIn;
|
|
366
491
|
var test_2 = require("@playwright/test");
|
|
367
492
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_2.expect; } });
|
|
368
493
|
//# sourceMappingURL=login.fixture.js.map
|
package/src/generators/playwright-configuration/files/root/playwright/tests/app.spec.ts__tmpl__
CHANGED
|
@@ -8,7 +8,7 @@ describe("Sample E2E Test", () => {
|
|
|
8
8
|
// await expect(page.getByTestId("your-app-element")).toBeVisible();
|
|
9
9
|
|
|
10
10
|
// Example: Test Iris app integration
|
|
11
|
-
// const app =
|
|
11
|
+
// const app = irisApp();
|
|
12
12
|
// await expect(app.getByTestId("your-test-id")).toBeVisible();
|
|
13
13
|
|
|
14
14
|
await expect(page.locator("#host-layout-content")).toBeVisible();
|
package/migrations/entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/iris-app-playwright/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.awaitIrisApp = exports.awaitIrisAppCalls = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
|
-
const MIGRATION_NAME = "v1-0-0-await-iris-app";
|
|
8
|
-
const FIXTURE_NAME = "irisApp";
|
|
9
|
-
const SOURCE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
10
|
-
const isSourceFile = (filePath) => SOURCE_EXTENSIONS.some(extension => filePath.endsWith(extension));
|
|
11
|
-
const isUnderNodeModulesOrDist = (filePath) => filePath.split("/").some(segment => segment === "node_modules" || segment === "dist" || segment === ".nx");
|
|
12
|
-
const scriptKindFor = (filePath) => {
|
|
13
|
-
if (filePath.endsWith(".tsx"))
|
|
14
|
-
return ts.ScriptKind.TSX;
|
|
15
|
-
if (filePath.endsWith(".jsx"))
|
|
16
|
-
return ts.ScriptKind.JSX;
|
|
17
|
-
if (filePath.endsWith(".ts"))
|
|
18
|
-
return ts.ScriptKind.TS;
|
|
19
|
-
return ts.ScriptKind.JS;
|
|
20
|
-
};
|
|
21
|
-
const parse = (filePath, content) => ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, scriptKindFor(filePath));
|
|
22
|
-
const FRAME_LOCATOR = "FrameLocator";
|
|
23
|
-
/** `irisApp(...)` or `<anything>.irisApp(...)`. */
|
|
24
|
-
const isIrisAppCall = (node) => {
|
|
25
|
-
if (!ts.isCallExpression(node))
|
|
26
|
-
return false;
|
|
27
|
-
const callee = node.expression;
|
|
28
|
-
if (ts.isIdentifier(callee))
|
|
29
|
-
return callee.text === FIXTURE_NAME;
|
|
30
|
-
return ts.isPropertyAccessExpression(callee) && callee.name.text === FIXTURE_NAME;
|
|
31
|
-
};
|
|
32
|
-
const unwrapParentheses = (node) => {
|
|
33
|
-
let current = node;
|
|
34
|
-
while (ts.isParenthesizedExpression(current.parent)) {
|
|
35
|
-
current = current.parent;
|
|
36
|
-
}
|
|
37
|
-
return current;
|
|
38
|
-
};
|
|
39
|
-
const isAlreadyAwaited = (call) => ts.isAwaitExpression(unwrapParentheses(call).parent);
|
|
40
|
-
/**
|
|
41
|
-
* `await` binds looser than member access and call, so `irisApp().x` must
|
|
42
|
-
* become `(await irisApp()).x`. Everything else (`const a = irisApp()`,
|
|
43
|
-
* `expect(irisApp())`, `return irisApp()`, `irisApp() ?? x`) reads correctly
|
|
44
|
-
* with a bare `await` in front.
|
|
45
|
-
*/
|
|
46
|
-
const needsParentheses = (call) => {
|
|
47
|
-
const parent = call.parent;
|
|
48
|
-
if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) {
|
|
49
|
-
return parent.expression === call;
|
|
50
|
-
}
|
|
51
|
-
if (ts.isCallExpression(parent))
|
|
52
|
-
return parent.expression === call;
|
|
53
|
-
// `await x ** 2` is a syntax error; the unary operand of `**` must be parenthesised.
|
|
54
|
-
if (ts.isBinaryExpression(parent)) {
|
|
55
|
-
return parent.operatorToken.kind === ts.SyntaxKind.AsteriskAsteriskToken && parent.left === call;
|
|
56
|
-
}
|
|
57
|
-
return ts.isNonNullExpression(parent) || ts.isTaggedTemplateExpression(parent);
|
|
58
|
-
};
|
|
59
|
-
const isFunctionLike = (node) => ts.isFunctionDeclaration(node) ||
|
|
60
|
-
ts.isFunctionExpression(node) ||
|
|
61
|
-
ts.isArrowFunction(node) ||
|
|
62
|
-
ts.isMethodDeclaration(node) ||
|
|
63
|
-
ts.isGetAccessorDeclaration(node) ||
|
|
64
|
-
ts.isSetAccessorDeclaration(node) ||
|
|
65
|
-
ts.isConstructorDeclaration(node);
|
|
66
|
-
const isAsync = (fn) => (ts.getModifiers(fn) ?? []).some(modifier => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
67
|
-
/**
|
|
68
|
-
* Positions where `await` is a syntax error even when an async function
|
|
69
|
-
* encloses them: parameter initialisers, class fields, class static blocks,
|
|
70
|
-
* decorators, and `extends` clauses. The class body boundary is what matters,
|
|
71
|
-
* so a nested async method under the same class is still fine.
|
|
72
|
-
*/
|
|
73
|
-
const forbidsAwait = (node) => ts.isParameter(node) ||
|
|
74
|
-
ts.isPropertyDeclaration(node) ||
|
|
75
|
-
ts.isClassStaticBlockDeclaration(node) ||
|
|
76
|
-
ts.isDecorator(node) ||
|
|
77
|
-
ts.isHeritageClause(node);
|
|
78
|
-
/**
|
|
79
|
-
* `await` is only valid directly inside an async function. A call inside a
|
|
80
|
-
* nested sync callback (`[0, 1].map(i => irisApp().getByTestId(...))`), at
|
|
81
|
-
* module top level, or in one of the {@link forbidsAwait} positions cannot be
|
|
82
|
-
* rewritten without changing the surrounding shape, which is the caller's
|
|
83
|
-
* decision.
|
|
84
|
-
*/
|
|
85
|
-
const isInsideAsyncFunction = (call) => {
|
|
86
|
-
let current = call.parent;
|
|
87
|
-
while (!ts.isSourceFile(current)) {
|
|
88
|
-
if (forbidsAwait(current))
|
|
89
|
-
return false;
|
|
90
|
-
if (isFunctionLike(current))
|
|
91
|
-
return isAsync(current);
|
|
92
|
-
current = current.parent;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
};
|
|
96
|
-
const applyEdits = (content, edits) => {
|
|
97
|
-
// Later positions first, so earlier positions stay valid while splicing.
|
|
98
|
-
// Edits are pushed outer-first (pre-order), and an outer call shares its
|
|
99
|
-
// start with the inner call it chains on (`x.irisApp().irisApp()`). The
|
|
100
|
-
// text inserted last at an offset ends up leftmost, so the inner edit is
|
|
101
|
-
// applied first and the outer `await` lands outside it.
|
|
102
|
-
const ordered = edits
|
|
103
|
-
.map((edit, index) => ({ edit, index }))
|
|
104
|
-
.sort((a, b) => b.edit.start - a.edit.start || b.index - a.index);
|
|
105
|
-
let updated = content;
|
|
106
|
-
for (const { edit: { start, end, text }, } of ordered) {
|
|
107
|
-
updated = updated.slice(0, start) + text + updated.slice(end);
|
|
108
|
-
}
|
|
109
|
-
return updated;
|
|
110
|
-
};
|
|
111
|
-
const isFrameLocatorReference = (type) => ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName) && type.typeName.text === FRAME_LOCATOR;
|
|
112
|
-
/**
|
|
113
|
-
* `() => FrameLocator` -> `() => Promise<FrameLocator>`. A function type whose
|
|
114
|
-
* return is anything else (already a `Promise`, a union, a different type) is
|
|
115
|
-
* not the fixture's old shape and is left alone.
|
|
116
|
-
*/
|
|
117
|
-
const widenFrameLocatorReturn = (type, sourceFile) => {
|
|
118
|
-
if (type === undefined || !ts.isFunctionTypeNode(type) || !isFrameLocatorReference(type.type))
|
|
119
|
-
return null;
|
|
120
|
-
return { start: type.type.getStart(sourceFile), end: type.type.getEnd(), text: `Promise<${FRAME_LOCATOR}>` };
|
|
121
|
-
};
|
|
122
|
-
/** A parameter, property signature, or property declaration named `irisApp` with a type annotation. */
|
|
123
|
-
const isIrisAppDeclaration = (node) => (ts.isParameter(node) || ts.isPropertySignature(node) || ts.isPropertyDeclaration(node)) &&
|
|
124
|
-
ts.isIdentifier(node.name) &&
|
|
125
|
-
node.name.text === FIXTURE_NAME &&
|
|
126
|
-
node.type !== undefined;
|
|
127
|
-
const awaitIrisAppCalls = (filePath, content) => {
|
|
128
|
-
const sourceFile = parse(filePath, content);
|
|
129
|
-
const edits = [];
|
|
130
|
-
const syncCallLines = [];
|
|
131
|
-
/** Local type aliases used as the type of an `irisApp` declaration, e.g. `irisApp: IrisAppFn`. */
|
|
132
|
-
const irisAppAliasNames = new Set();
|
|
133
|
-
const typeAliases = [];
|
|
134
|
-
const visit = (node) => {
|
|
135
|
-
if (isIrisAppCall(node) && !isAlreadyAwaited(node)) {
|
|
136
|
-
if (isInsideAsyncFunction(node)) {
|
|
137
|
-
const start = node.getStart(sourceFile);
|
|
138
|
-
if (needsParentheses(node)) {
|
|
139
|
-
edits.push({ start, end: start, text: "(await " }, { start: node.getEnd(), end: node.getEnd(), text: ")" });
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
edits.push({ start, end: start, text: "await " });
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
syncCallLines.push(sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
else if (isIrisAppDeclaration(node)) {
|
|
150
|
-
const widened = widenFrameLocatorReturn(node.type, sourceFile);
|
|
151
|
-
if (widened !== null) {
|
|
152
|
-
edits.push(widened);
|
|
153
|
-
}
|
|
154
|
-
else if (ts.isTypeReferenceNode(node.type) && ts.isIdentifier(node.type.typeName)) {
|
|
155
|
-
irisAppAliasNames.add(node.type.typeName.text);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else if (ts.isTypeAliasDeclaration(node)) {
|
|
159
|
-
typeAliases.push(node);
|
|
160
|
-
}
|
|
161
|
-
ts.forEachChild(node, visit);
|
|
162
|
-
};
|
|
163
|
-
visit(sourceFile);
|
|
164
|
-
for (const alias of typeAliases) {
|
|
165
|
-
if (!irisAppAliasNames.has(alias.name.text))
|
|
166
|
-
continue;
|
|
167
|
-
const widened = widenFrameLocatorReturn(alias.type, sourceFile);
|
|
168
|
-
if (widened !== null)
|
|
169
|
-
edits.push(widened);
|
|
170
|
-
}
|
|
171
|
-
return { content: edits.length === 0 ? content : applyEdits(content, edits), syncCallLines };
|
|
172
|
-
};
|
|
173
|
-
exports.awaitIrisAppCalls = awaitIrisAppCalls;
|
|
174
|
-
/**
|
|
175
|
-
* `@trackunit/iris-app-playwright` 1.0.0: the `irisApp` fixture resolves to
|
|
176
|
-
* `Promise<FrameLocator>` in every environment, so a feature-branch host can
|
|
177
|
-
* wait for the iframe before any page assertion. Every `irisApp(...)` call
|
|
178
|
-
* therefore needs an `await`.
|
|
179
|
-
*
|
|
180
|
-
* Rewrites `irisApp(...)` and `<x>.irisApp(...)` calls inside async functions
|
|
181
|
-
* to `await irisApp(...)`, parenthesised when the call is the receiver of a
|
|
182
|
-
* member access or call. Calls that are already awaited are left alone. Calls
|
|
183
|
-
* that are not inside an async function are reported with `file:line` and left
|
|
184
|
-
* for manual review, because adding `await` there would be a syntax error.
|
|
185
|
-
*
|
|
186
|
-
* Also widens the old fixture shape in local types: a parameter or property
|
|
187
|
-
* named `irisApp` typed `(...) => FrameLocator`, and any same-file type alias
|
|
188
|
-
* such a declaration uses, becomes `(...) => Promise<FrameLocator>`.
|
|
189
|
-
*/
|
|
190
|
-
const awaitIrisApp = (tree) => {
|
|
191
|
-
let touched = 0;
|
|
192
|
-
const manualReview = [];
|
|
193
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, "/", filePath => {
|
|
194
|
-
if (!isSourceFile(filePath) || isUnderNodeModulesOrDist(filePath))
|
|
195
|
-
return;
|
|
196
|
-
const content = tree.read(filePath, "utf-8");
|
|
197
|
-
if (content === null || !content.includes(FIXTURE_NAME))
|
|
198
|
-
return;
|
|
199
|
-
const result = (0, exports.awaitIrisAppCalls)(filePath, content);
|
|
200
|
-
if (result.content !== content) {
|
|
201
|
-
tree.write(filePath, result.content);
|
|
202
|
-
touched += 1;
|
|
203
|
-
}
|
|
204
|
-
for (const line of result.syncCallLines) {
|
|
205
|
-
manualReview.push(`${filePath}:${line}`);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
if (touched === 0) {
|
|
209
|
-
devkit_1.logger.info(` ${MIGRATION_NAME}: no files changed`);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
devkit_1.logger.info(` ${MIGRATION_NAME}: updated ${touched} file(s)`);
|
|
213
|
-
}
|
|
214
|
-
for (const location of manualReview) {
|
|
215
|
-
devkit_1.logger.warn(` ${MIGRATION_NAME}: ${location} calls irisApp() but is not inside an async function. Make the enclosing function async and await the call, or hoist \`const app = await irisApp();\` out of it.`);
|
|
216
|
-
}
|
|
217
|
-
if (touched > 0 || manualReview.length > 0) {
|
|
218
|
-
devkit_1.logger.info(` ${MIGRATION_NAME}: if you override the irisApp fixture, return Promise<FrameLocator> (or use createIrisApp from @trackunit/iris-app-playwright/support) so it matches IrisAppFixtures["irisApp"].`);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
exports.awaitIrisApp = awaitIrisApp;
|
|
222
|
-
exports.default = exports.awaitIrisApp;
|
|
223
|
-
//# sourceMappingURL=await-iris-app.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"await-iris-app.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-playwright/migrations/v1-0-0/await-iris-app.ts"],"names":[],"mappings":";;;;AAAA,uCAAqE;AACrE,uDAAi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nconst FIXTURE_NAME = \"irisApp\";\nconst SOURCE_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\", \".cjs\"] as const;\n\nconst isSourceFile = (filePath: string): boolean => SOURCE_EXTENSIONS.some(extension => filePath.endsWith(extension));\n\nconst isUnderNodeModulesOrDist = (filePath: string): boolean =>\n filePath.split(\"/\").some(segment => segment === \"node_modules\" || segment === \"dist\" || segment === \".nx\");\n\nconst scriptKindFor = (filePath: string): ts.ScriptKind => {\n if (filePath.endsWith(\".tsx\")) return ts.ScriptKind.TSX;\n if (filePath.endsWith(\".jsx\")) return ts.ScriptKind.JSX;\n if (filePath.endsWith(\".ts\")) return ts.ScriptKind.TS;\n return ts.ScriptKind.JS;\n};\n\nconst parse = (filePath: string, content: string): ts.SourceFile =>\n ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, scriptKindFor(filePath));\n\n/** Replaces `[start, end)` with `text`; an insertion has `start === end`. */\ntype Edit = { start: number; end: number; text: string };\n\nconst FRAME_LOCATOR = \"FrameLocator\";\n\ntype FileResult = {\n content: string;\n /** 1-based lines of `irisApp()` calls that were left for manual review. */\n syncCallLines: ReadonlyArray<number>;\n};\n\n/** `irisApp(...)` or `<anything>.irisApp(...)`. */\nconst isIrisAppCall = (node: ts.Node): node is ts.CallExpression => {\n if (!ts.isCallExpression(node)) return false;\n const callee = node.expression;\n if (ts.isIdentifier(callee)) return callee.text === FIXTURE_NAME;\n return ts.isPropertyAccessExpression(callee) && callee.name.text === FIXTURE_NAME;\n};\n\nconst unwrapParentheses = (node: ts.Node): ts.Node => {\n let current = node;\n while (ts.isParenthesizedExpression(current.parent)) {\n current = current.parent;\n }\n return current;\n};\n\nconst isAlreadyAwaited = (call: ts.CallExpression): boolean => ts.isAwaitExpression(unwrapParentheses(call).parent);\n\n/**\n * `await` binds looser than member access and call, so `irisApp().x` must\n * become `(await irisApp()).x`. Everything else (`const a = irisApp()`,\n * `expect(irisApp())`, `return irisApp()`, `irisApp() ?? x`) reads correctly\n * with a bare `await` in front.\n */\nconst needsParentheses = (call: ts.CallExpression): boolean => {\n const parent = call.parent;\n if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) {\n return parent.expression === call;\n }\n if (ts.isCallExpression(parent)) return parent.expression === call;\n // `await x ** 2` is a syntax error; the unary operand of `**` must be parenthesised.\n if (ts.isBinaryExpression(parent)) {\n return parent.operatorToken.kind === ts.SyntaxKind.AsteriskAsteriskToken && parent.left === call;\n }\n return ts.isNonNullExpression(parent) || ts.isTaggedTemplateExpression(parent);\n};\n\nconst isFunctionLike = (node: ts.Node): node is ts.FunctionLikeDeclaration =>\n ts.isFunctionDeclaration(node) ||\n ts.isFunctionExpression(node) ||\n ts.isArrowFunction(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isSetAccessorDeclaration(node) ||\n ts.isConstructorDeclaration(node);\n\nconst isAsync = (fn: ts.FunctionLikeDeclaration): boolean =>\n (ts.getModifiers(fn) ?? []).some(modifier => modifier.kind === ts.SyntaxKind.AsyncKeyword);\n\n/**\n * Positions where `await` is a syntax error even when an async function\n * encloses them: parameter initialisers, class fields, class static blocks,\n * decorators, and `extends` clauses. The class body boundary is what matters,\n * so a nested async method under the same class is still fine.\n */\nconst forbidsAwait = (node: ts.Node): boolean =>\n ts.isParameter(node) ||\n ts.isPropertyDeclaration(node) ||\n ts.isClassStaticBlockDeclaration(node) ||\n ts.isDecorator(node) ||\n ts.isHeritageClause(node);\n\n/**\n * `await` is only valid directly inside an async function. A call inside a\n * nested sync callback (`[0, 1].map(i => irisApp().getByTestId(...))`), at\n * module top level, or in one of the {@link forbidsAwait} positions cannot be\n * rewritten without changing the surrounding shape, which is the caller's\n * decision.\n */\nconst isInsideAsyncFunction = (call: ts.CallExpression): boolean => {\n let current: ts.Node = call.parent;\n while (!ts.isSourceFile(current)) {\n if (forbidsAwait(current)) return false;\n if (isFunctionLike(current)) return isAsync(current);\n current = current.parent;\n }\n return false;\n};\n\nconst applyEdits = (content: string, edits: ReadonlyArray<Edit>): string => {\n // Later positions first, so earlier positions stay valid while splicing.\n // Edits are pushed outer-first (pre-order), and an outer call shares its\n // start with the inner call it chains on (`x.irisApp().irisApp()`). The\n // text inserted last at an offset ends up leftmost, so the inner edit is\n // applied first and the outer `await` lands outside it.\n const ordered = edits\n .map((edit, index) => ({ edit, index }))\n .sort((a, b) => b.edit.start - a.edit.start || b.index - a.index);\n let updated = content;\n for (const {\n edit: { start, end, text },\n } of ordered) {\n updated = updated.slice(0, start) + text + updated.slice(end);\n }\n return updated;\n};\n\nconst isFrameLocatorReference = (type: ts.TypeNode): boolean =>\n ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName) && type.typeName.text === FRAME_LOCATOR;\n\n/**\n * `() => FrameLocator` -> `() => Promise<FrameLocator>`. A function type whose\n * return is anything else (already a `Promise`, a union, a different type) is\n * not the fixture's old shape and is left alone.\n */\nconst widenFrameLocatorReturn = (type: ts.TypeNode | undefined, sourceFile: ts.SourceFile): Edit | null => {\n if (type === undefined || !ts.isFunctionTypeNode(type) || !isFrameLocatorReference(type.type)) return null;\n return { start: type.type.getStart(sourceFile), end: type.type.getEnd(), text: `Promise<${FRAME_LOCATOR}>` };\n};\n\n/** A parameter, property signature, or property declaration named `irisApp` with a type annotation. */\nconst isIrisAppDeclaration = (\n node: ts.Node\n): node is (ts.ParameterDeclaration | ts.PropertySignature | ts.PropertyDeclaration) & { type: ts.TypeNode } =>\n (ts.isParameter(node) || ts.isPropertySignature(node) || ts.isPropertyDeclaration(node)) &&\n ts.isIdentifier(node.name) &&\n node.name.text === FIXTURE_NAME &&\n node.type !== undefined;\n\nexport const awaitIrisAppCalls = (filePath: string, content: string): FileResult => {\n const sourceFile = parse(filePath, content);\n const edits: Array<Edit> = [];\n const syncCallLines: Array<number> = [];\n /** Local type aliases used as the type of an `irisApp` declaration, e.g. `irisApp: IrisAppFn`. */\n const irisAppAliasNames = new Set<string>();\n const typeAliases: Array<ts.TypeAliasDeclaration> = [];\n\n const visit = (node: ts.Node): void => {\n if (isIrisAppCall(node) && !isAlreadyAwaited(node)) {\n if (isInsideAsyncFunction(node)) {\n const start = node.getStart(sourceFile);\n if (needsParentheses(node)) {\n edits.push({ start, end: start, text: \"(await \" }, { start: node.getEnd(), end: node.getEnd(), text: \")\" });\n } else {\n edits.push({ start, end: start, text: \"await \" });\n }\n } else {\n syncCallLines.push(sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);\n }\n } else if (isIrisAppDeclaration(node)) {\n const widened = widenFrameLocatorReturn(node.type, sourceFile);\n if (widened !== null) {\n edits.push(widened);\n } else if (ts.isTypeReferenceNode(node.type) && ts.isIdentifier(node.type.typeName)) {\n irisAppAliasNames.add(node.type.typeName.text);\n }\n } else if (ts.isTypeAliasDeclaration(node)) {\n typeAliases.push(node);\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n for (const alias of typeAliases) {\n if (!irisAppAliasNames.has(alias.name.text)) continue;\n const widened = widenFrameLocatorReturn(alias.type, sourceFile);\n if (widened !== null) edits.push(widened);\n }\n\n return { content: edits.length === 0 ? content : applyEdits(content, edits), syncCallLines };\n};\n\n/**\n * `@trackunit/iris-app-playwright` 1.0.0: the `irisApp` fixture resolves to\n * `Promise<FrameLocator>` in every environment, so a feature-branch host can\n * wait for the iframe before any page assertion. Every `irisApp(...)` call\n * therefore needs an `await`.\n *\n * Rewrites `irisApp(...)` and `<x>.irisApp(...)` calls inside async functions\n * to `await irisApp(...)`, parenthesised when the call is the receiver of a\n * member access or call. Calls that are already awaited are left alone. Calls\n * that are not inside an async function are reported with `file:line` and left\n * for manual review, because adding `await` there would be a syntax error.\n *\n * Also widens the old fixture shape in local types: a parameter or property\n * named `irisApp` typed `(...) => FrameLocator`, and any same-file type alias\n * such a declaration uses, becomes `(...) => Promise<FrameLocator>`.\n */\nexport const awaitIrisApp = (tree: Tree): void => {\n let touched = 0;\n const manualReview: Array<string> = [];\n\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isSourceFile(filePath) || isUnderNodeModulesOrDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null || !content.includes(FIXTURE_NAME)) return;\n\n const result = awaitIrisAppCalls(filePath, content);\n if (result.content !== content) {\n tree.write(filePath, result.content);\n touched += 1;\n }\n for (const line of result.syncCallLines) {\n manualReview.push(`${filePath}:${line}`);\n }\n });\n\n if (touched === 0) {\n logger.info(` ${MIGRATION_NAME}: no files changed`);\n } else {\n logger.info(` ${MIGRATION_NAME}: updated ${touched} file(s)`);\n }\n\n for (const location of manualReview) {\n logger.warn(\n ` ${MIGRATION_NAME}: ${location} calls irisApp() but is not inside an async function. Make the enclosing function async and await the call, or hoist \\`const app = await irisApp();\\` out of it.`\n );\n }\n\n if (touched > 0 || manualReview.length > 0) {\n logger.info(\n ` ${MIGRATION_NAME}: if you override the irisApp fixture, return Promise<FrameLocator> (or use createIrisApp from @trackunit/iris-app-playwright/support) so it matches IrisAppFixtures[\"irisApp\"].`\n );\n }\n};\n\nexport default awaitIrisApp;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-playwright/src/credentials/guards.ts"],"names":[],"mappings":";;;AAAA,oEAAoE;AAC7D,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAC3E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AADjC,QAAA,QAAQ,YACyB","sourcesContent":["/** Narrows `unknown` to a plain object without a type assertion. */\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-playwright/src/credentials/keys.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAU,EAAE,CAC1D,QAAQ;KACL,WAAW,EAAE;KACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;KAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAJhB,QAAA,eAAe,mBAIC;AAE7B,+EAA+E;AACxE,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,UAAU,IAAA,uBAAe,EAAC,QAAQ,CAAC,EAAE,CAAC;AAAnF,QAAA,YAAY,gBAAuE;AAEhG;;;;;;GAMG;AACI,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,IAAA,oBAAY,EAAC,QAAQ,CAAC,CAAC;AAAxE,QAAA,gBAAgB,oBAAwD","sourcesContent":["/**\n * Credential-key derivation for the manager E2E password lookup (GLU-1451 / GLU-1452).\n *\n * An `auth.json` fixture identifies its account by `username` only — the password\n * is resolved at runtime by a stable key derived from the name: from a CircleCI\n * env variable in CI and from Vault locally.\n *\n * The `E2E_PW_<SLUG>` convention MUST stay in sync with the publish side in\n * `devtools/e2e-okta-rotation/slug.ts` (which writes the CircleCI/Vault values).\n */\n\n/**\n * Uppercase slug of an account name: non-alphanumeric runs collapse to a single\n * `_`, with leading/trailing separators trimmed. Keeps account names with spaces\n * and dashes valid as env-var/Vault-field keys.\n *\n * `Team Helios - E2E Test` -> `TEAM_HELIOS_E2E_TEST`\n */\nexport const slugifyUsername = (username: string): string =>\n username\n .toUpperCase()\n .replace(/[^A-Z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n\n/** The environment-variable key for an account's password: `E2E_PW_<SLUG>`. */\nexport const deriveEnvKey = (username: string): string => `E2E_PW_${slugifyUsername(username)}`;\n\n/**\n * The Vault field key for an account's password. This is the **same** key as the\n * env variable (`E2E_PW_<SLUG>`): the publish side writes each account's password\n * to a Vault field named by `devtools/e2e-okta-rotation/slug.ts`'s `envKey()`\n * (`E2E_PW_<SLUG>`), so the resolver must read it back under that exact key. A\n * lowercased-slug field would never be found once Vault is seeded.\n */\nexport const deriveVaultField = (username: string): string => deriveEnvKey(username);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveE2EPassword.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-playwright/src/credentials/resolveE2EPassword.ts"],"names":[],"mappings":";;;;AAAA,2BAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,gEAA6D;AAC7D,qCAAoC;AACpC,iCAAwD;AAwBxD;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,MAAe,EAAE,KAAa,EAAsB,EAAE;IAC5E,IAAI,CAAC,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,IAAI,CAAC,IAAA,iBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,iBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACzD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,KAAK,EAAE,GAAsB,EAAoC,EAAE;IAC5F,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IACtC,IAAI,KAAa,CAAC;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,IAAA,iBAAY,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port * as path from \"path\";\nimport { redactSensitive } from \"../plugins/redactSensitive\";\nimport { isRecord } from \"./guards\";\nimport { deriveEnvKey, deriveVaultField } from \"./keys\";\n\n/**\n * Minimal structural view of the `node-vault` client's KV read: it returns\n * `{ data: ... }` (KV v1) or `{ data: { data: ... } }` (KV v2). Kept as an\n * interface so tests inject a fake and neither `node-vault` nor a real\n * Vault/VPN is needed. `read` returns `unknown` so callers narrow structurally\n * (no `as` cast at the boundary).\n */\nexport interface VaultReader {\n read(secretPath: string): Promise<unknown>;\n}\n\nexport interface ResolveE2EPasswordOptions {\n /** Process env to read (env-first precedence). Defaults to `process.env`. */\n env?: NodeJS.ProcessEnv;\n /**\n * Vault client factory (local path). Returns `undefined` when Vault can't be\n * reached/authenticated (e.g. no `~/.vault-token`). Defaults to a `node-vault`\n * client using the local token, matching `libs/server/vault`.\n */\n createVault?: (env: NodeJS.ProcessEnv) => Promise<VaultReader | undefined>;\n}\n\n/**\n * Reads a field from a node-vault KV read result. KV v2 nests the fields under\n * `data.data`; KV v1 puts them directly on `data`. Narrows structurally.\n */\nconst readVaultField = (result: unknown, field: string): string | undefined => {\n if (!isRecord(result)) {\n return undefined;\n }\n const outer = result.data;\n if (!isRecord(outer)) {\n return undefined;\n }\n const fields = isRecord(outer.data) ? outer.data : outer;\n const value = fields[field];\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n};\n\n/**\n * Default Vault client: reads the local `~/.vault-token` and points `node-vault`\n * at the endpoint from `E2E_VAULT_ENDPOINT` (or `VAULT_ENDPOINT`).\n *\n * The Vault address is **never hardcoded** — it is supplied by the environment,\n * so any consumer of this package can opt into their own Vault. `node-vault` is\n * an optional peer dependency, imported lazily and only on the local path, so\n * consumers that only use the env-var (CI) path never load it.\n */\nconst defaultCreateVault = async (env: NodeJS.ProcessEnv): Promise<VaultReader | undefined> => {\n const home = env.HOME ?? os.homedir();\n let token: string;\n try {\n token = readFileSync(path.join(home, \".vault-token\"), \"utf-8\").trim();\n } catch {\n return undefined; // not logged in / not on VPN\n }\n if (token === \"\") {\n return undefined;\n }\n const endpoint = env.E2E_VAULT_ENDPOINT ?? env.VAULT_ENDPOINT;\n if (endpoint === undefined || endpoint === \"\") {\n throw new Error(\n \"E2E credentials: a Vault token was found but no endpoint — set E2E_VAULT_ENDPOINT (or VAULT_ENDPOINT) to your Vault address.\"\n );\n }\n // Imported lazily so consumers on the env-var path (and unit tests, which\n // inject `createVault`) never load the optional `node-vault` peer. Its absence\n // is an expected configuration state, so fail with the resolver's actionable,\n // redacted style instead of leaking a raw `ERR_MODULE_NOT_FOUND` stack.\n const nodeVault = await import(\"node-vault\").catch(() => undefined);\n if (nodeVault === undefined) {\n return fail(\n \"E2E credentials: install the optional `node-vault` peer dependency for local Vault lookup, \" +\n \"or set the E2E_PW_<SLUG> env variable.\"\n );\n }\n // `timeout` bounds the whole request so an off-VPN endpoint that black-holes\n // the connection fails fast (~10s) instead of hanging until the test times out.\n const client = nodeVault.default({\n endpoint,\n token,\n requestOptions: { strictSSL: true, timeout: 10_000 },\n });\n return { read: secretPath => client.read(secretPath) };\n};\n\n/**\n * Node/socket error codes that mean the Vault host could not be reached at all —\n * as opposed to a reachable Vault answering with a 403/404. Off-VPN, the internal\n * Vault hostname either fails DNS (`ENOTFOUND`/`EAI_AGAIN`) or the connection is\n * refused/timed out, so these map to an actionable \"connect to the VPN\" hint.\n */\nconst VAULT_UNREACHABLE_CODES: ReadonlySet<string> = new Set([\n \"ENOTFOUND\",\n \"EAI_AGAIN\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"EHOSTUNREACH\",\n \"ENETUNREACH\",\n]);\n\n/** True when a thrown Vault-read error is a transport failure (host unreachable), not an HTTP response. */\nconst isVaultUnreachableError = (error: unknown): boolean => {\n if (!isRecord(error)) {\n return false;\n }\n const code = error.code;\n return typeof code === \"string\" && VAULT_UNREACHABLE_CODES.has(code);\n};\n\n/**\n * HTTP statuses a *reachable* Vault returns when the caller's token is missing,\n * invalid, or expired — i.e. \"not logged in / not authenticated\" (as opposed to a\n * 404 for a real missing path). `node-vault` attaches the HTTP response to the\n * thrown error as `error.response.statusCode`, so we narrow to it structurally\n * rather than making an extra `tokenLookupSelf` round-trip.\n */\nconst VAULT_UNAUTHENTICATED_STATUS: ReadonlySet<number> = new Set([401, 403]);\n\n/** Extracts the HTTP status code from a thrown `node-vault` read error, if present. */\nconst getVaultErrorStatus = (error: unknown): number | undefined => {\n if (!isRecord(error)) {\n return undefined;\n }\n const response = error.response;\n if (!isRecord(response)) {\n return undefined;\n }\n const statusCode = response.statusCode;\n return typeof statusCode === \"number\" ? statusCode : undefined;\n};\n\n/** Throws an error whose message is routed through `redactSensitive` (defence in depth). */\nconst fail = (message: string): never => {\n throw new Error(redactSensitive(message));\n};\n\nconst passwordCache = new Map<string, string | undefined>();\n\n/**\n * Clears the in-memory resolved-password cache. The cache is a module-level\n * singleton that lives for the whole process, so a resolved value would\n * otherwise leak across calls (and across test cases). Call this between tests\n * to keep each `resolveE2EPassword` call independent.\n */\nexport const resetE2EPasswordCache = (): void => {\n passwordCache.clear();\n};\n\n/**\n * Resolves an account's E2E password by name.\n *\n * Order: env variable `E2E_PW_<SLUG>` (CI path, never touches Vault) -> Vault\n * field `<slug>` (local path). Throws a clear, account-named, redacted error on\n * miss. The password is never included in any error/diagnostic (on failure there\n * is no resolved value to leak).\n *\n * @param username - Account identifier from the fixture (`auth.json` `username`).\n * @param options - Process env and Vault-client seams.\n * @returns {Promise<string>} The resolved password.\n * @throws when the fixture is a placeholder, or neither env nor Vault yields a value.\n */\nexport const resolveE2EPassword = async (\n username: string,\n options: ResolveE2EPasswordOptions = {}\n): Promise<string> => {\n if (username === \"\" || username === \"REPLACE_ME\") {\n return fail(`E2E credentials: fixture account name is unresolved (\"${username}\").`);\n }\n const cached = passwordCache.get(username);\n if (cached !== undefined) {\n return cached;\n }\n\n const env = options.env ?? process.env;\n const key = deriveEnvKey(username);\n\n // CI path: an injected env variable wins and Vault is never contacted.\n const fromEnv = env[key];\n if (fromEnv !== undefined && fromEnv !== \"\") {\n passwordCache.set(username, fromEnv);\n return fromEnv;\n }\n\n // Local path: read the password from Vault by the same key.\n const createVault = options.createVault ?? defaultCreateVault;\n const vault = await createVault(env);\n if (vault === undefined) {\n return fail(\n `E2E credentials for \"${username}\": no env variable (${key}) and Vault is unavailable ` +\n `(not authenticated / not on VPN). Run \\`vault login -address=${env.E2E_VAULT_ENDPOINT} -method=oidc -path=okta\\` on VPN, or set the env variable.`\n );\n }\n\n const logicalPath = env.E2E_VAULT_PATH;\n if (!logicalPath) {\n return fail(\"E2E_VAULT_PATH is not set\");\n }\n const readPath = logicalPath;\n\n let result: unknown;\n try {\n result = await vault.read(readPath);\n } catch (error) {\n if (isVaultUnreachableError(error)) {\n return fail(\n `E2E credentials for \"${username}\": Vault endpoint is unreachable ` +\n `(likely not on VPN, or E2E_VAULT_ENDPOINT is misconfigured). ` +\n `Connect to the VPN and retry, or set the ${key} env variable, right now vault is trying to connect to ${env.E2E_VAULT_ENDPOINT}.`\n );\n }\n const status = getVaultErrorStatus(error);\n if (status !== undefined && VAULT_UNAUTHENTICATED_STATUS.has(status)) {\n return fail(\n `E2E credentials for \"${username}\": Vault rejected the request (HTTP ${status}) — ` +\n `your Vault token is missing or expired. ` +\n `Run something like \\`vault login -address=${env.E2E_VAULT_ENDPOINT} -method=oidc -path=okta\\` on VPN, or set the ${key} env variable, right now vault is trying to connect to a logged in vault at ${env.E2E_VAULT_ENDPOINT}.`\n );\n }\n return fail(\n `E2E credentials for \"${username}\": Vault read of \"${readPath}\" failed on host ${env.E2E_VAULT_ENDPOINT}.`\n );\n }\n\n const fromVault = readVaultField(result, deriveVaultField(username));\n if (fromVault === undefined) {\n return fail(\n `E2E credentials for \"${username}\": no field \"${deriveVaultField(username)}\" at Vault path \"${readPath}\".`\n );\n }\n passwordCache.set(username, fromVault);\n return fromVault;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseTest.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-playwright/src/fixtures/baseTest.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AAQ7C,uFARA,aAAM,OAQA;AAPf,iEAAkE;AAClE,iEAAkE;AAClE,uDAAwD;AACxD,iEAAkE;AAClE,mDAAoD;AAEvC,QAAA,IAAI,GAAG,IAAA,iBAAU,EAAC,2BAAgB,EAAE,oBAAS,EAAE,sBAAW,EAAE,2BAAgB,EAAE,2BAAgB,CAAC,CAAC;AAI7G,qDAAkD;AAAzC,gHAAA,aAAa,OAAA","sourcesContent":["import { expect, mergeTests } from \"@playwright/test\";\nimport { test as featureFlagsTest } from \"./featureFlags.fixture\";\nimport { test as harRecordingTest } from \"./harRecording.fixture\";\nimport { test as irisAppTest } from \"./irisApp.fixture\";\nimport { test as localDevModeTest } from \"./localDevMode.fixture\";\nimport { test as loginTest } from \"./login.fixture\";\n\nexport const test = mergeTests(harRecordingTest, loginTest, irisAppTest, featureFlagsTest, localDevModeTest);\nexport { expect };\n\nexport type { FeatureFlag, FeatureFlagFixtures } from \"./featureFlags.fixture\";\nexport { createIrisApp } from \"./irisApp.fixture\";\nexport type { CreateIrisAppOptions, IrisAppFixtures, IrisAppOptions, StorybookPreviewOptions } from \"./irisApp.fixture\";\nexport type { LocalDevModeFixtures } from \"./localDevMode.fixture\";\nexport type { AuthCredentials, LoginOptions, TrackunitBaseFixtures } from \"./login.fixture\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-playwright/src/fixtures/describe.ts"],"names":[],"mappings":";;;AAAA,2CAA0D;AAK1D,MAAM,eAAe,GAAG,CAAC,KAAa,EAAU,EAAE;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IACxC,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AACvD,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,QAAQ,GAAwD,MAAM,CAAC,MAAM,CACxF,CAAC,KAAa,EAAE,QAA0B,EAAQ,EAAE;IAClD,WAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC,EACD;IACE,IAAI,EAAE,CAAC,KAAa,EAAE,QAA0B,EAAQ,EAAE;QACxD,WAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,EAAE,CAAC,KAAa,EAAE,QAA0B,EAAQ,EAAE;QACxD,WAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;CACF,CACF,CAAC","sourcesContent":["import { test as playwrightTest } from \"@playwright/test\";\n\ntype DescribeCallback = () => void;\ntype DescribeFn = (title: string, callback: DescribeCallback) => void;\n\nconst addOwnerToTitle = (title: string): string => {\n const codeowner = process.env.codeowner;\n return codeowner ? `${title} [${codeowner}]` : title;\n};\n\n/**\n * Wrapped `describe` that appends `[codeowner]` to the suite title when the\n * `codeowner` environment variable is set. Drop-in replacement for `test.describe`.\n */\nexport const describe: DescribeFn & { only: DescribeFn; skip: DescribeFn } = Object.assign(\n (title: string, callback: DescribeCallback): void => {\n playwrightTest.describe(addOwnerToTitle(title), callback);\n },\n {\n only: (title: string, callback: DescribeCallback): void => {\n playwrightTest.describe.only(addOwnerToTitle(title), callback);\n },\n skip: (title: string, callback: DescribeCallback): void => {\n playwrightTest.describe.skip(addOwnerToTitle(title), callback);\n },\n }\n);\n"]}
|