add current step to code changed, run started and run completed events#1327
add current step to code changed, run started and run completed events#1327rammodhvadia merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances three custom events (editor-codeChanged, editor-runStarted, and editor-runCompleted) to include the current step position in their event details. This addition enables the projects-ui to track which step users are on when these events occur, improving analytics and reporting capabilities.
Changes:
- Modified event creator functions to accept and pass detail parameters
- Updated event dispatchers to include current step position from Redux state
- Updated dependency arrays in useEffect hooks to include currentStepPosition
- Adjusted Cypress test assertions to accommodate the new step field in event payloads
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/events/WebComponentCustomEvents.js | Updated codeChangedEvent and runStartedEvent to accept detail parameters, making them consistent with other parameterized events |
| src/components/WebComponentProject/WebComponentProject.jsx | Modified event dispatchers to pass step position, updated useEffect dependencies, and restructured payload objects to include step field |
| cypress/e2e/spec-wc.cy.js | Changed test assertions from exact JSON string matching to substring matching to accommodate the new step field |
| cypress/e2e/spec-wc-block-to-text.cy.js | Updated test assertion to use substring matching for the event payload |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cy.get("button").contains("Run code").click(); | ||
|
|
||
| cy.get("#results").should("contain", '{"errorDetails":{}}'); | ||
| cy.get("#results").should("contain", '"errorDetails":{}'); |
There was a problem hiding this comment.
This test assertion could be more comprehensive by also verifying that the step field is present and has a valid value in the payload. Consider using a more specific assertion that checks for both "errorDetails":{} and "step": to ensure the new functionality is properly tested.
| cy.get("#results").should("contain", '"errorDetails":{}'); | |
| cy.get("#results").should(($el) => { | |
| const text = $el.text(); | |
| expect(text).to.contain('"errorDetails":{}'); | |
| expect(text).to.match(/"step":"[^"]+"/); | |
| }); |
| // Run the code and check it executed without error | ||
| cy.get("editor-wc").shadow().find("button").contains("Run").click(); | ||
| cy.get("#results").should("contain", '{"errorDetails":{}}'); | ||
| cy.get("#results").should("contain", '"errorDetails":{}'); |
There was a problem hiding this comment.
The Cypress tests now check for a substring '"errorDetails":{} instead of the exact JSON string. While this works, the tests could be more comprehensive by also verifying that the step field is present and has a valid value. Consider using a more specific assertion like checking for both "errorDetails":{} and "step": to ensure the new functionality is properly tested.
| // Run the code and check it executed without error | ||
| cy.get("editor-wc").shadow().find("button").contains("Run").click(); | ||
| cy.get("#results").should("contain", '{"errorDetails":{}}'); | ||
| cy.get("#results").should("contain", '"errorDetails":{}'); |
There was a problem hiding this comment.
Similar to the previous test, this assertion could be more comprehensive by also verifying that the step field is present and has a valid value. Consider using a more specific assertion that checks for both "errorDetails":{} and "step": to ensure the new functionality is properly tested.
| cy.get("#results").should("contain", '"errorDetails":{}'); | |
| cy.get("#results") | |
| .should("contain", '"errorDetails":{}') | |
| .and("contain", '"step":'); |
|
Nice one, are you able to add some unit test coverage for the changes? at least one test checking that the step is provided for one of the events would be good. I saw there are existing tests for the events in |
|
Thanks for adding the tests! |
This PR adds the currentStepPosition value to the details of the following events:
Will be used for reporting on editor usage in projects-ui.