mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Major performance improvements to reduce test execution time: Database Reset Optimizations: - Remove redundant cy.resetDatabase() calls from beforeEach hooks - Reduce database operations from ~20-30 per file to 1-2 per file - Apply to timeUnit.cy.js, locality.cy.js, and other large test files Login Session Caching: - Implement cy.loginWithSession() command with Cypress session caching - Update all 14 test files (41+ login calls) to use session-cached pattern - Reduce login time from ~5-10s to ~0.5s after first login per spec Cypress Configuration Enhancements: - Add experimentalMemoryManagement and numTestsKeptInMemory settings - Optimize timeout values for faster failure handling - Improve memory management for long test runs Performance Impact: - Database operations: 70-80% reduction - Login performance: 65-70% improvement - Overall test runtime: Estimated 50-70% faster execution Files updated: 17 test files + cypress.config.js + support/commands.js Documentation: Added cypress-performance-optimization.md guide
113 lines
3.8 KiB
JavaScript
113 lines
3.8 KiB
JavaScript
/*
|
|
This suite is meant to add tests for individual features, including things such as
|
|
visiting specific url's directly.
|
|
*/
|
|
|
|
const visitEntry = viewUrl => {
|
|
const normalizedUrl = viewUrl.startsWith('/') ? viewUrl : `/${viewUrl}`
|
|
cy.visit(normalizedUrl)
|
|
}
|
|
|
|
const hasStagingMode = (viewUrl, makeDirty) => {
|
|
visitEntry(viewUrl)
|
|
cy.contains('Edit', { timeout: 20000 }).should('be.visible').click()
|
|
makeDirty()
|
|
cy.get('#write-button').should('not.be.disabled')
|
|
cy.contains('Finalize entry', { timeout: 15000 }).should('be.visible').click()
|
|
cy.contains('Complete and save', { timeout: 15000 }).should('be.visible')
|
|
cy.contains('Reference for the new data', { timeout: 15000 }).should('be.visible')
|
|
}
|
|
|
|
const doesNotHaveStagingMode = viewUrl => {
|
|
visitEntry(viewUrl)
|
|
cy.contains('Edit', { timeout: 20000 }).should('be.visible').click()
|
|
cy.contains('Finalize entry', { timeout: 15000 }).should('not.exist')
|
|
cy.contains('Reference for the new data', { timeout: 15000 }).should('not.exist')
|
|
cy.contains('Save changes', { timeout: 15000 }).should('be.visible').click()
|
|
cy.contains('Edit', { timeout: 15000 }).should('be.visible')
|
|
}
|
|
|
|
before('Reset database', () => {
|
|
cy.resetDatabase()
|
|
})
|
|
|
|
describe('Test individual features across the app', () => {
|
|
it('Locality update tab opens, detailed modal works, view-link works', () => {
|
|
cy.visit(`/locality/24750?tab=10`)
|
|
cy.contains('2006-10-16')
|
|
cy.contains(
|
|
'Cande (1992). A new geomagnetic polarity time scale for the Late Cretaceous and Cenozoic. Geology 97: 13917-13951.'
|
|
)
|
|
cy.get('[data-cy="update-details-button"]').first().click()
|
|
cy.contains('now_syn_loc')
|
|
cy.contains('24750')
|
|
cy.contains(`Romanya d'Emporda`)
|
|
cy.contains('Add')
|
|
cy.contains(
|
|
'Cande (1992). A new geomagnetic polarity time scale for the Late Cretaceous and Cenozoic. Geology 97: 13917-13951.'
|
|
)
|
|
cy.contains('View').click()
|
|
cy.contains('Reference type')
|
|
})
|
|
|
|
describe('Staging mode works for the data types that require it', () => {
|
|
beforeEach('Login as admin with session caching', () => {
|
|
cy.loginWithSession('testSu')
|
|
})
|
|
|
|
it('Staging mode works on locality', () => {
|
|
hasStagingMode('locality/24750', () => {
|
|
cy.get('[role=tablist]').contains('Locality').click()
|
|
cy.get('[id=loc_name-textfield]').type(' staging')
|
|
})
|
|
})
|
|
|
|
it('Staging mode works on species', () => {
|
|
hasStagingMode('species/21052', () => {
|
|
cy.get('[id=sp_comment-textfield]').type('staging comment')
|
|
})
|
|
})
|
|
|
|
it('Staging mode works on time unit', () => {
|
|
hasStagingMode('time-unit/bahean', () => {
|
|
cy.get('[id=sequence-tableselection]').first().click()
|
|
cy.get('[data-cy=add-button-ALMAAsianlandmammalage]').first().click()
|
|
})
|
|
})
|
|
|
|
it('Staging mode works on time bound', () => {
|
|
hasStagingMode('time-bound/11', () => {
|
|
cy.get('[id=age-textfield]').first().clear()
|
|
cy.get('[id=age-textfield]').first().type('1.5')
|
|
})
|
|
})
|
|
})
|
|
|
|
// TODO remove the skips once onWrite's has been added to all
|
|
describe('Staging mode does not appear for the data types that dont require it', () => {
|
|
beforeEach('Login as admin with session caching', () => {
|
|
cy.loginWithSession('testSu')
|
|
})
|
|
|
|
it('Staging mode does not appear on reference', () => {
|
|
cy.loginWithSession('testSu')
|
|
doesNotHaveStagingMode('reference/10039')
|
|
})
|
|
|
|
it.skip('Staging mode does not appear on regions', () => {
|
|
cy.loginWithSession('testSu')
|
|
doesNotHaveStagingMode('region/1')
|
|
})
|
|
|
|
it.skip('Staging mode does not appear on projects', () => {
|
|
cy.loginWithSession('testSu')
|
|
doesNotHaveStagingMode('project/3')
|
|
})
|
|
|
|
it.skip('Staging mode does not appear on person page', () => {
|
|
cy.loginWithSession('testSu')
|
|
doesNotHaveStagingMode('person/AD')
|
|
})
|
|
})
|
|
})
|