Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ module.exports = {
},
},
{
files: ['./e2e-tests/*.ts'],
files: ['./e2e-tests/*.ts', './e2e-internal/*.ts'],
extends: ['plugin:playwright/recommended'],
rules: {
'playwright/no-skipped-test': [
Expand Down
25 changes: 25 additions & 0 deletions code/e2e-internal/internal-storybook.smoke.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect, test } from '@playwright/test';
import process from 'process';

/**
* Smoke tests for the internal Storybook UI (`code/.storybook`), not sandbox templates.
*
* Run locally (from repo root) with internal Storybook on port 6006:
* cd code && yarn storybook:ui
* yarn task e2e-tests-internal --no-link -s e2e-tests-internal
*/

const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006';

/** Stable core template story shipped with the internal UI. */
const STORY_PATH = '/story/core-basics--basic';

test.describe('internal Storybook UI', () => {
test('loads a story in the preview iframe', async ({ page }) => {
await page.goto(`${storybookUrl}/?path=${STORY_PATH}`);
await expect(page.locator('#storybook-preview-iframe')).toBeVisible();

const preview = page.frameLocator('#storybook-preview-iframe');
await expect(preview.getByRole('button', { name: 'Click Me!' })).toBeVisible();
});
});
7 changes: 7 additions & 0 deletions code/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export default defineConfig({

/* Configure projects for major browsers */
projects: [
{
name: 'internal-storybook',
testDir: './e2e-internal',
use: {
...devices['Desktop Chrome'],
},
},
{
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
// Playwright recommends project dependencies over globalSetup when setup needs runner features
// like fixtures, traces, and retries:
Expand Down
42 changes: 39 additions & 3 deletions scripts/ci/common-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import glob from 'fast-glob';
import { join } from 'path/posix';

import { WINDOWS_ROOT_DIR, WORKING_DIR } from './utils/constants.ts';
import { LINUX_ROOT_DIR, WINDOWS_ROOT_DIR, WORKING_DIR } from './utils/constants.ts';
import {
CACHE_KEYS,
CACHE_PATHS,
Expand Down Expand Up @@ -161,6 +161,42 @@ export const storybookChromatic = defineJob(
[commonJobsNoOpJob]
);

export const internalStorybookE2e = defineJob(
'Internal storybook E2E',
(workflowName) => ({
executor: {
name: 'sb_playwright',
class: 'medium+',
},
steps: [
...workflow.restoreLinux(),
{
run: {
name: 'Run internal Storybook',
working_directory: 'code',
background: true,
command: 'yarn storybook:ui',
},
},
server.wait(['6006']),
{
run: {
name: 'Run internal Storybook E2E tests',
command: 'yarn task e2e-tests-internal --no-link -s e2e-tests-internal --junit',
},
},
artifact.persist(join(LINUX_ROOT_DIR, WORKING_DIR, 'test-results'), 'test-results'),
artifact.persist(
join(LINUX_ROOT_DIR, WORKING_DIR, 'code', 'playwright-results'),
'playwright-results'
),
testResults.persist(join(LINUX_ROOT_DIR, WORKING_DIR, 'test-results')),
...workflow.reportOnFailure(workflowName),
],
}),
[commonJobsNoOpJob]
);

export const check = defineJob(
'TypeScript validation',
(workflowName) => ({
Expand Down Expand Up @@ -253,7 +289,7 @@ export const testsUnit_linux = defineJob(
run: {
name: 'Run tests',
command: [
'TEST_FILES=$(circleci tests glob "code/**/*.{test,spec}.{ts,tsx,js,jsx,cjs}" "scripts/**/*.{test,spec}.{ts,tsx,js,jsx,cjs}" | sed "/e2e-tests\\//d" | sed "/node_modules\\//d")',
'TEST_FILES=$(circleci tests glob "code/**/*.{test,spec}.{ts,tsx,js,jsx,cjs}" "scripts/**/*.{test,spec}.{ts,tsx,js,jsx,cjs}" | sed "/e2e-tests\\//d" | sed "/e2e-internal\\//d" | sed "/node_modules\\//d")',
'echo "$TEST_FILES" | circleci tests run --command="xargs yarn test --reporter=junit --reporter=default --outputFile=./test-results/junit.xml" --verbose',
].join('\n'),
},
Expand Down Expand Up @@ -281,7 +317,7 @@ export const testsStories_linux = defineJob(
run: {
name: 'Run stories tests',
command: [
'TEST_FILES=$(circleci tests glob "code/**/*.{stories}.{ts,tsx,js,jsx,cjs}" | sed "/e2e-tests\\//d" | sed "/node_modules\\//d")',
'TEST_FILES=$(circleci tests glob "code/**/*.{stories}.{ts,tsx,js,jsx,cjs}" | sed "/e2e-tests\\//d" | sed "/e2e-internal\\//d" | sed "/node_modules\\//d")',
'echo "$TEST_FILES" | circleci tests run --command="xargs yarn test --reporter=junit --reporter=default --outputFile=./test-results/junit.xml" --verbose',
].join('\n'),
},
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
knip,
lint,
fmt,
internalStorybookE2e,
storybookChromatic,
testUnit_windows,
testsStories_linux,
Expand Down Expand Up @@ -66,6 +67,7 @@ function generateConfig(workflow: Workflow) {
knip,

storybookChromatic,
internalStorybookE2e,
benchmarkPackages,

sandboxesNoOpJob,
Expand Down
12 changes: 11 additions & 1 deletion scripts/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { compile } from './tasks/compile.ts';
import { dev } from './tasks/dev.ts';
import { e2eTestsBuild } from './tasks/e2e-tests-build.ts';
import { e2eTestsDev } from './tasks/e2e-tests-dev.ts';
import { e2eTestsInternal } from './tasks/e2e-tests-internal.ts';
import { generate } from './tasks/generate.ts';
import { install } from './tasks/install.ts';
import { publish } from './tasks/publish.ts';
Expand Down Expand Up @@ -100,13 +101,22 @@ export const tasks = {
chromatic,
'e2e-tests': e2eTestsBuild,
'e2e-tests-dev': e2eTestsDev,
'e2e-tests-internal': e2eTestsInternal,
bench,
'vitest-integration': vitestTests,
};
export type TaskKey = keyof typeof tasks;

function isSandboxTask(taskKey: TaskKey) {
return !['install', 'compile', 'publish', 'run-registry', 'check', 'sync-docs'].includes(taskKey);
return ![
'install',
'compile',
'publish',
'run-registry',
'check',
'sync-docs',
'e2e-tests-internal',
].includes(taskKey);
}

export const options = createOptions({
Expand Down
39 changes: 39 additions & 0 deletions scripts/tasks/e2e-tests-internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import waitOn from 'wait-on';

import type { Task } from '../task.ts';
import { exec } from '../utils/exec.ts';

const STORYBOOK_PORT = 6006;

export const e2eTestsInternal: Task = {
description: 'Run e2e tests against the internal Storybook UI (code/.storybook)',
dependsOn: ['compile'],
junit: true,
async ready() {
return false;
},
async run({ codeDir, junitFilename }, { dryRun, debug }) {
const storybookUrl = `http://localhost:${STORYBOOK_PORT}`;

await waitOn({
resources: [`${storybookUrl}/index.json`],
interval: 16,
timeout: 300_000,
});

Comment thread
cursor[bot] marked this conversation as resolved.
await exec(
'yarn playwright test --project=internal-storybook',
{
env: {
CI: 'true',
STORYBOOK_URL: storybookUrl,
...(junitFilename && {
PLAYWRIGHT_JUNIT_OUTPUT_NAME: junitFilename,
}),
},
cwd: codeDir,
},
{ dryRun, debug }
);
Comment thread
cursor[bot] marked this conversation as resolved.
},
};