Skip to content

37 test sprint 1 code #45

Merged
merged 10 commits into from
Oct 27, 2025
Merged

37 test sprint 1 code #45

merged 10 commits into from
Oct 27, 2025

Conversation

kleinc
Copy link
Member

@kleinc kleinc commented Oct 27, 2025

Issue number

Closes 37

Description

Made tests for interactions on the applications made under sprint 1.

Testing steps

See readme for a guide on how to run tests

Screenshots (optional)

Summary by CodeRabbit

  • Documentation

    • Added a "Cypress Testing" subsection to the README with run instructions.
  • Tests

    • Added end-to-end tests for Shaded Lighting and Measurement Tool interactions.
    • Updated existing test suites and test descriptions to improve clarity.
  • Chores

    • Added an npm "test" script to run Cypress in Chrome.
    • Updated ignore rules to exclude Cypress artifacts.

@kleinc kleinc self-assigned this Oct 27, 2025
@kleinc kleinc linked an issue Oct 27, 2025 that may be closed by this pull request
@coderabbit
Copy link

coderabbit bot commented Oct 27, 2025

Walkthrough

Adds Cypress end-to-end tests and test tooling: two new test suites (shaded lighting, measurement tool), updates and renames in existing Cypress tests, a new Cypress config flag, a npm "test" script, .gitignore update, and README instructions for running Cypress.

Changes

Cohort / File(s) Change Summary
New Cypress test suites
cypress/e2e/shadedLighting.cy.js, cypress/e2e/measurementTool.cy.js
Adds end-to-end tests for Shaded Lighting UI (EDL toggles and parameters) and Measurement Tool (create/delete/copy/switch measurements, toggle list visibility).
Updated Cypress tests
cypress/e2e/filtering.cy.js, cypress/e2e/globeRendering.cy.js
Changes selector in filtering test from #doAcceptedFilter#doAcceptedFiltering; renames globeRendering test descriptions and removes a redundant interaction test.
Cypress configuration & scripts
cypress.config.js, package.json
Adds trashAssetsBeforeRuns: false to Cypress config and adds "test": "cypress run --browser chrome" npm script.
Repo metadata and docs
README.md, .gitignore
Adds "Cypress Testing" subsection with run instructions to README; updates .gitignore to include /cypress/screenshots/ and normalizes /public/pointclouds/ entry.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer / CI
  participant Cypress as Cypress Runner
  participant Browser as Chrome
  participant App as Dev Server (http://localhost:5173)
  note over Cypress,Browser #DDEBF7: Test orchestration
  Dev->>Cypress: npm run test (cypress run --browser chrome)
  Cypress->>Browser: launch & load test spec
  Browser->>App: GET / (navigate to http://localhost:5173/#)
  App->>Browser: Render UI (Potree viewer, controls)
  Browser->>App: UI interactions (clicks, toggles, input)
  App->>Browser: DOM updates / visual changes
  Browser->>Cypress: assertions (visible, count, state)
  Cypress->>Dev: exit code / artifacts (screenshots on failure)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect selectors and stability of UI interactions in shadedLighting.cy.js and measurementTool.cy.js.
  • Validate selector change in filtering.cy.js matches application DOM.
  • Confirm trashAssetsBeforeRuns placement and test script correctness.
  • Check .gitignore entry and README instructions for accuracy.

Possibly related PRs

  • 8 point filtering #39 — Related: updates to Accepted Filtering UI that correspond to the selector change (#doAcceptedFilter#doAcceptedFiltering).

Suggested reviewers

  • adriahso
  • mariewah

Poem

🐰 I hopped through tests both bright and clear,

toggled lights and measured here and there,
screenshots saved and scripts set to run,
Cypress trails beneath the sun—
a rabbit's cheer for testing done!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The PR title "37 test sprint 1 code" does relate to the changeset, which involves adding Cypress end-to-end tests and testing infrastructure for sprint 1 work. However, the title is vague and generic, relying primarily on the issue number and non-descriptive terms like "sprint 1 code" without clearly conveying what specific aspects are being tested or what the main technical change entails. A reader scanning the commit history would struggle to understand the primary purpose beyond it being test-related work for sprint 1. Consider using a more descriptive title that clearly indicates the primary change, such as "Add Cypress E2E tests for sprint 1 features" or "Add Cypress E2E tests for filtering, rendering, and measurement tools." This would provide better clarity about what testing infrastructure is being added without requiring readers to look into the PR details.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description follows the required template structure and includes all mandatory sections. The issue number (37) is clearly referenced with "Closes 37," a concise description explains that tests for sprint 1 application interactions were added, and testing steps appropriately point to the README guidance. The optional screenshots section is omitted without issue. The description is sufficiently complete and on-topic, providing the essential information needed to understand the PR's purpose.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 37-test-sprint-1-code

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a16a71 and 9311ba8.

📒 Files selected for processing (1)
  • cypress.config.js (1 hunks)
🔇 Additional comments (1)
cypress.config.js (1)

8-9: Verify that preserving test artifacts between runs is intentional.

The syntax and placement are correct. Setting trashAssetsBeforeRuns: false prevents Cypress from cleaning up screenshots and videos before each test run, which can be helpful for debugging by preserving historical test artifacts.

Consider whether this behavior aligns with your workflow:

  • Local development: Preserving artifacts can aid debugging but may accumulate over time
  • CI/CD: Typically less of a concern if the workspace is cleaned between pipeline runs
  • Disk space: Monitor for artifact accumulation in local environments

If this is intentional, consider adding a comment explaining the rationale:

   },
+  // Preserve test artifacts (screenshots, videos) between runs for debugging
   trashAssetsBeforeRuns: false

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbit coderabbit bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (10)
cypress/e2e/filtering.cy.js (2)

1-7: Consider adding assertions to verify filtering behavior.

The test only clicks the filtering button without verifying the expected outcome. Consider adding assertions to check that filtering was actually applied or that the UI state changed as expected.

Example:

 describe('Accepted filtering', () => {
   it('test accepted filter button', function () {
     cy.visit('http://localhost:5173/#')
+    cy.get('#doAcceptedFiltering').should('exist')
     cy.get('#doAcceptedFiltering').click()
+    // Add assertion to verify filtering was applied
+    cy.get('#doAcceptedFiltering').should('have.class', 'active')
   })
 })

9-24: Add assertions to verify elevation control changes.

The test clicks various elevation controls but doesn't verify that the elevation settings actually changed. Consider adding assertions to check the applied elevation values or visible changes.

cypress/e2e/shadedLighting.cy.js (3)

1-25: Optimize with beforeEach and configure baseUrl.

The URL http://localhost:5173/# is repeated in every test. Consider:

  1. Adding a baseUrl to cypress.config.js
  2. Using a beforeEach hook to avoid repetition

Apply this pattern:

 describe('Shaded Lighting', () => {
+  beforeEach(() => {
+    cy.visit('/')
+  })
+
   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()
   })
   // ... remaining tests
 })

Then configure baseUrl in cypress.config.js:

{
  e2e: {
    baseUrl: 'http://localhost:5173'
  }
}

1-25: Add assertions to verify EDL setting changes.

The tests interact with EDL controls but don't verify that the settings actually changed. Consider adding assertions to check:

  • Checkbox state after toggle
  • Slider values after adjustment
  • Visual changes if applicable

Example:

   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')
   })

8-12: Container click may be fragile - consider adding context.

Clicking div.potree_container without a specific coordinate or context might produce inconsistent results depending on what's rendered in the container. Consider adding a comment explaining why this click is necessary, or use a more specific interaction if possible.

cypress/e2e/globeRendering.cy.js (1)

15-21: Consider adding assertions for interaction verification.

The test verifies that the viewer and container exist but doesn't actually test any interactions with the globe. Consider adding user interactions (e.g., camera movements, clicks) and assertions to verify they work correctly.

Example:

   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')
+    
+    // Test interaction: click on the globe
+    cy.get('#cesiumContainer canvas').click(400, 300)
+    // Verify camera position changed or other interaction effect
   })
cypress/e2e/viewAttribute.cy.js (4)

9-9: Remove trailing spaces from test descriptions.

Several test descriptions have trailing spaces that should be removed for consistency.

Apply this diff:

-  it('Delete view attribute ', function () {
+  it('Delete view attribute', function () {
 
-  it('Copy attribute positions ', function () {
+  it('Copy attribute positions', function () {
 
-  it('Switch between attributes ', function () {
+  it('Switch between attributes', function () {
 
-  it('Open and close List of Measurements ', function () {
+  it('Open and close List of Measurements', function () {

Also applies to: 20-20, 27-27, 40-40


1-50: Optimize with beforeEach and configure baseUrl.

Similar to the shadedLighting tests, the URL is repeated in every test. Use a beforeEach hook and configure baseUrl in cypress.config.js to reduce duplication.

Apply this pattern:

 describe('View Attribute', () => {
+  beforeEach(() => {
+    cy.visit('/')
+  })
+
   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()
   })
   // ... remaining tests
 })

1-50: Add assertions to verify attribute operations.

The tests interact with view attributes but don't verify the expected outcomes. Consider adding assertions to check:

  • Attribute was created after placement
  • Attribute was removed after deletion
  • Attribute was copied successfully
  • Correct attribute is selected when switching
  • Measurements list visibility state

Example:

   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()
+    // Verify attribute was created
+    cy.get('#scene_object_properties').should('be.visible')
+    cy.get('#g_point_body').children().should('have.length.at.least', 1)
   })

27-38: Complex test flow could benefit from comments.

The "Switch between attributes" test creates three points and then clicks them in a specific sequence. Adding comments explaining the expected behavior would improve test maintainability.

Example:

   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()
   })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f93b94 and fb1333e.

📒 Files selected for processing (5)
  • README.md (1 hunks)
  • cypress/e2e/filtering.cy.js (1 hunks)
  • cypress/e2e/globeRendering.cy.js (2 hunks)
  • cypress/e2e/shadedLighting.cy.js (1 hunks)
  • cypress/e2e/viewAttribute.cy.js (1 hunks)
🔇 Additional comments (3)
README.md (1)

50-65: Excellent documentation for Cypress testing.

The new Cypress Testing section clearly documents how to run the development server and execute tests. The instructions are concise and properly formatted.

cypress/e2e/globeRendering.cy.js (1)

2-2: Test description updates improve clarity.

The renamed test descriptions better reflect what each test validates. "Check that the viewer is rendered correctly" and "Render the globe and test interactions with the globe" are more precise than the previous versions.

Also applies to: 15-15

cypress/e2e/filtering.cy.js (1)

5-5: Selector update verified as correct.

The change to #doAcceptedFiltering is confirmed. The element with this ID is created in src/AcceptedFiltering/threePanels.js (line 266) and the test selector now correctly matches the application's button ID.

Copy link
Member

@gautegf gautegf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the tests fail for me, but as it is technically outside the scope of this issue I will approve

Copy link
Member

@adriahso adriahso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Have some comments.

Can't make a suggestion for the .gitignore as it is not changed, but we should add /cypress/screenshots/ to the .gitignore so that test screenshots are ignored by git.

I also got this error: SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.. Was fixed by running the tests in the chrome browser. We should make a script in package.json so we can just write npm run test instead of npc cypress run. Under scripts, just add "test": "cypress run --browser chrome".

Copy link

@coderabbit coderabbit bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
cypress/e2e/shadedLighting.cy.js (1)

1-25: Extract hardcoded URL to configuration.

The URL http://localhost:5173/# is duplicated across all four tests. Consider using Cypress's baseUrl in your cypress.config.js or extracting it to a constant to improve maintainability.

Example using baseUrl in cypress.config.js:

export default {
  e2e: {
    baseUrl: 'http://localhost:5173'
  }
}

Then update tests to use:

-    cy.visit('http://localhost:5173/#')
+    cy.visit('/#')
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb1333e and 1bb2606.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • cypress/e2e/shadedLighting.cy.js (1 hunks)
  • cypress/e2e/viewAttribute.cy.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cypress/e2e/viewAttribute.cy.js
🔇 Additional comments (1)
.gitignore (1)

29-30: LGTM!

Adding Cypress screenshots to .gitignore is standard practice for excluding test artifacts from version control.

Copy link

@coderabbit coderabbit bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
cypress/e2e/measurementTool.cy.js (1)

6-6: Consider more reliable selectors for the canvas element.

The selector canvas[tabindex="2222"] is unusual and fragile. If the tabindex changes, all tests will break. Consider adding a data-testid attribute to the canvas for more stable test selection.

In your application code:

<canvas data-testid="measurement-canvas" tabindex="2222">

Then in tests:

-cy.get('#potree_render_area canvas[tabindex="2222"]').click()
+cy.get('[data-testid="measurement-canvas"]').click()

Also applies to: 17-17, 20-20, 27-27, 35-35, 37-37, 39-39, 50-50, 52-52

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a197e4 and 8a16a71.

📒 Files selected for processing (1)
  • cypress/e2e/measurementTool.cy.js (1 hunks)
🔇 Additional comments (1)
cypress/e2e/measurementTool.cy.js (1)

2-11: Good test structure with proper assertions.

This test correctly verifies both the visibility of the properties panel and the creation of measurement elements.

Copy link
Member

@adriahso adriahso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding trashAssetsBeforeRuns: false, to cypress.config.js removed another warning I got: Warning: We failed to trash the existing run results..

@kleinc
Copy link
Member Author

kleinc commented Oct 27, 2025

Added the specification now

Copy link
Member

@adriahso adriahso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@kleinc kleinc merged commit 1315491 into dev Oct 27, 2025
2 checks passed
@kleinc kleinc deleted the 37-test-sprint-1-code branch October 27, 2025 11:32
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test sprint 1 code
3 participants