fix: fix storybook pages tests coverage (#5319)
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"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-storybook": "cd ../.. && npx nx storybook:build twenty-front",
|
||||
"storybook:build:chromatic": "nx storybook:build",
|
||||
"start:prod": "NODE_ENV=production npx vite --host",
|
||||
"tsup": "npx tsup"
|
||||
},
|
||||
|
||||
@ -59,26 +59,33 @@
|
||||
}
|
||||
},
|
||||
"test": {},
|
||||
"storybook:build": {},
|
||||
"storybook:build:scope": {
|
||||
"executor": "nx:run-commands",
|
||||
"storybook:build": {
|
||||
"options": {
|
||||
"command": "nx storybook:build twenty-front"
|
||||
"env": { "NODE_OPTIONS": "--max_old_space_size=5000" }
|
||||
},
|
||||
"configurations": {
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
"docs": {
|
||||
"env": {
|
||||
"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": {
|
||||
"options": { "port": 6006 }
|
||||
},
|
||||
"storybook:dev:scope": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "nx storybook:dev twenty-front"
|
||||
},
|
||||
"options": { "port": 6006 },
|
||||
"configurations": {
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
@ -86,16 +93,7 @@
|
||||
}
|
||||
},
|
||||
"storybook:static": {
|
||||
"options": {
|
||||
"buildTarget": "twenty-front:storybook:build",
|
||||
"port": 6006
|
||||
}
|
||||
},
|
||||
"storybook:static:scope": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "nx storybook:static twenty-front"
|
||||
},
|
||||
"options": { "port": 6006 },
|
||||
"configurations": {
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
@ -104,15 +102,14 @@
|
||||
},
|
||||
"storybook:coverage": {
|
||||
"configurations": {
|
||||
"text": {},
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
"pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
|
||||
}
|
||||
},
|
||||
"storybook:test": {
|
||||
"options": {
|
||||
"port": 6006
|
||||
},
|
||||
"options": { "port": 6006 },
|
||||
"configurations": {
|
||||
"docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
|
||||
"modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
|
||||
@ -124,8 +121,7 @@
|
||||
"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}'"
|
||||
],
|
||||
"port": 6006,
|
||||
"env": { "NODE_OPTIONS": "--max-old-space-size=5000" }
|
||||
"port": 6006
|
||||
},
|
||||
"configurations": {
|
||||
"docs": { "scope": "ui-docs" },
|
||||
|
||||
@ -51,7 +51,11 @@ export const SettingsObjectFieldActiveActionDropdown = ({
|
||||
<Dropdown
|
||||
dropdownId={dropdownId}
|
||||
clickableComponent={
|
||||
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
||||
<LightIconButton
|
||||
aria-label="Active Field Options"
|
||||
Icon={IconDotsVertical}
|
||||
accent="tertiary"
|
||||
/>
|
||||
}
|
||||
dropdownComponents={
|
||||
<DropdownMenu width="160px">
|
||||
|
||||
@ -67,7 +67,11 @@ export const SettingsObjectSummaryCard = ({
|
||||
<Dropdown
|
||||
dropdownId={dropdownId}
|
||||
clickableComponent={
|
||||
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
||||
<LightIconButton
|
||||
aria-label="Object Options"
|
||||
Icon={IconDotsVertical}
|
||||
accent="tertiary"
|
||||
/>
|
||||
}
|
||||
dropdownComponents={
|
||||
<DropdownMenu width="160px">
|
||||
|
||||
@ -3,6 +3,7 @@ import styled from '@emotion/styled';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
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 { 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';
|
||||
@ -10,7 +11,6 @@ import { PageBody } from '@/ui/layout/page/PageBody';
|
||||
import { PageContainer } from '@/ui/layout/page/PageContainer';
|
||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||
import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
|
||||
import { RecordIndexPageHeader } from '~/pages/object-record/RecordIndexPageHeader';
|
||||
import { capitalize } from '~/utils/string/capitalize';
|
||||
|
||||
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 { userEvent, within } from '@storybook/test';
|
||||
|
||||
import {
|
||||
PageDecorator,
|
||||
@ -37,3 +38,38 @@ export const CustomObject: Story = {
|
||||
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