From a5210a3eced1e82b7e79d12a8f7c2997198f23b9 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 20 Sep 2024 08:57:46 -0300 Subject: [PATCH 1/3] remove unused manual cleanups from tests --- src/layouts/BaseLayout/BaseLayout.test.tsx | 3 +-- .../InstallationHelpBanner.test.jsx | 3 +-- src/layouts/BaseLayout/hooks/useUserAccessGate.test.tsx | 3 +-- src/layouts/Header/Header.test.tsx | 3 +-- .../Header/components/AdminLink/AdminLink.test.tsx | 3 +-- .../Header/components/GuestHeader/GuestHeader.test.tsx | 3 +-- .../components/Navigator/MyContextSwitcher.test.tsx | 3 +-- .../Header/components/SeatDetails/SeatDetails.test.tsx | 3 +-- .../Header/components/ThemeToggle/ThemeToggle.test.tsx | 9 +-------- .../Header/components/UserDropdown/UserDropdown.test.tsx | 3 +-- src/layouts/LoginLayout/LoginLayout.test.tsx | 3 +-- 11 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/layouts/BaseLayout/BaseLayout.test.tsx b/src/layouts/BaseLayout/BaseLayout.test.tsx index 5512aadf13..4bcea05a1e 100644 --- a/src/layouts/BaseLayout/BaseLayout.test.tsx +++ b/src/layouts/BaseLayout/BaseLayout.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { graphql, http, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' import { MemoryRouter, Route, useLocation } from 'react-router-dom' @@ -193,7 +193,6 @@ afterEach(() => { queryClient.clear() server.resetHandlers() vi.clearAllMocks() - cleanup() }) afterAll(() => { diff --git a/src/layouts/BaseLayout/InstallationHelpBanner/InstallationHelpBanner.test.jsx b/src/layouts/BaseLayout/InstallationHelpBanner/InstallationHelpBanner.test.jsx index 6a559cbe6d..da6b1deaef 100644 --- a/src/layouts/BaseLayout/InstallationHelpBanner/InstallationHelpBanner.test.jsx +++ b/src/layouts/BaseLayout/InstallationHelpBanner/InstallationHelpBanner.test.jsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { graphql, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' @@ -19,7 +19,6 @@ beforeAll(() => { }) beforeEach(() => { - cleanup() queryClient.clear() server.resetHandlers() }) diff --git a/src/layouts/BaseLayout/hooks/useUserAccessGate.test.tsx b/src/layouts/BaseLayout/hooks/useUserAccessGate.test.tsx index 3bfc94ce0a..d26b931d38 100644 --- a/src/layouts/BaseLayout/hooks/useUserAccessGate.test.tsx +++ b/src/layouts/BaseLayout/hooks/useUserAccessGate.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, renderHook, waitFor } from '@testing-library/react' +import { renderHook, waitFor } from '@testing-library/react' import { delay, graphql, http, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' @@ -221,7 +221,6 @@ beforeAll(() => { }) beforeEach(() => { - cleanup() queryClient.clear() server.resetHandlers() }) diff --git a/src/layouts/Header/Header.test.tsx b/src/layouts/Header/Header.test.tsx index da72163f87..2967bebf50 100644 --- a/src/layouts/Header/Header.test.tsx +++ b/src/layouts/Header/Header.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { graphql, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' @@ -93,7 +93,6 @@ beforeAll(() => { }) afterEach(() => { - cleanup() server.resetHandlers() queryClient.clear() }) diff --git a/src/layouts/Header/components/AdminLink/AdminLink.test.tsx b/src/layouts/Header/components/AdminLink/AdminLink.test.tsx index 14f9f00f9b..d4110817f0 100644 --- a/src/layouts/Header/components/AdminLink/AdminLink.test.tsx +++ b/src/layouts/Header/components/AdminLink/AdminLink.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { http, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' @@ -32,7 +32,6 @@ beforeAll(() => { }) beforeEach(() => { - cleanup() server.resetHandlers() queryClient.clear() }) diff --git a/src/layouts/Header/components/GuestHeader/GuestHeader.test.tsx b/src/layouts/Header/components/GuestHeader/GuestHeader.test.tsx index 609c42f6a9..1f2b1096f5 100644 --- a/src/layouts/Header/components/GuestHeader/GuestHeader.test.tsx +++ b/src/layouts/Header/components/GuestHeader/GuestHeader.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import React from 'react' import { MemoryRouter, Route } from 'react-router-dom' import { type Mock } from 'vitest' @@ -40,7 +40,6 @@ beforeEach(() => { }) afterEach(() => { - cleanup() queryClient.clear() }) diff --git a/src/layouts/Header/components/Navigator/MyContextSwitcher.test.tsx b/src/layouts/Header/components/Navigator/MyContextSwitcher.test.tsx index 1c7dd9bd50..d14c95f98f 100644 --- a/src/layouts/Header/components/Navigator/MyContextSwitcher.test.tsx +++ b/src/layouts/Header/components/Navigator/MyContextSwitcher.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { graphql, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' @@ -59,7 +59,6 @@ beforeAll(() => { }) afterEach(() => { - cleanup() queryClient.clear() server.restoreHandlers() }) diff --git a/src/layouts/Header/components/SeatDetails/SeatDetails.test.tsx b/src/layouts/Header/components/SeatDetails/SeatDetails.test.tsx index d158b490ac..ff8fe76c26 100644 --- a/src/layouts/Header/components/SeatDetails/SeatDetails.test.tsx +++ b/src/layouts/Header/components/SeatDetails/SeatDetails.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { graphql, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' @@ -43,7 +43,6 @@ beforeAll(() => { }) afterEach(() => { - cleanup() server.resetHandlers() queryClient.clear() }) diff --git a/src/layouts/Header/components/ThemeToggle/ThemeToggle.test.tsx b/src/layouts/Header/components/ThemeToggle/ThemeToggle.test.tsx index 6a0ef9294f..210721d84f 100644 --- a/src/layouts/Header/components/ThemeToggle/ThemeToggle.test.tsx +++ b/src/layouts/Header/components/ThemeToggle/ThemeToggle.test.tsx @@ -1,11 +1,5 @@ import * as Sentry from '@sentry/react' -import { - cleanup, - render, - screen, - waitFor, - within, -} from '@testing-library/react' +import { render, screen, waitFor, within } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { ThemeContextProvider } from 'shared/ThemeContext' @@ -33,7 +27,6 @@ describe('ThemeToggle', () => { }) afterEach(() => { - cleanup() vi.clearAllMocks() }) diff --git a/src/layouts/Header/components/UserDropdown/UserDropdown.test.tsx b/src/layouts/Header/components/UserDropdown/UserDropdown.test.tsx index d7fdca0dca..e72d563097 100644 --- a/src/layouts/Header/components/UserDropdown/UserDropdown.test.tsx +++ b/src/layouts/Header/components/UserDropdown/UserDropdown.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { graphql, http, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' @@ -92,7 +92,6 @@ beforeAll(() => { }) afterEach(() => { - cleanup() queryClient.clear() server.resetHandlers() }) diff --git a/src/layouts/LoginLayout/LoginLayout.test.tsx b/src/layouts/LoginLayout/LoginLayout.test.tsx index c0dc61c571..dae4acfeb9 100644 --- a/src/layouts/LoginLayout/LoginLayout.test.tsx +++ b/src/layouts/LoginLayout/LoginLayout.test.tsx @@ -1,5 +1,5 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { cleanup, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { graphql, HttpResponse } from 'msw2' import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' @@ -44,7 +44,6 @@ beforeAll(() => { afterEach(() => { queryClient.clear() server.resetHandlers() - cleanup() vi.clearAllMocks() }) From d3cad7dd82f13f2836fb61742d0da3fa2c366739 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 20 Sep 2024 08:59:34 -0300 Subject: [PATCH 2/3] cleanup cleanup in new tests: --- src/ui/TotalsNumber/TotalsNumber.test.tsx | 6 +----- src/ui/TruncatedMessage/TruncatedMessage.test.tsx | 6 +----- src/ui/TruncatedMessage/hooks/useTruncation.test.ts | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/ui/TotalsNumber/TotalsNumber.test.tsx b/src/ui/TotalsNumber/TotalsNumber.test.tsx index 19a67cdfb6..5278edb4da 100644 --- a/src/ui/TotalsNumber/TotalsNumber.test.tsx +++ b/src/ui/TotalsNumber/TotalsNumber.test.tsx @@ -1,11 +1,7 @@ -import { cleanup, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import TotalsNumber from './TotalsNumber' -afterEach(() => { - cleanup() -}) - describe('TotalsNumber', () => { describe('when rendered', () => { it('renders commit change when there is a valid value', () => { diff --git a/src/ui/TruncatedMessage/TruncatedMessage.test.tsx b/src/ui/TruncatedMessage/TruncatedMessage.test.tsx index 505e04651a..7c0a255e7d 100644 --- a/src/ui/TruncatedMessage/TruncatedMessage.test.tsx +++ b/src/ui/TruncatedMessage/TruncatedMessage.test.tsx @@ -1,4 +1,4 @@ -import { cleanup, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { useTruncation } from './hooks' @@ -6,10 +6,6 @@ import TruncatedMessage from './TruncatedMessage' vi.mock('./hooks') -afterEach(() => { - cleanup() -}) - describe('TruncatedMessage', () => { function setup({ canTruncate = false }) { // @ts-expect-error diff --git a/src/ui/TruncatedMessage/hooks/useTruncation.test.ts b/src/ui/TruncatedMessage/hooks/useTruncation.test.ts index aa1744df20..3ec40af092 100644 --- a/src/ui/TruncatedMessage/hooks/useTruncation.test.ts +++ b/src/ui/TruncatedMessage/hooks/useTruncation.test.ts @@ -1,4 +1,4 @@ -import { cleanup, renderHook } from '@testing-library/react' +import { renderHook } from '@testing-library/react' import { useTruncation } from './useTruncation' @@ -36,10 +36,6 @@ vi.mock('react', async () => { } }) -afterEach(() => { - cleanup() -}) - describe('useTruncation', () => { function setup({ clientHeight = 0, From 6acb7d5ac20925e3dccfa1b34e96da58ae3e8b8f Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 06:24:46 -0400 Subject: [PATCH 3/3] lower the amount of n builds for the time being --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 7c24041679..48617e04e2 100644 --- a/codecov.yml +++ b/codecov.yml @@ -23,7 +23,7 @@ comment: require_changes: false require_base: false require_head: true - after_n_builds: 10 # ceil(number of test files / 80). See ci.yml for more details. + after_n_builds: 9 # ceil(number of test files / 80). See ci.yml for more details. ignore: - ./src/**/*.stories.js