From 56c7ffb54553f5ff9f8c418d44bd239d959960ad Mon Sep 17 00:00:00 2001 From: Robert Gabriel Macalintal Date: Mon, 23 Dec 2024 15:23:12 -0500 Subject: [PATCH] Migrated object-store/object/external-resource-view.test.tsx to RTL --- .../metadata/__tests__/revisions.test.tsx | 4 ---- .../object/external-resource-view.test.tsx | 16 ++++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/dina-ui/page-tests/object-store/metadata/__tests__/revisions.test.tsx b/packages/dina-ui/page-tests/object-store/metadata/__tests__/revisions.test.tsx index 7a247462e0..5e9564ee0f 100644 --- a/packages/dina-ui/page-tests/object-store/metadata/__tests__/revisions.test.tsx +++ b/packages/dina-ui/page-tests/object-store/metadata/__tests__/revisions.test.tsx @@ -1,9 +1,7 @@ import { mountWithAppContext2 } from "../../../../test-util/mock-app-context"; import MetadataRevisionListPage from "../../../../pages/object-store/metadata/revisions"; import { DefaultRow } from "../../../../../common-ui/lib"; -import { fireEvent, screen } from "@testing-library/react"; import "@testing-library/jest-dom"; -import userEvent from "@testing-library/user-event"; const TEST_SNAPSHOTS = [ { @@ -56,8 +54,6 @@ describe("MetadataRevisionListPage", () => { // Await metadata query: await new Promise(setImmediate); - screen.logTestingPlaygroundURL(); - // Renders the title: expect( wrapper.getByRole("heading", { name: /revisions for my\-image\.png/i }) diff --git a/packages/dina-ui/page-tests/object-store/object/external-resource-view.test.tsx b/packages/dina-ui/page-tests/object-store/object/external-resource-view.test.tsx index 4331a6d9ae..00a7fbf608 100644 --- a/packages/dina-ui/page-tests/object-store/object/external-resource-view.test.tsx +++ b/packages/dina-ui/page-tests/object-store/object/external-resource-view.test.tsx @@ -1,7 +1,8 @@ import { PersistedResource } from "kitsu"; import ExternalResourceMetadataViewPage from "../../../../dina-ui/pages/object-store/object/external-resource-view"; -import { mountWithAppContext } from "../../../../dina-ui/test-util/mock-app-context"; +import { mountWithAppContext2 } from "../../../../dina-ui/test-util/mock-app-context"; import { Metadata } from "../../../../dina-ui/types/objectstore-api/resources/Metadata"; +import "@testing-library/jest-dom"; const TEST_METADATA: PersistedResource = { acSubtype: "TEST_SUBTYPE", @@ -55,20 +56,23 @@ jest.mock("next/router", () => ({ describe("Stored Object external resource view page", () => { it("Renders the page.", async () => { - const wrapper = mountWithAppContext(, { + const wrapper = mountWithAppContext2(, { apiContext }); await new Promise(setImmediate); - wrapper.update(); // Shows the caption - expect(wrapper.contains("test caption")).toBeTruthy(); + expect( + wrapper.getByRole("cell", { name: /test caption/i }) + ).toBeInTheDocument(); // Shows the resource URL - expect(wrapper.contains("http://agr.gc.ca")).toEqual(true); + expect( + wrapper.getByRole("cell", { name: /http:\/\/agr\.gc\.ca/i }) + ).toBeInTheDocument(); // Shows the media format: - expect(wrapper.contains("jpeg")).toEqual(true); + expect(wrapper.getByRole("cell", { name: /jpeg/i })).toBeInTheDocument(); }); });