From a3d2d03429bc654935e11717d8d1c33d65258747 Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 20 Oct 2025 12:31:24 +0200 Subject: [PATCH 1/9] test(#37): :test_tube: Write test for sprint 1 code --- cypress/e2e/shadedLighting.cy.js | 25 ++++++++++++++++ cypress/e2e/viewAttribute.cy.js | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 cypress/e2e/shadedLighting.cy.js create mode 100644 cypress/e2e/viewAttribute.cy.js diff --git a/cypress/e2e/shadedLighting.cy.js b/cypress/e2e/shadedLighting.cy.js new file mode 100644 index 0000000..40ead6f --- /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() + cy.get('#chkEDLEnabled').check() + }) + + 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/cypress/e2e/viewAttribute.cy.js b/cypress/e2e/viewAttribute.cy.js new file mode 100644 index 0000000..3edae8b --- /dev/null +++ b/cypress/e2e/viewAttribute.cy.js @@ -0,0 +1,50 @@ +describe('View Attribute', () => { + it('Places the view attribute', () => { + 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() + }) + + it('Delete view attribute ', 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 attribute 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 attributes ', 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('#tools img[data-i18n="[title]tt.point_measurement"]').click() + cy.get('#potree_render_area canvas[tabindex="2222"]').click() + 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() + }) +}) From dc9f0a6f24c3b1dd3e72948f5a949496269e7a01 Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 10:05:39 +0100 Subject: [PATCH 2/9] test(#37): :test_tube: Make test for sprint 1 code Make tests for testable interactions in the application for code from sprint 1 --- cypress/e2e/filtering.cy.js | 2 +- cypress/e2e/globeRendering.cy.js | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) 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..7c8586f 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,7 +12,7 @@ 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) @@ -20,10 +20,4 @@ describe('Globe Rendering and Interaction Test', () => { 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() - }) }) From b5a3798e77d98c2a1ddb20dfc8a13de939098637 Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 10:11:15 +0100 Subject: [PATCH 3/9] docs(#37): :memo: Update readme to explain how to run cypress tests --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 625f104..9d0e231 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 +npx cypress run +``` From fb1333e182c45db2f2108bc24c7682e4e8991f8b Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 10:13:36 +0100 Subject: [PATCH 4/9] refactor(#37): :recycle: run prettier --- README.md | 4 ++-- cypress/e2e/globeRendering.cy.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d0e231..b972540 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,6 @@ This application is built using Potree as a package, meaning that the potree bui 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 @@ -57,7 +56,8 @@ To update the version of Potree that this application uses you must make a build npm run dev ``` -### Run Cypress tests +### Run Cypress tests + Then in a new terminal run the tests: ```bash diff --git a/cypress/e2e/globeRendering.cy.js b/cypress/e2e/globeRendering.cy.js index 7c8586f..cff90e4 100644 --- a/cypress/e2e/globeRendering.cy.js +++ b/cypress/e2e/globeRendering.cy.js @@ -19,5 +19,4 @@ describe('Globe Rendering and Interaction Test', () => { cy.window({ timeout: 20000 }).its('cesiumViewer').should('exist') cy.get('#cesiumContainer').should('exist') }) - }) From 38c08d37b49b14dd58bba9f50eb6c38a41650677 Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 11:10:16 +0100 Subject: [PATCH 5/9] refactor(#37): :recycle: add verifications for tests --- cypress/e2e/shadedLighting.cy.js | 4 ++-- cypress/e2e/viewAttribute.cy.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/shadedLighting.cy.js b/cypress/e2e/shadedLighting.cy.js index 40ead6f..04c5222 100644 --- a/cypress/e2e/shadedLighting.cy.js +++ b/cypress/e2e/shadedLighting.cy.js @@ -1,8 +1,8 @@ describe('Shaded Lighting', () => { it('Toggle the EDL checkbox on and off', () => { cy.visit('http://localhost:5173/#') - cy.get('#chkEDLEnabled').uncheck() - cy.get('#chkEDLEnabled').check() + cy.get('#chkEDLEnabled').uncheck().should('not.be.checked') + cy.get('#chkEDLEnabled').check().should('be.checked') }) it('Change radius', function () { diff --git a/cypress/e2e/viewAttribute.cy.js b/cypress/e2e/viewAttribute.cy.js index 3edae8b..bc69bf6 100644 --- a/cypress/e2e/viewAttribute.cy.js +++ b/cypress/e2e/viewAttribute.cy.js @@ -4,6 +4,10 @@ describe('View Attribute', () => { cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() cy.get('#potree_render_area canvas[tabindex="2222"]').click() + + // Verify attribute was created + cy.get('#scene_object_properties').should('be.visible') + cy.get('#g_point_body').children().should('have.length.at.least', 1) }) it('Delete view attribute ', function () { @@ -26,12 +30,14 @@ describe('View Attribute', () => { it('Switch between attributes ', 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() From 1bb2606c5750e4730d0dcb45d323fffbd5b60f0c Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 11:12:23 +0100 Subject: [PATCH 6/9] refactor(#37): add git ignore for cypress screenshots and add test specification under scripts --- .gitignore | 5 ++++- package-lock.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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/package-lock.json b/package-lock.json index 1bb01a8..1897644 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3,6 +3,7 @@ "version": "0.0.0", "lockfileVersion": 3, "requires": true, + "test": "cypress run --browser chrome", "packages": { "": { "name": "molloyexplorer", From 7a197e46d2fc67613de3a2daabe35e0c219d0de3 Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 11:15:38 +0100 Subject: [PATCH 7/9] refactor(#37): :recycle: move test specification from package-lock.sjon to package.json and update readme --- README.md | 2 +- package-lock.json | 1 - package.json | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b972540..df7e28e 100644 --- a/README.md +++ b/README.md @@ -61,5 +61,5 @@ npm run dev Then in a new terminal run the tests: ```bash -npx cypress run +npm run test ``` diff --git a/package-lock.json b/package-lock.json index 1897644..1bb01a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3,7 +3,6 @@ "version": "0.0.0", "lockfileVersion": 3, "requires": true, - "test": "cypress run --browser chrome", "packages": { "": { "name": "molloyexplorer", 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", From 8a16a71e48aea3a386250f8bbd043d7651e384ef Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 11:19:36 +0100 Subject: [PATCH 8/9] refactor(#37): change file name from viewAttribute to measurementTool --- .../{viewAttribute.cy.js => measurementTool.cy.js} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename cypress/e2e/{viewAttribute.cy.js => measurementTool.cy.js} (88%) diff --git a/cypress/e2e/viewAttribute.cy.js b/cypress/e2e/measurementTool.cy.js similarity index 88% rename from cypress/e2e/viewAttribute.cy.js rename to cypress/e2e/measurementTool.cy.js index bc69bf6..883f1e7 100644 --- a/cypress/e2e/viewAttribute.cy.js +++ b/cypress/e2e/measurementTool.cy.js @@ -1,16 +1,16 @@ -describe('View Attribute', () => { - it('Places the view attribute', () => { +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 attribute was created + // 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 view attribute ', function () { + it('Delete measurement point', function () { cy.visit('http://localhost:5173/#') cy.get('#tools img[data-i18n="[title]tt.point_measurement"]').click() @@ -21,14 +21,14 @@ describe('View Attribute', () => { cy.get('#g_point_body button.m-row-delete').click() }) - it('Copy attribute positions ', function () { + 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 attributes ', function () { + 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() From 9311ba8163f51a9bebba3b3c8427a51d8306bebf Mon Sep 17 00:00:00 2001 From: Kleinc Date: Mon, 27 Oct 2025 11:52:54 +0100 Subject: [PATCH 9/9] refactor(#37): :recycle: Add specification to remove warning about trashing results --- cypress.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 })