Skip to content

Commit

Permalink
[test] Spped up regression and e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Jan 23, 2025
1 parent d12518c commit d95003e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
8 changes: 3 additions & 5 deletions test/e2e/TestViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ function TestViewer(props: { children: React.ReactNode }) {
}, []);

return (
<React.Suspense fallback={<div aria-busy />}>
<div aria-busy={!ready} data-testid="testcase">
{children}
</div>
</React.Suspense>
<div aria-busy={!ready} data-testid="testcase">
{children}
</div>
);
}

Expand Down
16 changes: 3 additions & 13 deletions test/regressions/TestViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { useFakeTimers } from 'sinon';

function TestViewer(props: { children: React.ReactNode }) {
const { children } = props;
Expand All @@ -24,12 +23,6 @@ function TestViewer(props: { children: React.ReactNode }) {
document.fonts.addEventListener('loading', handleFontsEvent);
document.fonts.addEventListener('loadingdone', handleFontsEvent);

// Use a "real timestamp" so that we see a useful date instead of "00:00"
// eslint-disable-next-line react-hooks/rules-of-hooks -- not a React hook
const clock = useFakeTimers({
now: new Date('Mon Aug 18 14:11:54 2014 -0500'),
toFake: ['Date'],
});
// In case the child triggered font fetching we're not ready yet.
// The fonts event handler will mark the test as ready on `loadingdone`
if (document.fonts.status === 'loaded') {
Expand All @@ -39,7 +32,6 @@ function TestViewer(props: { children: React.ReactNode }) {
return () => {
document.fonts.removeEventListener('loading', handleFontsEvent);
document.fonts.removeEventListener('loadingdone', handleFontsEvent);
clock.restore();
};
}, []);

Expand Down Expand Up @@ -68,11 +60,9 @@ function TestViewer(props: { children: React.ReactNode }) {
<React.Fragment>
{/* eslint-disable-next-line react/no-danger */}
<style dangerouslySetInnerHTML={{ __html: globalStyles }} />
<React.Suspense fallback={<div aria-busy />}>
<div aria-busy={!ready} data-testid="testcase" style={{ display: 'block', padding: '8px' }}>
{children}
</div>
</React.Suspense>
<div aria-busy={!ready} data-testid="testcase" style={{ display: 'block', padding: '8px' }}>
{children}
</div>
</React.Fragment>
);
}
Expand Down

0 comments on commit d95003e

Please sign in to comment.