feat(deploy): build + serve worker and admin as static nginx images
All checks were successful
Build and Push Docker Image / build (push) Successful in 53s
All checks were successful
Build and Push Docker Image / build (push) Successful in 53s
- per-app Dockerfiles (vite build → nginx) + SPA nginx.conf - Gitea workflow pushes 3 images; frontends bake VITE_API_URL - docker-compose.prod.yml (registry images, solelog_network) + .env.prod.example - docker-compose.yml runs the full stack locally; add .dockerignore
This commit is contained in:
@@ -17,9 +17,9 @@ vi.mock('../api/me', () => ({
|
||||
const mockedSignIn = vi.mocked(apiSignIn);
|
||||
const mockedFetchMe = vi.mocked(fetchMe);
|
||||
|
||||
// A tiny harness that exposes the auth context's state + signIn.
|
||||
// A tiny harness that exposes the auth context's state + signIn + signOut.
|
||||
function Harness() {
|
||||
const { isAuthed, signIn } = useAuth();
|
||||
const { isAuthed, signIn, signOut } = useAuth();
|
||||
return (
|
||||
<div>
|
||||
<span data-testid="authed">{String(isAuthed)}</span>
|
||||
@@ -34,6 +34,9 @@ function Harness() {
|
||||
>
|
||||
go
|
||||
</button>
|
||||
<button type="button" onClick={() => signOut()}>
|
||||
uit
|
||||
</button>
|
||||
<span id="err" />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -72,4 +72,71 @@ describe('Live', () => {
|
||||
expect(await screen.findByText('Niemand is nu aan het werk.')).toBeInTheDocument();
|
||||
expect(screen.getByText('Actief nu (0)')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows a Gepauzeerd badge with a frozen worked timer when paused_at is set', async () => {
|
||||
vi.useFakeTimers();
|
||||
const start = Date.now() - 100_000;
|
||||
const pausedAt = Date.now() - 40_000; // paused 40s ago
|
||||
mockApiFetch.mockResolvedValue([
|
||||
makeSession({
|
||||
id: 1,
|
||||
user_name: 'Jan',
|
||||
start_time: new Date(start).toISOString(),
|
||||
paused_at: new Date(pausedAt).toISOString(),
|
||||
paused_seconds: 10,
|
||||
}),
|
||||
]);
|
||||
|
||||
renderLive();
|
||||
|
||||
// The fake clock needs to advance for react-query's async resolution.
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
expect(screen.getByText('Gepauzeerd')).toBeInTheDocument();
|
||||
|
||||
// worked = (paused_at - start)/1000 - paused_seconds = 60 - 10 = 50s = 00:00:50
|
||||
const frozen = screen.getByText('00:00:50');
|
||||
expect(frozen).toBeInTheDocument();
|
||||
|
||||
// Advance the 1s tick: the worked timer must stay frozen (does not count up).
|
||||
await vi.advanceTimersByTimeAsync(3000);
|
||||
expect(screen.getByText('00:00:50')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the paused total when paused_seconds > 0', async () => {
|
||||
mockApiFetch.mockResolvedValue([
|
||||
makeSession({
|
||||
id: 1,
|
||||
user_name: 'Jan',
|
||||
paused_seconds: 125,
|
||||
paused_at: new Date().toISOString(),
|
||||
}),
|
||||
]);
|
||||
|
||||
renderLive();
|
||||
|
||||
// 125s = 00:02:05
|
||||
expect(await screen.findByText('Pauze 00:02:05')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps the timer counting (no Gepauzeerd badge) when not paused', async () => {
|
||||
vi.useFakeTimers();
|
||||
mockApiFetch.mockResolvedValue([
|
||||
makeSession({
|
||||
id: 1,
|
||||
user_name: 'Jan',
|
||||
start_time: new Date(Date.now() - 10_000).toISOString(),
|
||||
paused_at: null,
|
||||
paused_seconds: 0,
|
||||
}),
|
||||
]);
|
||||
|
||||
renderLive();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
expect(screen.queryByText('Gepauzeerd')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('00:00:10')).toBeInTheDocument();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(2000);
|
||||
expect(screen.getByText('00:00:12')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user