diff --git a/client/src/__test__/components/Footer.test.tsx b/client/src/__test__/components/Footer.test.tsx index 42c9af1..fb4e820 100644 --- a/client/src/__test__/components/Footer.test.tsx +++ b/client/src/__test__/components/Footer.test.tsx @@ -1,19 +1,21 @@ import React from 'react'; -import { render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; -import { describe, it, expect, vi } from 'vitest'; +import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'; import authContextMock from '../__mocks__/authContextMock'; import Footer from '../../components/Footer'; import AuthContext from '../../context/AuthContext'; -// Mock necessary dependencies -vi.mock('../../env', () => ({ - env: { - VITE_BUILD: 'test-build', - }, -})); - describe('Footer component test', () => { + beforeAll(() => { + //import.meta.env.VITE_BUILD = ; + vi.stubEnv('VITE_BUILD', 'test-build'); + }); + + afterAll(() => { + vi.unstubAllEnvs(); + }); + it('should renders the footer with current year and build version', () => { render( @@ -27,7 +29,7 @@ describe('Footer component test', () => { const footerText = screen.getByTestId('footer-text'); expect(footerText).toBeDefined(); - expect(footerText.innerHTML).toBe(`TaskNote App ©${currentYear} (test-build)`); + expect(footerText.innerHTML).toBe(`TaskNote App © ${currentYear} (Build test-build)`); }); it('should renders the user email when logged in', () => { @@ -63,8 +65,12 @@ describe('Footer component test', () => { , ); + const logoutButton = getByText('Logout'); - logoutButton.click(); - expect(signOutMock).toHaveBeenCalledTimes(1); + + act(() => { + logoutButton.click(); + expect(signOutMock).toHaveBeenCalledTimes(1); + }); }); }); diff --git a/client/src/assets/landing-bg.jpg b/client/src/assets/landing-bg.jpg new file mode 100644 index 0000000..fccf093 Binary files /dev/null and b/client/src/assets/landing-bg.jpg differ diff --git a/client/src/components/Footer/index.tsx b/client/src/components/Footer/index.tsx index 205e38d..d7b76e6 100644 --- a/client/src/components/Footer/index.tsx +++ b/client/src/components/Footer/index.tsx @@ -3,7 +3,6 @@ import { Button, Col, Container, Row } from 'react-bootstrap'; import { useNavigate } from 'react-router-dom'; -import { env } from '../../env'; import AuthContext from '../../context/AuthContext'; import './style.css'; @@ -11,15 +10,14 @@ import './style.css'; * Footer component. * * This component provides the footer section of the application, - * providing navigation to logout. - * It also includes the build version. + * including logout functionality and version information. * * @returns {JSX.Element} The Footer component. */ function Footer(): JSX.Element { const { signOut, user } = useContext(AuthContext); const navigate = useNavigate(); - const build = env.VITE_BUILD; + const build = import.meta.env.VITE_BUILD; const currentYear = new Date().getFullYear(); const goOut = () => { @@ -31,21 +29,30 @@ function Footer(): JSX.Element {