Improve test coverage (#6244)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { Meta, StoryObj } from '@storybook/react';
|
||||
import { within } from '@storybook/test';
|
||||
import { graphql, HttpResponse } from 'msw';
|
||||
import { userEvent, within } from '@storybook/test';
|
||||
import { HttpResponse, graphql } from 'msw';
|
||||
|
||||
import { SettingsDevelopersApiKeyDetail } from '~/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail';
|
||||
import {
|
||||
@ -8,6 +8,7 @@ import {
|
||||
PageDecoratorArgs,
|
||||
} from '~/testing/decorators/PageDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { sleep } from '~/utils/sleep';
|
||||
|
||||
const meta: Meta<PageDecoratorArgs> = {
|
||||
title: 'Pages/Settings/Developers/ApiKeys/SettingsDevelopersApiKeyDetail',
|
||||
@ -50,6 +51,56 @@ export const Default: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findByText('Settings');
|
||||
await canvas.findByText('Regenerate an Api key');
|
||||
await canvas.findByText('sfsfdsf API Key');
|
||||
},
|
||||
};
|
||||
|
||||
export const RegenerateApiKey: Story = {
|
||||
play: async ({ canvasElement, step }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findByText('Settings');
|
||||
|
||||
await userEvent.click(canvas.getByText('Regenerate Key'));
|
||||
|
||||
await canvas.findByText('Cancel');
|
||||
const confirmationInput = await canvas.findByPlaceholderText('yes');
|
||||
await userEvent.click(confirmationInput);
|
||||
await userEvent.keyboard('y');
|
||||
await userEvent.keyboard('e');
|
||||
await userEvent.keyboard('s');
|
||||
|
||||
const confirmButton = await canvas.findByTestId(
|
||||
'confirmation-modal-confirm-button',
|
||||
);
|
||||
|
||||
await step('Click on confirm button', async () => {
|
||||
await sleep(1000);
|
||||
await userEvent.click(confirmButton);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export const DeleteApiKey: Story = {
|
||||
play: async ({ canvasElement, step }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await canvas.findByText('Settings');
|
||||
|
||||
await userEvent.click(canvas.getByText('Delete'));
|
||||
|
||||
await canvas.findByText('Cancel');
|
||||
const confirmationInput = await canvas.findByPlaceholderText('yes');
|
||||
await userEvent.click(confirmationInput);
|
||||
await userEvent.keyboard('y');
|
||||
await userEvent.keyboard('e');
|
||||
await userEvent.keyboard('s');
|
||||
|
||||
const confirmButton = await canvas.findByTestId(
|
||||
'confirmation-modal-confirm-button',
|
||||
);
|
||||
|
||||
await step('Click on confirm button', async () => {
|
||||
await sleep(1000);
|
||||
await userEvent.click(confirmButton);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { DateTime } from 'luxon';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { H2Title, IconRepeat, IconSettings, IconTrash } from 'twenty-ui';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user