Skip to content

Commit 363bce9

Browse files
committed
fix: updated CI to remove tarball after injection
1 parent c7786f8 commit 363bce9

File tree

9 files changed

+136
-947
lines changed

9 files changed

+136
-947
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ on:
55
branches: [main]
66
pull_request:
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
test:
1014
runs-on: ubuntu-latest
11-
timeout-minutes: 15
15+
timeout-minutes: 20
1216

1317
steps:
14-
# 1 ▸ code
18+
# 1 ▸ Checkout code
1519
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # required for git-diff later
1622

17-
# 2 ▸ pnpm
23+
# 2 ▸ Set up pnpm
1824
- uses: pnpm/action-setup@v3
1925
with:
2026
version: 10.12.1
@@ -26,45 +32,73 @@ jobs:
2632
node-version: 20
2733
cache: pnpm
2834

29-
# 4 ▸ deps
35+
# 4 ▸ Install deps (deterministic)
3036
- name: Install dependencies
3137
run: pnpm install --frozen-lockfile
3238

33-
# 5 ▸ **cache Playwright browsers**
39+
# 5 ▸ Playwright browser cache ────────────────
3440
- name: Cache Playwright browsers
41+
id: pw-cache
3542
uses: actions/cache@v4
3643
with:
37-
path: ~/.cache/ms-playwright # default download dir
44+
path: ~/.cache/ms-playwright
3845
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
39-
restore-keys: ${{ runner.os }}-playwright-
46+
restore-keys: |
47+
${{ runner.os }}-playwright-
4048
41-
# 6 ▸ download browsers if cache miss
42-
- name: Install Playwright browsers
49+
- name: Install Playwright browsers (if cache miss)
50+
if: steps.pw-cache.outputs.cache-hit != 'true'
4351
run: pnpm --filter @austinserb/react-zero-ui exec playwright install --with-deps
4452

45-
# 7 ▸ lint
46-
- run: pnpm lint
47-
name: Lint
48-
49-
# 8 ▸ pack, inject tarball, run tests
50-
- run: pnpm run prepack:core
51-
name: Pack core tarball
52-
- run: node scripts/install-local-tarball.js
53-
name: Inject tarball into fixtures
54-
- run: pnpm test:vite
55-
name: Run Vite tests
56-
- run: pnpm test:next
57-
name: Run Next.js tests
58-
59-
- run: pnpm test:unit
60-
name: Run unit tests
61-
- run: pnpm test:cli
62-
name: Run CLI tests
63-
64-
# 9 ▸ traces on failure
65-
- name: Upload Playwright traces on failure
53+
- name: Save Playwright cache
54+
if: steps.pw-cache.outputs.cache-hit != 'true'
55+
uses: actions/cache/save@v4
56+
with:
57+
path: ~/.cache/ms-playwright
58+
key: ${{ steps.pw-cache.outputs.cache-primary-key }}
59+
60+
# 6 ▸ Lint fast, fail fast
61+
- name: Lint
62+
run: pnpm lint
63+
64+
# 7 ▸ Pack → inject tar-ball → run whole test suite
65+
- name: Pack core tarball
66+
run: pnpm run prepack:core
67+
68+
- name: Inject tarball into fixtures
69+
run: node scripts/install-local-tarball.js
70+
71+
- name: Run Vite tests
72+
run: pnpm test:vite
73+
- name: Run Next.js tests
74+
run: pnpm test:next
75+
76+
- name: Run unit tests
77+
run: pnpm test:unit
78+
79+
- name: Run CLI tests
80+
run: pnpm test:cli
81+
82+
# 8 ▸ Ensure repo is clean (tar-ball didn't dirty fixtures)
83+
- name: Verify clean git tree
84+
run: |
85+
if [[ -n $(git status --porcelain) ]]; then
86+
echo "::error::Git tree dirty after tests"
87+
git status --porcelain
88+
exit 1
89+
fi
90+
91+
# 9 ▸ Upload Playwright traces & junit on failure
92+
- name: Upload Playwright traces
6693
if: failure()
6794
uses: actions/upload-artifact@v4
6895
with:
6996
name: playwright-traces
7097
path: packages/core/__tests__/test-results/
98+
99+
- name: Upload unit snapshots
100+
if: failure()
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: unit-snapshots
104+
path: packages/core/__tests__/snapshots/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ test-results/
1010
npm-debug.log*
1111
yarn-error.log*
1212
.DS_Store
13+
**/playwright-report/
1314

1415
# IDE/editor
1516
.vscode/

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

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

1111
export default defineConfig({
1212
testDir: "../e2e", // all E2E specs live here
13+
snapshotDir: "../snapshots",
1314
workers: 1,
1415
timeout: 300_000,
1516
expect: {

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,32 @@ const BASE_URL = `http://localhost:${PORT}`;
1010

1111
export default defineConfig({
1212
testDir: "../e2e", // all E2E specs live here
13+
snapshotDir: "../snapshots",
1314
workers: 1,
1415
timeout: 300_000,
1516
expect: {
1617
timeout: 150_000,
17-
}, reporter: "html",
18+
},
19+
reporter: "html",
1820
globalSetup: path.resolve(__dirname, "../helpers/globalSetup.vite.js"),
1921

2022
use: {
2123
headless: true,
2224
baseURL: BASE_URL,
23-
2425
},
2526

2627
// One project = one fixture app (Next, Vite, etc.)
2728
projects: [
29+
{
30+
name: "vite-cli-e2e",
31+
testMatch: /cli-vite\.spec\.js/, // Matches both cli-vite.spec.js and vite.spec.js
32+
use: {
33+
baseURL: BASE_URL,
34+
},
35+
},
2836
{
2937
name: "vite-e2e",
30-
testMatch: /.*vite.*\.spec\.js/, // Matches both cli-vite.spec.js and vite.spec.js
38+
testMatch: /vite\.spec\.js/, // Matches both cli-vite.spec.js and vite.spec.js
3139
use: {
3240
baseURL: BASE_URL,
3341
},

packages/core/__tests__/e2e/next.spec.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,39 @@ test.describe.configure({ mode: 'serial' }); // run one after another
1010
test.describe('Zero-UI Next.js integration', () => {
1111
for (const { toggle, attr } of scenarios) {
1212
test(`starts "light" and flips <${attr}> → "dark"`, async ({ page }) => {
13+
console.log(`\n🧪 Testing ${toggle} with attribute ${attr}`);
14+
1315
await page.goto('/', { waitUntil: 'networkidle' });
16+
console.log('📄 Page loaded');
1417

1518
const body = page.locator('body');
1619
const button = page.getByTestId(toggle);
1720

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)
21+
/* ① Wait until the attribute is "light" */
22+
console.log(`🔍 Checking initial ${attr} attribute...`);
23+
24+
// Debug: Check what the actual attribute value is
25+
const actualValue = await body.getAttribute(attr);
26+
console.log(`🐛 DEBUG: Current ${attr} value is:`, actualValue);
27+
28+
// Check if button exists
29+
const buttonExists = await button.count();
30+
console.log(`🐛 DEBUG: Button ${toggle} count:`, buttonExists);
2331

24-
/* ② Now assert it is "light" */
2532
await expect(body).toHaveAttribute(attr, 'light');
33+
console.log(`✅ Initial ${attr} is "light"`);
2634

27-
/* ③ Click & assert "dark" */
35+
/* ② Click & assert "dark" */
36+
console.log(`🖱️ Clicking ${toggle} button...`);
2837
await button.click();
29-
await expect.poll(async () => {
30-
const v = await body.getAttribute(attr);
31-
return v !== null;
32-
}).toBe(true);
38+
console.log(`🔍 Checking ${attr} attribute after click...`);
39+
40+
// Debug: Check what the actual attribute value is after click
41+
const actualValueAfter = await body.getAttribute(attr);
42+
console.log(`🐛 DEBUG: ${attr} value after click is:`, actualValueAfter);
43+
3344
await expect(body).toHaveAttribute(attr, 'dark');
45+
console.log(`✅ ${attr} is now "dark"`);
3446
});
3547
}
3648
});

packages/core/__tests__/e2e/vite.spec.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,39 @@ test.describe.configure({ mode: 'serial' }); // run one after another
1010
test.describe('Zero-UI Vite integration', () => {
1111
for (const { toggle, attr } of scenarios) {
1212
test(`starts "light" and flips <${attr}> → "dark"`, async ({ page }) => {
13+
console.log(`\n🧪 Testing ${toggle} with attribute ${attr}`);
14+
1315
await page.goto('/', { waitUntil: 'networkidle' });
16+
console.log('📄 Page loaded');
1417

1518
const body = page.locator('body');
1619
const button = page.getByTestId(toggle);
1720

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)
21+
/* ① Wait until the attribute is "light" */
22+
console.log(`🔍 Checking initial ${attr} attribute...`);
23+
24+
// Debug: Check what the actual attribute value is
25+
const actualValue = await body.getAttribute(attr);
26+
console.log(`🐛 DEBUG: Current ${attr} value is:`, actualValue);
27+
28+
// Check if button exists
29+
const buttonExists = await button.count();
30+
console.log(`🐛 DEBUG: Button ${toggle} count:`, buttonExists);
2331

24-
/* ② Now assert it is "light" */
2532
await expect(body).toHaveAttribute(attr, 'light');
33+
console.log(`✅ Initial ${attr} is "light"`);
2634

27-
/* ③ Click & assert "dark" */
35+
/* ② Click & assert "dark" */
36+
console.log(`🖱️ Clicking ${toggle} button...`);
2837
await button.click();
29-
await expect.poll(async () => {
30-
const v = await body.getAttribute(attr);
31-
return v !== null;
32-
}).toBe(true);
38+
console.log(`🔍 Checking ${attr} attribute after click...`);
39+
40+
// Debug: Check what the actual attribute value is after click
41+
const actualValueAfter = await body.getAttribute(attr);
42+
console.log(`🐛 DEBUG: ${attr} value after click is:`, actualValueAfter);
43+
3344
await expect(body).toHaveAttribute(attr, 'dark');
45+
console.log(`✅ ${attr} is now "dark"`);
3446
});
3547
}
3648
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// packages/core/__tests__/helpers/globalSetup.vite.js
12
import { resetZeroUiState } from './resetProjectState.js';
23
import { loadCliFromFixture } from './loadCli.js';
34
import path from 'node:path';

0 commit comments

Comments
 (0)