Skip to content

Commit de2fca8

Browse files
author
RobJellinghaus
committed
All good now
1 parent 10ca23a commit de2fca8

3 files changed

Lines changed: 29 additions & 13 deletions

File tree

globalSetup.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { spawn, ChildProcess } from 'child_process';
22
import { writeFile } from 'fs/promises';
3+
import { chromium } from 'playwright';
34
import path from 'path';
45

56
let serverProcess: ChildProcess;
@@ -217,16 +218,28 @@ async function extractActivationLinkFromLogs(): Promise<string> {
217218
}
218219

219220
async function activateUser(activationUrl: string): Promise<void> {
220-
// Visit the activation URL directly (like a user clicking the email link)
221-
const response = await fetch(activationUrl, {
222-
method: 'GET',
223-
redirect: 'follow'
224-
});
221+
// Use Playwright to visit the activation page and click the Activate button
222+
const browser = await chromium.launch({ headless: true });
223+
const page = await browser.newPage();
225224

226-
if (!response.ok) {
227-
throw new Error(`Activation failed: ${response.status} ${response.statusText}`);
225+
try {
226+
// Navigate to the activation URL
227+
await page.goto(activationUrl);
228+
await page.waitForLoadState('networkidle');
229+
230+
// Look for and click the Activate button
231+
await page.click('button:has-text("Activate")');
232+
233+
// Wait for any processing to complete
234+
await page.waitForLoadState('networkidle');
235+
236+
// Give the activation time to process in the database
237+
await new Promise(resolve => setTimeout(resolve, 1000));
238+
239+
console.log('Successfully clicked Activate button');
240+
} catch (error) {
241+
throw new Error(`Activation failed: ${error.message}`);
242+
} finally {
243+
await browser.close();
228244
}
229-
230-
// Give the activation time to process in the database
231-
await new Promise(resolve => setTimeout(resolve, 1000));
232245
}

playwright.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export default defineConfig({
2222
/* Opt out of parallel tests on CI. */
2323
workers: process.env.CI ? 1 : undefined,
2424
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25-
reporter: 'html',
25+
reporter: [
26+
['html', { open: 'never' }], // Generate HTML report but don't serve it
27+
['list'] // Also show list output for immediate feedback
28+
],
2629

2730
/* Global setup and teardown */
2831
globalSetup: require.resolve('./globalSetup'),

tests/graphql.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ test.describe('GraphQL Features', () => {
2424
// Navigate to GraphQL todos page
2525
await page.click('text=Todos (GraphQL)');
2626

27-
// Check that the page loads (may show todos or empty state)
28-
await expect(page.locator('h1, h2, div')).toBeVisible();
27+
// Check that the page loads by looking for the specific heading
28+
await expect(page.locator('h1:has-text("Todos (GraphQL)")')).toBeVisible();
2929

3030
// The exact content depends on whether there are existing todos
3131
// For now, just verify the page loads without errors

0 commit comments

Comments
 (0)