Skip to content

Commit 86a9359

Browse files
committed
refactor: changed to single worker
1 parent 7d73fd2 commit 86a9359

File tree

6 files changed

+44
-46
lines changed

6 files changed

+44
-46
lines changed

packages/core/__tests__/config/playwright.next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const BASE_URL = `http://localhost:${PORT}`;
1010

1111
export default defineConfig({
1212
testDir: "../e2e", // all E2E specs live here
13-
workers: 2,
13+
workers: 1,
1414
timeout: 300_000,
1515
expect: {
1616
timeout: 150_000,

packages/core/__tests__/config/playwright.vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const BASE_URL = `http://localhost:${PORT}`;
1010

1111
export default defineConfig({
1212
testDir: "../e2e", // all E2E specs live here
13-
workers: 2,
13+
workers: 1,
1414
timeout: 300_000,
1515
expect: {
1616
timeout: 150_000,
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
import { test, expect } from '@playwright/test';
22

3-
// Table-driven so every toggle runs in its own fresh browser context.
43
const scenarios = [
54
{ toggle: 'theme-toggle', attr: 'data-theme' },
65
{ toggle: 'theme-toggle-secondary', attr: 'data-theme-2' },
76
{ toggle: 'theme-toggle-3', attr: 'data-theme-three' },
87
];
98

10-
test.describe('Zero-UI Next Integration', () => {
9+
test.describe.configure({ mode: 'serial' }); // run one after another
10+
test.describe('Zero-UI Next.js integration', () => {
1111
for (const { toggle, attr } of scenarios) {
12-
test(`toggles <${attr}> from light → dark`, async ({ page }) => {
13-
// 1️⃣ Load fully hydrated page
12+
test(`starts "light" and flips <${attr}> → "dark"`, async ({ page }) => {
1413
await page.goto('/', { waitUntil: 'networkidle' });
15-
await page.locator('body').waitFor({ state: 'visible', timeout: 5000 });
16-
console.log(`✅ page loaded testing ${attr} from light → dark`);
1714

1815
const body = page.locator('body');
1916
const button = page.getByTestId(toggle);
2017

21-
22-
// 2️⃣ Assert initial state
23-
await expect.poll(async () => await body.getAttribute(attr)).toBe('light');
24-
await expect.poll(async () => await button.isVisible()).toBe(true); // auto-retries until true
25-
26-
27-
// 3️⃣ Action
28-
await button.click((console.log(`✅ ${button} clicked`)));
29-
30-
// 4️⃣ Final state
31-
await expect.poll(async () => await body.getAttribute(attr)).toBe('dark');
18+
/* ① Wait until the attribute exists at all */
19+
await expect.poll(async () => {
20+
const v = await body.getAttribute(attr);
21+
return v !== null;
22+
}).toBe(true); // attribute now present (any value)
23+
24+
/* ② Now assert it is "light" */
25+
await expect(body).toHaveAttribute(attr, 'light');
26+
27+
/* ③ Click & assert "dark" */
28+
await button.click();
29+
await expect.poll(async () => {
30+
const v = await body.getAttribute(attr);
31+
return v !== null;
32+
}).toBe(true);
33+
await expect(body).toHaveAttribute(attr, 'dark');
3234
});
3335
}
34-
});
36+
});
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
import { test, expect } from '@playwright/test';
22

3-
// Table-driven so every toggle runs in its own fresh browser context.
43
const scenarios = [
54
{ toggle: 'theme-toggle', attr: 'data-theme' },
65
{ toggle: 'theme-toggle-secondary', attr: 'data-theme-2' },
76
{ toggle: 'theme-toggle-3', attr: 'data-theme-three' },
87
];
98

10-
test.describe('Zero-UI Vite Integration', () => {
9+
test.describe.configure({ mode: 'serial' }); // run one after another
10+
test.describe('Zero-UI Vite integration', () => {
1111
for (const { toggle, attr } of scenarios) {
12-
test(`toggles <${attr}> from light → dark`, async ({ page }) => {
13-
// 1️⃣ Load fully hydrated page
12+
test(`starts "light" and flips <${attr}> → "dark"`, async ({ page }) => {
1413
await page.goto('/', { waitUntil: 'networkidle' });
15-
await page.locator('body').waitFor({ state: 'visible', timeout: 5000 });
16-
console.log(`✅ page loaded testing ${attr} from light → dark`);
1714

1815
const body = page.locator('body');
1916
const button = page.getByTestId(toggle);
2017

21-
22-
// 2️⃣ Assert initial state
23-
await expect.poll(async () => await body.getAttribute(attr)).toBe('light');
24-
await expect.poll(async () => await button.isVisible()).toBe(true); // auto-retries until true
25-
26-
27-
// 3️⃣ Action
28-
await button.click((console.log(`✅ ${button} clicked`)));
29-
30-
// 4️⃣ Final state
31-
await expect.poll(async () => await body.getAttribute(attr)).toBe('dark');
18+
/* ① Wait until the attribute exists at all */
19+
await expect.poll(async () => {
20+
const v = await body.getAttribute(attr);
21+
return v !== null;
22+
}).toBe(true); // attribute now present (any value)
23+
24+
/* ② Now assert it is "light" */
25+
await expect(body).toHaveAttribute(attr, 'light');
26+
27+
/* ③ Click & assert "dark" */
28+
await button.click();
29+
await expect.poll(async () => {
30+
const v = await body.getAttribute(attr);
31+
return v !== null;
32+
}).toBe(true);
33+
await expect(body).toHaveAttribute(attr, 'dark');
3234
});
3335
}
34-
});
36+
});

packages/core/__tests__/helpers/globalSetup.next.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ export default async function globalSetup() {
1414
resetZeroUiState(projectDir, true);
1515

1616
const zeroUiCli = await loadCliFromFixture(projectDir);
17-
const cwd = process.cwd();
18-
process.chdir(projectDir);
19-
await Promise.resolve(zeroUiCli([]));
20-
process.chdir(cwd);
17+
await zeroUiCli([]);
2118

2219
console.log('[Global Setup] Next.js fixture setup complete!');
2320
}

packages/core/__tests__/helpers/globalSetup.vite.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ export default async function globalSetup() {
1313
resetZeroUiState(projectDir, false);
1414

1515
const zeroUiCli = await loadCliFromFixture(projectDir);
16-
const cwd = process.cwd();
17-
process.chdir(projectDir);
18-
await Promise.resolve(zeroUiCli([]));
19-
process.chdir(cwd);
16+
await zeroUiCli([]);
2017

2118
console.log('[Global Setup] Vite fixture setup complete!');
2219
}

0 commit comments

Comments
 (0)