Skip to content

Commit 4a45007

Browse files
committed
Merge branch 'add-e2e-test' into improve-dev
2 parents dcfa402 + 4cb4c4b commit 4a45007

4 files changed

Lines changed: 43 additions & 28 deletions

File tree

.github/workflows/publish.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,36 @@ jobs:
9191
bun run --filter landing build
9292
- name: Install Playwright Browsers
9393
run: bunx playwright install chromium --with-deps
94+
- name: Check for Existing E2E Snapshots
95+
id: check-snapshots
96+
run: |
97+
SNAPSHOT_COUNT=$(find e2e -name '*.png' -path '*-snapshots/*' 2>/dev/null | wc -l)
98+
echo "count=$SNAPSHOT_COUNT" >> $GITHUB_OUTPUT
99+
echo "Found $SNAPSHOT_COUNT existing snapshot(s)"
100+
- name: Generate E2E Snapshots
101+
if: steps.check-snapshots.outputs.count == '0'
102+
run: bunx playwright test --update-snapshots
103+
- name: Commit E2E Snapshots
104+
if: steps.check-snapshots.outputs.count == '0' && github.event_name == 'pull_request'
105+
uses: stefanzweifel/git-auto-commit-action@v5
106+
with:
107+
commit_message: "chore: generate e2e visual snapshots from CI"
108+
file_pattern: "e2e/**/*-snapshots/*.png"
94109
- name: Run E2E Tests
95110
run: bun run test:e2e
96111
- name: Upload artifact
97-
uses: actions/upload-pages-artifact@v3
98-
with:
99-
path: ./apps/landing/out
100-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
101-
- uses: actions/deploy-pages@v4
102-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
112+
uses: actions/upload-pages-artifact@v3
113+
with:
114+
path: ./apps/landing/out
115+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
116+
- uses: actions/deploy-pages@v4
117+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
118+
- name: Build Landing (singleCss)
119+
run: |
120+
rm -rf apps/landing/out apps/landing/.next apps/landing/df
121+
DEVUP_SINGLE_CSS=1 bun run --filter landing build
122+
- name: Run E2E Tests (singleCss)
123+
run: bun run test:e2e
103124
- name: Upload to codecov.io
104125
uses: codecov/codecov-action@v5
105126
with:

apps/landing/next.config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ const withMDX = createMDX({
66
})
77

88
export default withMDX(
9-
DevupUI({
10-
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
11-
output: 'export',
12-
reactCompiler: true,
13-
}),
9+
DevupUI(
10+
{
11+
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
12+
output: 'export',
13+
reactCompiler: true,
14+
},
15+
{
16+
singleCss: process.env.DEVUP_SINGLE_CSS === '1',
17+
},
18+
),
1419
)

e2e/docs-pages.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,17 @@ test.describe('Documentation Pages', () => {
185185
await context.close()
186186
})
187187

188-
// Dark mode screenshot requires JS for ThemeScript to set data-theme attribute.
189-
// With javaScriptEnabled: false, the theme cannot switch to dark mode.
190-
// Using colorScheme: 'dark' in context only sets prefers-color-scheme media,
191-
// which is insufficient if the app relies on a JS-driven theme class/attribute.
192-
test.skip('dark mode features section screenshot', async ({ browser }) => {
188+
test('dark mode features section screenshot', async ({ browser }) => {
193189
const context = await browser.newContext({
194-
javaScriptEnabled: false,
195190
viewport: { width: 1440, height: 900 },
196191
colorScheme: 'dark',
197192
})
198193
const page = await context.newPage()
199194
await page.goto('/')
195+
await page.waitForLoadState('networkidle')
196+
await page.evaluate(() =>
197+
document.documentElement.setAttribute('data-theme', 'dark'),
198+
)
200199
await page.waitForTimeout(500)
201200

202201
const features = page.getByText('Features').first()

playwright.config.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@ export default defineConfig({
2222
projects: [
2323
{
2424
name: 'chromium',
25-
use: {
26-
...devices['Desktop Chrome'],
27-
launchOptions: {
28-
args: [
29-
'--font-render-hinting=none',
30-
'--disable-font-subpixel-positioning',
31-
'--disable-skia-runtime-opts',
32-
'--disable-lcd-text',
33-
],
34-
},
35-
},
25+
use: { ...devices['Desktop Chrome'] },
3626
},
3727
],
3828
webServer: {

0 commit comments

Comments
 (0)