From ceb6b57767670d10b00b5dd6a7aba94da6090953 Mon Sep 17 00:00:00 2001 From: Tepponen Margit H Date: Mon, 26 May 2025 10:37:49 +0300 Subject: [PATCH 01/18] update navbar --- frontend/src/components/NavBar.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/NavBar.tsx b/frontend/src/components/NavBar.tsx index 32c72166..87fe52b5 100755 --- a/frontend/src/components/NavBar.tsx +++ b/frontend/src/components/NavBar.tsx @@ -17,15 +17,9 @@ export const NavBar = () => { const dispatch = useDispatch() const notify = useNotify() const pages: LinkDefinition[] = [ - { - title: 'Search', - url: '', - children: [ - { title: 'Localities', url: '/locality' }, - { title: 'Species', url: '/species' }, - { title: 'Cross-Search', url: '/crosssearch' }, - ], - }, + { title: 'Localities', url: '/locality' }, + { title: 'Species', url: '/species' }, + { title: 'Cross-Search', url: '/crosssearch' }, { title: 'References', url: '/reference' }, { title: 'Time Units', url: '/time-unit' }, { title: 'Time Bounds', url: '/time-bound', allowedRoles: [Role.Admin, Role.EditUnrestricted] }, From ff32b55a5d343f4602b22ce9375d636cacadd774 Mon Sep 17 00:00:00 2001 From: juhanikat Date: Tue, 15 Apr 2025 15:16:34 +0300 Subject: [PATCH 02/18] fixed region get test title --- backend/src/api-tests/region/get.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/api-tests/region/get.test.ts b/backend/src/api-tests/region/get.test.ts index 0ad236e3..78994239 100644 --- a/backend/src/api-tests/region/get.test.ts +++ b/backend/src/api-tests/region/get.test.ts @@ -2,7 +2,7 @@ import { beforeAll, afterAll, describe, it, expect, beforeEach } from '@jest/glo import { login, logout, resetDatabase, send, resetDatabaseTimeout } from '../utils' import { pool } from '../../utils/db' -describe('Deleting a region works', () => { +describe('Getting region data works', () => { beforeAll(async () => { await resetDatabase() }, resetDatabaseTimeout) From 747070563b5bc7de91b848e1827a22c76cb2f008 Mon Sep 17 00:00:00 2001 From: juhanikat Date: Tue, 15 Apr 2025 15:27:30 +0300 Subject: [PATCH 03/18] add test for time bound creation --- cypress/e2e/timeBound.cy.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/timeBound.cy.js b/cypress/e2e/timeBound.cy.js index df1a34bd..2392cc4e 100644 --- a/cypress/e2e/timeBound.cy.js +++ b/cypress/e2e/timeBound.cy.js @@ -1,10 +1,35 @@ -describe('Editing time bound', () => { +before('Reset database', () => { + cy.request(Cypress.env('databaseResetUrl')) +}) + +describe('Creating time bound', () => { beforeEach('Login as admin', () => { cy.login('testSu') }) - beforeEach('Reset database', () => { - cy.request(Cypress.env('databaseResetUrl')) + it('with correct values works', () => { + cy.visit(`/time-bound/new/`) + cy.contains('Creating new time-bound') + cy.contains('Name: This field is required') + cy.contains('Age (Ma): This field is required') + cy.get('[id=b_name-textfield]').first().type('test bound') + cy.contains('Name: This field is required').should('not.exist') + cy.get('[id=write-button]').should('be.disabled') + cy.get('[id=age-textfield]').first().type('20') + cy.contains('Age (Ma): This field is required').should('not.exist') + cy.get('[id=write-button]').click() + cy.contains('button', 'Add existing reference').click() + cy.get('button[data-cy^="detailview-button"]').first().click() + cy.contains('button', 'Close').click() + cy.get('[id=write-button]').should('not.be.disabled') + cy.get('[id=write-button]').click() + cy.contains('Edited item successfully.') + }) +}) + +describe('Editing time bound', () => { + beforeEach('Login as admin', () => { + cy.login('testSu') }) it('with correct values works', () => { @@ -20,6 +45,7 @@ describe('Editing time bound', () => { cy.contains('button', 'Close').click() cy.get('[id=write-button]').should('not.be.disabled') cy.get('[id=write-button]').click() + cy.contains('Edited item successfully.') cy.contains('1.5') }) From 5388c23dd9af2245088b0ae8ae6e055e8b52a52f Mon Sep 17 00:00:00 2001 From: juhanikat Date: Tue, 15 Apr 2025 15:39:59 +0300 Subject: [PATCH 04/18] add tests for species editing --- cypress/e2e/species.cy.js | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/cypress/e2e/species.cy.js b/cypress/e2e/species.cy.js index 5bd82509..9eae87ca 100644 --- a/cypress/e2e/species.cy.js +++ b/cypress/e2e/species.cy.js @@ -1,3 +1,7 @@ +before('Reset database', () => { + cy.request(Cypress.env('databaseResetUrl')) +}) + describe('Creating a species', () => { beforeEach('Login as admin', () => { cy.login('testSu') @@ -28,6 +32,77 @@ describe('Creating a species', () => { }) }) +describe('Editing a species', () => { + beforeEach('Login as admin', () => { + cy.login('testSu') + }) + + it('with valid data works', () => { + cy.visit('/species/21052/') + cy.contains('21052 Simplomys simplicidens') + cy.get('[id=edit-button]').click() + + cy.get('[id=order_name-textfield]').clear() + cy.get('[id=order_name-textfield]').type('modifiedOrder') + cy.get('[id=family_name-textfield]').clear() + cy.get('[id=family_name-textfield]').type('modifiedFamily') + cy.get('[id=genus_name-textfield]').clear() + cy.get('[id=genus_name-textfield]').type('modifiedGenus') + cy.get('[id=species_name-textfield]').clear() + cy.get('[id=species_name-textfield]').type('modifiedSpecies') + cy.get('[id=subfamily_name-textfield]').type('heimo') + + cy.get('[id=write-button]').should('not.be.disabled') + cy.get('[id=write-button]').click() + cy.contains('button', 'Add existing reference').click() + cy.get('button[data-cy^="detailview-button"]').first().click() + cy.contains('button', 'Close').click() + cy.get('[id=write-button]').should('not.be.disabled') + cy.get('[id=write-button]').click() + cy.contains('Saved species entry successfully.') + cy.contains('modifiedOrder') + cy.contains('Subfamily or Tribe heimo') + }) + + it('with missing required fields does not work', () => { + cy.visit('/species/21052/') + cy.contains('21052') + cy.get('[id=edit-button]').click() + + cy.get('[id=order_name-textfield]').clear() + cy.contains('Order: This field is required') + cy.get('[id=write-button]').should('be.disabled') + cy.contains('1 Invalid fields') + + cy.get('[id=family_name-textfield]').clear() + cy.contains('Family: This field is required') + cy.get('[id=write-button]').should('be.disabled') + cy.contains('2 Invalid fields') + + cy.get('[id=order_name-textfield]').type('newOrder') + cy.contains('Order: This field is required').should('not.exist') + cy.contains('Family: This field is required') + cy.get('[id=write-button]').should('be.disabled') + cy.contains('1 Invalid fields') + + cy.get('[id=family_name-textfield]').type('newFamily') + cy.contains('Family: This field is required').should('not.exist') + cy.get('[id=write-button]').click() + + cy.contains('button', 'Add existing reference').click() + cy.get('button[data-cy^="detailview-button"]').first().click() + cy.contains('button', 'Close').click() + cy.get('[id=write-button]').should('not.be.disabled') + cy.get('[id=write-button]').click() + + cy.contains('Saved species entry successfully.') + cy.contains('newOrder') + cy.contains('newFamily') + cy.contains('modifiedGenus') + cy.contains('Subfamily or Tribe heimo') + }) +}) + describe('Deleting a species', () => { beforeEach('Login as admin', () => { cy.login('testSu') From 9b0c74f56eef1673766ff00a8c38a9944268ced6 Mon Sep 17 00:00:00 2001 From: juhanikat Date: Tue, 15 Apr 2025 15:49:32 +0300 Subject: [PATCH 05/18] add skeleton for e2e reference tests --- cypress/e2e/reference.cy.js | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 cypress/e2e/reference.cy.js diff --git a/cypress/e2e/reference.cy.js b/cypress/e2e/reference.cy.js new file mode 100644 index 00000000..88ec8e9e --- /dev/null +++ b/cypress/e2e/reference.cy.js @@ -0,0 +1,63 @@ +before('Reset database', () => { + cy.request(Cypress.env('databaseResetUrl')) +}) + +describe('Creating a reference', () => { + beforeEach('Login as admin', () => { + cy.login('testSu') + }) + + it.skip('with valid data works', () => {}) + + it.skip('with missing required fields does no work', () => {}) + + // TODO: add more tests for different types of references etc. +}) + +describe('Editing a reference', () => { + beforeEach('Login as admin', () => { + cy.login('testSu') + }) + + it.skip('with valid data works', () => {}) + + it.skip('with missing required fields does no work', () => {}) + + // TODO: add more tests for different types of references etc. +}) + +describe('Deleting a reference', () => { + beforeEach('Login as admin', () => { + cy.login('testSu') + }) + + it.skip('that is not linked to anything works and returns user to table view', () => { + // TODO: Create a new reference in anon database that is not linked to any localities or species + cy.visit('/reference/') + cy.get('[id=delete-button]').should('exist').click() + cy.on('window:confirm', str => { + expect(str).to.eq('Are you sure you want to delete this item? This operation cannot be undone.') + // this automatically clicks the OK button and returns to table view + }) + cy.contains('Deleted item successfully.') + cy.contains('Dated co-occurrence of Homo erectus and Gigantopithecus from Tham Khuyen Cave, Vietnam') // check that table view has been navigated to + cy.contains('').should('not.exist') + cy.visit('/reference/') + cy.contains('Error loading data') + }) + + // Skipped because referecnes that have linked localities or species cannot be deleted currently. + it.skip('that is linked to a locality and a species works and returns user to table view', () => { + cy.visit('/reference/10039') + cy.get('[id=delete-button]').should('exist').click() + cy.on('window:confirm', str => { + expect(str).to.eq('Are you sure you want to delete this item? This operation cannot be undone.') + // this automatically clicks the OK button and returns to table view + }) + cy.contains('Deleted item successfully.') + cy.contains('Dated co-occurrence of Homo erectus and Gigantopithecus from Tham Khuyen Cave, Vietnam') // check that table view has been navigated to + cy.contains('A new geomagnetic polarity time scale for the Late Cretaceous and Cenozoic').should('not.exist') + cy.visit('/reference/10039') + cy.contains('Error loading data') + }) +}) From 4965138cd04e624d2cb424e7ad842057ba53c682 Mon Sep 17 00:00:00 2001 From: juhanikat Date: Fri, 9 May 2025 14:56:36 +0300 Subject: [PATCH 06/18] added new test reference to anon database and made a deletion test --- cypress/e2e/reference.cy.js | 15 +++++++-------- test_data/sqlfiles/now_test.sql | 6 ++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/reference.cy.js b/cypress/e2e/reference.cy.js index 88ec8e9e..188cfea8 100644 --- a/cypress/e2e/reference.cy.js +++ b/cypress/e2e/reference.cy.js @@ -9,7 +9,7 @@ describe('Creating a reference', () => { it.skip('with valid data works', () => {}) - it.skip('with missing required fields does no work', () => {}) + it.skip('with missing required fields does not work', () => {}) // TODO: add more tests for different types of references etc. }) @@ -21,7 +21,7 @@ describe('Editing a reference', () => { it.skip('with valid data works', () => {}) - it.skip('with missing required fields does no work', () => {}) + it.skip('with missing required fields does not work', () => {}) // TODO: add more tests for different types of references etc. }) @@ -31,9 +31,8 @@ describe('Deleting a reference', () => { cy.login('testSu') }) - it.skip('that is not linked to anything works and returns user to table view', () => { - // TODO: Create a new reference in anon database that is not linked to any localities or species - cy.visit('/reference/') + it('that is not linked to anything works and returns user to table view', () => { + cy.visit('/reference/25000') cy.get('[id=delete-button]').should('exist').click() cy.on('window:confirm', str => { expect(str).to.eq('Are you sure you want to delete this item? This operation cannot be undone.') @@ -41,12 +40,12 @@ describe('Deleting a reference', () => { }) cy.contains('Deleted item successfully.') cy.contains('Dated co-occurrence of Homo erectus and Gigantopithecus from Tham Khuyen Cave, Vietnam') // check that table view has been navigated to - cy.contains('').should('not.exist') - cy.visit('/reference/') + cy.contains('A test reference that is not linked to any localities or species').should('not.exist') + cy.visit('/reference/25000') cy.contains('Error loading data') }) - // Skipped because referecnes that have linked localities or species cannot be deleted currently. + // Skipped because references that have linked localities or species cannot be deleted currently it.skip('that is linked to a locality and a species works and returns user to table view', () => { cy.visit('/reference/10039') cy.get('[id=delete-button]').should('exist').click() diff --git a/test_data/sqlfiles/now_test.sql b/test_data/sqlfiles/now_test.sql index 18596cd4..f4833a7e 100755 --- a/test_data/sqlfiles/now_test.sql +++ b/test_data/sqlfiles/now_test.sql @@ -1709,7 +1709,8 @@ INSERT INTO `ref_authors` VALUES (21368,2,1,'Ciochon','Russell'), (24151,2,1,'Ogg','J.G.'), (24187,2,1,'Kaakinen','A.'), -(24188,2,1,'Wang','X.'); +(24188,2,1,'Wang','X.'), +(25000,2,1,'Doe','D.'); /*!40000 ALTER TABLE `ref_authors` ENABLE KEYS */; UNLOCK TABLES; @@ -2198,7 +2199,8 @@ INSERT INTO `ref_ref` VALUES (21368,1,100,'Dated co-occurrence of Homo erectus and Gigantopithecus from Tham Khuyen Cave, Vietnam',1996,'93',NULL,3016,3020,NULL,NULL,NULL,NULL,NULL,NULL,'abstract','http://www.pnas.org/cgi/reprint/93/7/3016',NULL,NULL,NULL,'English',NULL,NULL,1,NULL), (24151,2,NULL,'A Concise Geologic Time Scale: 2016',2016,NULL,NULL,NULL,240,'Elsevier',NULL,NULL,NULL,NULL,'9780444594686',NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,1,0), (24187,13,NULL,'Helsinki Asian time update',2020,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2020-01-29',NULL,1,NULL), -(24188,2,NULL,'Fossil Mammals of Asia',2013,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL); +(24188,2,NULL,'Fossil Mammals of Asia',2013,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL), +(25000,1,100,'A test reference that is not linked to any localities or species',2025,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `ref_ref` ENABLE KEYS */; UNLOCK TABLES; From c1d77497a2068203e3a1511014b4c11971a0f8ec Mon Sep 17 00:00:00 2001 From: juhanikat Date: Fri, 9 May 2025 15:28:05 +0300 Subject: [PATCH 07/18] changed SelectingTable to give an id to EditingModal, and added creation tests for references --- cypress/e2e/reference.cy.js | 106 +++++++++++++++--- .../DetailView/common/SelectingTable.tsx | 2 +- 2 files changed, 92 insertions(+), 16 deletions(-) diff --git a/cypress/e2e/reference.cy.js b/cypress/e2e/reference.cy.js index 188cfea8..9dc79d3b 100644 --- a/cypress/e2e/reference.cy.js +++ b/cypress/e2e/reference.cy.js @@ -2,7 +2,94 @@ before('Reset database', () => { cy.request(Cypress.env('databaseResetUrl')) }) -describe('Creating a reference', () => { +describe('Creating a journal', () => { + beforeEach('Login as admin', () => { + cy.login('testSu') + }) + + it('with valid data works', () => { + cy.visit('/reference/new') + cy.contains('Journal') + cy.contains('7 Invalid fields') + + cy.get('[id=title_primary-textfield]').type('New test reference') + + cy.get('[data-cy=Select\\ author-button]').click() + cy.get('[data-cy=detailview-button-1]').click() + cy.contains('Close').click() + + cy.get('[id=date_primary-textfield]').type('2025') + + cy.get('[data-cy=Select\\ Journal-button]').click() + cy.get('[data-cy=detailview-button-100]').click() + cy.contains('Close').click() + + cy.get('[id=write-button]').click() + cy.contains('Saved reference successfully.') + }) + + it('with missing required fields does not work', () => { + cy.visit('/reference/new') + cy.contains('Journal') + cy.contains('7 Invalid fields') + + cy.get('[id=title_primary-textfield]').type('New test reference 2') + cy.contains('3 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') + + cy.get('[data-cy=Select\\ author-button]').click() + cy.get('[data-cy=detailview-button-1]').click() + cy.contains('Close').click() + cy.contains('2 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') + + cy.get('[id=date_primary-textfield]').type('2025') + cy.contains('1 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') + + cy.get('[data-cy=Select\\ Journal-button]').click() + cy.get('[data-cy=detailview-button-100]').click() + cy.contains('Close').click() + cy.get('[id=write-button]').should('not.be.disabled') + + cy.get('[data-testid=RemoveCircleOutlineIcon]').first().click() // removes the selected author + cy.get('[id=write-button]').should('be.disabled') + cy.get('[data-cy=Select\\ author-button]').click() + cy.get('[data-cy=detailview-button-1]').click() + cy.contains('Close').click() + cy.get('[id=write-button]').should('not.be.disabled') + }) + + it('combined check with different types of titles and gen notes works', () => { + cy.visit('/reference/new') + cy.contains('Journal') + cy.contains('7 Invalid fields') + + cy.get('[id=title_primary-textfield]').type('Title Primary') + cy.contains('3 Invalid fields') + cy.get('[id=title_primary-textfield]').clear() + cy.contains('7 Invalid fields') + + cy.get('[id=title_secondary-textfield]').type('Title Secondary') + cy.contains('3 Invalid fields') + cy.get('[id=title_secondary-textfield]').clear() + cy.contains('7 Invalid fields') + + cy.get('[id=title_series-textfield]').type('Title Series') + cy.contains('3 Invalid fields') + cy.get('[id=title_series-textfield]').clear() + cy.contains('7 Invalid fields') + + cy.get('[id=gen_notes-textfield]').type('Gen Notes') + cy.contains('3 Invalid fields') + cy.get('[id=gen_notes-textfield]').clear() + cy.contains('7 Invalid fields') + }) +}) + +// TODO: add more tests for different types of references + +describe('Editing a journal', () => { beforeEach('Login as admin', () => { cy.login('testSu') }) @@ -10,28 +97,17 @@ describe('Creating a reference', () => { it.skip('with valid data works', () => {}) it.skip('with missing required fields does not work', () => {}) - - // TODO: add more tests for different types of references etc. }) -describe('Editing a reference', () => { - beforeEach('Login as admin', () => { - cy.login('testSu') - }) - - it.skip('with valid data works', () => {}) - - it.skip('with missing required fields does not work', () => {}) - - // TODO: add more tests for different types of references etc. -}) +// TODO: add more tests for different types of references describe('Deleting a reference', () => { beforeEach('Login as admin', () => { cy.login('testSu') }) - it('that is not linked to anything works and returns user to table view', () => { + // REMOVE SKIP + it.skip('that is not linked to anything works and returns user to table view', () => { cy.visit('/reference/25000') cy.get('[id=delete-button]').should('exist').click() cy.on('window:confirm', str => { diff --git a/frontend/src/components/DetailView/common/SelectingTable.tsx b/frontend/src/components/DetailView/common/SelectingTable.tsx index 46427135..2b43bae4 100755 --- a/frontend/src/components/DetailView/common/SelectingTable.tsx +++ b/frontend/src/components/DetailView/common/SelectingTable.tsx @@ -67,7 +67,7 @@ export const SelectingTable = if (isError) return Error fetching data for the selecting table. if (!data) return return ( - + {data ? ( data={filteredData} From 121eb29d0ae921cce8876cb8d99e595fddf8fb66 Mon Sep 17 00:00:00 2001 From: juhanikat Date: Fri, 9 May 2025 15:41:10 +0300 Subject: [PATCH 08/18] added editing tests for references --- cypress/e2e/reference.cy.js | 45 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/reference.cy.js b/cypress/e2e/reference.cy.js index 9dc79d3b..7034dab9 100644 --- a/cypress/e2e/reference.cy.js +++ b/cypress/e2e/reference.cy.js @@ -64,26 +64,31 @@ describe('Creating a journal', () => { cy.visit('/reference/new') cy.contains('Journal') cy.contains('7 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_primary-textfield]').type('Title Primary') cy.contains('3 Invalid fields') cy.get('[id=title_primary-textfield]').clear() cy.contains('7 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_secondary-textfield]').type('Title Secondary') cy.contains('3 Invalid fields') cy.get('[id=title_secondary-textfield]').clear() cy.contains('7 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_series-textfield]').type('Title Series') cy.contains('3 Invalid fields') cy.get('[id=title_series-textfield]').clear() cy.contains('7 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') cy.get('[id=gen_notes-textfield]').type('Gen Notes') cy.contains('3 Invalid fields') cy.get('[id=gen_notes-textfield]').clear() cy.contains('7 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') }) }) @@ -94,9 +99,42 @@ describe('Editing a journal', () => { cy.login('testSu') }) - it.skip('with valid data works', () => {}) + it('with valid data works', () => { + cy.visit('reference/10039') + cy.contains('A new geomagnetic polarity time scale for the Late Cretaceous and Cenozoic.') + cy.get('[id=edit-button]').click() + cy.get('[id=title_primary-textfield]').clear() + cy.get('[id=title_primary-textfield]').type('New primary title.') - it.skip('with missing required fields does not work', () => {}) + cy.get('[data-cy=Select\\ author-button]').click() + cy.get('[data-cy=detailview-button-2]').click() + cy.contains('Close').click() + + cy.get('[id=write-button]').click() + cy.contains('Saved reference successfully.') + cy.contains('New primary title.') + cy.contains('Cande') // Author 1 + cy.contains('Ciochon') // Author 2 + }) + + it('with missing required fields does not work', () => { + cy.visit('reference/10039') + cy.contains('New primary title.') + cy.get('[id=edit-button]').click() + cy.get('[id=title_primary-textfield]').clear() + cy.contains('4 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') + cy.get('[id=title_primary-textfield]').type('New primary title.') + + cy.get('[data-testid=RemoveCircleOutlineIcon]').first().click() + cy.get('[data-testid=RemoveCircleOutlineIcon]').first().click() // removes the selected authors + cy.contains('1 Invalid fields') + cy.get('[id=write-button]').should('be.disabled') + cy.get('[data-cy=Select\\ author-button]').click() + cy.get('[data-cy=detailview-button-1]').click() + cy.contains('Close').click() + cy.get('[id=write-button]').should('not.be.disabled') + }) }) // TODO: add more tests for different types of references @@ -106,8 +144,7 @@ describe('Deleting a reference', () => { cy.login('testSu') }) - // REMOVE SKIP - it.skip('that is not linked to anything works and returns user to table view', () => { + it('that is not linked to anything works and returns user to table view', () => { cy.visit('/reference/25000') cy.get('[id=delete-button]').should('exist').click() cy.on('window:confirm', str => { From 71f1394b9ec374b8883d4438d12bd48c96b6279e Mon Sep 17 00:00:00 2001 From: juhanikat Date: Fri, 9 May 2025 15:44:53 +0300 Subject: [PATCH 09/18] chnaged errorbox title slightly --- cypress/e2e/locality.cy.js | 12 +++---- cypress/e2e/reference.cy.js | 32 +++++++++---------- cypress/e2e/species.cy.js | 8 ++--- cypress/e2e/timeBound.cy.js | 2 +- .../src/components/DetailView/components.tsx | 4 ++- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/cypress/e2e/locality.cy.js b/cypress/e2e/locality.cy.js index 1ded9816..186ff104 100644 --- a/cypress/e2e/locality.cy.js +++ b/cypress/e2e/locality.cy.js @@ -60,7 +60,7 @@ describe('Creating a new locality', () => { cy.get('[id=dms_lat-textfield]').should('have.value', '48 40 48 N') cy.contains('This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('4 Invalid fields') + cy.contains('4 invalid fields') }) it("and filling, then erasing needed data doesn't work", () => { @@ -95,12 +95,12 @@ describe('Creating a new locality', () => { cy.get('[id=min_age-textfield]').type('{backspace}{backspace}{backspace}{backspace}{backspace}') cy.contains('This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') // make sure errors in other tabs disable the write button cy.get('[role=tablist]').contains('Locality').click() cy.get('[id=write-button]').should('be.disabled') - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') }) it('write button is disabled if unvisited tab has validation errors', () => { @@ -116,12 +116,12 @@ describe('Creating a new locality', () => { // Age tab has no errors, but Locality tab has unfilled mandatory fields cy.get('[id=write-button]').should('be.disabled') - cy.contains('6 Invalid fields') + cy.contains('6 invalid fields') cy.get('[id=min_age-textfield-helper-text]').should('not.exist') cy.get('[id=max_age-textfield-helper-text]').should('not.exist') cy.get('[role=tablist]').contains('Locality').click() cy.get('[id=write-button]').should('be.disabled') - cy.contains('6 Invalid fields') + cy.contains('6 invalid fields') }) it('composite dating method works', () => { @@ -233,7 +233,7 @@ describe('Editing a locality', () => { cy.get('[id=max_age-textfield]').type('{backspace}{backspace}{backspace}{backspace}{backspace}9') cy.contains('Min value cannot be higher than max') cy.get('[id=write-button]').should('be.disabled') - cy.contains('4 Invalid fields') + cy.contains('4 invalid fields') }) it('changing fractions and basis for age updates the age correctly', () => { diff --git a/cypress/e2e/reference.cy.js b/cypress/e2e/reference.cy.js index 7034dab9..0a0817a5 100644 --- a/cypress/e2e/reference.cy.js +++ b/cypress/e2e/reference.cy.js @@ -10,7 +10,7 @@ describe('Creating a journal', () => { it('with valid data works', () => { cy.visit('/reference/new') cy.contains('Journal') - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=title_primary-textfield]').type('New test reference') @@ -31,20 +31,20 @@ describe('Creating a journal', () => { it('with missing required fields does not work', () => { cy.visit('/reference/new') cy.contains('Journal') - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=title_primary-textfield]').type('New test reference 2') - cy.contains('3 Invalid fields') + cy.contains('3 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[data-cy=Select\\ author-button]').click() cy.get('[data-cy=detailview-button-1]').click() cy.contains('Close').click() - cy.contains('2 Invalid fields') + cy.contains('2 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[id=date_primary-textfield]').type('2025') - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') cy.get('[id=write-button]').should('be.disabled') cy.get('[data-cy=Select\\ Journal-button]').click() @@ -63,31 +63,31 @@ describe('Creating a journal', () => { it('combined check with different types of titles and gen notes works', () => { cy.visit('/reference/new') cy.contains('Journal') - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_primary-textfield]').type('Title Primary') - cy.contains('3 Invalid fields') + cy.contains('3 invalid fields') cy.get('[id=title_primary-textfield]').clear() - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_secondary-textfield]').type('Title Secondary') - cy.contains('3 Invalid fields') + cy.contains('3 invalid fields') cy.get('[id=title_secondary-textfield]').clear() - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_series-textfield]').type('Title Series') - cy.contains('3 Invalid fields') + cy.contains('3 invalid fields') cy.get('[id=title_series-textfield]').clear() - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[id=gen_notes-textfield]').type('Gen Notes') - cy.contains('3 Invalid fields') + cy.contains('3 invalid fields') cy.get('[id=gen_notes-textfield]').clear() - cy.contains('7 Invalid fields') + cy.contains('7 invalid fields') cy.get('[id=write-button]').should('be.disabled') }) }) @@ -122,13 +122,13 @@ describe('Editing a journal', () => { cy.contains('New primary title.') cy.get('[id=edit-button]').click() cy.get('[id=title_primary-textfield]').clear() - cy.contains('4 Invalid fields') + cy.contains('4 invalid fields') cy.get('[id=write-button]').should('be.disabled') cy.get('[id=title_primary-textfield]').type('New primary title.') cy.get('[data-testid=RemoveCircleOutlineIcon]').first().click() cy.get('[data-testid=RemoveCircleOutlineIcon]').first().click() // removes the selected authors - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') cy.get('[id=write-button]').should('be.disabled') cy.get('[data-cy=Select\\ author-button]').click() cy.get('[data-cy=detailview-button-1]').click() diff --git a/cypress/e2e/species.cy.js b/cypress/e2e/species.cy.js index 9eae87ca..cdb62933 100644 --- a/cypress/e2e/species.cy.js +++ b/cypress/e2e/species.cy.js @@ -28,7 +28,7 @@ describe('Creating a species', () => { cy.visit('/species/new') cy.contains('This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('4 Invalid fields') + cy.contains('4 invalid fields') }) }) @@ -72,18 +72,18 @@ describe('Editing a species', () => { cy.get('[id=order_name-textfield]').clear() cy.contains('Order: This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') cy.get('[id=family_name-textfield]').clear() cy.contains('Family: This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('2 Invalid fields') + cy.contains('2 invalid fields') cy.get('[id=order_name-textfield]').type('newOrder') cy.contains('Order: This field is required').should('not.exist') cy.contains('Family: This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') cy.get('[id=family_name-textfield]').type('newFamily') cy.contains('Family: This field is required').should('not.exist') diff --git a/cypress/e2e/timeBound.cy.js b/cypress/e2e/timeBound.cy.js index 2392cc4e..4099711f 100644 --- a/cypress/e2e/timeBound.cy.js +++ b/cypress/e2e/timeBound.cy.js @@ -56,7 +56,7 @@ describe('Editing time bound', () => { cy.get('[id=age-textfield]').first().type('{backspace}{backspace}{backspace}{backspace}{backspace}') cy.contains('This field is required') cy.get('[id=write-button]').should('be.disabled') - cy.contains('1 Invalid fields') + cy.contains('1 invalid field') }) }) diff --git a/frontend/src/components/DetailView/components.tsx b/frontend/src/components/DetailView/components.tsx index f530089d..cc8b5681 100755 --- a/frontend/src/components/DetailView/components.tsx +++ b/frontend/src/components/DetailView/components.tsx @@ -113,6 +113,8 @@ export const ErrorBox = () => { const { fieldsWithErrors } = useDetailContext() const fields = Object.keys(fieldsWithErrors) + const title = fields.length > 1 ? `${fields.length} invalid fields` : '1 invalid field' + return ( () => { }} > - {`${fields.length} Invalid fields`} + {title} {fields.map(field => ( From 46be8d1d165512f08b251d1b3d4fe9b21cdcb9ac Mon Sep 17 00:00:00 2001 From: arttu Date: Wed, 28 May 2025 09:49:26 +0300 Subject: [PATCH 10/18] bug fix on map filtering --- frontend/src/components/Map/LocalitiesMap.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index 7820658a..0dcd7851 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -90,7 +90,7 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } return () => { map.remove() } - }, [localitiesQueryData, localitiesQueryIsFetching, columnFilters]) + }, [localitiesQueryData, localitiesQueryIsFetching, columnFilters?.idList]) document.title = 'Map' From 6e27a86d76c1a8f67ed3474918ebf20a3b9615a5 Mon Sep 17 00:00:00 2001 From: Tepponen Margit H Date: Wed, 28 May 2025 10:11:25 +0300 Subject: [PATCH 11/18] fixed tests --- cypress/e2e/asAdmin.cy.js | 2 -- cypress/e2e/ui.cy.js | 4 ---- 2 files changed, 6 deletions(-) diff --git a/cypress/e2e/asAdmin.cy.js b/cypress/e2e/asAdmin.cy.js index bc2d28ed..00413575 100644 --- a/cypress/e2e/asAdmin.cy.js +++ b/cypress/e2e/asAdmin.cy.js @@ -8,7 +8,6 @@ describe('Open each page, table view and detail view, and check at least some co }) it('Locality works', () => { - cy.contains('Search').click() cy.contains('Localities').click() cy.contains('Dmanisi') cy.get('[data-cy="detailview-button-21050"]').click() @@ -17,7 +16,6 @@ describe('Open each page, table view and detail view, and check at least some co }) it('Species works', () => { - cy.contains('Search').click() cy.contains('Species').click() cy.contains('Rodentia') cy.get('[data-cy="detailview-button-21052"]').first().click() diff --git a/cypress/e2e/ui.cy.js b/cypress/e2e/ui.cy.js index 68c795e6..1d392f4d 100644 --- a/cypress/e2e/ui.cy.js +++ b/cypress/e2e/ui.cy.js @@ -14,7 +14,6 @@ describe('Button Tests', () => { cy.contains('References').should('be.visible') cy.contains('Time Units').should('be.visible') - cy.contains('Search').click() cy.contains('Cross-Search').should('be.visible') cy.contains('Localities').should('be.visible') cy.contains('Species').should('be.visible') @@ -22,7 +21,6 @@ describe('Button Tests', () => { it('Localities button works', () => { cy.visit('/') - cy.contains('Search').click() cy.contains('Localities').click() cy.url().should('include', '/locality') cy.contains('Name').should('be.visible') @@ -33,7 +31,6 @@ describe('Button Tests', () => { it('Species button works', () => { cy.visit('/') - cy.contains('Search').click() cy.contains('Species').click() cy.url().should('include', '/species') cy.contains('Order').should('be.visible') @@ -52,7 +49,6 @@ describe('Button Tests', () => { it('Cross Search button works', () => { cy.visit('/') - cy.contains('Search').click() cy.contains('Cross-Search').click() cy.url().should('include', '/crosssearch') cy.contains('Locality name').should('be.visible') From 3e35a3cd769c7df7e23c80d663acba5155ceff53 Mon Sep 17 00:00:00 2001 From: Laura Kauria Date: Wed, 28 May 2025 10:42:56 +0300 Subject: [PATCH 12/18] added country borders as separate layer to layer control --- frontend/src/components/Map/LocalitiesMap.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index 7820658a..ec6180a3 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -4,7 +4,7 @@ import { borders } from './country_borders_WGS84' import { Button } from '@mui/material' import MapIcon from '@mui/icons-material/Map' -import L, { LatLngExpression, Icon } from 'leaflet' +import L, { LatLngExpression, Icon} from 'leaflet' import { Locality } from '@/shared/types/data.js' import { usePageContext } from '../Page' @@ -23,6 +23,7 @@ interface Props { const markerIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=' + export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching }: Props) => { const mapRef = useRef(null) const [isOpen, setIsOpen] = useState(false) @@ -71,17 +72,30 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } noWrap: true, }) - const baseMaps = { - OpenTopoMap: topomap, - OpenStreetMap: osm, - } - // LAYERS ON TOP OF BASE MAPS //// Add borders to the map borders.forEach(poly => { L.polygon(poly as LatLngExpression[], { color: 'gray', weight: 1 }).addTo(map) }) + // create a polygon layer for the country borders that is in layer control panel + const borderLayer = L.layerGroup(); + borders.forEach(country_border => { + const polygon = L.polygon(country_border, { + color: '#136f94', + fillOpacity: 0.3, + weight: 1 + + }); + borderLayer.addLayer(polygon); + }); + + const baseMaps = { + OpenTopoMap: topomap, + OpenStreetMap: osm, + Countries: borderLayer + } + // Add a scale bar to the map L.control.scale({ position: 'bottomright' }).addTo(map) // Add a layer control to the map From e9334294d3f36fd6c932ef3bcd21029d1f0a93fb Mon Sep 17 00:00:00 2001 From: arttu Date: Wed, 28 May 2025 10:45:28 +0300 Subject: [PATCH 13/18] bug fix on map filtering --- frontend/src/components/Map/LocalitiesMap.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index 0dcd7851..b017ebc7 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -45,7 +45,13 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } const markers: Layer = L.markerClusterGroup() const localityIds = columnFilters.idList as unknown as number[] - const filteredLocalities = localitiesQueryData?.filter(locality => localityIds.includes(locality.lid)) + const validIds = localityIds.filter(id => typeof id === 'number') + + const filteredLocalities = + validIds.length > 0 + ? localitiesQueryData?.filter(locality => localityIds.includes(locality.lid)) + : localitiesQueryData + filteredLocalities?.forEach(locality => markers.addLayer( L.marker([locality.dec_lat, locality.dec_long], { @@ -90,7 +96,7 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } return () => { map.remove() } - }, [localitiesQueryData, localitiesQueryIsFetching, columnFilters?.idList]) + }, [localitiesQueryData, localitiesQueryIsFetching, columnFilters]) document.title = 'Map' From 8afeefe8a897f784f109e79b8b37e34fc062cbd0 Mon Sep 17 00:00:00 2001 From: Laura Kauria Date: Wed, 28 May 2025 10:53:07 +0300 Subject: [PATCH 14/18] test --- frontend/src/components/Map/LocalitiesMap.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index 75f9edc7..cbf53884 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -93,7 +93,7 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } const baseMaps = { OpenTopoMap: topomap, OpenStreetMap: osm, - Countries: borderLayer + Countries: borderLayer, } // Add a scale bar to the map From f8149ee7e2863523f4cdb8d475df1730d800c49d Mon Sep 17 00:00:00 2001 From: Laura Kauria Date: Wed, 28 May 2025 12:04:03 +0300 Subject: [PATCH 15/18] prettier changes for lint --- frontend/src/components/Map/LocalitiesMap.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index cbf53884..fb0df9eb 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -4,7 +4,7 @@ import { borders } from './country_borders_WGS84' import { Button } from '@mui/material' import MapIcon from '@mui/icons-material/Map' -import L, { LatLngExpression, Icon} from 'leaflet' +import L, { LatLngExpression, Icon } from 'leaflet' import { Locality } from '@/shared/types/data.js' import { usePageContext } from '../Page' @@ -23,7 +23,6 @@ interface Props { const markerIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=' - export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching }: Props) => { const mapRef = useRef(null) const [isOpen, setIsOpen] = useState(false) @@ -80,12 +79,11 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } // create a polygon layer for the country borders that is in layer control panel const borderLayer = L.layerGroup(); - borders.forEach(country_border => { + borders.forEach((country_border) => { const polygon = L.polygon(country_border, { - color: '#136f94', - fillOpacity: 0.3, - weight: 1 - + color: "#136f94", + fillOpacity: 0.3, + weight: 1, }); borderLayer.addLayer(polygon); }); @@ -94,7 +92,8 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } OpenTopoMap: topomap, OpenStreetMap: osm, Countries: borderLayer, - } + }; + // Add a scale bar to the map L.control.scale({ position: 'bottomright' }).addTo(map) From b095334fd33ace6cd699e1dc4f8c51d2f4716e78 Mon Sep 17 00:00:00 2001 From: Laura Kauria Date: Wed, 28 May 2025 12:09:23 +0300 Subject: [PATCH 16/18] prettier changes for lint --- .vscode/settings.json | 4 +++- frontend/src/components/Map/LocalitiesMap.tsx | 17 ++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5e17857a..254ce7e8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,7 @@ "eslint.workingDirectories": [ { "directory": "./frontend", "changeProcessCWD": true }, { "directory": "./backend", "changeProcessCWD": true } - ] + ], + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true } diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index fb0df9eb..7e317f7f 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -77,23 +77,22 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } L.polygon(poly as LatLngExpression[], { color: 'gray', weight: 1 }).addTo(map) }) - // create a polygon layer for the country borders that is in layer control panel - const borderLayer = L.layerGroup(); - borders.forEach((country_border) => { + // create a polygon layer for the country borders that is in layer control panel + const borderLayer = L.layerGroup() + borders.forEach(country_border => { const polygon = L.polygon(country_border, { - color: "#136f94", + color: '#136f94', fillOpacity: 0.3, weight: 1, - }); - borderLayer.addLayer(polygon); - }); + }) + borderLayer.addLayer(polygon) + }) const baseMaps = { OpenTopoMap: topomap, OpenStreetMap: osm, Countries: borderLayer, - }; - + } // Add a scale bar to the map L.control.scale({ position: 'bottomright' }).addTo(map) From 18bc5e944332730a0e12018f5a53b87e539c0a27 Mon Sep 17 00:00:00 2001 From: Laura Kauria Date: Wed, 28 May 2025 12:21:40 +0300 Subject: [PATCH 17/18] prettier changes for lint latlongexp --- frontend/src/components/Map/LocalitiesMap.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index 7e317f7f..973b486e 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -80,7 +80,7 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } // create a polygon layer for the country borders that is in layer control panel const borderLayer = L.layerGroup() borders.forEach(country_border => { - const polygon = L.polygon(country_border, { + const polygon = L.polygon(country_border as LatLngExpression[], { color: '#136f94', fillOpacity: 0.3, weight: 1, From 6fb37fb4ff004a6a1b36e5adf0f3b7b2dc8e84b2 Mon Sep 17 00:00:00 2001 From: arttu Date: Wed, 28 May 2025 12:52:35 +0300 Subject: [PATCH 18/18] bug fix on map filtering --- frontend/src/components/Map/LocalitiesMap.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Map/LocalitiesMap.tsx b/frontend/src/components/Map/LocalitiesMap.tsx index b017ebc7..433356a0 100755 --- a/frontend/src/components/Map/LocalitiesMap.tsx +++ b/frontend/src/components/Map/LocalitiesMap.tsx @@ -45,12 +45,13 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching } const markers: Layer = L.markerClusterGroup() const localityIds = columnFilters.idList as unknown as number[] + const filterApplied = localityIds.length > 0 && localityIds.every(id => id === null) + const validIds = localityIds.filter(id => typeof id === 'number') - const filteredLocalities = - validIds.length > 0 - ? localitiesQueryData?.filter(locality => localityIds.includes(locality.lid)) - : localitiesQueryData + const filteredLocalities = !filterApplied + ? localitiesQueryData?.filter(locality => validIds.includes(locality.lid)) + : localitiesQueryData filteredLocalities?.forEach(locality => markers.addLayer(