Add edge case tests and SweetAlert2 modal interaction tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 21:06:35 +08:00
parent 6641bc1f8f
commit 0ab037dac0
3 changed files with 232 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
import { loginWithFixtures } from '../support/intercept';
describe('SweetAlert2 Modals', () => {
describe('File Context Menu - Rename', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/files');
cy.wait('@getFiles');
});
it('right-click on table row shows context menu with Rename', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Rename').should('be.visible');
});
it('right-click context menu shows Download option', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Download').should('be.visible');
});
it('right-click context menu shows Delete option', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Delete').should('be.visible');
});
it('clicking Rename opens SweetAlert rename dialog', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Rename').click();
// SweetAlert popup should appear with RENAME title
cy.get('.swal2-popup').should('be.visible');
cy.get('.swal2-title').should('contain', 'RENAME');
cy.get('.swal2-input').should('exist');
});
it('rename dialog has pre-filled file name', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Rename').click();
cy.get('.swal2-input').should('not.have.value', '');
});
it('rename dialog can be cancelled', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Rename').click();
cy.get('.swal2-popup').should('be.visible');
cy.get('.swal2-cancel').click();
cy.get('.swal2-popup').should('not.exist');
});
it('clicking Delete opens SweetAlert delete confirmation', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Delete').click();
// SweetAlert popup should appear with CONFIRM DELETION
cy.get('.swal2-popup').should('be.visible');
cy.get('.swal2-title').should('contain', 'CONFIRM DELETION');
});
it('delete confirmation shows file name', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Delete').click();
cy.get('.swal2-popup').should('be.visible');
cy.get('.swal2-html-container').should('contain', 'delete');
});
it('delete confirmation can be cancelled', () => {
cy.get('table tbody tr').first().rightclick();
cy.contains('Delete').click();
cy.get('.swal2-popup').should('be.visible');
cy.get('.swal2-cancel').click();
cy.get('.swal2-popup').should('not.exist');
});
});
describe('File Context Menu on Grid View', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/files');
cy.wait('@getFiles');
// Switch to grid view
cy.get('svg').parent('li.cursor-pointer').last().click();
});
it('right-click on grid card shows context menu', () => {
cy.get('li[title]').first().rightclick();
cy.contains('Rename').should('be.visible');
cy.contains('Delete').should('be.visible');
});
it('grid card rename opens SweetAlert dialog', () => {
cy.get('li[title]').first().rightclick();
cy.contains('Rename').click();
cy.get('.swal2-popup').should('be.visible');
cy.get('.swal2-title').should('contain', 'RENAME');
});
});
describe('Account Delete Confirmation', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/account-admin');
cy.wait('@getUsers');
});
it('delete confirmation Yes button triggers delete API', () => {
cy.get('.delete-account').first().click();
cy.get('#modal_container').should('be.visible');
cy.get('#sure_to_delete_acct_btn').click();
cy.wait('@deleteUser');
// Modal should close after deletion
});
});
});