Add E2E tests for logout, account CRUD, and file operations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 20:40:46 +08:00
parent 733bfd7509
commit 1a4062487e
5 changed files with 249 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
import { loginWithFixtures } from '../support/intercept';
describe('Account Management CRUD', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/account-admin');
cy.wait('@getUsers');
});
it('shows Create New button', () => {
cy.get('#create_new_acct_btn').should('exist');
cy.get('#create_new_acct_btn').should('contain', 'Create New');
});
it('opens create new account modal', () => {
cy.get('#create_new_acct_btn').click();
cy.get('#modal_container').should('be.visible');
cy.get('#modal_account_edit_or_create_new').should('be.visible');
// Should show account, name, password fields
cy.get('#input_account_field').should('exist');
cy.get('#input_name_field').should('exist');
cy.get('#input_first_pwd').should('exist');
});
it('create account confirm is disabled when fields are empty', () => {
cy.get('#create_new_acct_btn').click();
cy.get('.confirm-btn').should('be.disabled');
});
it('create account confirm enables when fields are filled', () => {
cy.get('#create_new_acct_btn').click();
cy.get('#input_account_field').type('newuser');
cy.get('#input_name_field').type('New User');
cy.get('#input_first_pwd').type('password1234');
cy.get('.confirm-btn').should('not.be.disabled');
});
it('cancel button closes the modal', () => {
cy.get('#create_new_acct_btn').click();
cy.get('#modal_container').should('be.visible');
cy.get('.cancel-btn').click();
cy.get('#modal_container').should('not.exist');
});
it('close (X) button closes the modal', () => {
cy.get('#create_new_acct_btn').click();
cy.get('#modal_container').should('be.visible');
cy.get('img[alt="X"]').click();
cy.get('#modal_container').should('not.exist');
});
it('double-click username opens account info modal', () => {
// Double-click on the first account username
cy.get('.account-cell').first().dblclick();
cy.get('#modal_container').should('be.visible');
});
it('delete button opens delete confirmation modal', () => {
// Click the delete icon for a non-current user
cy.get('.delete-account').first().click();
cy.get('#modal_container').should('be.visible');
cy.get('#modal_delete_acct_alert').should('be.visible');
});
it('delete modal has Yes and No buttons', () => {
cy.get('.delete-account').first().click();
cy.get('#calcel_delete_acct_btn').should('exist');
cy.get('#sure_to_delete_acct_btn').should('exist');
});
it('delete modal No button closes the modal', () => {
cy.get('.delete-account').first().click();
cy.get('#calcel_delete_acct_btn').click();
cy.get('#modal_container').should('not.exist');
});
it('shows checkboxes for Set as Admin and Activate in create modal', () => {
cy.get('#create_new_acct_btn').click();
cy.get('#account_create_checkboxes_section').should('be.visible');
cy.contains('Set as admin.').should('exist');
cy.contains('Activate now.').should('exist');
});
it('search bar filters user list', () => {
// Search filters by username, not display name
cy.get('#input_search').type('user1');
cy.get('img[alt="search"]').click();
// Should only show user1 (Alice Wang)
cy.contains('user1').should('exist');
});
});

View File

@@ -0,0 +1,69 @@
import { loginWithFixtures } from '../support/intercept';
describe('File Operations', () => {
beforeEach(() => {
loginWithFixtures();
cy.visit('/files');
cy.wait('@getFiles');
});
it('file list table has sortable columns', () => {
// Check that table headers exist with expected columns
cy.get('table').within(() => {
cy.contains('th', 'Name').should('exist');
cy.contains('th', 'Dependency').should('exist');
cy.contains('th', 'File Type').should('exist');
cy.contains('th', 'Owner').should('exist');
cy.contains('th', 'Last Update').should('exist');
});
});
it('clicking column header sorts the table', () => {
// Click "Name" header to sort
cy.contains('th', 'Name').click();
// After sorting, table should still have data
cy.get('table tbody tr').should('have.length.greaterThan', 0);
});
it('table rows show file data from fixture', () => {
cy.get('table tbody').within(() => {
cy.contains('sample-process.xes').should('exist');
cy.contains('filtered-sample').should('exist');
cy.contains('production-log.csv').should('exist');
});
});
it('table shows owner names', () => {
cy.get('table tbody').within(() => {
cy.contains('Test Admin').should('exist');
cy.contains('Alice Wang').should('exist');
});
});
it('table shows file types', () => {
cy.get('table tbody').within(() => {
cy.contains('log').should('exist');
});
});
it('right-click on file row shows context menu', () => {
// PrimeVue DataTable with contextmenu
cy.get('table tbody tr').first().rightclick();
// Context menu behavior depends on implementation
// Just verify the right-click doesn't break anything
cy.get('table tbody tr').should('have.length.greaterThan', 0);
});
it('grid view shows file cards', () => {
// Switch to grid view
cy.get('svg').parent('li.cursor-pointer').last().click();
// Grid cards should be visible
cy.get('li[title]').should('have.length.greaterThan', 0);
});
it('Import button opens upload modal', () => {
cy.get('#import_btn').click();
// Upload modal should appear
cy.get('#import_btn').should('exist');
});
});

62
cypress/e2e/logout.cy.js Normal file
View File

@@ -0,0 +1,62 @@
import { loginWithFixtures } from '../support/intercept';
describe('Logout Flow', () => {
beforeEach(() => {
loginWithFixtures();
});
it('shows account menu when head icon is clicked', () => {
cy.visit('/files');
cy.wait('@getFiles');
// Click the head icon to open account menu
cy.get('#acct_mgmt_button').click();
cy.get('#account_menu').should('be.visible');
cy.get('#greeting').should('contain', 'Test Admin');
});
it('account menu shows admin management link for admin user', () => {
cy.visit('/files');
cy.wait('@getFiles');
cy.get('#acct_mgmt_button').click();
cy.get('#account_menu').should('be.visible');
// Admin user should see account management option
cy.get('#btn_acct_mgmt').should('exist');
});
it('account menu has logout button', () => {
cy.visit('/files');
cy.wait('@getFiles');
cy.get('#acct_mgmt_button').click();
cy.get('#btn_logout_in_menu').should('exist');
});
it('clicking My Account navigates to /my-account', () => {
cy.visit('/files');
cy.wait('@getFiles');
cy.get('#acct_mgmt_button').click();
cy.get('#btn_mang_ur_acct').click();
cy.url().should('include', '/my-account');
});
it('clicking Account Management navigates to /account-admin', () => {
cy.visit('/files');
cy.wait('@getFiles');
cy.get('#acct_mgmt_button').click();
cy.get('#btn_acct_mgmt').click();
cy.url().should('include', '/account-admin');
});
it('logout redirects to login page', () => {
cy.visit('/files');
cy.wait('@getFiles');
cy.get('#acct_mgmt_button').click();
cy.get('#btn_logout_in_menu').click();
cy.url().should('include', '/login');
});
});

View File

@@ -0,0 +1,11 @@
{
"username": "testadmin",
"name": "Test Admin",
"is_admin": true,
"is_active": true,
"is_sso": false,
"has_data": true,
"roles": [
{ "code": "admin", "name": "Administrator" }
]
}

View File

@@ -43,6 +43,22 @@ export function setupApiIntercepts() {
body: { success: true },
}).as('putUser');
// User detail (GET /api/users/:username)
cy.intercept('GET', '/api/users/*', {
fixture: 'api/user-detail.json',
}).as('getUserDetail');
// User roles
cy.intercept('PUT', '/api/users/*/roles/*', {
statusCode: 200,
body: { success: true },
}).as('putUserRole');
cy.intercept('DELETE', '/api/users/*/roles/*', {
statusCode: 200,
body: { success: true },
}).as('deleteUserRole');
// Discover (map data)
cy.intercept('GET', '/api/logs/*/discover', {
fixture: 'api/discover.json',