Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(cypress): opendetails tests #50945

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading