Skip to content

add current step to code changed, run started and run completed events#1327

Merged
rammodhvadia merged 3 commits intomainfrom
event-listeners-add-current-step
Feb 13, 2026
Merged

add current step to code changed, run started and run completed events#1327
rammodhvadia merged 3 commits intomainfrom
event-listeners-add-current-step

Conversation

@rammodhvadia
Copy link
Contributor

This PR adds the currentStepPosition value to the details of the following events:

  • codeChanged
  • runStarted
  • runCompleted

Will be used for reporting on editor usage in projects-ui.

@rammodhvadia rammodhvadia temporarily deployed to previews/1327/merge February 13, 2026 10:36 — with GitHub Actions Inactive
@rammodhvadia rammodhvadia temporarily deployed to previews/1327/merge February 13, 2026 11:23 — with GitHub Actions Inactive
@rammodhvadia rammodhvadia marked this pull request as ready for review February 13, 2026 12:02
Copilot AI review requested due to automatic review settings February 13, 2026 12:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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":{}');
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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":"[^"]+"/);
});

Copilot uses AI. Check for mistakes.
// 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":{}');
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
// 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":{}');
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
cy.get("#results").should("contain", '"errorDetails":{}');
cy.get("#results")
.should("contain", '"errorDetails":{}')
.and("contain", '"step":');

Copilot uses AI. Check for mistakes.
@zetter-rpf
Copy link
Contributor

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 src/components/WebComponentProject/WebComponentProject.test.js that you could extend.

Copy link
Contributor

@zetter-rpf zetter-rpf left a comment

Choose a reason for hiding this comment

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

(see above comment about unit tests)

@zetter-rpf
Copy link
Contributor

Thanks for adding the tests!

@rammodhvadia rammodhvadia merged commit 25dc8d7 into main Feb 13, 2026
7 checks passed
@rammodhvadia rammodhvadia deleted the event-listeners-add-current-step branch February 13, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants