From 7f89c7c476e41224a5210888195f2b1f6d8e3f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 14 Nov 2023 14:44:24 +0000 Subject: [PATCH] [web] Several improvements from review --- web/src/client/index.js | 18 +++++++-------- web/src/client/software.js | 2 +- web/src/client/software.test.js | 4 ++-- web/src/components/core/EmailInput.test.jsx | 8 +++---- web/src/components/core/SectionSkeleton.jsx | 22 +++++++++---------- .../components/product/ProductPage.test.jsx | 4 ++-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/web/src/client/index.js b/web/src/client/index.js index 96079edcc3..34a656972e 100644 --- a/web/src/client/index.js +++ b/web/src/client/index.js @@ -37,15 +37,15 @@ const MANAGER_SERVICE = "org.opensuse.Agama.Manager1"; /** * @typedef {object} InstallerClient - * @property {LanguageClient} language - language client - * @property {ManagerClient} manager - manager client - * @property {Monitor} monitor - service monitor - * @property {NetworkClient} network - network client - * @property {SoftwareClient} software - software client - * @property {StorageClient} storage - storage client - * @property {UsersClient} users - users client - * @property {QuestionsClient} questions - questions client - * @property {() => Promise} issues - issues from all contexts + * @property {LanguageClient} language - language client. + * @property {ManagerClient} manager - manager client. + * @property {Monitor} monitor - service monitor. + * @property {NetworkClient} network - network client. + * @property {SoftwareClient} software - software client. + * @property {StorageClient} storage - storage client. + * @property {UsersClient} users - users client. + * @property {QuestionsClient} questions - questions client. + * @property {() => Promise} issues - issues from all contexts. * @property {(handler: IssuesHandler) => (() => void)} onIssuesChange - registers a handler to run * when issues from any context change. It returns a function to deregister the handler. * @property {() => Promise} isConnected - determines whether the client is connected diff --git a/web/src/client/software.js b/web/src/client/software.js index 2bb678446c..edec2fcc21 100644 --- a/web/src/client/software.js +++ b/web/src/client/software.js @@ -40,7 +40,7 @@ const REGISTRATION_IFACE = "org.opensuse.Agama1.Registration"; /** * @typedef {object} Registration - * @property {string} requirement - Registration requirement (i.e., "not-required, "optional", + * @property {string} requirement - Registration requirement (i.e., "not-required", "optional", * "mandatory"). * @property {string|null} code - Registration code, if any. * @property {string|null} email - Registration email, if any. diff --git a/web/src/client/software.test.js b/web/src/client/software.test.js index 6c68a69b4e..dfcdaeaed7 100644 --- a/web/src/client/software.test.js +++ b/web/src/client/software.test.js @@ -75,14 +75,14 @@ describe("#product", () => { }); describe("#getRegistration", () => { - describe("if there the product is not registered yet", () => { + describe("if the product is not registered yet", () => { beforeEach(() => { registrationProxy.RegCode = ""; registrationProxy.Email = ""; registrationProxy.Requirement = 1; }); - it("returns the expected registration", async () => { + it("returns the expected registration result", async () => { const client = new SoftwareClient(); const registration = await client.product.getRegistration(); expect(registration).toStrictEqual({ diff --git a/web/src/components/core/EmailInput.test.jsx b/web/src/components/core/EmailInput.test.jsx index 5834ca8a21..0c64ce08b7 100644 --- a/web/src/components/core/EmailInput.test.jsx +++ b/web/src/components/core/EmailInput.test.jsx @@ -36,7 +36,7 @@ describe("EmailInput component", () => { /> ); - const inputField = screen.getByLabelText("User email"); + const inputField = screen.getByRole('textbox', { name: "User email" }); expect(inputField).toHaveAttribute("type", "email"); }); @@ -63,7 +63,7 @@ describe("EmailInput component", () => { it("triggers onChange callback", async () => { const { user } = plainRender(); - const emailInput = screen.getByLabelText("Test email"); + const emailInput = screen.getByRole('textbox', { name: "Test email" }); expect(screen.queryByText("Email value updated!")).toBeNull(); @@ -73,7 +73,7 @@ describe("EmailInput component", () => { it("triggers onValidate callback", async () => { const { user } = plainRender(); - const emailInput = screen.getByLabelText("Test email"); + const emailInput = screen.getByRole('textbox', { name: "Test email" }); expect(screen.queryByText("Email is not valid!")).toBeNull(); @@ -83,7 +83,7 @@ describe("EmailInput component", () => { it("marks the input as invalid if the value is not a valid email", async () => { const { user } = plainRender(); - const emailInput = screen.getByLabelText("Test email"); + const emailInput = screen.getByRole('textbox', { name: "Test email" }); await user.type(emailInput, "foo"); diff --git a/web/src/components/core/SectionSkeleton.jsx b/web/src/components/core/SectionSkeleton.jsx index bc6cf20cda..e34da05402 100644 --- a/web/src/components/core/SectionSkeleton.jsx +++ b/web/src/components/core/SectionSkeleton.jsx @@ -1,5 +1,5 @@ /* - * Copyright (c) [2022] SUSE LLC + * Copyright (c) [2022-2023] SUSE LLC * * All Rights Reserved. * @@ -23,17 +23,17 @@ import React from "react"; import { Skeleton } from "@patternfly/react-core"; import { _ } from "~/i18n"; -const SectionSkeleton = ({ numRows = 2 }) => { - const WaitingSkeleton = ({ width }) => { - return ( - - ); - }; +const WaitingSkeleton = ({ width }) => { + return ( + + ); +}; +const SectionSkeleton = ({ numRows = 2 }) => { return ( <> { diff --git a/web/src/components/product/ProductPage.test.jsx b/web/src/components/product/ProductPage.test.jsx index 8b46818a5c..af2531340a 100644 --- a/web/src/components/product/ProductPage.test.jsx +++ b/web/src/components/product/ProductPage.test.jsx @@ -20,7 +20,7 @@ */ import React from "react"; -import { act, screen, within } from "@testing-library/react"; +import { screen, within } from "@testing-library/react"; import { BUSY } from "~/client/status"; import { installerRender } from "~/test-utils"; @@ -177,7 +177,7 @@ describe("when the services are busy", () => { }); it("shows disabled buttons", async () => { - await act(async () => installerRender()); + installerRender(); const selectButton = await screen.findByRole("button", { name: "Change product" }); const registerButton = screen.getByRole("button", { name: "Register" });