Skip to content

Commit

Permalink
fix(cypress): opendetails tests
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv authored and backportbot[bot] committed Feb 21, 2025
1 parent 306fa8d commit e601503
Showing 1 changed file with 2 additions and 71 deletions.
73 changes: 2 additions & 71 deletions cypress/e2e/files/router-query.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ function skipIfViewerDisabled(this: Mocha.Context): void {
})
}

/**
* Check a file was not downloaded
* @param filename The expected filename
*/
function fileNotDownloaded(filename: string): void {
const downloadsFolder = Cypress.config('downloadsFolder')
cy.readFile(join(downloadsFolder, filename)).should('not.exist')
}

describe('Check router query flags:', function() {
let user: User
let imageId: number
Expand All @@ -61,50 +52,6 @@ describe('Check router query flags:', function() {
})
})

describe('"opendetails"', () => {
it('open details for known file type', () => {
cy.visit(`/apps/files/files/${imageId}?opendetails`)

// see sidebar
sidebarIsOpen('image.jpg')

// but no viewer
cy.findByRole('dialog', { name: 'image.jpg' })
.should('not.exist')

// and no download
fileNotDownloaded('image.jpg')
})

it('open details for unknown file type', () => {
cy.visit(`/apps/files/files/${archiveId}?opendetails`)

// see sidebar
sidebarIsOpen('archive.zst')

// but no viewer
cy.findByRole('dialog', { name: 'archive.zst' })
.should('not.exist')

// and no download
fileNotDownloaded('archive.zst')
})

it('open details for folder', () => {
cy.visit(`/apps/files/files/${folderId}?opendetails`)

// see sidebar
sidebarIsOpen('folder')

// but no viewer
cy.findByRole('dialog', { name: 'folder' })
.should('not.exist')

// and no download
fileNotDownloaded('folder')
})
})

describe('"openfile"', function() {
/** Check the viewer is open and shows the image */
function viewerShowsImage(): void {
Expand Down Expand Up @@ -143,16 +90,8 @@ describe('Check router query flags:', function() {
it('does not open folders but shows details', () => {
cy.visit(`/apps/files/files/${folderId}?openfile`)

// See the URL was replaced
cy.url()
.should('match', /[?&]opendetails(&|=|$)/)
.and('not.match', /openfile/)

// See the sidebar is correctly opened
cy.get('[data-cy-sidebar]')
.should('be.visible')
.findByRole('heading', { name: 'folder' })
.should('be.visible')
sidebarIsOpen('folder')

// see the folder was not changed
getRowForFileId(imageId).should('exist')
Expand All @@ -161,16 +100,8 @@ describe('Check router query flags:', function() {
it('does not open unknown file types but shows details', () => {
cy.visit(`/apps/files/files/${archiveId}?openfile`)

// See the URL was replaced
cy.url()
.should('match', /[?&]opendetails(&|=|$)/)
.and('not.match', /openfile/)

// See the sidebar is correctly opened
cy.get('[data-cy-sidebar]')
.should('be.visible')
.findByRole('heading', { name: 'archive.zst' })
.should('be.visible')
sidebarIsOpen('archive.zst')

// See no file was downloaded
const downloadsFolder = Cypress.config('downloadsFolder')
Expand Down

0 comments on commit e601503

Please sign in to comment.