added upload queue notifications
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user