-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add testing identifier to elements #764
Conversation
@@ -232,10 +232,10 @@ export default memo( | |||
inPublicSharing, | |||
}; | |||
return isMobile ? ( | |||
<DocumentRow {...commonProps} /> | |||
<DocumentRow {...commonProps} testClassId="browser-document-row" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, semantically what i would have done also. But please check because using css selectors makes it easy to find by hierarchy, if there is something else in browser to select, then maybe the browser part should be on it and only document-row here. We can then select just as easily .browser .document-row
and if there's other stuff in the browser, we can reuse that parent class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your idea, but this name has a rule behind, it is combination of component name and element name. Also, it helps to reduce the number of parent classes needed for selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we don't want to reduce the number of parent selectors, and this means:
- we have to repeat multiple times the parent's name
- it's not composable if this is reused in multiple places
- it the parent is repeated then using the hierarchy ensures we get the consistent set of children
- if we don't need the parent in the selector because this isn't reused, repeated, etc ; then there's still no reason to repeat the parent selector on each child
please don't mix parent and child element, the DOM will let us choose how much hierarchy we want to specify and change it easily without changing the code if we need to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is one example to clarify why this is a very bad idea, beyond just having to repeat code, being un-composable, breaching concern separation etc. Imagine we want to read each person in the list:
<li id="person">
<div id="name">name 1</div>
<div id="phone">123</div>
</li>
<li id="person">
<div id="name">name 2</div>
<div id="phone">123</div>
</li>
versus
<li>
<div id="person-name">name 1</div>
<div id="person-phone">123</div>
</li>
<li>
<div id="person-name">name 2</div>
<div id="person-phone">123</div>
</li>
see how much more complicated it would be to figure out which phone number goes with which name ? youd end up walking up and back down the tree and be specific to the html structure.
now imagine we want to reuse the name+phone for companies in another list.
now imagine we want to rename "person" into "employee" you have to change it at multiple places instead of one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because of the size of this PR, and the rapidly increasing risk of conflict, let's merge this for now
Note - at this timestamp just closed the review because the code was updated while it was pending, so I'll restart instead of continuing on the old version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall this is a ton of work well done, my issue is that it was too early/quickly done, and i see testids more as a last resort, only better than using labels/roles or data-test-id. If there's any other reliable way to identify something we should probably do that. I think after the mini fixes we'll take it in, then do a second pass review with QA with actual script test cases etc.
tdrive/frontend/src/app/components/file-uploads/pending-file-components/pending-file-row.tsx
Outdated
Show resolved
Hide resolved
tdrive/frontend/src/app/components/search-popup/parts/result-context.tsx
Outdated
Show resolved
Hide resolved
tdrive/frontend/src/app/views/client/body/drive/modals/confirm-trash/index.tsx
Outdated
Show resolved
Hide resolved
808700b
to
23322f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval to figure this out without the pending huge PR merge since it's benign
33bb909
to
80423d9
Compare
Add testing identifier to elements
How Has This Been Tested?
The test id class names have prefix
testid:
Types of changes
Checklist: