diff --git a/src/__tests__/Explore/Explore.test.js b/src/__tests__/Explore/Explore.test.js index 8568cd73..ac8a0013 100644 --- a/src/__tests__/Explore/Explore.test.js +++ b/src/__tests__/Explore/Explore.test.js @@ -332,7 +332,7 @@ describe('Explore component', () => { it('displays the no data message if no data is received', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: { GlobalSearch: { Repos: [] } } } }); render(); - expect(await screen.findByText(/Looks like/i)).toBeInTheDocument(); + expect(await screen.findByText(/explore.noResults/i)).toBeInTheDocument(); }); it('renders signature icons', async () => { @@ -344,17 +344,17 @@ describe('Explore component', () => { const allUntrustedSignaturesIcons = await screen.findAllByTestId("untrusted-icon"); fireEvent.mouseOver(allUntrustedSignaturesIcons[0]); - expect(await screen.findByText("Signed-by: Unknown")).toBeInTheDocument(); + expect(await screen.findByText("signatureTooltip.signedBy: main.unknown")).toBeInTheDocument(); const allTrustedSignaturesIcons = await screen.findAllByTestId("verified-icon"); fireEvent.mouseOver(allTrustedSignaturesIcons[8]); - expect(await screen.findByText("Tool: cosign")).toBeInTheDocument(); - expect(await screen.findByText("Signed-by: author1")).toBeInTheDocument(); + expect(await screen.findByText("signatureTooltip.tool: cosign")).toBeInTheDocument(); + expect(await screen.findByText("signatureTooltip.signedBy: author1")).toBeInTheDocument(); fireEvent.mouseOver(allTrustedSignaturesIcons[9]); - expect(await screen.findByText("Tool: notation")).toBeInTheDocument(); - expect(await screen.findByText("Signed-by: author2")).toBeInTheDocument(); + expect(await screen.findByText("signatureTooltip.tool: notation")).toBeInTheDocument(); + expect(await screen.findByText("signatureTooltip.signedBy: author2")).toBeInTheDocument(); const allNoSignedIcons = await screen.findAllByTestId("unverified-icon"); fireEvent.mouseOver(allNoSignedIcons[0]); - expect(await screen.findByText("Not signed")).toBeInTheDocument(); + expect(await screen.findByText("signatureTooltip.notSigned")).toBeInTheDocument(); }); it('renders vulnerability icons', async () => { @@ -379,12 +379,12 @@ describe('Explore component', () => { it("should render the sort filter and be able to change it's value", async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageList } }); render(); - const selectFilter = await screen.findByText('Relevance'); + const selectFilter = await screen.findByText('sortCriteria.relevance'); expect(selectFilter).toBeInTheDocument(); userEvent.click(selectFilter); - const newOption = await screen.findByText('Alphabetical'); + const newOption = await screen.findByText('sortCriteria.alphabetical'); userEvent.click(newOption); - expect(await screen.findByText('Alphabetical')).toBeInTheDocument(); + expect(await screen.findByText('sortCriteria.alphabetical')).toBeInTheDocument(); }); it('should get preselected filters and sorting order from query params', async () => { @@ -412,7 +412,7 @@ describe('Explore component', () => { await userEvent.click(windowsCheckbox); expect(windowsCheckbox).toBeChecked(); expect(await screen.findAllByTestId('repo-card')).toHaveLength(1); - const signedCheckboxLabel = await screen.findByText(/signed images/i); + const signedCheckboxLabel = await screen.findByText(/filterConstants.signedImages/i); jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: filteredMockImageListSigned() } }); await userEvent.click(signedCheckboxLabel); expect(await screen.findAllByTestId('repo-card')).toHaveLength(6); diff --git a/src/__tests__/HomePage/Home.test.js b/src/__tests__/HomePage/Home.test.js index 3a5073f0..29c60d43 100644 --- a/src/__tests__/HomePage/Home.test.js +++ b/src/__tests__/HomePage/Home.test.js @@ -288,7 +288,7 @@ describe('Home component', () => { jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockImageListBookmarks } }); jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockImageListStars } }); render(); - const viewAllButtons = await screen.findAllByText(/view all/i); + const viewAllButtons = await screen.findAllByText(/home.viewAll/i); expect(viewAllButtons).toHaveLength(4); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: [] } }); fireEvent.click(viewAllButtons[0]); diff --git a/src/__tests__/LoginPage/SignIn.test.js b/src/__tests__/LoginPage/SignIn.test.js index 7052c078..c611d6f4 100644 --- a/src/__tests__/LoginPage/SignIn.test.js +++ b/src/__tests__/LoginPage/SignIn.test.js @@ -49,8 +49,8 @@ describe('Sign in form', () => { it('should change username and password values on user input', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); fireEvent.change(usernameInput, { target: { value: 'test' } }); fireEvent.change(passwordInput, { target: { value: 'test' } }); expect(usernameInput).toHaveValue('test'); @@ -60,8 +60,8 @@ describe('Sign in form', () => { it('should display error if username and password values are empty after change', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.click(usernameInput); userEvent.type(usernameInput, 't'); userEvent.type(usernameInput, '{backspace}'); @@ -77,13 +77,13 @@ describe('Sign in form', () => { it('should log in the user and navigate to homepage if login is successful using button', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(usernameInput, 'test'); userEvent.type(passwordInput, 'test'); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: {} } }); - const submitButton = await screen.findByText('Continue'); + const submitButton = await screen.findByText('signIn.continue'); fireEvent.click(submitButton); await waitFor(() => { expect(mockedUsedNavigate).toHaveBeenCalledWith('/home'); @@ -93,7 +93,7 @@ describe('Sign in form', () => { it('should display an error if username is blank and login is attempted using button', async () => { render( {}} />); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(passwordInput, 'test'); const submitButton = await screen.findByTestId('basic-auth-submit-btn'); fireEvent.click(submitButton); @@ -108,7 +108,7 @@ describe('Sign in form', () => { it('should display an error if password is blank and login is attempted using button', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); userEvent.type(usernameInput, 'test'); const submitButton = await screen.findByTestId('basic-auth-submit-btn'); fireEvent.click(submitButton); @@ -136,8 +136,8 @@ describe('Sign in form', () => { it('should log in the user and navigate to homepage if login is successful using enter key on username field', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(usernameInput, 'test'); userEvent.type(passwordInput, 'test'); @@ -151,8 +151,8 @@ describe('Sign in form', () => { it('should log in the user and navigate to homepage if login is successful using enter key on password field', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(usernameInput, 'test'); userEvent.type(passwordInput, 'test'); @@ -166,7 +166,7 @@ describe('Sign in form', () => { it('should display an error if username is blank and login is attempted using enter key', async () => { render( {}} />); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(passwordInput, 'test'); userEvent.type(passwordInput, '{enter}'); @@ -180,7 +180,7 @@ describe('Sign in form', () => { it('should display an error if password is blank and login is attempted using enter key', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); userEvent.type(usernameInput, 'test'); userEvent.type(usernameInput, '{enter}'); @@ -194,7 +194,7 @@ describe('Sign in form', () => { it('should display an error if username and password are both blank and login is attempted using enter key', async () => { render( {}} />); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(passwordInput, '{enter}'); await waitFor(() => expect(screen.queryByText(/enter a username/i)).toBeInTheDocument()); @@ -207,18 +207,18 @@ describe('Sign in form', () => { it('should should display login error if login not successful', async () => { render( {}} />); - const usernameInput = await screen.findByLabelText(/^Username/i); - const passwordInput = await screen.findByLabelText(/^Enter Password/i); + const usernameInput = await screen.findByLabelText(/^signIn.username/i); + const passwordInput = await screen.findByLabelText(/^signIn.enterPassword/i); userEvent.type(usernameInput, 'test'); userEvent.type(passwordInput, 'test'); jest.spyOn(api, 'get').mockRejectedValue({ status: 401, data: {} }); - const submitButton = await screen.findByText('Continue'); + const submitButton = await screen.findByText('signIn.continue'); fireEvent.click(submitButton); await waitFor(() => { - expect(screen.queryByText(/Authentication Failed/i)).toBeInTheDocument(); + expect(screen.queryByText(/signIn.authFailed/i)).toBeInTheDocument(); }); await waitFor(() => { expect(mockedUsedNavigate).not.toHaveBeenCalled(); diff --git a/src/__tests__/RepoPage/Repo.test.js b/src/__tests__/RepoPage/Repo.test.js index 98f5b175..c5dfd6e4 100644 --- a/src/__tests__/RepoPage/Repo.test.js +++ b/src/__tests__/RepoPage/Repo.test.js @@ -270,7 +270,7 @@ describe('Repo details component', () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockRepoDetailsWithMissingData } }); render(); expect(await screen.findByText('test')).toBeInTheDocument(); - expect((await screen.findAllByText(/timestamp n\/a/i)).length).toBeGreaterThan(0); + expect((await screen.findAllByText(/main.timestampNA/i)).length).toBeGreaterThan(0); }); it('renders vulnerability icons', async () => { @@ -302,13 +302,13 @@ describe('Repo details component', () => { render(); expect(await screen.findAllByTestId('verified-icon')).toHaveLength(2); - const allTrustedSignaturesIcons = await screen.findAllByTestId("verified-icon"); + const allTrustedSignaturesIcons = await screen.findAllByTestId('verified-icon'); fireEvent.mouseOver(allTrustedSignaturesIcons[0]); - expect(await screen.findByText("Tool: cosign")).toBeInTheDocument(); - expect(await screen.findByText("Signed-by: author1")).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.tool: cosign')).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.signedBy: author1')).toBeInTheDocument(); fireEvent.mouseOver(allTrustedSignaturesIcons[1]); - expect(await screen.findByText("Tool: notation")).toBeInTheDocument(); - expect(await screen.findByText("Signed-by: author2")).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.tool: notation')).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.signedBy: author2')).toBeInTheDocument(); }); it("should log error if data can't be fetched", async () => { diff --git a/src/__tests__/RepoPage/Tags.test.js b/src/__tests__/RepoPage/Tags.test.js index 4d574000..91ba8a51 100644 --- a/src/__tests__/RepoPage/Tags.test.js +++ b/src/__tests__/RepoPage/Tags.test.js @@ -74,9 +74,9 @@ describe('Tags component', () => { render(); const openBtn = screen.getAllByText(/show/i); fireEvent.click(openBtn[0]); - expect(screen.getByText(/OS\/ARCH/i)).toBeInTheDocument(); + expect(screen.getByText(/main.osOrArch/i)).toBeInTheDocument(); fireEvent.click(openBtn[0]); - await waitFor(() => expect(screen.queryByText(/OS\/ARCH/i)).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByText(/main.osOrArch/i)).not.toBeInTheDocument()); }); // it('should see delete tag button and its dialog', async () => { @@ -115,7 +115,7 @@ describe('Tags component', () => { it('should filter tag list based on user input', async () => { render(); - const tagFilterInput = await screen.findByPlaceholderText(/Search Tags/i); + const tagFilterInput = await screen.findByPlaceholderText(/tags.searchTags/i); expect(await screen.findByText(/latest/i)).toBeInTheDocument(); expect(await screen.findByText(/bullseye/i)).toBeInTheDocument(); userEvent.type(tagFilterInput, 'bull'); @@ -125,12 +125,12 @@ describe('Tags component', () => { it('should sort tags based on the picked sort criteria', async () => { render(); - const selectFilter = await screen.findByText('Newest'); + const selectFilter = await screen.findByText('sortCriteria.newest'); expect(selectFilter).toBeInTheDocument(); userEvent.click(selectFilter); - const newOption = await screen.findByText('A - Z'); + const newOption = await screen.findByText('sortCriteria.AZ'); userEvent.click(newOption); - expect(await screen.findByText('A - Z')).toBeInTheDocument(); - expect(await screen.queryByText('Newest')).not.toBeInTheDocument(); + expect(await screen.findByText('sortCriteria.AZ')).toBeInTheDocument(); + expect(await screen.queryByText('sortCriteria.newest')).not.toBeInTheDocument(); }); }); diff --git a/src/__tests__/Shared/RepoCard.test.js b/src/__tests__/Shared/RepoCard.test.js index 2aa201e6..c18adc33 100644 --- a/src/__tests__/Shared/RepoCard.test.js +++ b/src/__tests__/Shared/RepoCard.test.js @@ -87,7 +87,7 @@ describe('Repo card component', () => { expect(cardTitle).toBeInTheDocument(); userEvent.click(cardTitle); expect(mockedUsedNavigate).toBeCalledWith(`/image/${mockImage.name}`); - expect(await screen.findByText(/timestamp n\/a/i)).toBeInTheDocument(); + expect(await screen.findByText(/main.timestampNA/i)).toBeInTheDocument(); }); it('navigates to explore page when platform chip is clicked', async () => { diff --git a/src/__tests__/Shared/SearchSuggestion.test.js b/src/__tests__/Shared/SearchSuggestion.test.js index 6456e30f..ae05f3b0 100644 --- a/src/__tests__/Shared/SearchSuggestion.test.js +++ b/src/__tests__/Shared/SearchSuggestion.test.js @@ -82,7 +82,7 @@ describe('Search component', () => { it('should display suggestions when user searches', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageList } }); render(); - const searchInput = screen.getByPlaceholderText(/search for content/i); + const searchInput = screen.getByPlaceholderText(/searchSuggestion.search/i); expect(searchInput).toBeInTheDocument(); userEvent.type(searchInput, 'test'); expect(await screen.findByText(/alpine/i)).toBeInTheDocument(); @@ -91,7 +91,7 @@ describe('Search component', () => { it('should navigate to repo page when a repo suggestion is clicked', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageList } }); render(); - const searchInput = screen.getByPlaceholderText(/search for content/i); + const searchInput = screen.getByPlaceholderText(/searchSuggestion.search/i); userEvent.type(searchInput, 'test'); const suggestionItemRepo = await screen.findByText(/alpine/i); userEvent.click(suggestionItemRepo); @@ -101,7 +101,7 @@ describe('Search component', () => { it('should navigate to repo page when a image suggestion is clicked', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageList } }); render(); - const searchInput = screen.getByPlaceholderText(/search for content/i); + const searchInput = screen.getByPlaceholderText(/searchSuggestion.search/i); userEvent.type(searchInput, 'debian:test'); const suggestionItemImage = await screen.findByText(/debian:testTag/i); userEvent.click(suggestionItemImage); @@ -112,7 +112,7 @@ describe('Search component', () => { jest.spyOn(api, 'get').mockRejectedValue({ status: 500, data: {} }); const error = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); - const searchInput = screen.getByPlaceholderText(/search for content/i); + const searchInput = screen.getByPlaceholderText(/searchSuggestion.search/i); userEvent.type(searchInput, 'debian'); await waitFor(() => expect(error).toBeCalledTimes(1)); }); @@ -121,7 +121,7 @@ describe('Search component', () => { jest.spyOn(api, 'get').mockRejectedValue({ status: 500, data: {} }); const error = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); - const searchInput = screen.getByPlaceholderText(/search for content/i); + const searchInput = screen.getByPlaceholderText(/searchSuggestion.search/i); userEvent.type(searchInput, 'debian:test'); await waitFor(() => expect(error).toBeCalledTimes(1)); }); diff --git a/src/__tests__/TagPage/DependsOn.test.js b/src/__tests__/TagPage/DependsOn.test.js index f510609a..cf668327 100644 --- a/src/__tests__/TagPage/DependsOn.test.js +++ b/src/__tests__/TagPage/DependsOn.test.js @@ -90,7 +90,7 @@ describe('Dependencies tab', () => { it('should render the dependencies if there are any', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: mockDependenciesList }); render(); - expect(await screen.findAllByText(/Tag/i)).toHaveLength(8); + expect(await screen.findAllByText(/Tag/i)).toHaveLength(16); }); it('renders no dependencies if there are not any', async () => { @@ -99,7 +99,7 @@ describe('Dependencies tab', () => { data: { data: { BaseImageList: { Results: [], Page: {} } } } }); render(); - expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument(); + expect(await screen.findByText(/main.nothingFound/i)).toBeInTheDocument(); }); it("should log an error when data can't be fetched", async () => { @@ -113,6 +113,6 @@ describe('Dependencies tab', () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 500, data: { errors: ['test error'] } }); jest.spyOn(console, 'error').mockImplementation(() => {}); render(); - expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument(); + expect(await screen.findByText(/main.nothingFound/i)).toBeInTheDocument(); }); }); diff --git a/src/__tests__/TagPage/HistoryLayers.test.js b/src/__tests__/TagPage/HistoryLayers.test.js index 8baea02e..e44b5c9c 100644 --- a/src/__tests__/TagPage/HistoryLayers.test.js +++ b/src/__tests__/TagPage/HistoryLayers.test.js @@ -38,7 +38,7 @@ describe('Layers page', () => { it('renders no layers if there are not any', async () => { render(); - await waitFor(() => expect(screen.getAllByText(/No Layer data available/i)).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText(/historyLayers.noLayers/i)).toHaveLength(1)); }); it('opens dropdown and renders layer command and digest', async () => { diff --git a/src/__tests__/TagPage/IsDependentOn.test.js b/src/__tests__/TagPage/IsDependentOn.test.js index 6131579a..47397775 100644 --- a/src/__tests__/TagPage/IsDependentOn.test.js +++ b/src/__tests__/TagPage/IsDependentOn.test.js @@ -90,7 +90,7 @@ describe('Dependents tab', () => { it('should render the dependents if there are any', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: mockDependentsList }); render(); - expect(await screen.findAllByText(/tag/i)).toHaveLength(8); + expect(await screen.findAllByText(/tag/i)).toHaveLength(16); }); it('renders no dependents if there are not any', async () => { @@ -99,7 +99,7 @@ describe('Dependents tab', () => { data: { data: { DerivedImageList: { Results: [], Page: {} } } } }); render(); - expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument(); + expect(await screen.findByText(/main.nothingFound/i)).toBeInTheDocument(); }); it("should log an error when data can't be fetched", async () => { @@ -113,6 +113,6 @@ describe('Dependents tab', () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 500, data: { errors: ['test error'] } }); jest.spyOn(console, 'error').mockImplementation(() => {}); render(); - expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument(); + expect(await screen.findByText(/main.nothingFound/i)).toBeInTheDocument(); }); }); diff --git a/src/__tests__/TagPage/ReferredBy.test.js b/src/__tests__/TagPage/ReferredBy.test.js index 1d7a76c4..fe50e94c 100644 --- a/src/__tests__/TagPage/ReferredBy.test.js +++ b/src/__tests__/TagPage/ReferredBy.test.js @@ -53,12 +53,12 @@ afterEach(() => { describe('Referred by tab', () => { it('should render referrers if there are any', async () => { render(); - expect(await screen.findAllByText('Media type: application/vnd.oci.artifact.manifest.v1+json')).toHaveLength(2); + expect(await screen.findAllByText('referrerCard.mediaType application/vnd.oci.artifact.manifest.v1+json')).toHaveLength(2); }); it("renders no referrers if there aren't any", async () => { render(); - expect(await screen.findByText(/Nothing found/i)).toBeInTheDocument(); + expect(await screen.findByText(/main.nothingFound/i)).toBeInTheDocument(); }); it('should display the digest when clicking the dropdowns', async () => { diff --git a/src/__tests__/TagPage/TagDetails.test.js b/src/__tests__/TagPage/TagDetails.test.js index 9de14cf6..1b30507c 100644 --- a/src/__tests__/TagPage/TagDetails.test.js +++ b/src/__tests__/TagPage/TagDetails.test.js @@ -895,14 +895,14 @@ describe('Tags details', () => { fireEvent.click(dependenciesTab); expect(await screen.findByTestId('depends-on-container')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: mockDependentsList }); - const dependentsTab = await screen.findByText(/used by/i); + const dependentsTab = await screen.findByText(/main.usedBy/i); fireEvent.click(dependentsTab); expect(await screen.findByTestId('dependents-container')).toBeInTheDocument(); jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: mockCVEList }); - const vulnerabilityTab = await screen.findByText(/vulnerabilities/i); + const vulnerabilityTab = await screen.findByText(/main.vulnerabilities/i); fireEvent.click(vulnerabilityTab); expect(await screen.findByTestId('vulnerability-container')).toBeInTheDocument(); - const referrersTab = await screen.findByText(/referred by/i); + const referrersTab = await screen.findByText(/main.referredBy/i); fireEvent.click(referrersTab); jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: [] }); expect(await screen.findByTestId('referred-by-container')).toBeInTheDocument(); @@ -983,17 +983,17 @@ describe('Tags details', () => { const allTrustedSignaturesIcons = await screen.findAllByTestId('verified-icon'); fireEvent.mouseOver(allTrustedSignaturesIcons[0]); - expect(await screen.findByText('Tool: cosign')).toBeInTheDocument(); - expect(await screen.findByText('Signed-by: author1')).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.tool: cosign')).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.signedBy: author1')).toBeInTheDocument(); fireEvent.mouseOver(allTrustedSignaturesIcons[1]); - expect(await screen.findByText('Tool: notation')).toBeInTheDocument(); - expect(await screen.findByText('Signed-by: author2')).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.tool: notation')).toBeInTheDocument(); + expect(await screen.findByText('signatureTooltip.signedBy: author2')).toBeInTheDocument(); }); it('should copy the docker pull string to clipboard', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); render(); - const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); + const dropdown = await screen.findByText(`pullCommandButton.pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); await waitFor(() => expect(screen.queryAllByTestId('pull-menuItem')).toHaveLength(1)); @@ -1009,7 +1009,7 @@ describe('Tags details', () => { it('should copy the podman pull string to clipboard', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); render(); - const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); + const dropdown = await screen.findByText(`pullCommandButton.pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); await waitFor(() => expect(screen.queryAllByTestId('pull-menuItem')).toHaveLength(1)); @@ -1026,7 +1026,7 @@ describe('Tags details', () => { it('should copy the skopeo copy string to clipboard', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } }); render(); - const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); + const dropdown = await screen.findByText(`pullCommandButton.pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); await waitFor(() => expect(screen.queryAllByTestId('pull-menuItem')).toHaveLength(1)); @@ -1043,7 +1043,7 @@ 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(); - const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); + const dropdown = await screen.findByText(`pullCommandButton.pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); userEvent.click(dropdown); await waitFor(() => expect(screen.queryAllByTestId('pull-menuItem')).toHaveLength(1)); @@ -1056,7 +1056,7 @@ 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(); - const dropdown = await screen.findByText(`Pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); + const dropdown = await screen.findByText(`pullCommandButton.pull ${mockImage.Image.RepoName}:${mockImage.Image.Tag}`); expect(dropdown).toBeInTheDocument(); await userEvent.click(dropdown); await waitFor(() => expect(screen.queryAllByTestId('pull-dropdown')).toHaveLength(1)); diff --git a/src/__tests__/TagPage/VulnerabilitiesDetails.test.js b/src/__tests__/TagPage/VulnerabilitiesDetails.test.js index 8c4cab67..b7bf8b08 100644 --- a/src/__tests__/TagPage/VulnerabilitiesDetails.test.js +++ b/src/__tests__/TagPage/VulnerabilitiesDetails.test.js @@ -641,46 +641,46 @@ describe('Vulnerabilties page', () => { it('renders the vulnerabilities if there are any', async () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEList } }); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); - await waitFor(() => expect(screen.getAllByText('Total 5')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('vulnerabilityCountCard.total 5')).toHaveLength(1)); await waitFor(() => expect(screen.getAllByText(/CVE/)).toHaveLength(20)); }); it('renders the vulnerabilities by severity', async () => { jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockCVEList } }); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); - await waitFor(() => expect(screen.getAllByText('Total 5')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('vulnerabilityCountCard.total 5')).toHaveLength(1)); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(20)); - expect(screen.getByLabelText('Medium')).toBeInTheDocument(); - const mediumSeverity = await screen.getByLabelText('Medium'); + expect(screen.getByLabelText('vulnerabilityCountCard.medium')).toBeInTheDocument(); + const mediumSeverity = await screen.getByLabelText('vulnerabilityCountCard.medium'); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEListFilteredBySeverity('MEDIUM') } }); fireEvent.click(mediumSeverity); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(6)); - expect(screen.getByLabelText('High')).toBeInTheDocument(); - const highSeverity = await screen.getByLabelText('High'); + expect(screen.getByLabelText('vulnerabilityCountCard.high')).toBeInTheDocument(); + const highSeverity = await screen.getByLabelText('vulnerabilityCountCard.high'); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEListFilteredBySeverity('HIGH') } }); fireEvent.click(highSeverity); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(1)); - expect(screen.getByLabelText('Critical')).toBeInTheDocument(); - const criticalSeverity = await screen.getByLabelText('Critical'); + expect(screen.getByLabelText('vulnerabilityCountCard.critical')).toBeInTheDocument(); + const criticalSeverity = await screen.getByLabelText('vulnerabilityCountCard.critical'); jest .spyOn(api, 'get') .mockResolvedValue({ status: 200, data: { data: mockCVEListFilteredBySeverity('CRITICAL') } }); fireEvent.click(criticalSeverity); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(1)); - expect(screen.getByLabelText('Low')).toBeInTheDocument(); - const lowSeverity = await screen.getByLabelText('Low'); + expect(screen.getByLabelText('vulnerabilityCountCard.low')).toBeInTheDocument(); + const lowSeverity = await screen.getByLabelText('vulnerabilityCountCard.low'); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEListFilteredBySeverity('LOW') } }); fireEvent.click(lowSeverity); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(10)); - expect(screen.getByLabelText('Unknown')).toBeInTheDocument(); - const unknownSeverity = await screen.getByLabelText('Unknown'); + expect(screen.getByLabelText('main.unknown')).toBeInTheDocument(); + const unknownSeverity = await screen.getByLabelText('main.unknown'); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEListFilteredBySeverity('UNKNOWN') } }); fireEvent.click(unknownSeverity); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(1)); - expect(screen.getByText('Total 5')).toBeInTheDocument(); - const totalSeverity = await screen.getByText('Total 5'); + expect(screen.getByText('vulnerabilityCountCard.total 5')).toBeInTheDocument(); + const totalSeverity = await screen.getByText('vulnerabilityCountCard.total 5'); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEListFilteredBySeverity('') } }); fireEvent.click(totalSeverity); await waitFor(() => expect(screen.getAllByText(/CVE-/)).toHaveLength(20)); @@ -707,8 +707,8 @@ describe('Vulnerabilties page', () => { const cveSearchInput = screen.getByPlaceholderText(/search/i); const expandSearch = cveSearchInput.parentElement.parentElement.parentElement.parentElement.childNodes[0]; await fireEvent.click(expandSearch); - await waitFor(() => expect(screen.getAllByPlaceholderText('Exclude')).toHaveLength(1)); - const excludeInput = screen.getByPlaceholderText('Exclude'); + await waitFor(() => expect(screen.getAllByPlaceholderText('VulnerabilitiesDetails.exclude')).toHaveLength(1)); + const excludeInput = screen.getByPlaceholderText('VulnerabilitiesDetails.exclude'); userEvent.type(excludeInput, '2022'); expect(excludeInput).toHaveValue('2022'); await waitFor(() => expect(screen.queryAllByText(/2022/i)).toHaveLength(0)); @@ -721,7 +721,7 @@ describe('Vulnerabilties page', () => { data: { data: { CVEListForImage: { Tag: '', Page: {}, CVEList: [], Summary: {} } } } }); render(); - await waitFor(() => expect(screen.getAllByText('No Vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText(/VulnerabilitiesDetails.noVulnerabilities/i)).toHaveLength(1)); }); it('should show description for vulnerabilities', async () => { @@ -732,7 +732,7 @@ describe('Vulnerabilties page', () => { render(); const expandListBtn = await screen.findAllByTestId('ViewAgendaIcon'); fireEvent.click(expandListBtn[0]); - await waitFor(() => expect(screen.getAllByText(/Description/)).toHaveLength(20)); + await waitFor(() => expect(screen.getAllByText(/main.description/)).toHaveLength(20)); await waitFor(() => expect(screen.getAllByText(/CPAN 2.28 allows Signature Verification Bypass./i)).toHaveLength(1) ); @@ -752,12 +752,12 @@ describe('Vulnerabilties page', () => { .mockResolvedValueOnce({ status: 200, data: { data: mockCVEFixed.pageOne } }) .mockResolvedValueOnce({ status: 200, data: { data: mockCVEFixed.pageTwo } }); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); const expandListBtn = await screen.findAllByTestId('KeyboardArrowRightIcon'); fireEvent.click(expandListBtn[1]); await waitFor(() => expect(screen.getByText('1.0.16')).toBeInTheDocument()); - await waitFor(() => expect(screen.getAllByText(/Load more/).length).toBe(1)); - const loadMoreBtn = screen.getAllByText(/Load more/)[0]; + await waitFor(() => expect(screen.getAllByText(/vulnerabilityCard.loadMore/).length).toBe(1)); + const loadMoreBtn = screen.getAllByText(/vulnerabilityCard.loadMore/)[0]; await fireEvent.click(loadMoreBtn); await waitFor(() => expect(loadMoreBtn).not.toBeInTheDocument()); expect(await screen.findByText('latest')).toBeInTheDocument(); @@ -813,7 +813,7 @@ describe('Vulnerabilties page', () => { jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEList } }); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); const downloadBtn = await screen.findAllByTestId('DownloadIcon'); fireEvent.click(downloadBtn[0]); expect(await screen.findByTestId('export-csv-menuItem')).toBeInTheDocument(); @@ -840,7 +840,7 @@ describe('Vulnerabilties page', () => { .mockRejectedValue({ status: 500, data: {} }); const error = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); const downloadBtn = await screen.findAllByTestId('DownloadIcon'); fireEvent.click(downloadBtn[0]); expect(await screen.findByTestId('export-csv-menuItem')).toBeInTheDocument(); @@ -851,14 +851,14 @@ describe('Vulnerabilties page', () => { it('should expand/collapse the list of CVEs', async () => { jest.spyOn(api, 'get').mockResolvedValueOnce({ status: 200, data: { data: mockCVEList } }); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockCVEFixed.pageOne } }); const expandListBtn = await screen.findAllByTestId('ViewAgendaIcon'); fireEvent.click(expandListBtn[0]); - await waitFor(() => expect(screen.getAllByText('Fixed in')).toHaveLength(20)); + await waitFor(() => expect(screen.getAllByText('vulnerabilityCard.fixedIn')).toHaveLength(20)); const collapseListBtn = await screen.findAllByTestId('ViewHeadlineIcon'); fireEvent.click(collapseListBtn[0]); - expect(await screen.findByText('Fixed in')).not.toBeVisible(); + expect(await screen.findByText('vulnerabilityCard.fixedIn')).not.toBeVisible(); }); it('should handle fixed CVE query errors', async () => { @@ -867,11 +867,11 @@ describe('Vulnerabilties page', () => { .mockResolvedValueOnce({ status: 200, data: { data: mockCVEList } }) .mockRejectedValue({ status: 500, data: {} }); render(); - await waitFor(() => expect(screen.getAllByText('Vulnerabilities')).toHaveLength(1)); + await waitFor(() => expect(screen.getAllByText('main.vulnerabilities')).toHaveLength(1)); const error = jest.spyOn(console, 'error').mockImplementation(() => {}); const expandListBtn = await screen.findAllByTestId('KeyboardArrowRightIcon'); fireEvent.click(expandListBtn[1]); - await waitFor(() => expect(screen.getByText(/not fixed/i)).toBeInTheDocument()); + await waitFor(() => expect(screen.getByText(/vulnerabilityCard.notFixed/i)).toBeInTheDocument()); await waitFor(() => expect(error).toBeCalledTimes(1)); }); });