diff --git a/package-lock.json b/package-lock.json index 7934777..fb81cd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5954,9 +5954,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001687", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001687.tgz", - "integrity": "sha512-0S/FDhf4ZiqrTUiQ39dKeUjYRjkv7lOZU1Dgif2rIqrTzX/1wV2hfKu9TOm1IHkdSijfLswxTFzl/cvir+SLSQ==", + "version": "1.0.30001688", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001688.tgz", + "integrity": "sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA==", "dev": true, "funding": [ { diff --git a/src/__tests__/TagPage/TagDetails.test.js b/src/__tests__/TagPage/TagDetails.test.js index 9dbea87..ab393c3 100644 --- a/src/__tests__/TagPage/TagDetails.test.js +++ b/src/__tests__/TagPage/TagDetails.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { api } from 'api'; import TagDetails from 'components/Tag/TagDetails'; @@ -889,7 +889,9 @@ afterEach(() => { describe('Tags details', () => { it('should show tabs and allow nagivation between them', async () => { jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: mockDependenciesList }); const dependenciesTab = await screen.findByTestId('dependencies-tab'); fireEvent.click(dependenciesTab); @@ -912,13 +914,17 @@ describe('Tags details', () => { it("should log an error when data can't be fetched", async () => { jest.spyOn(api, 'get').mockRejectedValue({ status: 500, data: {} }); const error = jest.spyOn(console, 'error').mockImplementation(() => {}); - render(); + act(() => { + render(); + }); await waitFor(() => expect(error).toBeCalledTimes(1)); }); it('should show the data of the different manifests when switching between them', async () => { jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); const manifestSelect = await screen.findByText(/linux\/amd64/i); await userEvent.click(manifestSelect); await userEvent.click(await screen.findByText(/windows\/amd64/i)); @@ -930,55 +936,77 @@ describe('Tags details', () => { useLocation.mockImplementation(() => ({ state: { digest: 'sha256:63a795ca90aa6e7cca60941e826810a4cd0a2e73ea02bf458241df2a5c973e25' } })); - render(); + act(() => { + render(); + }); expect(await screen.findByText(/linux\/arm/i)).toBeInTheDocument(); }); it('should redirect to homepage if it receives invalid data', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: null, errors: ['testerror'] } }); - render(); + act(() => { + render(); + }); await waitFor(() => expect(mockUseNavigate).toBeCalledWith('/home')); }); it('should show tag details metadata', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('tagDetailsMetadata-container')).toBeInTheDocument(); }); it('renders vulnerability icons', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('critical-vulnerability-icon')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageNone } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('none-vulnerability-icon')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageUnknown } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('unknown-vulnerability-icon')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageFailed } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('failed-vulnerability-icon')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageLow } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('low-vulnerability-icon')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageMedium } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('medium-vulnerability-icon')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageHigh } }); - render(); + act(() => { + render(); + }); expect(await screen.findByTestId('high-vulnerability-icon')).toBeInTheDocument(); }); it('renders signature icons', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); expect(await screen.findAllByTestId('verified-icon')).toHaveLength(2); const allTrustedSignaturesIcons = await screen.findAllByTestId('verified-icon'); @@ -992,7 +1020,9 @@ describe('Tags details', () => { it('should copy the docker pull string to clipboard', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); @@ -1008,7 +1038,9 @@ describe('Tags details', () => { it('should copy the podman pull string to clipboard', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); @@ -1025,7 +1057,9 @@ describe('Tags details', () => { it('should copy the skopeo copy string to clipboard', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); @@ -1042,7 +1076,9 @@ describe('Tags details', () => { it('should show pull tabs in dropdown and allow nagivation between them', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); @@ -1055,7 +1091,9 @@ describe('Tags details', () => { it('should show the copied successfully button for 3 seconds', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); - render(); + act(() => { + render(); + }); const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); await userEvent.click(dropdown);