docker builder and test fixes

This commit is contained in:
2026-03-09 12:47:52 +01:00 Verified
parent 0b3f857f50
commit fb3c7bc831
4 changed files with 174 additions and 116 deletions
+39 -4
View File
@@ -1,9 +1,44 @@
// frontend/src/App.test.jsx
import { render } from '@testing-library/react';
import { test } from 'vitest';
import { render, waitFor } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import App from './App';
test('renders the App', () => {
render(<App />);
const localStorageMock = {
getItem: vi.fn(),
setItem: vi.fn(),
removeItem: vi.fn(),
clear: vi.fn(),
theme: 'light',
};
global.localStorage = localStorageMock;
global.fetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({}),
})
);
describe('App Component', () => {
beforeEach(() => {
vi.clearAllMocks();
document.documentElement.classList.remove('dark');
document.documentElement.style.backgroundColor = '';
});
// Notice the "async" keyword added here
it('renders the App and applies the light theme by default', async () => {
render(<App />);
// 1. Verify your synchronous theme logic
expect(document.documentElement.style.backgroundColor).toBe('rgb(250, 250, 250)');
expect(document.documentElement.classList.contains('dark')).toBe(false);
expect(localStorageMock.setItem).toHaveBeenCalledWith('theme', 'light');
// 2. Wait for the asynchronous fetch to finish so React doesn't complain
await waitFor(() => {
expect(global.fetch).toHaveBeenCalled();
});
});
});