diff --git a/pages/setup/account.page.test.tsx b/pages/setup/account.page.test.tsx index e4c99bc07..9e68cc0f2 100644 --- a/pages/setup/account.page.test.tsx +++ b/pages/setup/account.page.test.tsx @@ -20,25 +20,30 @@ const context = { req: {}, } as unknown as GetServerSidePropsContext; +const mutationSpy = jest.fn(); + +const TestComponent: React.FC = () => { + const accountListOptions = { + accountLists: { + nodes: [1, 2, 3].map((id) => ({ + id: `account-list-${id}`, + name: `Account List ${id}`, + })), + }, + }; + + return ( + + + + + + ); +}; + describe('Setup account page', () => { it('renders account options, saves default account, and advances to the next page', async () => { - const accountListOptions = { - accountLists: { - nodes: [1, 2, 3].map((id) => ({ - id: `account-list-${id}`, - name: `Account List ${id}`, - })), - }, - }; - - const mutationSpy = jest.fn(); - const { getByRole } = render( - - - - - , - ); + const { getByRole } = render(); expect( getByRole('heading', { name: 'Set default account' }), @@ -59,6 +64,16 @@ describe('Setup account page', () => { '/accountLists/account-list-1/settings/preferences', ); }); + + it('disables save button until the user selects an account', () => { + const { getByRole } = render(); + + expect(getByRole('button', { name: 'Continue Tour' })).toBeDisabled(); + + userEvent.click(getByRole('combobox', { name: 'Account' })); + userEvent.click(getByRole('option', { name: 'Account List 1' })); + expect(getByRole('button', { name: 'Continue Tour' })).not.toBeDisabled(); + }); }); describe('getServerSideProps', () => {