-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): re-enable product registration page test
The test for the product registration alert was removed since it’s already covered in its own test file. As with other page tests, mocking the ProductRegistrationAlert component was necessary to prevent the suite from rendering nothing, due to the component getting stuck in the useIssues hook request. An alternative would be to mock the useIssues hook itself, but it requires more mocking for the same result. This is something to improve globally, but outside the scope of this commit.
- Loading branch information
Showing
1 changed file
with
6 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,13 +36,17 @@ const tw: Product = { | |
const sle: Product = { | ||
id: "sle", | ||
name: "SLE", | ||
registration: false, | ||
registration: true, | ||
}; | ||
|
||
let selectedProduct: Product; | ||
let registrationInfoMock: RegistrationInfo; | ||
const registerMutationMock = jest.fn(); | ||
|
||
jest.mock("~/components/product/ProductRegistrationAlert", () => () => ( | ||
<div>ProductRegistrationAlert Mock</div> | ||
)); | ||
|
||
jest.mock("~/queries/software", () => ({ | ||
...jest.requireActual("~/queries/software"), | ||
useRegisterMutation: () => ({ mutate: registerMutationMock }), | ||
|
@@ -55,7 +59,7 @@ jest.mock("~/queries/software", () => ({ | |
}, | ||
})); | ||
|
||
describe.skip("ProductRegistrationPage", () => { | ||
describe("ProductRegistrationPage", () => { | ||
describe("when selected product is not registrable", () => { | ||
beforeEach(() => { | ||
selectedProduct = tw; | ||
|
@@ -74,11 +78,6 @@ describe.skip("ProductRegistrationPage", () => { | |
registrationInfoMock = { key: "", email: "" }; | ||
}); | ||
|
||
it("renders ProductRegistrationAlert component", () => { | ||
installerRender(<ProductRegistrationPage />); | ||
screen.getByText("Warning alert:"); | ||
}); | ||
|
||
it("renders a form to allow user registering the product", async () => { | ||
const { user } = installerRender(<ProductRegistrationPage />); | ||
const registrationCodeInput = screen.getByLabelText("Registration code"); | ||
|
@@ -107,11 +106,6 @@ describe.skip("ProductRegistrationPage", () => { | |
registrationInfoMock = { key: "INTERNAL-USE-ONLY-1234-5678", email: "[email protected]" }; | ||
}); | ||
|
||
it("does not render ProductRegistrationAlert component", () => { | ||
installerRender(<ProductRegistrationPage />); | ||
expect(screen.queryByText("Warning alert:")).toBeNull(); | ||
}); | ||
|
||
it("renders registration information with code partially hidden", async () => { | ||
const { user } = installerRender(<ProductRegistrationPage />); | ||
const visibilityCodeToggler = screen.getByRole("button", { name: "Show" }); | ||
|
@@ -125,42 +119,5 @@ describe.skip("ProductRegistrationPage", () => { | |
expect(screen.queryByText("INTERNAL-USE-ONLY-1234-5678")).toBeNull(); | ||
screen.getByText(/\*?5678/); | ||
}); | ||
|
||
// describe("but at registration path already", () => { | ||
// beforeEach(() => { | ||
// mockRoutes(REGISTRATION.root); | ||
// }); | ||
// | ||
// it("does not render the link to registration", () => { | ||
// installerRender(<ProductRegistrationAlert />); | ||
// screen.getByRole("heading", { | ||
// name: /Warning alert:.*must be registered/, | ||
// }); | ||
// expect(screen.queryAllByRole("link")).toEqual([]); | ||
// }); | ||
// }); | ||
// }); | ||
// | ||
// describe("when product is registrable and registration code is already set", () => { | ||
// beforeEach(() => { | ||
// selectedProduct = sle; | ||
// registrationInfoMock = { key: "INTERNAL-USE-ONLY-1234-5678", email: "" }; | ||
// }); | ||
// | ||
// it("renders nothing", () => { | ||
// const { container } = installerRender(<ProductRegistrationAlert />); | ||
// expect(container).toBeEmptyDOMElement(); | ||
// }); | ||
// }); | ||
// | ||
// describe("when product is not registrable", () => { | ||
// beforeEach(() => { | ||
// selectedProduct = tw; | ||
// }); | ||
// | ||
// it("renders nothing", () => { | ||
// const { container } = installerRender(<ProductRegistrationAlert />); | ||
// expect(container).toBeEmptyDOMElement(); | ||
// }); | ||
}); | ||
}); |