From 67fb9ea755bfb6f872746416e5136731a8d0ea21 Mon Sep 17 00:00:00 2001 From: akhuoa Date: Mon, 18 Aug 2025 16:23:23 +1200 Subject: [PATCH 1/8] Test duplicate markerids --- cypress/component/MapContent.cy.js | 58 ++++++++++++++++++++++++++++++ src/mixins/DynamicMarkerMixin.js | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index e8e6070d..a1662ec0 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -188,6 +188,63 @@ ${publicationLink}`; cy.get('.search-box.el-autocomplete > .el-input > .el-input__wrapper > .el-input__inner').should('exist').clear(); }) + Cypress.Commands.add('markerFeatureIdsTest', () => { + const markerFeatureIds = []; + cy.get('.el-scrollbar__view.el-select-dropdown__list > li').then($lis => { + const liCount = Cypress.$($lis).filter(':visible').length; + + function clickAndProcess(index) { + // TODO: to fix index issue + if (index >= liCount) return; + cy.get('#flatmap-select').click({force: true}); + cy.get('.el-scrollbar__view.el-select-dropdown__list > li') + .eq(index) + .should('be.visible') + .click(); + + cy.get('.multi-container > .el-loading-parent--relative > [name="el-loading-fade"] > .el-loading-mask', {timeout: 60000}) + .should('not.exist'); + + cy.window().then((win) => { + if (win.Cypress && win.Cypress.vue) { + const cypressVue = win.Cypress.vue; + const markers = cypressVue.settingsStore.globalSettings.displayMarkers ? cypressVue.settingsStore.markers : []; + const splitdialog = cypressVue.$refs.flow.$refs.splitdialog; + + if (splitdialog) { + const activeContents = splitdialog.getActiveContents(); + + activeContents.forEach(content => { + if (content?.$refs['viewer']) { + const contentViewer = content.$refs['viewer']; + const flatmapImp = contentViewer.getFlatmapImp(); + + if (flatmapImp && markers.length) { + let fmMarkers = contentViewer.removeMarkersNotOnFlatmap(flatmapImp, markers); + const flatTerms = fmMarkers.map(t => t.terms).flat(Infinity); + + flatTerms.forEach(term => { + const featureId = flatmapImp.modelFeatureIds(term); + if (featureId.length > 1) { + if (!markerFeatureIds.includes(term)) { + markerFeatureIds.push(term); + } + } + }); + } + } + }); + } + } + }).then(() => { + // TODO: to print out markerFeatureIds + clickAndProcess(index + 1); + }); + } + clickAndProcess(0); + }); + }) + //Wait for the curie response before continuing // cy.wait('@categoryResponse'); @@ -219,6 +276,7 @@ ${publicationLink}`; cy.get('.multi-container > .el-loading-parent--relative > [name="el-loading-fade"] > .el-loading-mask', {timeout: 60000}).should('not.exist'); + cy.markerFeatureIdsTest(); //There is some issue with capture function with Cypress causing the screenshot to be taken incorrectly, //the following attempt to workaround it. diff --git a/src/mixins/DynamicMarkerMixin.js b/src/mixins/DynamicMarkerMixin.js index 31662d9b..fd8ea50f 100644 --- a/src/mixins/DynamicMarkerMixin.js +++ b/src/mixins/DynamicMarkerMixin.js @@ -9,7 +9,7 @@ const removeDuplicates = function (arrayOfAnything) { JSON.parse(e) ) } - + /* eslint-disable no-alert, no-console */ export default { computed: { From c1b7aeb8f463cf12397fb6ade54ffc8bf92a8695 Mon Sep 17 00:00:00 2001 From: akhuoa Date: Tue, 19 Aug 2025 11:27:26 +1200 Subject: [PATCH 2/8] Print output of duplicate markers features testing --- cypress/component/MapContent.cy.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index a1662ec0..c86a6c6f 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -190,13 +190,17 @@ ${publicationLink}`; Cypress.Commands.add('markerFeatureIdsTest', () => { const markerFeatureIds = []; + cy.get('#flatmap-select').click({force: true}); cy.get('.el-scrollbar__view.el-select-dropdown__list > li').then($lis => { const liCount = Cypress.$($lis).filter(':visible').length; function clickAndProcess(index) { - // TODO: to fix index issue if (index >= liCount) return; - cy.get('#flatmap-select').click({force: true}); + // if no visible list items, reopen the dropdown + if (!Cypress.$($lis).eq(index).is(':visible')) { + cy.get('#flatmap-select').click({force: true}); + } + cy.get('.el-scrollbar__view.el-select-dropdown__list > li') .eq(index) .should('be.visible') @@ -237,7 +241,9 @@ ${publicationLink}`; } } }).then(() => { - // TODO: to print out markerFeatureIds + if (markerFeatureIds.length > 0) { + cy.writeFile('cypress/output/duplicate_marker_feature_ids.json', markerFeatureIds); + } clickAndProcess(index + 1); }); } @@ -276,6 +282,7 @@ ${publicationLink}`; cy.get('.multi-container > .el-loading-parent--relative > [name="el-loading-fade"] > .el-loading-mask', {timeout: 60000}).should('not.exist'); + // Testing duplicate marker feature IDs cy.markerFeatureIdsTest(); //There is some issue with capture function with Cypress causing the screenshot to be taken incorrectly, From cf367a8aa3cb0bafcd766a804338c86c06d5d99d Mon Sep 17 00:00:00 2001 From: akhuoa Date: Tue, 19 Aug 2025 11:40:16 +1200 Subject: [PATCH 3/8] Format duplicate marker test output --- cypress/component/MapContent.cy.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index c86a6c6f..6e2b8c47 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -224,17 +224,26 @@ ${publicationLink}`; const flatmapImp = contentViewer.getFlatmapImp(); if (flatmapImp && markers.length) { - let fmMarkers = contentViewer.removeMarkersNotOnFlatmap(flatmapImp, markers); + const flatmapId = flatmapImp.id + const fmMarkers = contentViewer.removeMarkersNotOnFlatmap(flatmapImp, markers); const flatTerms = fmMarkers.map(t => t.terms).flat(Infinity); + const duplicateTerms = []; flatTerms.forEach(term => { const featureId = flatmapImp.modelFeatureIds(term); if (featureId.length > 1) { - if (!markerFeatureIds.includes(term)) { - markerFeatureIds.push(term); + if (!duplicateTerms.includes(term)) { + duplicateTerms.push(term); } } }); + + if (duplicateTerms.length > 0) { + markerFeatureIds.push({ + flatmapId, + duplicateTerms + }); + } } } }); From 89a4fcde6b9d89d88be229a8400c7dfb98c0c144 Mon Sep 17 00:00:00 2001 From: akhuoa Date: Tue, 19 Aug 2025 11:41:15 +1200 Subject: [PATCH 4/8] Update gitignore for cypress test --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 576ab011..ced5a405 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ cypress/results/ cypress/snapshots/ cypress/videos/ cypress/reports/ +cypress/output/ +cypress.env.json test/src/ docs/.vitepress/dist docs/.vitepress/cache From b5e21a996c7867e903b2186ca44890978a9c3af3 Mon Sep 17 00:00:00 2001 From: akhuoa Date: Tue, 19 Aug 2025 11:48:54 +1200 Subject: [PATCH 5/8] Add feature id count in duplicate markers testing --- cypress/component/MapContent.cy.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index 6e2b8c47..2b9e17b7 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -232,8 +232,11 @@ ${publicationLink}`; flatTerms.forEach(term => { const featureId = flatmapImp.modelFeatureIds(term); if (featureId.length > 1) { - if (!duplicateTerms.includes(term)) { - duplicateTerms.push(term); + if (!duplicateTerms.some(item => item.term === term)) { + duplicateTerms.push({ + term, + featureIdCount: featureId.length + }); } } }); From 2e564fd07a383d1fe601efcfc166e72c6adf2bed Mon Sep 17 00:00:00 2001 From: akhuoa Date: Tue, 19 Aug 2025 15:13:14 +1200 Subject: [PATCH 6/8] Add label for duplicate marker test --- cypress/component/MapContent.cy.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index 2b9e17b7..06d51810 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -233,7 +233,15 @@ ${publicationLink}`; const featureId = flatmapImp.modelFeatureIds(term); if (featureId.length > 1) { if (!duplicateTerms.some(item => item.term === term)) { + let termLabel = ''; + flatmapImp.annotations.forEach(annotation => { + if (annotation.models === term) { + termLabel = annotation.label; + } + }); + const label = termLabel.charAt(0).toUpperCase() + termLabel.slice(1); duplicateTerms.push({ + label, term, featureIdCount: featureId.length }); From ec49f1b1728dd0c6a24729bc7332d5b89f253ef6 Mon Sep 17 00:00:00 2001 From: akhuoa Date: Tue, 19 Aug 2025 15:50:58 +1200 Subject: [PATCH 7/8] Update label search in duplicate marker test for better performance --- cypress/component/MapContent.cy.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index 06d51810..921a4239 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -233,12 +233,9 @@ ${publicationLink}`; const featureId = flatmapImp.modelFeatureIds(term); if (featureId.length > 1) { if (!duplicateTerms.some(item => item.term === term)) { - let termLabel = ''; - flatmapImp.annotations.forEach(annotation => { - if (annotation.models === term) { - termLabel = annotation.label; - } - }); + const annotationsArray = Array.from(flatmapImp.annotations.values()); + const foundAnnotation = annotationsArray.find(annotation => annotation.models === term); + const termLabel = foundAnnotation ? foundAnnotation.label : ''; const label = termLabel.charAt(0).toUpperCase() + termLabel.slice(1); duplicateTerms.push({ label, From c9642c30a0b9d2333fb7b8135b946d0a373ecf03 Mon Sep 17 00:00:00 2001 From: akhuoa Date: Wed, 10 Sep 2025 12:35:39 +1200 Subject: [PATCH 8/8] Fix testing for different species and snapshot testing --- cypress/component/MapContent.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cypress/component/MapContent.cy.js b/cypress/component/MapContent.cy.js index 921a4239..92d59b4f 100644 --- a/cypress/component/MapContent.cy.js +++ b/cypress/component/MapContent.cy.js @@ -299,9 +299,6 @@ ${publicationLink}`; cy.get('.multi-container > .el-loading-parent--relative > [name="el-loading-fade"] > .el-loading-mask', {timeout: 60000}).should('not.exist'); - // Testing duplicate marker feature IDs - cy.markerFeatureIdsTest(); - //There is some issue with capture function with Cypress causing the screenshot to be taken incorrectly, //the following attempt to workaround it. function is_high_resolution_screen() { @@ -336,6 +333,9 @@ ${publicationLink}`; cy.checkFlatmapProvenanceCard('Rat', mousePublicationLink); }); + // Testing duplicate marker feature IDs + cy.markerFeatureIdsTest(); + //Search for non existance feature, expect not-found text cy.get('.search-box.el-autocomplete > .el-input > .el-input__wrapper > .el-input__inner').should('exist').type("NON_EXISTANCE"); cy.get('.search-container > .map-icon > use').should('exist').click();