Add E2E tests for my-account, account info modal, and compare tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 20:52:38 +08:00
parent 1a4062487e
commit 6641bc1f8f
7 changed files with 217 additions and 31 deletions

View File

@@ -0,0 +1,35 @@
import { loginWithFixtures } from '../support/intercept';
describe('Account Info Modal', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/account-admin');
cy.wait('@getUsers');
});
it('double-click username opens info modal with user data', () => {
cy.get('.account-cell').first().dblclick();
cy.get('#modal_container').should('be.visible');
cy.get('#acct_info_user_name').should('exist');
});
it('info modal shows Account Information header', () => {
cy.get('.account-cell').first().dblclick();
cy.get('#modal_container').should('be.visible');
cy.contains('Account Information').should('exist');
});
it('info modal shows account visit info', () => {
cy.get('.account-cell').first().dblclick();
cy.get('#modal_container').should('be.visible');
cy.get('#account_visit_info').should('exist');
cy.get('#account_visit_info').should('contain', 'Account:');
});
it('info modal can be closed via X button', () => {
cy.get('.account-cell').first().dblclick();
cy.get('#modal_container').should('be.visible');
cy.get('img[alt="X"]').click();
cy.get('#modal_container').should('not.exist');
});
});

View File

@@ -0,0 +1,44 @@
import { loginWithFixtures } from '../support/intercept';
describe('Files Page - COMPARE Tab', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/files');
cy.wait('@getFiles');
// Switch to COMPARE tab
cy.contains('li', 'COMPARE').click();
});
it('shows Performance Comparison heading', () => {
cy.contains('h2', 'Performance Comparison').should('be.visible');
});
it('shows two drag-and-drop slots', () => {
cy.get('#primaryDragCard').should('exist');
cy.get('#secondaryDragCard').should('exist');
});
it('drag slots show placeholder text', () => {
cy.get('#primaryDragCard').should('contain', 'Drag and drop a file here');
cy.get('#secondaryDragCard').should('contain', 'Drag and drop a file here');
});
it('Compare button is disabled when no files are dragged', () => {
cy.contains('button', 'Compare').should('be.disabled');
});
it('shows sorting dropdown', () => {
cy.get('.p-dropdown').should('exist');
});
it('grid cards display file names', () => {
cy.get('#compareGridCards').should('exist');
cy.get('#compareGridCards li').should('have.length.greaterThan', 0);
});
it('clicking sorting dropdown shows sort options', () => {
cy.get('.p-dropdown').click();
cy.get('.p-dropdown-items').should('be.visible');
cy.contains('.p-dropdown-item', 'By File Name').should('exist');
});
});

View File

@@ -0,0 +1,68 @@
import { loginWithFixtures } from '../support/intercept';
describe('My Account Page', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/my-account');
cy.wait('@getUserDetail');
});
it('displays user name heading', () => {
cy.get('#general_acct_info_user_name').should('exist');
cy.get('#general_acct_info_user_name').should('contain', 'Test Admin');
});
it('shows Admin badge for admin user', () => {
cy.contains('Admin').should('exist');
});
it('shows visit count info', () => {
cy.get('#general_account_visit_info').should('exist');
cy.get('#general_account_visit_info').should('contain', 'Total visits');
});
it('displays account username (read-only)', () => {
cy.contains('Test Admin').should('exist');
});
it('shows Edit button for name field', () => {
cy.contains('button', 'Edit').should('exist');
});
it('clicking Edit shows input field and Save/Cancel buttons', () => {
cy.contains('button', 'Edit').first().click();
cy.get('#input_name_field').should('exist');
cy.contains('button', 'Save').should('exist');
cy.contains('button', 'Cancel').should('exist');
});
it('clicking Cancel reverts name field to read-only', () => {
cy.contains('button', 'Edit').first().click();
cy.get('#input_name_field').should('exist');
cy.contains('button', 'Cancel').click();
cy.get('#input_name_field').should('not.exist');
});
it('shows Reset button for password field', () => {
cy.contains('button', 'Reset').should('exist');
});
it('clicking Reset shows password input and Save/Cancel', () => {
cy.contains('button', 'Reset').click();
cy.get('input[type="password"]').should('exist');
cy.contains('button', 'Save').should('exist');
cy.contains('button', 'Cancel').should('exist');
});
it('clicking Cancel on password field hides the input', () => {
cy.contains('button', 'Reset').click();
cy.get('input[type="password"]').should('exist');
// The Cancel button for password is the second one
cy.get('.cancel-btn').click();
cy.get('input[type="password"]').should('not.exist');
});
it('shows Session section', () => {
cy.contains('Session').should('exist');
});
});