Skip to content
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
84 changes: 83 additions & 1 deletion cypress/component/MapContent.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,86 @@ ${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('#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) {
if (index >= liCount) return;
// 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')
.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) {
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 (!duplicateTerms.some(item => item.term === term)) {
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,
term,
featureIdCount: featureId.length
});
}
}
});

if (duplicateTerms.length > 0) {
markerFeatureIds.push({
flatmapId,
duplicateTerms
});
}
}
}
});
}
}
}).then(() => {
if (markerFeatureIds.length > 0) {
cy.writeFile('cypress/output/duplicate_marker_feature_ids.json', markerFeatureIds);
}
clickAndProcess(index + 1);
});
}
clickAndProcess(0);
});
})

//Wait for the curie response before continuing
// cy.wait('@categoryResponse');

Expand Down Expand Up @@ -219,7 +299,6 @@ ${publicationLink}`;

cy.get('.multi-container > .el-loading-parent--relative > [name="el-loading-fade"] > .el-loading-mask', {timeout: 60000}).should('not.exist');


//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() {
Expand Down Expand Up @@ -254,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();
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/DynamicMarkerMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const removeDuplicates = function (arrayOfAnything) {
JSON.parse(e)
)
}

/* eslint-disable no-alert, no-console */
export default {
computed: {
Expand Down