From 82995118454e5b8762231476cca4ede21980fea9 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 08:51:02 -0500 Subject: [PATCH 01/11] fix: wrap report unit case in act util --- resources/js/Components/Report.test.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index 281a19d04..7bb69a17c 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -11,7 +11,7 @@ import NftFactory from "@/Tests/Factories/Nfts/NftFactory"; import UserDataFactory from "@/Tests/Factories/UserDataFactory"; import WalletFactory from "@/Tests/Factories/Wallet/WalletFactory"; import { getSampleMetaMaskState } from "@/Tests/SampleData/SampleMetaMaskState"; -import { mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; +import { act, mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; let routerSpy: SpyInstance; let useAuthorizedActionSpy: SpyInstance; @@ -132,13 +132,15 @@ describe("Report", () => { it("show report modal on load", () => { const collection = new CollectionDetailDataFactory().create(); - render( - , - ); + act(() => { + render( + , + ); + }); expect(screen.getByTestId("ReportModal")).toBeInTheDocument(); }); From d229bb53eb2b6b348ff78717464843f65bacf0c8 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 08:56:24 -0500 Subject: [PATCH 02/11] wip --- resources/js/Components/Report.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index 7bb69a17c..c9136f5ee 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -11,7 +11,8 @@ import NftFactory from "@/Tests/Factories/Nfts/NftFactory"; import UserDataFactory from "@/Tests/Factories/UserDataFactory"; import WalletFactory from "@/Tests/Factories/Wallet/WalletFactory"; import { getSampleMetaMaskState } from "@/Tests/SampleData/SampleMetaMaskState"; -import { act, mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; +import { mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; +import { act } from "@testing-library/react-hooks"; let routerSpy: SpyInstance; let useAuthorizedActionSpy: SpyInstance; From 348f9c601a5e222a68ded5aa7d4b4782aa3926f6 Mon Sep 17 00:00:00 2001 From: patricio0312rev Date: Thu, 2 Nov 2023 13:57:50 +0000 Subject: [PATCH 03/11] style: resolve linting violations --- resources/js/Components/Report.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index c9136f5ee..f79c9bf14 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -1,4 +1,5 @@ import { router } from "@inertiajs/react"; +import { act } from "@testing-library/react-hooks"; import { t } from "i18next"; import React from "react"; import { expect, type SpyInstance } from "vitest"; @@ -12,7 +13,6 @@ import UserDataFactory from "@/Tests/Factories/UserDataFactory"; import WalletFactory from "@/Tests/Factories/Wallet/WalletFactory"; import { getSampleMetaMaskState } from "@/Tests/SampleData/SampleMetaMaskState"; import { mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; -import { act } from "@testing-library/react-hooks"; let routerSpy: SpyInstance; let useAuthorizedActionSpy: SpyInstance; From 7c270d7d68c295798ca76509e4b47ee1ad4260c5 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 09:08:45 -0500 Subject: [PATCH 04/11] wip --- resources/js/Components/Report.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index f79c9bf14..829b78389 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -130,11 +130,11 @@ describe("Report", () => { expect(screen.queryByTestId("ReportModal")).not.toBeInTheDocument(); }); - it("show report modal on load", () => { + it("show report modal on load", async () => { const collection = new CollectionDetailDataFactory().create(); - act(() => { - render( + await act(async () => { + await render( Date: Thu, 2 Nov 2023 09:13:32 -0500 Subject: [PATCH 05/11] fix: make test async and wrap it in act util from testing libraryg --- resources/js/Components/Report.test.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index 829b78389..4ed48b2cd 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -1,5 +1,4 @@ import { router } from "@inertiajs/react"; -import { act } from "@testing-library/react-hooks"; import { t } from "i18next"; import React from "react"; import { expect, type SpyInstance } from "vitest"; @@ -12,7 +11,7 @@ import NftFactory from "@/Tests/Factories/Nfts/NftFactory"; import UserDataFactory from "@/Tests/Factories/UserDataFactory"; import WalletFactory from "@/Tests/Factories/Wallet/WalletFactory"; import { getSampleMetaMaskState } from "@/Tests/SampleData/SampleMetaMaskState"; -import { mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; +import { act, mockAuthContext, render, screen, userEvent } from "@/Tests/testing-library"; let routerSpy: SpyInstance; let useAuthorizedActionSpy: SpyInstance; From a0fce9dff16769642763ec876a7d18f029308a11 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 09:27:52 -0500 Subject: [PATCH 06/11] fix: remove await from render method --- resources/js/Components/Report.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index 4ed48b2cd..ab7158014 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -132,8 +132,8 @@ describe("Report", () => { it("show report modal on load", async () => { const collection = new CollectionDetailDataFactory().create(); - await act(async () => { - await render( + await act(() => { + render( Date: Thu, 2 Nov 2023 09:30:59 -0500 Subject: [PATCH 07/11] wip --- resources/js/Components/Report.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index ab7158014..94c438f30 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -132,7 +132,7 @@ describe("Report", () => { it("show report modal on load", async () => { const collection = new CollectionDetailDataFactory().create(); - await act(() => { + await act(() => render( { show={true} />, ); - }); + ); expect(screen.getByTestId("ReportModal")).toBeInTheDocument(); }); From 2482c17c3abf1420832c0298d9e8402ace722863 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 09:33:22 -0500 Subject: [PATCH 08/11] wip --- resources/js/Components/Report.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index 94c438f30..b60996ac8 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -139,7 +139,7 @@ describe("Report", () => { modelType={"collection"} show={true} />, - ); + ) ); expect(screen.getByTestId("ReportModal")).toBeInTheDocument(); From 2f3d7de45a9382538a022226afa9dcc0b9d0cd07 Mon Sep 17 00:00:00 2001 From: patricio0312rev Date: Thu, 2 Nov 2023 14:34:39 +0000 Subject: [PATCH 09/11] style: resolve style guide violations --- resources/js/Components/Report.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index b60996ac8..d0a82e57c 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -139,7 +139,7 @@ describe("Report", () => { modelType={"collection"} show={true} />, - ) + ), ); expect(screen.getByTestId("ReportModal")).toBeInTheDocument(); From 7ba4abda7a674c2aac0785a80672eaefec48b043 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 09:38:47 -0500 Subject: [PATCH 10/11] wip --- resources/js/Components/Report.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index b60996ac8..ff473fe35 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -130,7 +130,6 @@ describe("Report", () => { }); it("show report modal on load", async () => { - const collection = new CollectionDetailDataFactory().create(); await act(() => render( @@ -141,6 +140,7 @@ describe("Report", () => { />, ) ); + const collection = new CollectionDetailDataFactory().create(); expect(screen.getByTestId("ReportModal")).toBeInTheDocument(); }); From 07b5d52b912a23095f9eaa1970fec70d47e7cc10 Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 2 Nov 2023 09:39:14 -0500 Subject: [PATCH 11/11] refactor: wrap render method correctly --- resources/js/Components/Report.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Components/Report.test.tsx b/resources/js/Components/Report.test.tsx index ff473fe35..b60996ac8 100644 --- a/resources/js/Components/Report.test.tsx +++ b/resources/js/Components/Report.test.tsx @@ -130,6 +130,7 @@ describe("Report", () => { }); it("show report modal on load", async () => { + const collection = new CollectionDetailDataFactory().create(); await act(() => render( @@ -140,7 +141,6 @@ describe("Report", () => { />, ) ); - const collection = new CollectionDetailDataFactory().create(); expect(screen.getByTestId("ReportModal")).toBeInTheDocument(); });