-
-
Notifications
You must be signed in to change notification settings - Fork 829
Remove mx_HeaderButtons
class and add a test
#10713
Conversation
Now that mx_HeaderButtons class is no longer necessary as ARIA "tabpanel" role has been removed from it, it is possible to remove both the class and the style rule for it. Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
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.
Hello. A few comments and some questions (mainly due to a bit of unfamiliarity on my side). The question about how to repeat a check for multiple buttons also applies to some of the later tests in this file.
Thanks for the contribution!
cypress/e2e/room/room-header.spec.ts
Outdated
cy.findByRole("button", { name: "Room options" }).should("be.visible"); | ||
cy.findByRole("button", { name: "Voice call" }).should("be.visible"); | ||
cy.findByRole("button", { name: "Video call" }).should("be.visible"); | ||
cy.findByRole("button", { name: "Search" }).should("be.visible"); | ||
cy.findByRole("button", { name: "Threads" }).should("be.visible"); | ||
cy.findByRole("button", { name: "Notifications" }).should("be.visible"); | ||
cy.findByRole("button", { name: "Room info" }).should("be.visible"); |
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'll preface this comment with saying I'm pretty new to cypress (and specifically the testing-library stuff with it).
To me, it seems that on line 40 we're already doing this test, aren't we? We're grabbing all the buttons, checking there are 7 of them, and I think checking that each thing with the role of button is visible (I could be misunderstanding how chaining a .should
after a findAllBy*
works though).
There may still be value in checking that we have these 7 specific buttons on the page though (ie checking the name of each button).
I've had a look to see if there's a neater way of doing this, nothing leaps out at me from the jest documentation. Perhaps something like:
const expectedButtonNames = [`Room options`...];
for (const name of expectedButtonNames) {
cy.findByRole("button", { name}).should("be.visible");
}
Might make it a bit easier to read. What do you think?
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.
Basically the object of this test is to ensure that just those seven (not six or eight) buttons are rendered by default. This can be achieved by combining findAllBy
query with should(have.length)
by counting the exact number of the all found buttons.
Each findByRole
query does ensure that button whose name is specified exists, but it cannot ensure that there was not another button rendered besides them unexpectedly.
Based on your hint, b20ceec should optimize the readability and the test flow.
cypress/e2e/room/room-header.spec.ts
Outdated
}); | ||
|
||
cy.get(".mx_RoomHeader").percySnapshotElement("Room header", { | ||
widths: [300, 600], // Magic numbers |
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.
Again I'm unfamiliar with percy too - what are these magic numbers for? Are they the widths the snapshots are performed at? How come you chose these values?
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.
Values specified with widths
are used to set custom widths of a snapshot of the chained element. The default values are 1024 and 1920 (both in pixel) specified here on .percy.yml
.
On this case, Percy creates a snapshot of mx_RoomHeader
(mind this is not the whole UI) in 300px and 600px. Similarly, this snapshot was captured in 320px and 640px, in order to emulate the narrow UI.
The custom values are indeed relevant only for Room header - with a long room name
, since the object of the snapshot with overriding the default values should be to emulate the narrow UI and ensure that room name overflow is properly hidden with horizontal ellipsis. I'm going to remove unrelated widths settings.
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.
Addressed with 2922c66.
cypress/e2e/room/room-header.spec.ts
Outdated
cy.get(".mx_RoomHeader_button") | ||
.should("have.length", 3) | ||
.should("be.visible") | ||
.should("have.css", "height", "32px") | ||
.should("have.css", "width", "32px"); | ||
cy.get(".mx_RightPanel_headerButton") // TODO: use the same class name | ||
.should("have.length", 3) | ||
.should("be.visible") | ||
.should("have.css", "height", "32px") | ||
.should("have.css", "width", "32px"); |
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.
How come we have a test for 7 buttons earlier on, but we only check 6 here?
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.
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'm going to add a comment about it. It is indeed confusing.
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.
Addressed with de2dd1c
cypress/e2e/room/room-header.spec.ts
Outdated
|
||
cy.get(".mx_RoomHeader").findByRole("button", { name: "Chat" }).click(); | ||
|
||
// Assert that the video is rnedered |
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.
Tiny typo here in rnedered
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.
Thanks! Fixed with d7a700d
cypress/e2e/room/room-header.spec.ts
Outdated
it("should have a button highlighted by being clicked", () => { | ||
cy.createRoom({ name: "Test Room" }).viewRoomByName("Test Room"); | ||
|
||
cy.findByRole("button", { name: "Room info" }) |
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.
Would we want to test for all buttons here?
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.
Currently only buttons which display content on the right panel by being clicked are highlighted; Thread, Notification, and Room Info, though I am not sure if this is intended or not.
8c9eee1 should address this.
Thanks for the initial review. I'm checking the code to reply to your feedback comments. |
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
|
||
// Assert the size of buttons on RoomHeader are specified and the buttons are not compressed | ||
// Note these assertions do not check the size of mx_RoomHeader_name button | ||
// TODO: merge the assertions by using the same class name |
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.
It will be achieved by #10495.
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 all looks good to me
Thanks for the review! |
The Persy snapshots were taken as expected: https://percy.io/dfde73bd/matrix-react-sdk/builds/27192947/search?searchParam=Room%20header |
https://percy.io/dfde73bd/matrix-react-sdk/builds/27192947/missing This is because the snapshot was renamed to |
Cherry-picked from #10495
This PR intends to remove
mx_HeaderButtons
class and add a test for the room header.Thanks to #10628
mx_HeaderButtons
class is no longer necessary as ARIAtabpanel
role has been removed from the element with that class name, and it is possible to remove both the class and the style rule for it.Here is the cropped screenshot of the DOM tree of
mx_RoomHeader
(mx_RoomHeader_wrapper
) on this PR:Please note that #10628 changed the buttons' ARIA role from
tab
tobutton
and removedrole="tabpanel"
from thediv
element which had wrapped buttons withtab
role, so we no longer need the wrapper.mx_RoomHeader_wrapper
takes care of the placement of the all buttons inside it.With this PR these Percy snapshots are added:
Room header
Room header - with a long room name
Room header - with a highlighted button
Room header - with a video room
Signed-off-by: Suguru Hirahara luixxiul@users.noreply.github.com
type: task
Checklist
This change is marked as an internal change (Task), so will not be included in the changelog.