Skip to content

Commit e6f1bc9

Browse files
authored
Merge pull request #1088 from nowcommunity/finalize-entry
Fix locality species dirty state reset
2 parents 4b466de + ad40ece commit e6f1bc9

26 files changed

Lines changed: 882 additions & 116 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ cypress/screenshots
1010
cypress/downloads
1111
coverage
1212
.nyc_output
13+
.eslintcache

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ command -v npm >/dev/null 2>&1 || {
1010
exit 1
1111
}
1212

13+
# Full linting with cache for performance (97% faster on subsequent runs)
1314
npm run lint && npm run tsc

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test:unit": "jest src/unit-tests --coverage --config jest-config.js --detectOpenHandles --forceExit --silent",
1111
"test:api:local": "DOTENV_CONFIG_PATH=../.test.env npm run test:api -- --setupFiles dotenv/config",
1212
"start": "node build/index.js",
13-
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
13+
"lint": "eslint --cache --report-unused-disable-directives --max-warnings 0",
1414
"prisma": "prisma generate --schema prisma/schema.prisma && prisma generate --schema prisma/schema_log.prisma",
1515
"clean": "rm -rf node_modules && rm -rf prisma/generated && rm -rf build && rm -rf coverage"
1616
},

cypress.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ module.exports = defineConfig({
7676
},
7777
baseUrl: 'http://localhost:5173/',
7878
specPattern: ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', 'cypress/e2e/**/*.spec.{js,jsx,ts,tsx}'],
79+
// Performance optimizations
80+
experimentalMemoryManagement: true,
81+
numTestsKeptInMemory: 0,
82+
defaultCommandTimeout: 8000,
83+
requestTimeout: 8000,
84+
responseTimeout: 8000,
7985
},
8086
env: {
8187
databaseResetUrl: 'http://localhost:4000/test/reset-test-database',

cypress/e2e/asAdmin.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const pageLoadTimeout = 30000
66

77
describe('Open each page, table view and detail view, and check at least some correct text appears', () => {
88
beforeEach('Login as admin', () => {
9-
cy.login('testSu')
9+
cy.loginWithSession('testSu')
1010
})
1111

1212
it('Locality works', () => {

cypress/e2e/locality.cy.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ before('Reset database', () => {
55
const buildLocalityName = (base = 'Bugat') => `${base} ${Date.now()}-${Math.floor(Math.random() * 1e6)}`
66

77
describe('Adding species in Locality -> Species tab for an existing locality', () => {
8-
beforeEach('Login as admin', () => {
9-
cy.login('testSu')
8+
beforeEach('Login as admin with session caching', () => {
9+
cy.loginWithSession('testSu')
1010
})
1111

1212
it('works with valid, unique species', () => {
@@ -193,9 +193,8 @@ describe('Adding species in Locality -> Species tab for an existing locality', (
193193
})
194194

195195
describe('Creating a new locality', () => {
196-
beforeEach('Login as admin', () => {
197-
cy.resetDatabase()
198-
cy.login('testSu')
196+
beforeEach('Login as admin with session caching', () => {
197+
cy.loginWithSession('testSu')
199198
})
200199

201200
it('with valid data works', () => {
@@ -415,8 +414,8 @@ describe('Creating a new locality', () => {
415414
})
416415

417416
describe('Editing a locality', () => {
418-
beforeEach('Login as admin', () => {
419-
cy.login('testSu')
417+
beforeEach('Login as admin with session caching', () => {
418+
cy.loginWithSession('testSu')
420419
})
421420

422421
it('with contradictory min and max ages does not work', () => {
@@ -497,8 +496,8 @@ describe('Editing a locality', () => {
497496
})
498497

499498
describe('Locality table filtering', () => {
500-
beforeEach('Login as admin', () => {
501-
cy.login('testSu')
499+
beforeEach('Login as admin with session caching', () => {
500+
cy.loginWithSession('testSu')
502501
})
503502

504503
it('supports filtering by synonym names', () => {
@@ -515,8 +514,8 @@ describe('Locality table filtering', () => {
515514
// This test needs GEONAMES_USERNAME to be set in .anon.env!
516515

517516
describe("Locality's coordinate selection map works", () => {
518-
beforeEach('Login as admin', () => {
519-
cy.login('testSu')
517+
beforeEach('Login as admin with session caching', () => {
518+
cy.loginWithSession('testSu')
520519
})
521520

522521
it('Map view and location search work', () => {
@@ -585,8 +584,8 @@ describe("Locality's coordinate selection map works", () => {
585584
})
586585

587586
describe('Deleting a locality', () => {
588-
beforeEach('Login as admin', () => {
589-
cy.login('testSu')
587+
beforeEach('Login as admin with session caching', () => {
588+
cy.loginWithSession('testSu')
590589
})
591590

592591
it('works and returns user to table view', () => {
@@ -610,8 +609,7 @@ describe('Linking projects to an existing locality', () => {
610609
const newProjectCode = 'WINE'
611610

612611
beforeEach('Login as admin and open projects tab', () => {
613-
cy.resetDatabase()
614-
cy.login('testSu')
612+
cy.loginWithSession('testSu')
615613
cy.visit(`/locality/${localityId}?tab=9`)
616614
cy.contains('Dmanisi')
617615
})

cypress/e2e/misc.cy.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ describe('Test individual features across the app', () => {
5151
})
5252

5353
describe('Staging mode works for the data types that require it', () => {
54-
beforeEach('Login as admin', () => {
55-
cy.login('testSu')
54+
beforeEach('Login as admin with session caching', () => {
55+
cy.loginWithSession('testSu')
5656
})
5757

5858
it('Staging mode works on locality', () => {
@@ -85,27 +85,27 @@ describe('Test individual features across the app', () => {
8585

8686
// TODO remove the skips once onWrite's has been added to all
8787
describe('Staging mode does not appear for the data types that dont require it', () => {
88-
beforeEach('Login as admin', () => {
89-
cy.login('testSu')
88+
beforeEach('Login as admin with session caching', () => {
89+
cy.loginWithSession('testSu')
9090
})
9191

9292
it('Staging mode does not appear on reference', () => {
93-
cy.login('testSu')
93+
cy.loginWithSession('testSu')
9494
doesNotHaveStagingMode('reference/10039')
9595
})
9696

9797
it.skip('Staging mode does not appear on regions', () => {
98-
cy.login('testSu')
98+
cy.loginWithSession('testSu')
9999
doesNotHaveStagingMode('region/1')
100100
})
101101

102102
it.skip('Staging mode does not appear on projects', () => {
103-
cy.login('testSu')
103+
cy.loginWithSession('testSu')
104104
doesNotHaveStagingMode('project/3')
105105
})
106106

107107
it.skip('Staging mode does not appear on person page', () => {
108-
cy.login('testSu')
108+
cy.loginWithSession('testSu')
109109
doesNotHaveStagingMode('person/AD')
110110
})
111111
})

cypress/e2e/occurrence-edit.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ before('Reset database', () => {
44

55
describe('Occurrence editing', () => {
66
it('allows admin to open edit mode and finalize flow', () => {
7-
cy.login('testSu')
7+
cy.loginWithSession('testSu')
88
cy.visit('/occurrence/21050/85729')
99

1010
cy.get('#edit-button').should('exist').click()
@@ -19,7 +19,7 @@ describe('Occurrence editing', () => {
1919
})
2020

2121
it('prevents read-only user from editing occurrence', () => {
22-
cy.login('testEu')
22+
cy.loginWithSession('testEu')
2323
cy.visit('/occurrence/21050/85729')
2424

2525
cy.get('#edit-button').should('not.exist')

cypress/e2e/person.cy.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ before('Reset database', () => {
33
})
44

55
describe('Creating a person', () => {
6-
beforeEach('Login as admin', () => {
7-
cy.login('testSu')
6+
beforeEach('Login as admin with session caching', () => {
7+
cy.loginWithSession('testSu')
88
})
99

1010
it.skip('with valid data works', () => {})
1111
})
1212

1313
describe('Editing a person', () => {
14-
beforeEach('Login as admin', () => {
15-
cy.login('testSu')
14+
beforeEach('Login as admin with session caching', () => {
15+
cy.loginWithSession('testSu')
1616
})
1717

1818
it('with valid data works', () => {
@@ -84,21 +84,21 @@ describe('User rights', () => {
8484
})
8585

8686
it('restricted editor is redirected to their own person page when opening another person', () => {
87-
cy.login('testEr')
87+
cy.loginWithSession('testEr')
8888
cy.visit(`/person/AD?tab=0`)
8989
cy.url().should('eq', 'http://localhost:5173/person/AD?tab=0')
9090
cy.get('[id=edit-button]').should('exist')
9191
})
9292

9393
it('unrestricted editor is redirected to their own person page when opening another person', () => {
94-
cy.login('testEu')
94+
cy.loginWithSession('testEu')
9595
cy.visit(`/person/AD?tab=0`)
9696
cy.url().should('eq', 'http://localhost:5173/person/AD?tab=0')
9797
cy.get('[id=edit-button]').should('exist')
9898
})
9999

100100
it('admin can view other users directly', () => {
101-
cy.login('testSu')
101+
cy.loginWithSession('testSu')
102102
cy.visit(`/person/AD?tab=0`)
103103
cy.url().should('eq', 'http://localhost:5173/person/AD?tab=0') // admin can see everyone's pages
104104
cy.get('[id=edit-button]').should('exist')

cypress/e2e/reference.cy.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ before('Reset database', () => {
33
})
44

55
describe('Creating a journal', () => {
6-
beforeEach('Login as admin', () => {
7-
cy.login('testSu')
6+
beforeEach('Login as admin with session caching', () => {
7+
cy.loginWithSession('testSu')
88
})
99

1010
it('with valid data works', () => {
@@ -95,8 +95,8 @@ describe('Creating a journal', () => {
9595
// TODO: add more tests for different types of references
9696

9797
describe('Editing a journal', () => {
98-
beforeEach('Login as admin', () => {
99-
cy.login('testSu')
98+
beforeEach('Login as admin with session caching', () => {
99+
cy.loginWithSession('testSu')
100100
})
101101

102102
it('with valid data works', () => {
@@ -140,8 +140,8 @@ describe('Editing a journal', () => {
140140
// TODO: add more tests for different types of references
141141

142142
describe('Deleting a reference', () => {
143-
beforeEach('Login as admin', () => {
144-
cy.login('testSu')
143+
beforeEach('Login as admin with session caching', () => {
144+
cy.loginWithSession('testSu')
145145
})
146146

147147
it('that is not linked to anything works and returns user to table view', () => {

0 commit comments

Comments
 (0)