Skip to content

Commit 263fff9

Browse files
authored
fix: use conductor values for Common App form step checkpoints (#5504)
* feat: use conductor values for form step checkpoints * test: rework redirection tests to use conductor * test: fix inconsistent setups
1 parent d784a68 commit 263fff9

4 files changed

Lines changed: 14 additions & 15 deletions

File tree

sites/public/__tests__/pages/applications/review/redirection.test.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ window.scrollTo = jest.fn()
1313

1414
const server = setupServer()
1515

16+
const mockApplication = JSON.parse(JSON.stringify(blankApplication))
17+
1618
beforeAll(() => {
1719
server.listen()
1820
})
@@ -31,12 +33,12 @@ describe("applications pages", () => {
3133
describe("back button to ada step", () => {
3234
it("no listing available should redirect to listings page", async () => {
3335
const { pushMock } = mockNextRouter()
34-
const conductor = new ApplicationConductor({}, {})
36+
const conductor = new ApplicationConductor(mockApplication, null)
3537
render(
3638
<AppSubmissionContext.Provider
3739
value={{
3840
conductor: conductor,
39-
application: JSON.parse(JSON.stringify(blankApplication)),
41+
application: mockApplication,
4042
listing: null,
4143
syncApplication: () => {
4244
return
@@ -57,12 +59,12 @@ describe("applications pages", () => {
5759

5860
it("listing available should not redirect to listings page", async () => {
5961
const { pushMock } = mockNextRouter()
60-
const conductor = new ApplicationConductor({}, {})
62+
const conductor = new ApplicationConductor(mockApplication, {})
6163
render(
6264
<AppSubmissionContext.Provider
6365
value={{
6466
conductor: conductor,
65-
application: JSON.parse(JSON.stringify(blankApplication)),
67+
application: mockApplication,
6668
listing: {} as Listing,
6769
syncApplication: () => {
6870
return
@@ -85,12 +87,12 @@ describe("applications pages", () => {
8587
describe("back button to summary step", () => {
8688
it("no listing available should redirect to listings page", async () => {
8789
const { pushMock } = mockNextRouter()
88-
const conductor = new ApplicationConductor({}, {})
90+
const conductor = new ApplicationConductor(mockApplication, null)
8991
render(
9092
<AppSubmissionContext.Provider
9193
value={{
9294
conductor: conductor,
93-
application: JSON.parse(JSON.stringify(blankApplication)),
95+
application: mockApplication,
9496
listing: null,
9597
syncApplication: () => {
9698
return
@@ -111,12 +113,12 @@ describe("applications pages", () => {
111113

112114
it("listing available should not redirect to listings page", async () => {
113115
const { pushMock } = mockNextRouter()
114-
const conductor = new ApplicationConductor({}, {})
116+
const conductor = new ApplicationConductor(mockApplication, {})
115117
render(
116118
<AppSubmissionContext.Provider
117119
value={{
118120
conductor: conductor,
119-
application: JSON.parse(JSON.stringify(blankApplication)),
121+
application: mockApplication,
120122
listing: {} as Listing,
121123
syncApplication: () => {
122124
return

sites/public/src/lib/hooks.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,11 @@ export const useRedirectToPrevPage = (defaultPath = "/") => {
8484
* @param bypassCheckpoint true if it should bypass checking that listing & application is in progress
8585
* @returns
8686
*/
87-
export const useFormConductor = (stepName: string, bypassCheckpoint?: boolean) => {
87+
export const useFormConductor = (stepName: string) => {
8888
useRequireLoggedInUser("/", !process.env.showMandatedAccounts)
8989
const context = useContext(AppSubmissionContext)
90-
if (!bypassCheckpoint) {
91-
// eslint-disable-next-line react-hooks/rules-of-hooks
92-
useAuthenticApplicationCheckpoint(context.listing, context.application)
93-
}
9490
const conductor = context.conductor
91+
useAuthenticApplicationCheckpoint(conductor.listing, conductor.application)
9592

9693
conductor.stepTo(stepName)
9794

sites/public/src/pages/applications/start/autofill.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { CardSection } from "@bloom-housing/ui-seeds/src/blocks/Card"
2727

2828
const Autofill = () => {
2929
const router = useRouter()
30-
const context = useFormConductor("autofill", true)
30+
const context = useFormConductor("autofill")
3131
const { conductor, application, listing } = context
3232
const { initialStateLoaded, profile, applicationsService } = useContext(AuthContext)
3333
const [submitted, setSubmitted] = useState(false)

sites/public/src/pages/applications/start/what-to-expect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { isUnitGroupAppBase, isUnitGroupAppWaitlist } from "../../../lib/helpers
1616

1717
const ApplicationWhatToExpect = () => {
1818
const { profile } = useContext(AuthContext)
19-
const { conductor, listing } = useFormConductor("whatToExpect", true)
19+
const { conductor, listing } = useFormConductor("whatToExpect")
2020
const router = useRouter()
2121

2222
const { handleSubmit } = useForm()

0 commit comments

Comments
 (0)