Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/challenge/challenge.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
font-size: var(--text-body-size-large, 16px);
color: var(--fgColor-muted, #656d76);
}

.authoringWrapper {
flex: 1;
overflow: hidden;
}
12 changes: 6 additions & 6 deletions src/app/challenge/create/create-page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ describe('CreateChallengePage', () => {
container.remove();
});

function renderPage() {
act(() => {
async function renderPage() {
await act(async () => {
root = createRoot(container);
root.render(createElement(CreateChallengePage));
});
Expand All @@ -110,8 +110,8 @@ describe('CreateChallengePage', () => {
});
}

it('should start with no error message', () => {
renderPage();
it('should start with no error message', async () => {
await renderPage();

expect(container.textContent).not.toContain('Queue is full');
expect(container.textContent).not.toContain('Failed to add challenge to queue. Please try again.');
Expand All @@ -122,7 +122,7 @@ describe('CreateChallengePage', () => {
queueState.isQueueFull = true;
queueState.maxQueueSize = 3;

renderPage();
await renderPage();
await clickSave();

expect(addChallengeMock).not.toHaveBeenCalled();
Expand All @@ -137,7 +137,7 @@ describe('CreateChallengePage', () => {
const alertSpy = vi.spyOn(window, 'alert').mockImplementation(() => {});
addChallengeMock.mockResolvedValue(false);

renderPage();
await renderPage();
await clickSave();

expect(addChallengeMock).toHaveBeenCalledTimes(1);
Expand Down
14 changes: 11 additions & 3 deletions src/app/challenge/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@
*/

import { AppHeader } from '@/components/AppHeader';
import { ChallengeAuthoring } from '@/components/ChallengeAuthoring';
import { useBreadcrumb } from '@/contexts/breadcrumb-context';
import { useCustomChallengeQueue } from '@/hooks/use-custom-challenge-queue';
import { useUserProfile } from '@/hooks/use-user-profile';
import type { DailyChallenge } from '@/lib/focus/types';
import { Banner } from '@primer/react';
import { Banner, Spinner } from '@primer/react';
import dynamic from 'next/dynamic';
import { useRouter } from 'next/navigation';
import { useCallback, useState } from 'react';
import styles from '../challenge.module.css';

// Lazy-load ChallengeAuthoring (1005 lines across 5 files) to reduce /challenge/create
// initial JS bundle. The header, error banner, and hooks all load instantly; the heavy
// authoring UI streams in as a separate chunk.
const ChallengeAuthoring = dynamic(
() => import('@/components/ChallengeAuthoring').then((mod) => mod.ChallengeAuthoring),
{ ssr: false, loading: () => <div className={styles.loading}><Spinner size="medium" /></div> }
);

/**
* Challenge authoring page component.
*
Expand Down Expand Up @@ -71,7 +79,7 @@ export default function CreateChallengePage() {
)}

<main className={styles.main}>
<div style={{ flex: 1, overflow: 'hidden' }}>
<div className={styles.authoringWrapper}>
<ChallengeAuthoring
onSaveChallenge={handleSaveChallenge}
userAvatarUrl={profile?.user?.avatarUrl}
Expand Down
Loading