Skip to content

Commit

Permalink
Interactor add delete related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed Jul 26, 2024
1 parent 2a48f31 commit eef9901
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/app/components/editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ class UIServiceInteractor {
fireEvent.click(screen.getByText('Save'))
return this
}

clickDelete() {
fireEvent.click(screen.getByText('Delete'))
return this
}

clickConfirmDelete() {
fireEvent.click(
screen.getByRole('button', {
name: 'Confirm',
}),
)
return this
}

clickCancelDelete() {
fireEvent.click(
screen.getByRole('button', {
name: 'Cancel',
}),
)
return this
}
}

class QuestionComponentQueryHelper {
Expand Down Expand Up @@ -832,12 +855,7 @@ describe('QuestionSetEditor', () => {
})
interactor.renderModifyingPage(questionSet.id)

fireEvent.click(screen.getByText('Delete'))
fireEvent.click(
screen.getByRole('button', {
name: 'Confirm',
}),
)
interactor.clickDelete().clickConfirmDelete()

expect(questionSetRepo.getQuestionSets()).toEqual([])
})
Expand All @@ -850,12 +868,7 @@ describe('QuestionSetEditor', () => {
const interactor = new UIServiceInteractor({ questionSetRepo })
interactor.renderModifyingPage(questionSet.id)

fireEvent.click(screen.getByText('Delete'))
fireEvent.click(
screen.getByRole('button', {
name: 'Cancel',
}),
)
interactor.clickDelete().clickCancelDelete()

expect(screen.queryByRole('button', { name: 'Confirm' })).toBeNull()
})
Expand Down

0 comments on commit eef9901

Please sign in to comment.