From 326e217d3fc621c365f143138bc4b3b3e2274dd5 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Thu, 27 Apr 2023 18:11:48 +0000 Subject: [PATCH] Enable Jest and Percy snapshots for `PreferencesUserSettingsTab` (#10701) Signed-off-by: Suguru Hirahara --- .../preferences-user-settings-tab.spec.ts | 45 + .../tabs/user/PreferencesUserSettingsTab.tsx | 4 +- .../user/PreferencesUserSettingsTab-test.tsx | 5 + .../PreferencesUserSettingsTab-test.tsx.snap | 1049 +++++++++++++++++ 4 files changed, 1102 insertions(+), 1 deletion(-) create mode 100644 cypress/e2e/settings/preferences-user-settings-tab.spec.ts create mode 100644 test/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap diff --git a/cypress/e2e/settings/preferences-user-settings-tab.spec.ts b/cypress/e2e/settings/preferences-user-settings-tab.spec.ts new file mode 100644 index 0000000000..29fb668de1 --- /dev/null +++ b/cypress/e2e/settings/preferences-user-settings-tab.spec.ts @@ -0,0 +1,45 @@ +/* +Copyright 2023 Suguru Hirahara + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/// + +import { HomeserverInstance } from "../../plugins/utils/homeserver"; + +describe("Preferences user settings tab", () => { + let homeserver: HomeserverInstance; + + beforeEach(() => { + cy.startHomeserver("default").then((data) => { + homeserver = data; + cy.initTestUser(homeserver, "Bob"); + }); + }); + + afterEach(() => { + cy.stopHomeserver(homeserver); + }); + + it("should be rendered properly", () => { + cy.openUserSettings("Preferences"); + + cy.get(".mx_SettingsTab.mx_PreferencesUserSettingsTab").within(() => { + // Assert that the top heading is rendered + cy.findByTestId("preferences").should("have.text", "Preferences").should("be.visible"); + }); + + cy.get(".mx_SettingsTab.mx_PreferencesUserSettingsTab").percySnapshotElement("User settings tab - Preferences"); + }); +}); diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx index 0d8acbca55..4fbb174516 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx @@ -144,7 +144,9 @@ export default class PreferencesUserSettingsTab extends React.Component -
{_t("Preferences")}
+
+ {_t("Preferences")} +
{roomListSettings.length > 0 && (
diff --git a/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx b/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx index 634164338d..88eb1aa1cc 100644 --- a/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx +++ b/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx @@ -33,6 +33,11 @@ describe("PreferencesUserSettingsTab", () => { return render( {}} />); }; + it("should render", () => { + const { asFragment } = renderTab(); + expect(asFragment()).toMatchSnapshot(); + }); + describe("send read receipts", () => { beforeEach(() => { stubClient(); diff --git a/test/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap b/test/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap new file mode 100644 index 0000000000..45340dac36 --- /dev/null +++ b/test/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap @@ -0,0 +1,1049 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PreferencesUserSettingsTab should render 1`] = ` + +
+
+ Preferences +
+
+ + Room list + +
+ +
+
+
+
+
+
+ + Spaces + +
+ +
+
+
+
+
+
+ + Keyboard shortcuts + +
+ + To view all keyboard shortcuts, + + . + +
+
+ +
+
+
+
+
+
+ + Displaying time + +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + Presence + + + Share your activity and status with others. + +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + Composer + +
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + Code blocks + +
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + Images, GIFs and videos + +
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + Timeline + +
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + Room directory + +
+ +
+
+
+
+
+
+ + General + +
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ +`;