mirror of https://github.com/vector-im/riot-web
Update device-management.spec.ts - use Cypress Testing Library (#10585)
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>pull/28788/head^2
parent
c5de595e79
commit
9b8459e8e9
|
@ -48,74 +48,94 @@ describe("Device manager", () => {
|
|||
|
||||
it("should display sessions", () => {
|
||||
cy.openUserSettings("Sessions");
|
||||
cy.contains("Current session").should("exist");
|
||||
cy.findByText("Current session").should("exist");
|
||||
|
||||
cy.get('[data-testid="current-session-section"]').within(() => {
|
||||
cy.contains("Unverified session").should("exist");
|
||||
cy.findByTestId("current-session-section").within(() => {
|
||||
cy.findByText("Unverified session").should("exist");
|
||||
|
||||
// current session details opened
|
||||
cy.findByRole("button", { name: "Show details" }).click();
|
||||
cy.findByText("Session details").should("exist");
|
||||
|
||||
// close current session details
|
||||
cy.findByRole("button", { name: "Hide details" }).click();
|
||||
cy.findByText("Session details").should("not.exist");
|
||||
});
|
||||
|
||||
// current session details opened
|
||||
cy.get('[data-testid="current-session-toggle-details"]').click();
|
||||
cy.contains("Session details").should("exist");
|
||||
|
||||
// close current session details
|
||||
cy.get('[data-testid="current-session-toggle-details"]').click();
|
||||
cy.contains("Session details").should("not.exist");
|
||||
|
||||
cy.get('[data-testid="security-recommendations-section"]').within(() => {
|
||||
cy.contains("Security recommendations").should("exist");
|
||||
cy.get('[data-testid="unverified-devices-cta"]').should("have.text", "View all (3)").click();
|
||||
cy.findByTestId("security-recommendations-section").within(() => {
|
||||
cy.findByText("Security recommendations").should("exist");
|
||||
cy.findByRole("button", { name: "View all (3)" }).click();
|
||||
});
|
||||
|
||||
/**
|
||||
* Other sessions section
|
||||
*/
|
||||
cy.contains("Other sessions").should("exist");
|
||||
cy.findByText("Other sessions").should("exist");
|
||||
// filter applied after clicking through from security recommendations
|
||||
cy.get('[aria-label="Filter devices"]').should("have.text", "Show: Unverified");
|
||||
cy.get(".mx_FilteredDeviceList_list").find(".mx_FilteredDeviceList_listItem").should("have.length", 3);
|
||||
cy.findByLabelText("Filter devices").should("have.text", "Show: Unverified");
|
||||
cy.get(".mx_FilteredDeviceList_list").within(() => {
|
||||
cy.get(".mx_FilteredDeviceList_listItem").should("have.length", 3);
|
||||
|
||||
// select two sessions
|
||||
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem .mx_Checkbox").first().click();
|
||||
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem .mx_Checkbox").last().click();
|
||||
// select two sessions
|
||||
cy.get(".mx_FilteredDeviceList_listItem")
|
||||
.first()
|
||||
.within(() => {
|
||||
// force click as the input element itself is not visible (its size is zero)
|
||||
cy.findByRole("checkbox").click({ force: true });
|
||||
});
|
||||
cy.get(".mx_FilteredDeviceList_listItem")
|
||||
.last()
|
||||
.within(() => {
|
||||
// force click as the input element itself is not visible (its size is zero)
|
||||
cy.findByRole("checkbox").click({ force: true });
|
||||
});
|
||||
});
|
||||
// sign out from list selection action buttons
|
||||
cy.get('[data-testid="sign-out-selection-cta"]').click();
|
||||
cy.get('[data-testid="dialog-primary-button"]').click();
|
||||
cy.findByRole("button", { name: "Sign out" }).click();
|
||||
cy.get(".mx_Dialog .mx_QuestionDialog").within(() => {
|
||||
cy.findByRole("button", { name: "Sign out" }).click();
|
||||
});
|
||||
// list updated after sign out
|
||||
cy.get(".mx_FilteredDeviceList_list").find(".mx_FilteredDeviceList_listItem").should("have.length", 1);
|
||||
// security recommendation count updated
|
||||
cy.get('[data-testid="unverified-devices-cta"]').should("have.text", "View all (1)");
|
||||
cy.findByRole("button", { name: "View all (1)" });
|
||||
|
||||
const sessionName = `Alice's device`;
|
||||
// open the first session
|
||||
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem")
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.get('[aria-label="Show details"]').click();
|
||||
cy.findByRole("button", { name: "Show details" }).click();
|
||||
|
||||
cy.contains("Session details").should("exist");
|
||||
cy.findByText("Session details").should("exist");
|
||||
|
||||
cy.get('[data-testid="device-heading-rename-cta"]').click();
|
||||
cy.get('[data-testid="device-rename-input"]').type(sessionName);
|
||||
cy.get('[data-testid="device-rename-submit-cta"]').click();
|
||||
cy.findByRole("button", { name: "Rename" }).click();
|
||||
cy.findByTestId("device-rename-input").type(sessionName);
|
||||
cy.findByRole("button", { name: "Save" }).click();
|
||||
// there should be a spinner while device updates
|
||||
cy.get(".mx_Spinner").should("exist");
|
||||
// wait for spinner to complete
|
||||
cy.get(".mx_Spinner").should("not.exist");
|
||||
|
||||
// session name updated in details
|
||||
cy.get(".mx_DeviceDetailHeading h4").should("have.text", sessionName);
|
||||
cy.get(".mx_DeviceDetailHeading h4").within(() => {
|
||||
cy.findByText(sessionName);
|
||||
});
|
||||
// and main list item
|
||||
cy.get(".mx_DeviceTile h4").should("have.text", sessionName);
|
||||
cy.get(".mx_DeviceTile h4").within(() => {
|
||||
cy.findByText(sessionName);
|
||||
});
|
||||
|
||||
// sign out using the device details sign out
|
||||
cy.get('[data-testid="device-detail-sign-out-cta"]').click();
|
||||
cy.findByRole("button", { name: "Sign out of this session" }).click();
|
||||
});
|
||||
// confirm the signout
|
||||
cy.get('[data-testid="dialog-primary-button"]').click();
|
||||
cy.get(".mx_Dialog .mx_QuestionDialog").within(() => {
|
||||
cy.findByRole("button", { name: "Sign out" }).click();
|
||||
});
|
||||
|
||||
// no other sessions or security recommendations sections when only one session
|
||||
cy.contains("Other sessions").should("not.exist");
|
||||
cy.get('[data-testid="security-recommendations-section"]').should("not.exist");
|
||||
cy.findByText("Other sessions").should("not.exist");
|
||||
cy.findByTestId("security-recommendations-section").should("not.exist");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue