@rimori/playwright-testing 0.3.32 → 0.3.33
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.
|
@@ -24,6 +24,7 @@ export declare class RimoriE2ETestEnvironment {
|
|
|
24
24
|
private existingUserEmail;
|
|
25
25
|
private authToken;
|
|
26
26
|
constructor(options: RimoriE2ETestEnvironmentOptions);
|
|
27
|
+
private preflightLocal;
|
|
27
28
|
setup({ onboarding, exercises }?: SetupOptions): Promise<void>;
|
|
28
29
|
getTempUserPage(): Promise<Page>;
|
|
29
30
|
getPersistUserPage(): Promise<Page>;
|
|
@@ -5,9 +5,15 @@ const dotenv_1 = require("dotenv");
|
|
|
5
5
|
const onboarding_1 = require("../helpers/e2e/onboarding");
|
|
6
6
|
const create_exercise_1 = require("../helpers/e2e/create-exercise");
|
|
7
7
|
(0, dotenv_1.config)();
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const ENVS = {
|
|
9
|
+
local: { rimoriUrl: 'http://localhost:3000', backendUrl: 'http://localhost:2800' },
|
|
10
|
+
dev: { rimoriUrl: 'https://dev-app.rimori.se', backendUrl: 'https://dev-api.rimori.se' },
|
|
11
|
+
};
|
|
12
|
+
const envName = (process.env.RIMORI_E2E_ENV ?? 'dev');
|
|
13
|
+
if (!ENVS[envName]) {
|
|
14
|
+
throw new Error(`RIMORI_E2E_ENV must be one of: ${Object.keys(ENVS).join(', ')} (got: ${envName})`);
|
|
15
|
+
}
|
|
16
|
+
const { rimoriUrl: RIMORI_URL, backendUrl: BACKEND_URL } = ENVS[envName];
|
|
11
17
|
class RimoriE2ETestEnvironment {
|
|
12
18
|
constructor(options) {
|
|
13
19
|
this.persistentUserContext = null;
|
|
@@ -21,8 +27,21 @@ class RimoriE2ETestEnvironment {
|
|
|
21
27
|
if (!this.authToken) {
|
|
22
28
|
throw new Error('RIMORI_TOKEN is not set as an environment variable.');
|
|
23
29
|
}
|
|
30
|
+
console.log(`[E2E] Target: ${envName} (${RIMORI_URL} → ${BACKEND_URL})`);
|
|
31
|
+
}
|
|
32
|
+
async preflightLocal() {
|
|
33
|
+
if (envName !== 'local')
|
|
34
|
+
return;
|
|
35
|
+
try {
|
|
36
|
+
await fetch(BACKEND_URL, { signal: AbortSignal.timeout(2000) });
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new Error(`[E2E] local backend not reachable at ${BACKEND_URL}.\n` +
|
|
40
|
+
'Start the dev stack first: `pnpm dev` from the monorepo root.');
|
|
41
|
+
}
|
|
24
42
|
}
|
|
25
43
|
async setup({ onboarding, exercises } = {}) {
|
|
44
|
+
await this.preflightLocal();
|
|
26
45
|
const onboardingData = {
|
|
27
46
|
learning_reason: onboarding?.learning_reason ?? 'work',
|
|
28
47
|
target_country: onboarding?.target_country ?? 'SE',
|
|
@@ -144,7 +163,13 @@ class RimoriE2ETestEnvironment {
|
|
|
144
163
|
});
|
|
145
164
|
}
|
|
146
165
|
async setSessionFromMagicLink(page, magicLink) {
|
|
147
|
-
|
|
166
|
+
// Magic-link host = Supabase verify endpoint (must stay). For local env, only
|
|
167
|
+
// rewrite the `redirect_to` so the browser lands on localhost after verify.
|
|
168
|
+
// Include a trailing path so Supabase's `http://localhost:3000/**` allowlist matches.
|
|
169
|
+
const target = envName === 'local'
|
|
170
|
+
? magicLink.replace(/([?&]redirect_to=)[^&]+/i, `$1${encodeURIComponent(`${RIMORI_URL}/dashboard`)}`)
|
|
171
|
+
: magicLink;
|
|
172
|
+
await page.goto(target, { waitUntil: 'networkidle' });
|
|
148
173
|
try {
|
|
149
174
|
await page.waitForURL((url) => url.pathname.includes('/dashboard') || url.pathname.includes('/onboarding'), { timeout: 30000 });
|
|
150
175
|
}
|
|
@@ -152,7 +177,7 @@ class RimoriE2ETestEnvironment {
|
|
|
152
177
|
const url = page.url();
|
|
153
178
|
throw new Error(`Failed to set session from magic link: ${url}`);
|
|
154
179
|
}
|
|
155
|
-
console.log(`[E2E] Authentication completed`);
|
|
180
|
+
console.log(`[E2E] Authentication completed (landed at: ${page.url()})`);
|
|
156
181
|
}
|
|
157
182
|
async completeOnboarding(page, onboarding, e2ePluginId) {
|
|
158
183
|
console.log(`[E2E] Starting onboarding`);
|