diff --git a/.gitignore b/.gitignore index 7b8d95f..d2eed91 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ dist-ssr *.sw? # Point cloud data -/public/pointclouds/ \ No newline at end of file +/public/pointclouds/ + +# Cypress screenshots +/cypress/screenshots/ \ No newline at end of file diff --git a/README.md b/README.md index 625f104..df7e28e 100644 --- a/README.md +++ b/README.md @@ -47,3 +47,19 @@ This application is built using Potree as a package, meaning that the potree bui ### Updating Potree version To update the version of Potree that this application uses you must make a build from the official potree app and replace the build folder here with the new one. There is no guarantee that Molloy Explorer is compatible with other versions of potree. Make sure that everything works on the development server before applying this to the production server. + +## Cypress Testing + +### Run Development Server + +```bash +npm run dev +``` + +### Run Cypress tests + +Then in a new terminal run the tests: + +```bash +npm run test +``` diff --git a/cypress.config.js b/cypress.config.js index dc4f8e6..fc35005 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -5,5 +5,6 @@ export default defineConfig({ setupNodeEvents(on, config) { // implement node event listeners here } - } + }, + trashAssetsBeforeRuns: false }) diff --git a/cypress/e2e/filtering.cy.js b/cypress/e2e/filtering.cy.js index 9443380..2383fee 100644 --- a/cypress/e2e/filtering.cy.js +++ b/cypress/e2e/filtering.cy.js @@ -2,7 +2,7 @@ describe('Accepted filtering', () => { it('test accepted filter button', function () { cy.visit('http://localhost:5173/#') - cy.get('#doAcceptedFilter').click() + cy.get('#doAcceptedFiltering').click() }) }) diff --git a/cypress/e2e/globeRendering.cy.js b/cypress/e2e/globeRendering.cy.js index 9368e8a..cff90e4 100644 --- a/cypress/e2e/globeRendering.cy.js +++ b/cypress/e2e/globeRendering.cy.js @@ -1,5 +1,5 @@ describe('Globe Rendering and Interaction Test', () => { - it('Check that the globe is rendered correctly', () => { + it('Check that the viewer is rendered correctly', () => { cy.visit('http://localhost:5173/#') cy.wait(6000) @@ -12,18 +12,11 @@ describe('Globe Rendering and Interaction Test', () => { }) }) - it('Render the globe and test interactions', () => { + it('Render the globe and test interactions with the globe', () => { cy.visit('http://localhost:5173/#') cy.wait(6000) cy.window({ timeout: 20000 }).its('cesiumViewer').should('exist') cy.get('#cesiumContainer').should('exist') }) - - it('Test interactions', () => { - cy.visit('http://localhost:5173/#') - cy.wait(500) - cy.get('#potree_render_area canvas[tabindex="2222"]').click() - cy.get('#potree_render_area canvas[tabindex="2222"]').click() - }) }) diff --git a/cypress/e2e/measurementTool.cy.js b/cypress/e2e/measurementTool.cy.js new file mode 100644 index 0000000..883f1e7 --- /dev/null +++ b/cypress/e2e/measurementTool.cy.js @@ -0,0 +1,56 @@ +describe('Measurement tool', () => { + it('Places the measurement point', () => { + cy.visit('http://localhost:5173/#') + + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + + // Verify measurement was created + cy.get('#scene_object_properties').should('be.visible') + cy.get('#g_point_body').children().should('have.length.at.least', 1) + }) + + it('Delete measurement point', function () { + cy.visit('http://localhost:5173/#') + + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#scene_object_properties [name="remove"]').click() + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#g_point_body button.m-row-delete').click() + }) + + it('Copy measurement point positions', function () { + cy.visit('http://localhost:5173/#') + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#scene_object_properties [name="copy"]').click() + }) + + it('Switch between measurement points', function () { + cy.visit('http://localhost:5173/#') + // Create three point measurements + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + // Switch between the created points + cy.get('#g_point_body span[title="Point #2"]').click() + cy.get('#g_point_body div:nth-child(1)').click() + cy.get('#g_point_body span[title="Point #3"]').click() + }) + + it('Open and close List of Measurements ', function () { + cy.visit('http://localhost:5173/#') + + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + cy.get('#measurement_items span.m-group-title').click() + cy.get('#measurement_items span.m-group-title').click() + }) +}) diff --git a/cypress/e2e/shadedLighting.cy.js b/cypress/e2e/shadedLighting.cy.js new file mode 100644 index 0000000..04c5222 --- /dev/null +++ b/cypress/e2e/shadedLighting.cy.js @@ -0,0 +1,25 @@ +describe('Shaded Lighting', () => { + it('Toggle the EDL checkbox on and off', () => { + cy.visit('http://localhost:5173/#') + cy.get('#chkEDLEnabled').uncheck().should('not.be.checked') + cy.get('#chkEDLEnabled').check().should('be.checked') + }) + + it('Change radius', function () { + cy.visit('http://localhost:5173/#') + cy.get('div.potree_container').click() + cy.get('#sldEDLRadius span.ui-corner-all').click() + }) + + it('Change strength', function () { + cy.visit('http://localhost:5173/#') + cy.get('#sldEDLStrength span.ui-corner-all').click() + cy.get('#sldEDLStrength span.ui-corner-all').click() + }) + + it('Change opacity', function () { + cy.visit('http://localhost:5173/#') + cy.get('#sldEDLOpacity span.ui-corner-all').click() + cy.get('#sldEDLOpacity span.ui-corner-all').click() + }) +}) diff --git a/package.json b/package.json index 8540e47..2d81034 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "build": "vite build", "preview": "vite preview", "format": "prettier --write .", - "format:check": "prettier --check ." + "format:check": "prettier --check .", + "test": "cypress run --browser chrome" }, "dependencies": { "cors": "^2.8.5",