Increase storybook pages coverage (#4885)

On FE:
- refreshing metadata mocks
- updating jest tests
- fixing storybook pages coverage
- fixing storybook modules coverage
This commit is contained in:
Charles Bochet
2024-04-17 16:24:04 +02:00
committed by GitHub
parent 6804a90f2f
commit 75fd430149
46 changed files with 13679 additions and 7354 deletions

View File

@ -0,0 +1,75 @@
import { getOperationName } from '@apollo/client/utilities';
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/testing-library';
import { graphql, HttpResponse } from 'msw';
import { AppPath } from '@/types/AppPath';
import { GET_CURRENT_USER } from '@/users/graphql/queries/getCurrentUser';
import {
PageDecorator,
PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
import { mockedOnboardingUsersData } from '~/testing/mock-data/users';
import { sleep } from '~/testing/sleep';
import { ChooseYourPlan } from '../ChooseYourPlan';
const meta: Meta<PageDecoratorArgs> = {
title: 'Pages/Auth/ChooseYourPlan',
component: ChooseYourPlan,
decorators: [PageDecorator],
args: { routePath: AppPath.PlanRequired },
parameters: {
msw: {
handlers: [
graphql.query(getOperationName(GET_CURRENT_USER) ?? '', () => {
return HttpResponse.json({
data: {
currentUser: mockedOnboardingUsersData[0],
},
});
}),
graphql.query('GetProductPrices', () => {
return HttpResponse.json({
data: {
getProductPrices: {
__typename: 'ProductPricesEntity',
productPrices: [
{
__typename: 'ProductPriceEntity',
created: 1699860608,
recurringInterval: 'month',
stripePriceId: 'monthly8usd',
unitAmount: 900,
},
{
__typename: 'ProductPriceEntity',
created: 1701874964,
recurringInterval: 'year',
stripePriceId: 'priceId',
unitAmount: 9000,
},
],
},
},
});
}),
graphqlMocks.handlers,
],
},
},
};
export default meta;
export type Story = StoryObj<typeof ChooseYourPlan>;
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
sleep(100);
await canvas.findByText('Choose your Plan');
},
};

View File

@ -4,6 +4,7 @@ import { within } from '@storybook/test';
import { graphql, HttpResponse } from 'msw';
import { GET_CURRENT_USER } from '@/users/graphql/queries/getCurrentUser';
import { ValidatePasswordResetTokenDocument } from '~/generated/graphql';
import { PasswordReset } from '~/pages/auth/PasswordReset';
import {
PageDecorator,
@ -16,10 +17,26 @@ const meta: Meta<PageDecoratorArgs> = {
title: 'Pages/Auth/PasswordReset',
component: PasswordReset,
decorators: [PageDecorator],
args: { routePath: '/reset-password/resetToken' },
args: {
routePath: '/reset-password/:passwordResetToken',
routeParams: { ':passwordResetToken': 'MOCKED_TOKEN' },
},
parameters: {
msw: {
handlers: [
graphql.query(
getOperationName(ValidatePasswordResetTokenDocument) ?? '',
() => {
return HttpResponse.json({
data: {
validatePasswordResetToken: {
id: mockedOnboardingUsersData[0].id,
email: mockedOnboardingUsersData[0].email,
},
},
});
},
),
graphql.query(getOperationName(GET_CURRENT_USER) ?? '', () => {
return HttpResponse.json({
data: {