Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Replace data-heap-event with standardized data-test for Cypress and Telemetry #1995

Merged
merged 6 commits into from
Jul 23, 2024

Conversation

rashidakanchwala
Copy link
Contributor

@rashidakanchwala rashidakanchwala commented Jul 23, 2024

Description

This is a major refactor PR that removes all data-heap-event attributes and replaces them with data-test attributes.

I also noticed that our data-test attribute naming was not following any convention. Therefore, in this PR, I have introduced the following naming convention:
< parent component >-< component >-<ui element (button, input, dropdown)>-< state : optional (true/false) >

Development notes

I noticed that sometimes data-test attributes were defined at the UI component level. This caused multiple components using that UI component to have the same data-test attribute. I have changed this so that data-test attributes are now always defined at the component level. In cases where the component is shared, such as the primary toolbar, the data-test attribute is defined at the highest component level.

The state isn't required for Cypress Testing but it is for Heap Analytics. Hence I use 'data-test * =' in Cypress testing so it allows me to match the attribute partially.

QA notes

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

@rashidakanchwala rashidakanchwala changed the title [Draft] Telemetry Introduce naming convention for data-test attributed to be used for Cypress and Telemetry Jul 23, 2024
@rashidakanchwala rashidakanchwala changed the title Introduce naming convention for data-test attributed to be used for Cypress and Telemetry Introduce naming convention for data-test attribute to be used for Cypress and Telemetry Jul 23, 2024
@rashidakanchwala rashidakanchwala changed the title Introduce naming convention for data-test attribute to be used for Cypress and Telemetry Refactor: Replace data-heap-event with standardized data-test for Cypress and Telemetry Jul 23, 2024
@@ -3,7 +3,7 @@
describe('Experiment Tracking Primary Toolbar', () => {
it('verifies that users can hide/show the side menu. #TC-38', () => {
// Alias
cy.get('[data-test="btnToggleMenu"]').as('btnToggleMenu');
cy.get('[data-test*="sidebar-experiments-visible-btn-"]').as('btnToggleMenu');
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey is there a special meaning for *=?

Copy link
Contributor Author

@rashidakanchwala rashidakanchwala Jul 23, 2024

Choose a reason for hiding this comment

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

Good question -- I have added 'state' to the data-test attribute to help with Heap Analytics by indicating whether the sidebar is collapsed or expanded. This information isn't required for Cypress testing. When I use data-test*, it allows me to get the element that partially matches the data-test name.

So the original data-test attribute = sidebar-experiments-visible-btn-true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jitu5 -- see above.

Maybe I need to document this somewhere.

@@ -41,7 +41,7 @@ describe('Experiment Tracking', () => {

// Alias
cy.get('.details-metadata__notes').as('metadataNotes');
Copy link
Contributor

Choose a reason for hiding this comment

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

i wonder how we decide which element to target data-test, which one to target classname ? Cause it seems like we currently mix them both. Maybe not for this ticket but a bigger refactor ticket where we think about what we really want to track etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, data-test is used pervasively to test e2e clicks on Cypress. I am thinking of using the same for Heap. Once we release this PR and start getting better heap data -- we will be able to observe better. For now, it does track all the things that are clickable (or maybe other interactions) by users

cypress/tests/ui/flowchart/panel.cy.js Show resolved Hide resolved
cypress/tests/ui/flowchart/panel.cy.js Show resolved Hide resolved
cypress/tests/ui/flowchart/panel.cy.js Show resolved Hide resolved
@rashidakanchwala rashidakanchwala requested review from jitu5 and Huongg July 23, 2024 14:12
@ravi-kumar-pilla
Copy link
Contributor

Hi @rashidakanchwala , the refactor itself looks great. Since I am not sure on how to validate the telemetry info, i.e., ( whether the expected events are pushing data to the dashboard ), it would be great to have a doc for telemetry (in future) which describes -

  1. What are we collecting as of now
  2. Any gifs or images of the dashboard
  3. How can devs get access to the dev dashboard and test their local instance
  4. How is the data analyzed (may be example queries)
  5. Some use-cases on how the data collected is helpful for the product

Thank you

@ravi-kumar-pilla ravi-kumar-pilla self-requested a review July 23, 2024 15:57
Copy link
Contributor

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Choose a reason for hiding this comment

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

Happy to see a standard for cypress component identification. Great work @rashidakanchwala !!

Since e2e tests are passing and I am not sure on testing the heap events, the refactor looks good to me.

Copy link
Contributor

@Huongg Huongg left a comment

Choose a reason for hiding this comment

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

thank you @rashidakanchwala, all the names changes look good to me, thank you for changing them

also love the idea from @ravi-kumar-pilla to have somewhere to explain about how we're collecting and previewing data

Copy link
Contributor

@jitu5 jitu5 left a comment

Choose a reason for hiding this comment

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

@rashidakanchwala. This is really cool. Thanks for the cleanup.

@rashidakanchwala rashidakanchwala merged commit f8d6464 into main Jul 23, 2024
28 checks passed
@rashidakanchwala rashidakanchwala deleted the telemetry branch July 23, 2024 18:16
@ravi-kumar-pilla ravi-kumar-pilla mentioned this pull request Jul 25, 2024
5 tasks
@Huongg Huongg mentioned this pull request Aug 22, 2024
5 tasks
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.

4 participants