Skip to content

Commit

Permalink
fix flaky cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
alan2207 committed Sep 13, 2021
1 parent d4cfbed commit a527462
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
29 changes: 11 additions & 18 deletions cypress/integration/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,9 @@ describe('smoke', () => {
cy.wait(200);

// visit discussion page:
cy.findByRole('row', {
name: `${discussion.title} ${formatDate(discussion.createdAt)} View Delete`,
}).within(() => {
cy.findByRole('link', {
name: /view/i,
}).click();
});
cy.findByRole('link', {
name: /view/i,
}).click();

cy.findByRole('heading', {
name: discussion.title,
Expand Down Expand Up @@ -174,7 +170,7 @@ describe('smoke', () => {

cy.findByRole('dialog').within(() => {
cy.findByRole('button', {
name: /delete/i,
name: /delete comment/i,
}).click();
});

Expand All @@ -196,25 +192,22 @@ describe('smoke', () => {
cy.wait(200);

// delete discussion:
cy.findByRole('row', {
name: `${updatedDiscussion.title} ${formatDate(discussion.createdAt)} View Delete`,
}).within(() => {
cy.findByRole('button', {
name: 'Delete',
}).click();
});
cy.findByRole('button', {
name: /delete discussion/i,
}).click();

cy.findByRole('dialog').within(() => {
cy.findByRole('button', {
name: /delete/i,
name: /delete discussion/i,
}).click();
});

cy.checkAndDismissNotification(/discussion deleted/i);

cy.wait(200);
cy.findByRole('row', {
name: `${updatedDiscussion.title} ${formatDate(discussion.createdAt)} View Delete`,

cy.findByRole('cell', {
name: updatedDiscussion.title,
}).should('not.exist');
});
});
2 changes: 1 addition & 1 deletion src/features/comments/components/DeleteComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const DeleteComment = ({ id, discussionId }: DeleteCommentProps) => {
className="bg-red-600"
onClick={async () => await deleteCommentMutation.mutateAsync({ commentId: id })}
>
Delete
Delete Comment
</Button>
}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/features/discussions/components/DeleteDiscussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const DeleteDiscussion = ({ id }: DeleteDiscussionProps) => {
body="Are you sure you want to delete this discussion?"
triggerButton={
<Button variant="danger" startIcon={<TrashIcon className="h-4 w-4" />}>
Delete
Delete Discussion
</Button>
}
confirmButton={
Expand All @@ -30,7 +30,7 @@ export const DeleteDiscussion = ({ id }: DeleteDiscussionProps) => {
className="bg-red-600"
onClick={async () => await deleteDiscussionMutation.mutateAsync({ discussionId: id })}
>
Delete
Delete Discussion
</Button>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/features/users/components/DeleteUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const DeleteUser = ({ id }: DeleteUserProps) => {
className="bg-red-600"
onClick={() => deleteUserMutation.mutate({ userId: id })}
>
Delete
Delete User
</Button>
}
/>
Expand Down

0 comments on commit a527462

Please sign in to comment.