Skip to content

Commit

Permalink
Notes 100 - Share a note #1071 (#1090)
Browse files Browse the repository at this point in the history
* add share a note test

* add the test for the shared note

* minor fix

* refactor the tests

* change the cookie setting
  • Loading branch information
OlegMoshkovich authored Apr 5, 2024
1 parent 6d56d25 commit a3f0306
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cypress/e2e/notes-100/share-a-note.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {waitForModel, homepageSetup, setCookieAndVisitHome} from '../../support/utils'


describe('share-a-note', () => {
context('Open the model and access the list of notes', () => {
beforeEach(() => {
homepageSetup()
})

it('check that clipboard is activated when a note is shared', () => {
setCookieAndVisitHome()
waitForModel()

cy.get('[data-testid="Notes"]').click()
cy.get('[data-testid="panelTitle"]').contains('NOTES')
cy.get(':nth-child(1) > .MuiPaper-root > [data-testid="card-body"] > .MuiCardContent-root').contains('Test Issue body').click()
cy.get('.MuiCardHeader-title').contains('Local issue 2')

cy.window().then((win) => {
cy.spy(win.navigator.clipboard, 'writeText').as('clipboardSpy')
})

cy.get('.MuiCardActions-root > [data-testid="Share"] > .icon-share').click()

// Now, verify that the clipboardSpy was called
cy.get('@clipboardSpy').should('have.been.calledOnce')

cy.get('.MuiSnackbarContent-message > .css-1xhj18k').contains('The url path is copied to the clipboard')
})
})
})
8 changes: 8 additions & 0 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,11 @@ export function setupAuthenticationIntercepts() {
})
}).as('tokenRequest')
}

/**
*
*/
export function setCookieAndVisitHome() {
cy.setCookie('isFirstTime', '1')
cy.visit('/')
}

0 comments on commit a3f0306

Please sign in to comment.