@ -384,28 +384,28 @@ describe('RichHistoryCard', () => {
} ) ;
it ( 'should have title "Edit comment" at comment icon, if comment present' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const editComment = await screen . findByTitle ( 'Edit comment' ) ;
const editComment = await screen . findByLabelText ( 'Edit comment' ) ;
const addComment = screen . queryByTitle ( 'Add comment' ) ;
expect ( editComment ) . toBeInTheDocument ( ) ;
expect ( addComment ) . not . toBeInTheDocument ( ) ;
} ) ;
it ( 'should have title "Add comment" at comment icon, if no comment present' , async ( ) = > {
setup ( ) ;
const addComment = await screen . findByTitle ( 'Add comment' ) ;
const addComment = await screen . findByLabelText ( 'Add comment' ) ;
const editComment = await screen . queryByTitle ( 'Edit comment' ) ;
expect ( addComment ) . toBeInTheDocument ( ) ;
expect ( editComment ) . not . toBeInTheDocument ( ) ;
} ) ;
it ( 'should open update comment form when edit comment button clicked' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const editComment = await screen . findByTitle ( 'Edit comment' ) ;
const editComment = await screen . findByLabelText ( 'Edit comment' ) ;
await userEvent . click ( editComment ) ;
const updateCommentForm = await screen . findByLabelText ( 'Update comment form' ) ;
expect ( updateCommentForm ) . toBeInTheDocument ( ) ;
} ) ;
it ( 'should close update comment form when escape key pressed' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const editComment = await screen . findByTitle ( 'Edit comment' ) ;
const editComment = await screen . findByLabelText ( 'Edit comment' ) ;
await userEvent . click ( editComment ) ;
const updateCommentForm = await screen . findByLabelText ( 'Update comment form' ) ;
await userEvent . click ( updateCommentForm ) ;
@ -417,7 +417,7 @@ describe('RichHistoryCard', () => {
} ) ;
it ( 'should close update comment form when enter and shift keys pressed' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const editComment = await screen . findByTitle ( 'Edit comment' ) ;
const editComment = await screen . findByLabelText ( 'Edit comment' ) ;
await userEvent . click ( editComment ) ;
const updateCommentForm = await screen . findByLabelText ( 'Update comment form' ) ;
await userEvent . click ( updateCommentForm ) ;
@ -430,7 +430,7 @@ describe('RichHistoryCard', () => {
} ) ;
it ( 'should close update comment form when enter and ctrl keys pressed' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const editComment = await screen . findByTitle ( 'Edit comment' ) ;
const editComment = await screen . findByLabelText ( 'Edit comment' ) ;
await userEvent . click ( editComment ) ;
const updateCommentForm = await screen . findByLabelText ( 'Update comment form' ) ;
await userEvent . click ( updateCommentForm ) ;
@ -443,7 +443,7 @@ describe('RichHistoryCard', () => {
} ) ;
it ( 'should not close update comment form when enter key pressed' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const editComment = await screen . findByTitle ( 'Edit comment' ) ;
const editComment = await screen . findByLabelText ( 'Edit comment' ) ;
await userEvent . click ( editComment ) ;
const updateCommentForm = await screen . findByLabelText ( 'Update comment form' ) ;
await userEvent . click ( updateCommentForm ) ;
@ -459,14 +459,14 @@ describe('RichHistoryCard', () => {
describe ( 'starring' , ( ) = > {
it ( 'should have title "Star query", if not starred' , async ( ) = > {
setup ( ) ;
const starButton = await screen . findByTitle ( 'Star query' ) ;
const starButton = await screen . findByLabelText ( 'Star query' ) ;
expect ( starButton ) . toBeInTheDocument ( ) ;
await userEvent . click ( starButton ) ;
expect ( starRichHistoryMock ) . toBeCalledWith ( starredQueryWithComment . id , true ) ;
} ) ;
it ( 'should have title "Unstar query", if not starred' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const unstarButton = await screen . findByTitle ( 'Unstar query' ) ;
const unstarButton = await screen . findByLabelText ( 'Unstar query' ) ;
expect ( unstarButton ) . toBeInTheDocument ( ) ;
await userEvent . click ( unstarButton ) ;
expect ( starRichHistoryMock ) . toBeCalledWith ( starredQueryWithComment . id , false ) ;
@ -476,14 +476,14 @@ describe('RichHistoryCard', () => {
describe ( 'deleting' , ( ) = > {
it ( 'should delete if not starred' , async ( ) = > {
setup ( ) ;
const deleteButton = await screen . findByTitle ( 'Delete query' ) ;
const deleteButton = await screen . findByLabelText ( 'Delete query' ) ;
expect ( deleteButton ) . toBeInTheDocument ( ) ;
await userEvent . click ( deleteButton ) ;
expect ( deleteRichHistoryMock ) . toBeCalledWith ( starredQueryWithComment . id ) ;
} ) ;
it ( 'should display modal before deleting if starred' , async ( ) = > {
setup ( { query : starredQueryWithComment } ) ;
const deleteButton = await screen . findByTitle ( 'Delete query' ) ;
const deleteButton = await screen . findByLabelText ( 'Delete query' ) ;
await userEvent . click ( deleteButton ) ;
expect ( deleteRichHistoryMock ) . not . toBeCalled ( ) ;
expect ( appEvents . publish ) . toHaveBeenCalledWith ( new ShowConfirmModalEvent ( expect . anything ( ) ) ) ;