@rimori/playwright-testing 0.3.10 → 0.3.11

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.
@@ -34,35 +34,39 @@ class RimoriE2ETestEnvironment {
34
34
  this.existingUserEmail = persist.email;
35
35
  console.log(`[E2E] Test user (temp): ${temp.email}`);
36
36
  console.log(`[E2E] Existing user (persist): ${persist.email}`);
37
- this.tempUserContext = await this.browser.newContext({ baseURL: RIMORI_URL });
38
37
  this.persistentUserContext = await this.browser.newContext({ baseURL: RIMORI_URL });
39
- await this.setupConsoleLogging(this.tempUserContext, 'temp');
40
38
  await this.setupConsoleLogging(this.persistentUserContext, 'persist');
41
39
  console.log(`[E2E] Preparing existing user context`);
40
+ const persistPage = await this.persistentUserContext.newPage();
42
41
  // Step 2: Set up existing user browser context with session via magic link
43
- await this.setSessionFromMagicLink(this.persistentUserContext, persist.magicLink);
42
+ await this.setSessionFromMagicLink(persistPage, persist.magicLink);
44
43
  // Step 3: Run onboarding for existing user
45
- await this.completeOnboarding(this.persistentUserContext, onboardingData);
44
+ await this.completeOnboarding(persistPage, onboardingData);
45
+ persistPage.close();
46
46
  console.log(`[E2E] Setting up test user context`);
47
+ this.tempUserContext = await this.browser.newContext({ baseURL: RIMORI_URL });
48
+ await this.setupConsoleLogging(this.tempUserContext, 'temp');
49
+ const tempPage = await this.tempUserContext.newPage();
47
50
  // Step 4: Set up test user browser context with session via magic link
48
- await this.setSessionFromMagicLink(this.tempUserContext, temp.magicLink);
51
+ await this.setSessionFromMagicLink(tempPage, temp.magicLink);
49
52
  // Delete test user when test user context is closed
50
53
  this.tempUserContext.on('close', async () => {
51
54
  await this.deleteTestUserViaApi(temp.email);
52
55
  console.log(`[E2E] Deleted test user: ${temp.email}`);
53
56
  });
54
57
  // Step 5: Run onboarding for test user with e2e plugin flag
55
- await this.completeOnboarding(this.tempUserContext, onboardingData, this.pluginId);
58
+ await this.completeOnboarding(tempPage, onboardingData, this.pluginId);
56
59
  // Step 6: Add exercises if specified
57
60
  if (exercises && exercises?.length > 0) {
58
61
  console.log(`[E2E] Setting up exercises`);
59
- await this.completeExerciseSetup(this.tempUserContext, exercises);
62
+ await this.completeExerciseSetup(tempPage, exercises);
60
63
  }
61
64
  // Step 7: Complete study plan creation if specified
62
65
  if (studyPlan?.complete) {
63
66
  console.log(`[E2E] Setting up study plan`);
64
- await this.completeStudyPlanCreation(this.tempUserContext);
67
+ await this.completeStudyPlanCreation(tempPage);
65
68
  }
69
+ tempPage.close();
66
70
  console.log(`[E2E] Setup completed`);
67
71
  }
68
72
  async getTempUserPage() {
@@ -136,23 +140,22 @@ class RimoriE2ETestEnvironment {
136
140
  return;
137
141
  if (logMessage.includes('i18next: initialized {debug: true'))
138
142
  return;
143
+ if (logMessage.includes('i18next is maintained'))
144
+ return;
139
145
  console.log(`[browser:${logLevel}] [${user}]`, logMessage);
140
146
  });
141
147
  }
142
- async setSessionFromMagicLink(context, magicLink) {
143
- const page = await context.newPage();
148
+ async setSessionFromMagicLink(page, magicLink) {
144
149
  await page.goto(magicLink, { waitUntil: 'networkidle' });
145
150
  await page.waitForTimeout(5000);
146
151
  const url = page.url();
147
152
  if (!url.includes('/dashboard') && !url.includes('/onboarding')) {
148
153
  throw new Error(`Failed to set session from magic link: ${url}`);
149
154
  }
150
- await page.close();
151
155
  console.log(`[E2E] Authentication completed`);
152
156
  }
153
- async completeOnboarding(context, onboarding, e2ePluginId) {
157
+ async completeOnboarding(page, onboarding, e2ePluginId) {
154
158
  console.log(`[E2E] Starting onboarding`);
155
- const page = await context.newPage();
156
159
  await page.goto('/onboarding');
157
160
  await page.waitForTimeout(5000);
158
161
  const isOnboaded = page.url().includes('/dashboard');
@@ -164,22 +167,17 @@ class RimoriE2ETestEnvironment {
164
167
  else {
165
168
  console.log(`[E2E] User already onboarded`);
166
169
  }
167
- await page.close();
168
170
  }
169
- async completeExerciseSetup(context, exercises) {
170
- const page = await context.newPage();
171
+ async completeExerciseSetup(page, exercises) {
171
172
  for (const exercise of exercises) {
172
173
  const encoded = encodeURIComponent(JSON.stringify(exercise));
173
174
  await page.goto(`${RIMORI_URL}/dashboard?flag-e2e-exercise=${encoded}`);
174
175
  // Wait for the exercise to be created and the flag to be cleared from URL
175
176
  await page.waitForURL((url) => !url.searchParams.has('flag-e2e-exercise'), { timeout: 15000 });
176
177
  }
177
- await page.close();
178
178
  }
179
- async completeStudyPlanCreation(context) {
180
- const page = await context.newPage();
179
+ async completeStudyPlanCreation(page) {
181
180
  await (0, study_plan_setup_1.completeStudyPlanGettingStarted)(page);
182
- await page.close();
183
181
  }
184
182
  }
185
183
  exports.RimoriE2ETestEnvironment = RimoriE2ETestEnvironment;
@@ -24,6 +24,7 @@ async function completeOnboarding(page, onboarding, e2ePluginId) {
24
24
  page.setDefaultNavigationTimeout(60000);
25
25
  // Ensure we're on onboarding page
26
26
  await (0, test_1.expect)(page).toHaveURL(/\/onboarding/);
27
+ await page.waitForTimeout(2000);
27
28
  // Step 1: Learning Reason (radio select, auto-advances after selection)
28
29
  const learningReasonOption = page.getByText(learningReasonMap[onboarding.learning_reason]);
29
30
  await (0, test_1.expect)(learningReasonOption).toBeVisible({ timeout: 10000 });
@@ -34,6 +35,7 @@ async function completeOnboarding(page, onboarding, e2ePluginId) {
34
35
  await (0, test_1.expect)(interestsTextarea).toBeVisible({ timeout: 10000 });
35
36
  await interestsTextarea.click();
36
37
  await interestsTextarea.fill(onboarding.interests);
38
+ await page.waitForTimeout(1000);
37
39
  const interestsContinue = page.getByRole('button', { name: /continue/i });
38
40
  await (0, test_1.expect)(interestsContinue).toBeEnabled({ timeout: 10000 });
39
41
  await interestsContinue.click();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/playwright-testing",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Playwright testing utilities for Rimori plugins and workers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -26,11 +26,11 @@
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@playwright/test": "^1.40.0",
29
- "@rimori/client": "^2.5.17"
29
+ "@rimori/client": "^2.5.18"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@playwright/test": "^1.40.0",
33
- "@rimori/client": "^2.5.17",
33
+ "@rimori/client": "^2.5.18",
34
34
  "@types/node": "^20.12.7",
35
35
  "rimraf": "^5.0.7",
36
36
  "typescript": "^5.7.2"