Skip to content

Commit 0049882

Browse files
committed
update tests
1 parent bdac287 commit 0049882

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

.github/workflows/test-preview.yml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
github.event.deployment_status.state == 'success'
1919
) || (
2020
github.event_name == 'pull_request' &&
21-
github.event.action == 'labeled' &&
22-
github.event.label.name == 'visual-test'
21+
github.event.action == 'labeled'
2322
)
2423
runs-on: ubuntu-latest
2524

@@ -32,30 +31,27 @@ jobs:
3231
repository: ClickHouse/clickhouse-docs
3332
path: ./
3433

35-
- name: Fetch pull request labels
36-
if: github.event_name == 'deployment_status'
37-
id: fetch-labels
38-
uses: actions/github-script@v6
39-
with:
40-
script: |
41-
const pr = await github.pulls.get({
42-
owner: context.repo.owner,
43-
repo: context.repo.repo,
44-
pull_number: context.payload.deployment_status.deployment.payload.pull_request.number
45-
});
46-
core.setOutput('labels', JSON.stringify(pr.data.labels));
47-
48-
# Step 3: Check for "visual-test" label
49-
- name: Check for "visual-test" label
50-
id: label-check
51-
run: |
52-
echo "Checking for 'visual-test' label..."
53-
echo "${{ steps.fetch-labels.outputs.labels }}" | jq '.[].name' | grep -q 'visual-test' && echo "true" || echo "false"
54-
shell: bash
55-
env:
56-
LABELS: ${{ steps.fetch-labels.outputs.labels }}
57-
5834
- name: Log BASE_URL
5935
run: echo "BASE_URL=${{ github.event.deployment_status.environment_url }}"
6036
env:
61-
BASE_URL: ${{ github.event.deployment_status.environment_url }}
37+
BASE_URL: ${{ github.event.deployment_status.environment_url }}
38+
39+
# Step 2: Setup node
40+
- name: Set up Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: '20.18.0'
44+
cache: 'yarn'
45+
46+
47+
48+
# Step 3: Run Playwright tests
49+
- name: Run Playwright tests
50+
run: yarn playwright test
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
BASE_URL: ${{ github.event.deployment_status.environment_url }}
54+
ARGOS_BRANCH: ${{ github.event.deployment_status.environment == 'Production' && 'main' || github.ref_name }}
55+
CI: true
56+
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
57+

playwright.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import {devices} from '@playwright/test';
22
import type {PlaywrightTestConfig} from '@playwright/test';
33

4+
const isCI = !!process.env.CI; // Check if running in CI
5+
const baseURL = isCI ? process.env.BASE_URL : "http://localhost:3000";
6+
7+
48
const config: PlaywrightTestConfig = {
59
webServer: {
610
port: 3000,
@@ -22,7 +26,7 @@ const config: PlaywrightTestConfig = {
2226
"@argos-ci/playwright/reporter",
2327
{
2428
// Upload to Argos on CI only.
25-
uploadToArgos: !!process.env.CI,
29+
uploadToArgos: isCI,
2630

2731
// Set your Argos token.
2832
token: process.env.ARGOS_TOKEN,
@@ -32,7 +36,7 @@ const config: PlaywrightTestConfig = {
3236

3337
use: {
3438
// On CI, we will set `BASE_URL` from Vercel preview URL
35-
baseURL: process.env.CI ? process.env.BASE_URL : "http://localhost:3000",
39+
baseURL: baseURL,
3640
extraHTTPHeaders: {
3741
// Hide Vercel Toolbar in tests
3842
"x-vercel-skip-toolbar": "0",

tests/screenshot.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {test} from '@playwright/test';
44
import {extractSitemapPathnames, pathnameToArgosName} from './utils';
55

66
// Constants
7-
const siteUrl = 'http://localhost:3000';
7+
const siteUrl = process.env.CI ? process.env.BASE_URL : 'http://localhost:3000';
88
const sitemapPath = './build/sitemap.xml';
99
const stylesheetPath = './tests/screenshot.css';
1010
const stylesheet = fs.readFileSync(stylesheetPath).toString();

0 commit comments

Comments
 (0)