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:
gitstart-app[bot]
2024-02-24 15:06:51 +01:00
committed by GitHub
parent 3d809d5317
commit c434d1edb5
15 changed files with 605 additions and 246 deletions

View File

@ -1,4 +1,5 @@
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/test';
import {
PageDecorator,
@ -25,4 +26,10 @@ export default meta;
export type Story = StoryObj<typeof SettingsAccounts>;
export const Default: Story = {};
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await canvas.findByText('Connected accounts');
},
};

View File

@ -0,0 +1,78 @@
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/test';
import { graphql, HttpResponse } from 'msw';
import { SettingsAccountsEmailsInboxSettings } from '~/pages/settings/accounts/SettingsAccountsEmailsInboxSettings';
import {
PageDecorator,
PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
const meta: Meta<PageDecoratorArgs> = {
title: 'Pages/Settings/Accounts/SettingsAccountsEmailsInboxSettings',
component: SettingsAccountsEmailsInboxSettings,
decorators: [PageDecorator],
args: {
routePath: '/settings/accounts/emails/:accountUuid',
routeParams: { ':accountUuid': '123' },
},
parameters: {
layout: 'fullscreen',
msw: {
handlers: [
graphql.query('FindOnemessageChannel', () => {
return HttpResponse.json({
data: {
messageChannel: {
id: '1',
visibility: 'share_everything',
messageThreads: { edges: [] },
createdAt: '2021-08-27T12:00:00Z',
type: 'email',
updatedAt: '2021-08-27T12:00:00Z',
targetUrl: 'https://example.com/webhook',
connectedAccountId: '1',
handle: 'handle',
connectedAccount: {
id: '1',
handle: 'handle',
updatedAt: '2021-08-27T12:00:00Z',
accessToken: 'accessToken',
messageChannels: { edges: [] },
refreshToken: 'refreshToken',
__typename: 'ConnectedAccount',
accountOwner: { id: '1', __typename: 'WorkspaceMember' },
provider: 'provider',
createdAt: '2021-08-27T12:00:00Z',
accountOwnerId: '1',
},
__typename: 'MessageChannel',
},
},
});
}),
graphqlMocks.handlers,
],
},
},
};
export default meta;
export type Story = StoryObj<typeof SettingsAccountsEmailsInboxSettings>;
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await canvas.findByText('Email visibility');
await canvas.findByText(
'Define what will be visible to other users in your workspace',
);
await canvas.findByText('Contact auto-creation');
await canvas.findByText(
'Automatically create contacts for people youve sent emails to',
);
},
};