Skip to content

Commit

Permalink
Fix stories
Browse files Browse the repository at this point in the history
  • Loading branch information
RaymondLuong3 committed Oct 17, 2024
1 parent 6feba0b commit e409a7c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import { expect } from '@storybook/jest';
import { userEvent, within } from '@storybook/testing-library';
import { I18nStoryModule } from 'xforge-common/i18n-story.module';
import { UICommonModule } from 'xforge-common/ui-common.module';
import { AttachAudioComponent } from '../../../../attach-audio/attach-audio.component';
import { TextAndAudioComponent } from '../../../../text-and-audio/text-and-audio.component';
import { CheckingAudioRecorderComponent } from '../../../checking-audio-recorder/checking-audio-recorder.component';
import { CheckingCommentFormComponent } from './checking-comment-form.component';

const meta: Meta<CheckingCommentFormComponent> = {
title: 'Checking/Comments/Comment Form',
component: CheckingCommentFormComponent,
decorators: [moduleMetadata({ imports: [CommonModule, UICommonModule, I18nStoryModule] })]
decorators: [
moduleMetadata({
imports: [CommonModule, UICommonModule, I18nStoryModule],
declarations: [TextAndAudioComponent, AttachAudioComponent, CheckingAudioRecorderComponent]
})
]
};
export default meta;

Expand All @@ -24,22 +32,30 @@ export const NewForm: Story = {
};

export const EditForm: Story = {
args: { text: 'This is a comment' },
args: {
comment: {
dataId: 'c01',
ownerRef: 'user01',
text: 'This is a comment',
deleted: false,
dateCreated: '',
dateModified: ''
}
},
parameters: {
// Disabled for the same reason the story above
chromatic: { disableSnapshot: true }
}
};

export const InvalidForm: Story = {
args: { text: '' },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Only necessary because the autofocus directive has to use setTimeout
await new Promise(resolve => setTimeout(resolve, 0));
const saveButton: HTMLElement = canvas.getByRole('button', { name: /Save/i });
await userEvent.click(saveButton);
const error: HTMLElement = canvas.getByText(/You need to enter your comment before saving/i);
const error: HTMLElement = canvas.getByText(/Provide text or audio before saving/i);
expect(error).toBeInTheDocument();
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@
},
"checking_comment_form": {
"cancel": "Cancel",
"comment_cannot_be_blank": "You need to enter your comment before saving",
"save_comment": "Save comment",
"your_comment": "Your comment"
},
Expand Down

0 comments on commit e409a7c

Please sign in to comment.