Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(checkbox-list): shift event checkbox was broken #4619

Merged
merged 5 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
126 changes: 78 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,104 @@ on:
- main

jobs:
build:
strategy:
matrix:
node: ["22"]
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4 # v4.1.4
- uses: pnpm/[email protected]
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
- name: build
run: |
pnpm install --frozen-lockfile
pnpm run build
manypkg:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
- name: manypkg
run: |
pnpm install --frozen-lockfile
pnpm exec manypkg check

typecheck:
runs-on: ubuntu-24.04
needs: [build]
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
- name: typecheck
run: |
pnpm install --frozen-lockfile
pnpm typecheck

oxlint:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
- name: oxlint
run: |
pnpm install --frozen-lockfile
pnpm build
pnpm oxlint -c .oxlintrc.json --quiet

lint:
runs-on: ubuntu-24.04
needs: [build]
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- run: |
- name: lint
run: |
pnpm install --frozen-lockfile
pnpm build
pnpm run build
pnpm run lint

format:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
Expand All @@ -99,18 +118,17 @@ jobs:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
needs: [typecheck, format]
strategy:
matrix:
node: ["22"]
node: ["20", "22"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 10
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
cache: "pnpm"
Expand Down Expand Up @@ -139,35 +157,16 @@ jobs:
# - run: pnpm run build
# - run: pnpm install
# - run: pnpm run test:a11y
build:
strategy:
matrix:
node: ["22"]
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
needs: [typecheck, format]
steps:
- uses: actions/checkout@v4 # v4.1.4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
- run: |
pnpm install --frozen-lockfile
pnpm run build

publint:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
TURBO_CACHE: "remote:rw"
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
- name: publint
uses: actions/[email protected]
with:
node-version: 22
Expand All @@ -178,12 +177,15 @@ jobs:

deploy:
runs-on: ubuntu-24.04
needs: [publint, typecheck, build]
env:
IMAGE_NAME: rg.fr-par.scw.cloud/ultraviolet/storybook
DEPLOYMENT_NAME: "storybook"
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
needs: [publint, typecheck, build]
TURBO_CACHE: "remote:rw"
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#example-usage-of-the-jobs-context
outputs:
base_url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
- name: Inject slug/short variables
Expand Down Expand Up @@ -296,3 +298,31 @@ jobs:
run: |
rm -rf /tmp/docs/.buildx-cache
mv /tmp/docs/.buildx-cache-new /tmp/docs/.buildx-cache

e2e:
timeout-minutes: 5
runs-on: ubuntu-latest
needs: [deploy]
env:
CI: true
TURBO_CACHE: "remote:rw"
BASE_URL: ${{ needs.deploy.outputs.base_url }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- uses: actions/[email protected]
with:
node-version: 22
cache: "pnpm"
- name: install pnpm deps
run: |
pnpm install --frozen-lockfile
pnpm exec playwright install --with-deps
- name: run e2e
run: pnpm run test:e2e
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 5
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ tools/*/.turbo

# next
next-env.d.ts*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
43 changes: 43 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig, devices } from '@playwright/test'

const isCI = process.env['CI']

const baseURL = process.env['BASE_URL'] ?? 'http://localhost:6006'

const times = {
'1min': 60 * 1000,
'3min': 3 * 60 * 1000,
}

export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!isCI,
retries: isCI ? 2 : 0,
workers: isCI ? 1 : undefined,
reporter: 'html',
globalTimeout: isCI ? 5 * times['1min'] : undefined,
timeout: isCI ? 1 * times['1min'] : undefined,
use: {
baseURL,
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
})
9 changes: 9 additions & 0 deletions e2e/tests/default.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect, test } from '@playwright/test'

test.describe('Default', () => {
test('title', async ({ page, baseURL }) => {
await page.goto(`${baseURL}`)

await expect(page).toHaveTitle('Get started - Docs ⋅ Storybook')
})
})
22 changes: 22 additions & 0 deletions e2e/tests/ui/checkbox.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect, test } from '@playwright/test'

const defaultLocator = 'iframe[title="storybook-preview-iframe"]'

const defaultURL = `/?path=/story/components-data-entry-checkbox--playground`

test.describe('List', () => {
test('Checkbox Row', async ({ page, baseURL }) => {
const url = `${baseURL}${defaultURL}`

await page.goto(url)

const rootLocator = page.locator(defaultLocator).contentFrame()
await rootLocator.getByRole('checkbox').click()

const checkbox = rootLocator.locator(`input[type='checkbox']`)

await expect(checkbox).toBeChecked({
checked: true,
})
})
})
26 changes: 26 additions & 0 deletions e2e/tests/ui/list.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { expect, test } from '@playwright/test'

const defaultLocator = 'iframe[title="storybook-preview-iframe"]'
const defaultURL = `/?path=/story/components-data-display-list--selectable`

test.describe('List', () => {
test('Checkbox Row', async ({ page, baseURL }) => {
const url = `${baseURL}${defaultURL}`

await page.goto(url)

const rootLocator = page.locator(defaultLocator).contentFrame()
await rootLocator
.getByRole('row', { name: 'select Venus 0.718AU 0.728AU' })
.getByLabel('select')
.check()

const checkbox = rootLocator.locator(
`input[type='checkbox'][name='list-select-checkbox'][value="venus"]`,
)

await expect(checkbox).toBeChecked({
checked: true,
})
})
})
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"build:storybook:stats": "pnpm turbo build:storybook -- --webpack-stats-json",
"test:unit": "turbo run test:unit",
"test:unit:coverage": "turbo run test:unit:coverage",
"test:e2e": "playwright test -c e2e",
"test:e2e:headed": "pnpm run test:e2e --headed",
"test:e2e:debug": "PWDEBUG=1 pnpm run test:e2e",
"check:deps": "npx depcheck . --skip-missing=true --ignores='bin,eslint,vite,jest,husky,@commitlint/*,@babel/*,babel-*'",
"commit": "npx git-cz -a --disable-emoji",
"start": "STORYBOOK_ENVIRONMENT=development storybook dev -p 6006",
Expand Down Expand Up @@ -110,6 +113,7 @@
"@eslint/compat": "1.2.4",
"@eslint/eslintrc": "3.2.0",
"@manypkg/cli": "0.23.0",
"@playwright/test": "1.49.1",
"@scaleway/eslint-config-react": "4.0.9",
"@scaleway/tsconfig": "1.1.1",
"@size-limit/file": "11.1.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import type { StoryFn } from '@storybook/react'
import { useState } from 'react'
import { Checkbox } from '..'

export const Template: StoryFn<typeof Checkbox> = ({
'aria-label': ariaLabel,
...args
}) => (
<Checkbox onChange={console.log} {...args}>
Beautiful checkbox
</Checkbox>
)
}) => {
const [checked, setChecked] = useState(false)

return (
<Checkbox
checked={checked}
onChange={e => setChecked(e.target.checked)}
{...args}
>
Beautiful checkbox
</Checkbox>
)
}

Template.args = {
disabled: false,
name: 'basic',
value: 'label-1',
}
Loading
Loading