Skip to content
Merged
Prev Previous commit
Next Next commit
Try to chain cypress commands
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Apr 5, 2023
commit 63f872c516e27a29b66cbc57ec7dcaf8d024709d
17 changes: 8 additions & 9 deletions cypress/e2e/files_versions/filesVersionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
import path from "path"

export function uploadThreeVersions(user) {
cy.uploadContent(user, new Blob(['v1'], { type: 'text/plain' }), 'text/plain', '/test.txt')
// A new version will not be created if the changes occur
// within less than one second of each other.
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1500)
cy.uploadContent(user, new Blob(['v2'], { type: 'text/plain' }), 'text/plain', '/test.txt')
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1500)
cy.uploadContent(user, new Blob(['v3'], { type: 'text/plain' }), 'text/plain', '/test.txt')
cy.uploadContent(user, new Blob(['v1'], { type: 'text/plain' }), 'text/plain', '/test.txt')
.wait(1500)
.uploadContent(user, new Blob(['v2'], { type: 'text/plain' }), 'text/plain', '/test.txt')
.wait(1500)
.uploadContent(user, new Blob(['v3'], { type: 'text/plain' }), 'text/plain', '/test.txt')
cy.login(user)
}

Expand All @@ -56,7 +55,7 @@ export function openVersionMenu(index: number) {
cy.get('[data-files-versions-version]')
.eq(index).within(() => {
cy.get('.action-item__menutoggle').filter(':visible')
.click()
.click()
})
})
}
Expand All @@ -69,15 +68,15 @@ export function clickPopperAction(actionName: string) {

export function nameVersion(index: number, name: string) {
openVersionMenu(index)
clickPopperAction("Name this version")
clickPopperAction('Name this version')
cy.get(':focused').type(`${name}{enter}`)
}

export function assertVersionContent(index: number, expectedContent: string) {
const downloadsFolder = Cypress.config('downloadsFolder')

openVersionMenu(index)
clickPopperAction("Download version")
clickPopperAction('Download version')

return cy.readFile(path.join(downloadsFolder, 'test.txt'))
.then((versionContent) => expect(versionContent).to.equal(expectedContent))
Expand Down