fix: fix storybook pages tests coverage (#5319)
This commit is contained in:
4
.github/workflows/ci-front.yaml
vendored
4
.github/workflows/ci-front.yaml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
- name: Front / Write .env
|
- name: Front / Write .env
|
||||||
run: npx nx reset:env twenty-front
|
run: npx nx reset:env twenty-front
|
||||||
- name: Front / Build storybook
|
- name: Front / Build storybook
|
||||||
run: NODE_OPTIONS=--max-old-space-size=5000 npx nx storybook:build twenty-front
|
run: npx nx storybook:build twenty-front
|
||||||
front-sb-test:
|
front-sb-test:
|
||||||
runs-on: ci-8-cores
|
runs-on: ci-8-cores
|
||||||
needs: front-sb-build
|
needs: front-sb-build
|
||||||
@ -87,7 +87,7 @@ jobs:
|
|||||||
touch .env
|
touch .env
|
||||||
echo "REACT_APP_SERVER_BASE_URL: $REACT_APP_SERVER_BASE_URL" >> .env
|
echo "REACT_APP_SERVER_BASE_URL: $REACT_APP_SERVER_BASE_URL" >> .env
|
||||||
- name: Publish to Chromatic
|
- name: Publish to Chromatic
|
||||||
run: NODE_OPTIONS=--max-old-space-size=5000 npx nx run twenty-front:chromatic:ci
|
run: npx nx run twenty-front:chromatic:ci
|
||||||
front-task:
|
front-task:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
36
nx.json
36
nx.json
@ -106,30 +106,38 @@
|
|||||||
"dependsOn": ["^build"]
|
"dependsOn": ["^build"]
|
||||||
},
|
},
|
||||||
"storybook:build": {
|
"storybook:build": {
|
||||||
"executor": "@nx/storybook:build",
|
"executor": "nx:run-commands",
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"inputs": ["^default", "excludeTests"],
|
"inputs": ["^default", "excludeTests"],
|
||||||
"outputs": ["{options.outputDir}"],
|
"outputs": ["{options.output-dir}"],
|
||||||
"options": {
|
"options": {
|
||||||
"outputDir": "{projectRoot}/storybook-static",
|
"cwd": "{projectRoot}",
|
||||||
"configDir": "{projectRoot}/.storybook"
|
"command": "storybook build",
|
||||||
|
"output-dir": "storybook-static",
|
||||||
|
"config-dir": ".storybook"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:dev": {
|
"storybook:dev": {
|
||||||
"executor": "@nx/storybook:storybook",
|
"executor": "nx:run-commands",
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"options": {
|
"options": {
|
||||||
"configDir": "{projectRoot}/.storybook"
|
"cwd": "{projectRoot}",
|
||||||
|
"command": "storybook dev",
|
||||||
|
"config-dir": ".storybook"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:static": {
|
"storybook:static": {
|
||||||
"executor": "@nx/web:file-server",
|
"executor": "nx:run-commands",
|
||||||
|
"dependsOn": ["storybook:build"],
|
||||||
"options": {
|
"options": {
|
||||||
"staticFilePath": "{projectRoot}/storybook-static",
|
"cwd": "{projectRoot}",
|
||||||
"parallel": false,
|
"command": "npx http-server {args.staticDir} -a={args.host} --port={args.port} --silent={args.silent}",
|
||||||
"watch": false
|
"staticDir": "storybook-static",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 6006,
|
||||||
|
"silent": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:coverage": {
|
"storybook:coverage": {
|
||||||
@ -148,6 +156,9 @@
|
|||||||
"command": "npx nyc report --reporter={args.reporter} --reporter=text-summary -t {args.coverageDir} --report-dir {args.coverageDir} --check-coverage --cwd={projectRoot}",
|
"command": "npx nyc report --reporter={args.reporter} --reporter=text-summary -t {args.coverageDir} --report-dir {args.coverageDir} --check-coverage --cwd={projectRoot}",
|
||||||
"coverageDir": "coverage/storybook",
|
"coverageDir": "coverage/storybook",
|
||||||
"reporter": "lcov"
|
"reporter": "lcov"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"text": { "reporter": "text" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:test": {
|
"storybook:test": {
|
||||||
@ -179,8 +190,9 @@
|
|||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "{projectRoot}",
|
"cwd": "{projectRoot}",
|
||||||
"command": "cross-var chromatic --project-token=$CHROMATIC_PROJECT_TOKEN --build-script-name=build-storybook --exit-zero-on-changes={args.ci}",
|
"command": "cross-var chromatic --project-token=$CHROMATIC_PROJECT_TOKEN --build-script-name={args.targetPackageJsonScript} --exit-zero-on-changes={args.ci}",
|
||||||
"ci": false
|
"ci": false,
|
||||||
|
"targetPackageJsonScript": "storybook:build:chromatic"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"ci": {
|
"ci": {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npx vite build && sh ./scripts/inject-runtime-env.sh",
|
"build": "npx vite build && sh ./scripts/inject-runtime-env.sh",
|
||||||
"build:sourcemaps": "VITE_BUILD_SOURCEMAP=true NODE_OPTIONS=--max-old-space-size=4096 npx nx build",
|
"build:sourcemaps": "VITE_BUILD_SOURCEMAP=true NODE_OPTIONS=--max-old-space-size=4096 npx nx build",
|
||||||
"build-storybook": "cd ../.. && npx nx storybook:build twenty-front",
|
"storybook:build:chromatic": "nx storybook:build",
|
||||||
"start:prod": "NODE_ENV=production npx vite --host",
|
"start:prod": "NODE_ENV=production npx vite --host",
|
||||||
"tsup": "npx tsup"
|
"tsup": "npx tsup"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -59,26 +59,33 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {},
|
"test": {},
|
||||||
"storybook:build": {},
|
"storybook:build": {
|
||||||
"storybook:build:scope": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
"options": {
|
||||||
"command": "nx storybook:build twenty-front"
|
"env": { "NODE_OPTIONS": "--max_old_space_size=5000" }
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
"docs": {
|
||||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
"env": {
|
||||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
"NODE_OPTIONS": "--max_old_space_size=5000",
|
||||||
|
"STORYBOOK_SCOPE": "ui-docs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"modules": {
|
||||||
|
"env": {
|
||||||
|
"NODE_OPTIONS": "--max_old_space_size=5000",
|
||||||
|
"STORYBOOK_SCOPE": "modules"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pages": {
|
||||||
|
"env": {
|
||||||
|
"NODE_OPTIONS": "--max_old_space_size=5000",
|
||||||
|
"STORYBOOK_SCOPE": "pages"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:dev": {
|
"storybook:dev": {
|
||||||
"options": { "port": 6006 }
|
"options": { "port": 6006 },
|
||||||
},
|
|
||||||
"storybook:dev:scope": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"command": "nx storybook:dev twenty-front"
|
|
||||||
},
|
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||||
@ -86,16 +93,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:static": {
|
"storybook:static": {
|
||||||
"options": {
|
"options": { "port": 6006 },
|
||||||
"buildTarget": "twenty-front:storybook:build",
|
|
||||||
"port": 6006
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"storybook:static:scope": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"command": "nx storybook:static twenty-front"
|
|
||||||
},
|
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||||
@ -104,15 +102,14 @@
|
|||||||
},
|
},
|
||||||
"storybook:coverage": {
|
"storybook:coverage": {
|
||||||
"configurations": {
|
"configurations": {
|
||||||
|
"text": {},
|
||||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"storybook:test": {
|
"storybook:test": {
|
||||||
"options": {
|
"options": { "port": 6006 },
|
||||||
"port": 6006
|
|
||||||
},
|
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||||
@ -124,8 +121,7 @@
|
|||||||
"commands": [
|
"commands": [
|
||||||
"npx concurrently --kill-others --success=first -n SB,TEST 'nx storybook:static {projectName} --port={args.port}' 'npx wait-on tcp:{args.port} && nx storybook:test {projectName} --port={args.port} --configuration={args.scope}'"
|
"npx concurrently --kill-others --success=first -n SB,TEST 'nx storybook:static {projectName} --port={args.port}' 'npx wait-on tcp:{args.port} && nx storybook:test {projectName} --port={args.port} --configuration={args.scope}'"
|
||||||
],
|
],
|
||||||
"port": 6006,
|
"port": 6006
|
||||||
"env": { "NODE_OPTIONS": "--max-old-space-size=5000" }
|
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"docs": { "scope": "ui-docs" },
|
"docs": { "scope": "ui-docs" },
|
||||||
|
|||||||
@ -51,7 +51,11 @@ export const SettingsObjectFieldActiveActionDropdown = ({
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
dropdownId={dropdownId}
|
dropdownId={dropdownId}
|
||||||
clickableComponent={
|
clickableComponent={
|
||||||
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
<LightIconButton
|
||||||
|
aria-label="Active Field Options"
|
||||||
|
Icon={IconDotsVertical}
|
||||||
|
accent="tertiary"
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
dropdownComponents={
|
dropdownComponents={
|
||||||
<DropdownMenu width="160px">
|
<DropdownMenu width="160px">
|
||||||
|
|||||||
@ -67,7 +67,11 @@ export const SettingsObjectSummaryCard = ({
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
dropdownId={dropdownId}
|
dropdownId={dropdownId}
|
||||||
clickableComponent={
|
clickableComponent={
|
||||||
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
<LightIconButton
|
||||||
|
aria-label="Object Options"
|
||||||
|
Icon={IconDotsVertical}
|
||||||
|
accent="tertiary"
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
dropdownComponents={
|
dropdownComponents={
|
||||||
<DropdownMenu width="160px">
|
<DropdownMenu width="160px">
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import styled from '@emotion/styled';
|
|||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { RecordIndexContainer } from '@/object-record/record-index/components/RecordIndexContainer';
|
import { RecordIndexContainer } from '@/object-record/record-index/components/RecordIndexContainer';
|
||||||
|
import { RecordIndexPageHeader } from '@/object-record/record-index/components/RecordIndexPageHeader';
|
||||||
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
|
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
|
||||||
import { DEFAULT_CELL_SCOPE } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCell';
|
import { DEFAULT_CELL_SCOPE } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCell';
|
||||||
import { useSelectedTableCellEditMode } from '@/object-record/record-table/record-table-cell/hooks/useSelectedTableCellEditMode';
|
import { useSelectedTableCellEditMode } from '@/object-record/record-table/record-table-cell/hooks/useSelectedTableCellEditMode';
|
||||||
@ -10,7 +11,6 @@ import { PageBody } from '@/ui/layout/page/PageBody';
|
|||||||
import { PageContainer } from '@/ui/layout/page/PageContainer';
|
import { PageContainer } from '@/ui/layout/page/PageContainer';
|
||||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
|
import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
|
||||||
import { RecordIndexPageHeader } from '~/pages/object-record/RecordIndexPageHeader';
|
|
||||||
import { capitalize } from '~/utils/string/capitalize';
|
import { capitalize } from '~/utils/string/capitalize';
|
||||||
|
|
||||||
const StyledIndexContainer = styled.div`
|
const StyledIndexContainer = styled.div`
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
|
import {
|
||||||
|
PageDecorator,
|
||||||
|
PageDecoratorArgs,
|
||||||
|
} from '~/testing/decorators/PageDecorator';
|
||||||
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
|
|
||||||
|
import { RecordIndexPage } from '../RecordIndexPage';
|
||||||
|
|
||||||
|
const meta: Meta<PageDecoratorArgs> = {
|
||||||
|
title: 'Pages/ObjectRecord/RecordIndexPage',
|
||||||
|
component: RecordIndexPage,
|
||||||
|
decorators: [PageDecorator],
|
||||||
|
args: {
|
||||||
|
routePath: '/objects/:objectNamePlural',
|
||||||
|
routeParams: {
|
||||||
|
':objectNamePlural': 'companies',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
parameters: {
|
||||||
|
msw: graphqlMocks,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
export type Story = StoryObj<typeof RecordIndexPage>;
|
||||||
|
|
||||||
|
export const Default: Story = {};
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { userEvent, within } from '@storybook/test';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PageDecorator,
|
PageDecorator,
|
||||||
@ -37,3 +38,38 @@ export const CustomObject: Story = {
|
|||||||
routeParams: { ':objectSlug': 'workspaces' },
|
routeParams: { ':objectSlug': 'workspaces' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ObjectDropdownMenu: Story = {
|
||||||
|
play: async ({ canvasElement }) => {
|
||||||
|
await sleep(100);
|
||||||
|
|
||||||
|
const canvas = within(canvasElement);
|
||||||
|
const objectSummaryVerticalDotsIconButton = await canvas.findByRole(
|
||||||
|
'button',
|
||||||
|
{
|
||||||
|
name: 'Object Options',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await userEvent.click(objectSummaryVerticalDotsIconButton);
|
||||||
|
|
||||||
|
await canvas.findByText('Edit');
|
||||||
|
await canvas.findByText('Deactivate');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FieldDropdownMenu: Story = {
|
||||||
|
play: async ({ canvasElement }) => {
|
||||||
|
await sleep(100);
|
||||||
|
|
||||||
|
const canvas = within(canvasElement);
|
||||||
|
const [fieldVerticalDotsIconButton] = await canvas.findAllByRole('button', {
|
||||||
|
name: 'Active Field Options',
|
||||||
|
});
|
||||||
|
|
||||||
|
await userEvent.click(fieldVerticalDotsIconButton);
|
||||||
|
|
||||||
|
await canvas.findByText('View');
|
||||||
|
await canvas.findByText('Deactivate');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user