Show Entity task/note tabs (#1282)
* - show task tab - tab bar * - add notes tab * - fixed unused style * - add button - fixed company edit note test * - fixed merge & dropdown * - added Tests - refactored directory structure activities - moved Task/Note Pages to corresponding modules - fixed TabList * lint
This commit is contained in:
@ -15,7 +15,7 @@ import {
|
||||
type PageDecoratorArgs,
|
||||
} from '~/testing/decorators/PageDecorator';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
import { mockedActivities } from '~/testing/mock-data/activities';
|
||||
import { mockedActivities, mockedTasks } from '~/testing/mock-data/activities';
|
||||
import { mockedCompaniesData } from '~/testing/mock-data/companies';
|
||||
|
||||
import { CompanyShow } from '../CompanyShow';
|
||||
@ -37,7 +37,10 @@ const meta: Meta<PageDecoratorArgs> = {
|
||||
(req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
findManyActivities: mockedActivities,
|
||||
findManyActivities:
|
||||
req?.variables?.where?.type?.equals === 'Task'
|
||||
? mockedTasks
|
||||
: mockedActivities,
|
||||
}),
|
||||
);
|
||||
},
|
||||
@ -59,7 +62,7 @@ export type Story = StoryObj<typeof CompanyShow>;
|
||||
|
||||
export const Default: Story = {};
|
||||
|
||||
export const EditNote: Story = {
|
||||
export const EditNoteByAddButton: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const firstNoteTitle = await canvas.findByText('My very first note');
|
||||
@ -74,6 +77,9 @@ export const EditNote: Story = {
|
||||
|
||||
expect(await canvas.queryByDisplayValue('My very first note')).toBeNull();
|
||||
|
||||
const addDropdown = await canvas.findByTestId('add-showpage-button');
|
||||
await addDropdown.click();
|
||||
|
||||
const noteButton = await canvas.findByText('Note');
|
||||
await noteButton.click();
|
||||
|
||||
@ -114,3 +120,113 @@ export const EditNote: Story = {
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const NoteTab: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const noteTab = await canvas.findByTestId('tab-notes');
|
||||
await noteTab.click();
|
||||
|
||||
expect(await canvas.findByText('My very first note')).toBeInTheDocument();
|
||||
|
||||
const workspaceName = await canvas.findByText('Twenty');
|
||||
await fireEvent.click(workspaceName);
|
||||
|
||||
expect(await canvas.queryByDisplayValue('My very first note')).toBeNull();
|
||||
|
||||
const addButton = await canvas.findByText('Add note');
|
||||
await addButton.click();
|
||||
|
||||
const noteButton = await canvas.findByText('Note');
|
||||
await noteButton.click();
|
||||
|
||||
expect(await canvas.findByText('My very first note')).toBeInTheDocument();
|
||||
},
|
||||
parameters: {
|
||||
msw: [
|
||||
...meta.parameters?.msw,
|
||||
graphql.mutation(
|
||||
getOperationName(CREATE_ACTIVITY_WITH_COMMENT) ?? '',
|
||||
(req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
createOneActivity: mockedActivities[0],
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
graphql.query(getOperationName(GET_ACTIVITY) ?? '', (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
findManyActivities: [mockedActivities[0]],
|
||||
}),
|
||||
);
|
||||
}),
|
||||
graphql.mutation(
|
||||
getOperationName(UPDATE_ONE_COMPANY) ?? '',
|
||||
(req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
updateOneCompany: [mockedCompaniesData[0]],
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const TaskTab: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const taskTab = await canvas.findByTestId('tab-tasks');
|
||||
await taskTab.click();
|
||||
|
||||
expect(await canvas.findByText('My very first task')).toBeInTheDocument();
|
||||
|
||||
const workspaceName = await canvas.findByText('Twenty');
|
||||
await fireEvent.click(workspaceName);
|
||||
|
||||
expect(await canvas.queryByDisplayValue('My very first task')).toBeNull();
|
||||
|
||||
const addButton = await canvas.findByText('Add task');
|
||||
await addButton.click();
|
||||
|
||||
const taskButton = await canvas.findByText('Task');
|
||||
await taskButton.click();
|
||||
|
||||
expect(await canvas.findByText('My very first task')).toBeInTheDocument();
|
||||
},
|
||||
parameters: {
|
||||
msw: [
|
||||
...meta.parameters?.msw,
|
||||
graphql.mutation(
|
||||
getOperationName(CREATE_ACTIVITY_WITH_COMMENT) ?? '',
|
||||
(req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
createOneActivity: mockedTasks[0],
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
graphql.query(getOperationName(GET_ACTIVITY) ?? '', (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
findManyActivities: [mockedTasks[0]],
|
||||
}),
|
||||
);
|
||||
}),
|
||||
graphql.mutation(
|
||||
getOperationName(UPDATE_ONE_COMPANY) ?? '',
|
||||
(req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
updateOneCompany: [mockedCompaniesData[0]],
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user