Skip to content

Commit

Permalink
test: intake 6 UI pages temp
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasdc committed Jan 15, 2025
1 parent eb49cf1 commit 901f92c
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 174 deletions.
42 changes: 27 additions & 15 deletions app/tests/pages/applicantportal/dashboard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen } from '@testing-library/react';
import * as moduleApi from '@growthbook/growthbook-react';
import { FeatureResult, JSONValue } from '@growthbook/growthbook-react';
import userEvent from '@testing-library/user-event';
// import userEvent from '@testing-library/user-event';
import { schema } from 'formSchema';
import Dashboard, {
withRelayOptions,
Expand Down Expand Up @@ -279,7 +279,9 @@ describe('The index page', () => {
.spyOn(moduleApi, 'useFeature')
.mockReturnValueOnce(mockInternalIntakeClosed);

expect(screen.getByText('Create application')).toBeDisabled();
expect(screen.queryByText('Create application')).not.toBeInTheDocument();
// TEMP INTAKE 6 UI CHANGES
expect(screen.getByText('Email Us')).toBeEnabled();
});

it('displays the alert message when there is no open intake', async () => {
Expand Down Expand Up @@ -316,30 +318,40 @@ describe('The index page', () => {
pageTestingHelper.loadQuery();
pageTestingHelper.renderPage();

expect(
screen.getByText(`Create application`).closest('button').disabled
).toBeFalse();
// TEMP INTAKE 6 UI CHANGES
expect(screen.getByText('Email Us')).toBeEnabled();

// expect(
// screen.getByText(`Create application`).closest('button').disabled
// ).toBeFalse();
});

it('has create intake button disabled when there is no open intake', async () => {
pageTestingHelper.loadQuery(mockClosedIntakePayload);
pageTestingHelper.renderPage();

expect(screen.getByText(`Create application`)).toBeDisabled();
// TEMP INTAKE 6 UI CHANGES
expect(screen.getByText('Email Us')).toBeEnabled();

// expect(screen.getByText(`Create application`)).toBeDisabled();
});

it('has create application button enabled when open hidden intake returns a value', async () => {
pageTestingHelper.loadQuery(mockClosedIntakeOpenHiddenIntakePayload);
pageTestingHelper.renderPage();
pageTestingHelper.router.query = { code: 'asdf' };
const createApplicationButton = screen.getByText('Create application');
expect(createApplicationButton).toBeEnabled();
await userEvent.click(createApplicationButton);
pageTestingHelper.expectMutationToBeCalled('createApplicationMutation', {
input: {
code: 'asdf',
},
});

// TEMP INTAKE 6 UI CHANGES
expect(screen.getByText('Email Us')).toBeEnabled();

// const createApplicationButton = screen.getByText('Create application');
// expect(createApplicationButton).toBeEnabled();
// await userEvent.click(createApplicationButton);
// pageTestingHelper.expectMutationToBeCalled('createApplicationMutation', {
// input: {
// code: 'asdf',
// },
// });
});

it('displays the message when user has no applications', async () => {
Expand Down Expand Up @@ -403,7 +415,7 @@ describe('The index page', () => {
).not.toBeInTheDocument();
expect(
screen.getByText(
/The review of applications will begin immediately after submission. You will no longer be able to edit your application after submission/
/Intake 6 is now open until June 30, 2025. If you are interested in submitting an application, or for any questions about connectivity projects in your area, please email/
)
).toBeInTheDocument();
});
Expand Down
209 changes: 108 additions & 101 deletions app/tests/pages/applicantportal/form/[id]/submission.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ describe('The submission form page', () => {

expect(
screen.getByRole('button', { name: 'Submit' }).hasAttribute('disabled')
).toBeFalse();
).toBeTrue();
});

it('submission page submit button is disabled when geographic area is not filled', () => {
Expand Down Expand Up @@ -370,31 +370,31 @@ describe('The submission form page', () => {
// After the first mutation completes, we still don't redirect
expect(componentTestingHelper.router.push).not.toHaveBeenCalled();

componentTestingHelper.expectMutationToBeCalled(
'submitApplicationMutation',
{
input: {
applicationRowId: 42,
_formSchemaId: 42,
},
}
);

componentTestingHelper.environment.mock.resolveMostRecentOperation({
data: {
applicationsAddCcbcId: {
application: {
ccbcNumber: 'CCBC-010042',
status: 'submitted',
},
},
},
});

// We only redirect when the ccbc id is set
expect(componentTestingHelper.router.push).toHaveBeenCalledWith(
'/applicantportal/form/42/success'
);
// componentTestingHelper.expectMutationToBeCalled(
// 'submitApplicationMutation',
// {
// input: {
// applicationRowId: 42,
// _formSchemaId: 42,
// },
// }
// );

// componentTestingHelper.environment.mock.resolveMostRecentOperation({
// data: {
// applicationsAddCcbcId: {
// application: {
// ccbcNumber: 'CCBC-010042',
// status: 'submitted',
// },
// },
// },
// });

// // We only redirect when the ccbc id is set
// expect(componentTestingHelper.router.push).toHaveBeenCalledWith(
// '/applicantportal/form/42/success'
// );
});

it('Submission fields are disabled when visiting submitted application', async () => {
Expand Down Expand Up @@ -444,38 +444,41 @@ describe('The submission form page', () => {
query: data.query,
}));

await userEvent.click(
screen.getByRole('button', { name: 'Save as draft' })
);
// TEMP INTAKE 6 UI ONLY CHANGE
expect(screen.getByRole('button', { name: 'Submit' })).toBeDisabled();

componentTestingHelper.expectMutationToBeCalled(
'updateApplicationFormMutation',
{
input: {
formDataRowId: 42,
jsonData: {
organizationProfile: {
organizationName: 'Testing organization name',
},
submission: {
submissionCompletedFor: 'test',
submissionDate: '2022-09-27',
submissionCompletedBy: 'test',
submissionTitle: 'test',
},
projectArea: {
geographicArea: [1],
},
review: {
acknowledgeIncomplete: true,
},
acknowledgements: { acknowledgementsList: acknowledgementsEnum },
},
lastEditedPage: 'review',
clientUpdatedAt: '2022-09-12T14:04:10.790848-07:00',
},
}
);
// await userEvent.click(
// screen.getByRole('button', { name: 'Save as draft' })
// );

// componentTestingHelper.expectMutationToBeCalled(
// 'updateApplicationFormMutation',
// {
// input: {
// formDataRowId: 42,
// jsonData: {
// organizationProfile: {
// organizationName: 'Testing organization name',
// },
// submission: {
// submissionCompletedFor: 'test',
// submissionDate: '2022-09-27',
// submissionCompletedBy: 'test',
// submissionTitle: 'test',
// },
// projectArea: {
// geographicArea: [1],
// },
// review: {
// acknowledgeIncomplete: true,
// },
// acknowledgements: { acknowledgementsList: acknowledgementsEnum },
// },
// lastEditedPage: 'review',
// clientUpdatedAt: '2022-09-12T14:04:10.790848-07:00',
// },
// }
// );
});

it('submit page submit button is disabled for submitted application', async () => {
Expand Down Expand Up @@ -511,14 +514,17 @@ describe('The submission form page', () => {
query: data.query,
}));

expect(
screen.getByRole('button', { name: 'Changes submitted' })
).toBeTruthy();
expect(
screen
.getByRole('button', { name: 'Changes submitted' })
.hasAttribute('disabled')
).toBeTrue();
// TEMP INTAKE 6 UI ONLY CHANGE
expect(screen.getByRole('button', { name: 'Submit' })).toBeDisabled();

// expect(
// screen.getByRole('button', { name: 'Changes submitted' })
// ).toBeTruthy();
// expect(
// screen
// .getByRole('button', { name: 'Changes submitted' })
// .hasAttribute('disabled')
// ).toBeTrue();
});

it('submit page has functioning return to dashboard button for submitted application', async () => {
Expand Down Expand Up @@ -640,41 +646,42 @@ describe('The submission form page', () => {
const submitButton = screen.getByRole('button', { name: 'Submit' });

expect(submitButton).toBeInTheDocument();
expect(submitButton).toBeEnabled();

await userEvent.click(submitButton);

const confirmButton = screen.getByRole('button', {
name: 'Confirm Submission',
});
expect(confirmButton).toBeInTheDocument();

await userEvent.click(confirmButton);

componentTestingHelper.expectMutationToBeCalled(
'submitApplicationMutation',
{
input: {
applicationRowId: 42,
_formSchemaId: 42,
},
}
);

componentTestingHelper.environment.mock.resolveMostRecentOperation({
data: {
applicationsAddCcbcId: {
application: {
ccbcNumber: 'CCBC-010042',
status: 'submitted',
},
},
},
});

expect(fetch).toHaveBeenCalledWith(
'/api/email/notifyApplicationSubmission',
expect.objectContaining({ method: 'POST' })
);
// TEMP INTAKE 6 UI ONLY CHANGE
expect(submitButton).toBeDisabled();

// await userEvent.click(submitButton);

// const confirmButton = screen.getByRole('button', {
// name: 'Confirm Submission',
// });
// expect(confirmButton).toBeInTheDocument();

// await userEvent.click(confirmButton);

// componentTestingHelper.expectMutationToBeCalled(
// 'submitApplicationMutation',
// {
// input: {
// applicationRowId: 42,
// _formSchemaId: 42,
// },
// }
// );

// componentTestingHelper.environment.mock.resolveMostRecentOperation({
// data: {
// applicationsAddCcbcId: {
// application: {
// ccbcNumber: 'CCBC-010042',
// status: 'submitted',
// },
// },
// },
// });

// expect(fetch).toHaveBeenCalledWith(
// '/api/email/notifyApplicationSubmission',
// expect.objectContaining({ method: 'POST' })
// );
});
});
Loading

0 comments on commit 901f92c

Please sign in to comment.