diff --git a/src/main/webui/src/app/components/nav/NavFooter.test.jsx b/src/main/webui/src/app/components/nav/NavFooter.test.jsx new file mode 100644 index 0000000..a3c7ce9 --- /dev/null +++ b/src/main/webui/src/app/components/nav/NavFooter.test.jsx @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from "react"; +import {render, screen, cleanup, waitFor} from '@testing-library/react'; +import '@testing-library/jest-dom'; +import NavFooter from "./NavFooter.jsx"; + +afterEach(() => { + cleanup(); +}); + +describe('Footer tests', () => { + it("Verify Footer for elements existing", async ()=>{ + const mockStats = { + version: "3.3.2", + commitId: "f472176", + builder: "test-builder", + timestamp: "2023-10-24 05:54 +0000" + }; + global.fetch = jest.fn(() => Promise.resolve({ + ok: true, + json: () => Promise.resolve(mockStats), + })); + render(); + expect(screen.getByRole("link", {name: "Docs"})).toHaveAttribute("href", "http://commonjava.github.io/indy/"); + expect(screen.getByRole("link", {name: "Issues"})).toHaveAttribute("href", "http://github.com/commonjava/indy/issues"); + await waitFor(()=>{ + expect(screen.getByText(`Version:${mockStats.version}`)).toBeInTheDocument(); + expect(screen.getByRole("link", {name: mockStats.commitId})).toHaveAttribute("href", `http://github.com/commonjava/indy/commit/${mockStats.commitId}`); + expect(screen.getByRole("link", {name: mockStats.builder})).toHaveAttribute("href", `http://github.com/${mockStats.builder}`); + }); + + }); +}); diff --git a/src/main/webui/src/app/components/nav/NavHeader.jsx b/src/main/webui/src/app/components/nav/NavHeader.jsx index f8ec5ff..7a1749c 100644 --- a/src/main/webui/src/app/components/nav/NavHeader.jsx +++ b/src/main/webui/src/app/components/nav/NavHeader.jsx @@ -25,13 +25,7 @@ const isUserloggedIn = true; const username = "mock"; // eslint-disable-next-line max-lines-per-function -export default function IndyNavHeader(){ - // TODO: addons will be render based on the backend addons response, this is a mock; - // const addons=[ - // AutoProx Calculator, - // AutoProx Rules, - // Store Changelogs - // ]; +export default function NavHeader(){ return (