added upload queue notifications

This commit is contained in:
Codex Agent
2025-12-21 12:37:20 +01:00
parent 1e6027f438
commit 6ee40745ca
13 changed files with 566 additions and 114 deletions

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { describe, expect, it, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import { render, waitFor } from '@testing-library/react';
import UploadPage from '../UploadPage';
vi.mock('react-router-dom', () => ({
@@ -69,6 +69,7 @@ describe('UploadPage bottom nav visibility', () => {
beforeEach(() => {
document.body.classList.remove('guest-nav-visible');
document.body.classList.remove('guest-immersive');
Object.defineProperty(window, 'scrollY', { value: 0, writable: true, configurable: true });
vi.spyOn(window, 'requestAnimationFrame').mockImplementation((cb) => {
cb(0);
return 0;
@@ -76,46 +77,21 @@ describe('UploadPage bottom nav visibility', () => {
vi.spyOn(window, 'cancelAnimationFrame').mockImplementation(() => {});
});
it('shows the nav after the KPI chips are scrolled past', async () => {
it('toggles the nav visibility based on scroll position', async () => {
render(<UploadPage />);
const chips = screen.getByTestId('upload-kpi-chips');
const sentinel = screen.getByTestId('nav-visibility-sentinel');
let bottom = 20;
let top = 20;
vi.spyOn(chips, 'getBoundingClientRect').mockImplementation(() => ({
bottom,
top: bottom - 40,
left: 0,
right: 0,
width: 0,
height: 0,
x: 0,
y: 0,
toJSON: () => ({}),
}) as DOMRect);
vi.spyOn(sentinel, 'getBoundingClientRect').mockImplementation(() => ({
bottom: top,
top,
left: 0,
right: 0,
width: 0,
height: 0,
x: 0,
y: 0,
toJSON: () => ({}),
}) as DOMRect);
expect(document.body.classList.contains('guest-nav-visible')).toBe(false);
// nav is on by default now
expect(document.body.classList.contains('guest-nav-visible')).toBe(true);
bottom = -1;
top = -10;
window.scrollY = 120;
window.dispatchEvent(new Event('scroll'));
await waitFor(() => {
expect(document.body.classList.contains('guest-nav-visible')).toBe(true);
});
// Nav stays visible by design now
window.scrollY = 0;
window.dispatchEvent(new Event('scroll'));
await waitFor(() => {
expect(document.body.classList.contains('guest-nav-visible')).toBe(false);
});
});
});