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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import { Onboarding } from 'src/modules/onboarding';
import { useOnboarding } from 'src/modules/onboarding/hooks/use-onboarding';
import { UserSettings } from 'src/modules/user-settings';
import { WhatsNewModal, useWhatsNew } from 'src/modules/whats-new';
import { useRootSelector } from 'src/stores';
import { selectOnboardingLoading } from 'src/stores/onboarding-slice';
import 'src/index.css';

export default function App() {
useLocalizationSupport();
const { needsOnboarding } = useOnboarding();
const isOnboardingLoading = useRootSelector( selectOnboardingLoading );
const { isSidebarVisible, toggleSidebar } = useSidebarVisibility();
const { showWhatsNew, closeWhatsNew } = useWhatsNew();
const { sites: localSites, loadingSites } = useSiteDetails();
Expand All @@ -33,6 +36,10 @@ export default function App() {
void getIpcApi().setupAppMenu( { needsOnboarding } );
}, [ needsOnboarding ] );

if ( isOnboardingLoading ) {
return null;
}

return (
<>
{ needsOnboarding || isEmpty ? (
Expand Down
3 changes: 3 additions & 0 deletions src/components/tests/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { wordpressVersionsApi } from 'src/stores/wordpress-versions-api';
import { wpcomApi, wpcomPublicApi } from 'src/stores/wpcom-api';

jest.mock( 'src/index.css', () => ( {} ) );
jest.mock( 'src/stores/onboarding-slice', () => ( {
selectOnboardingLoading: jest.fn().mockReturnValue( false ),
} ) );
jest.mock( 'src/modules/onboarding/hooks/use-onboarding' );
jest.mock( 'src/hooks/use-site-details' );
jest.mock( 'src/modules/whats-new/hooks/use-whats-new', () => ( {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/onboarding-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface OnboardingState {

const initialState: OnboardingState = {
completed: false,
loading: false,
loading: true,
};

// Async thunk to load onboarding status
Expand Down
6 changes: 3 additions & 3 deletions src/stores/tests/onboarding-slice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe( 'onboarding-slice', () => {
it( 'should have correct initial state', () => {
const state = store.getState();
expect( selectOnboardingCompleted( state ) ).toBe( false );
expect( selectOnboardingLoading( state ) ).toBe( false );
expect( selectOnboardingLoading( state ) ).toBe( true );
} );
} );

Expand Down Expand Up @@ -174,9 +174,9 @@ describe( 'onboarding-slice', () => {
} );

it( 'should select onboarding loading state correctly', () => {
// Initial state should be false
// Initial state should be true
let state = store.getState();
expect( selectOnboardingLoading( state ) ).toBe( false );
expect( selectOnboardingLoading( state ) ).toBe( true );

// Mock the API to trigger loading state
mockIpcApi.getOnboardingData.mockResolvedValue( true );
Expand Down