TWNTY-3968 - Fix and enhance storybook:pages tests (#4072)
* Fix and enhance storybook:pages tests Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Fix and enhance storybook:pages tests Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Add minor refactors Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Revert temporary changes Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Fix tests * Fix tests duplicated locale --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
committed by
GitHub
parent
3d809d5317
commit
c434d1edb5
@ -1,11 +1,11 @@
|
||||
import { Meta, StoryObj } from '@storybook/react';
|
||||
import { userEvent, within } from '@storybook/test';
|
||||
|
||||
import {
|
||||
PageDecorator,
|
||||
PageDecoratorArgs,
|
||||
} from '~/testing/decorators/PageDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { sleep } from '~/testing/sleep';
|
||||
|
||||
import { SettingsNewObject } from '../SettingsNewObject';
|
||||
|
||||
@ -27,6 +27,17 @@ export type Story = StoryObj<typeof SettingsNewObject>;
|
||||
|
||||
export const WithStandardSelected: Story = {
|
||||
play: async () => {
|
||||
await sleep(100);
|
||||
const canvas = within(document.body);
|
||||
const listingInput = await canvas.findByPlaceholderText('Listing');
|
||||
const pluralInput = await canvas.findByPlaceholderText('Listings');
|
||||
const descriptionInput = await canvas.findByPlaceholderText(
|
||||
'Write a description',
|
||||
);
|
||||
const saveButton = await canvas.findByText('Save');
|
||||
await userEvent.type(listingInput, 'Company');
|
||||
await userEvent.type(pluralInput, 'Companies');
|
||||
await userEvent.type(descriptionInput, 'Test Description');
|
||||
|
||||
await userEvent.click(saveButton);
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { Meta, StoryObj } from '@storybook/react';
|
||||
import { within } from '@storybook/test';
|
||||
|
||||
import {
|
||||
PageDecorator,
|
||||
PageDecoratorArgs,
|
||||
} from '~/testing/decorators/PageDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { sleep } from '~/testing/sleep';
|
||||
|
||||
import { SettingsObjectNewFieldStep1 } from '../../SettingsObjectNewField/SettingsObjectNewFieldStep1';
|
||||
|
||||
@ -28,7 +28,12 @@ export default meta;
|
||||
export type Story = StoryObj<typeof SettingsObjectNewFieldStep1>;
|
||||
|
||||
export const Default: Story = {
|
||||
play: async () => {
|
||||
await sleep(100);
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findByText('Settings');
|
||||
await canvas.findByText('Objects');
|
||||
await canvas.findByText('Companies');
|
||||
await canvas.findByText('Check disabled fields');
|
||||
await canvas.findByText('Add Custom Field');
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { Meta, StoryObj } from '@storybook/react';
|
||||
import { userEvent, within } from '@storybook/test';
|
||||
|
||||
import {
|
||||
PageDecorator,
|
||||
PageDecoratorArgs,
|
||||
} from '~/testing/decorators/PageDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { sleep } from '~/testing/sleep';
|
||||
|
||||
import { SettingsObjectNewFieldStep2 } from '../../SettingsObjectNewField/SettingsObjectNewFieldStep2';
|
||||
|
||||
@ -28,7 +28,24 @@ export default meta;
|
||||
export type Story = StoryObj<typeof SettingsObjectNewFieldStep2>;
|
||||
|
||||
export const Default: Story = {
|
||||
play: async () => {
|
||||
await sleep(100);
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findByText('Settings');
|
||||
await canvas.findByText('Objects');
|
||||
await canvas.findByText('Name and description');
|
||||
|
||||
const employeeInput = await canvas.findByPlaceholderText('Employees');
|
||||
await userEvent.type(employeeInput, 'Test');
|
||||
|
||||
const descriptionInput = await canvas.findByPlaceholderText(
|
||||
'Write a description',
|
||||
);
|
||||
|
||||
await userEvent.type(descriptionInput, 'Test description');
|
||||
await canvas.findByText('Type and values');
|
||||
|
||||
const saveButton = await canvas.findByText('Save');
|
||||
|
||||
await userEvent.click(saveButton);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user