Skip to content

Commit 5c50876

Browse files
committed
organized better the desbribes
1 parent 6fe0e6d commit 5c50876

1 file changed

Lines changed: 170 additions & 166 deletions

File tree

sites/partners/__tests__/components/listings/PaperListingForm/sections/RankingsAndResults.test.tsx

Lines changed: 170 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -31,175 +31,179 @@ beforeAll(() => {
3131
})
3232

3333
describe("RankingsAndResults", () => {
34-
afterEach(() => server.resetHandlers())
35-
afterAll(() => server.close())
36-
const userWithWaitlistLotteryFlag = {
37-
jurisdictions: [
38-
{
39-
id: "jurisdiction1",
40-
name: "jurisdictionWithWaitlistLottery",
41-
featureFlags: [
42-
{
43-
name: FeatureFlagEnum.enableWaitlistLottery,
44-
active: true,
45-
},
46-
],
47-
},
48-
],
49-
}
50-
const userWithoutWaitlistLotteryFlag = {
51-
jurisdictions: [
52-
{
53-
id: "jurisdiction1",
54-
name: "jurisdictionWithoutWaitlistLottery",
55-
featureFlags: [],
56-
},
57-
],
58-
}
59-
60-
it("should not show lottery fields when enableWaitlistLottery is false and waitlist is open", async () => {
61-
document.cookie = "access-token-available=True"
62-
server.use(
63-
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
64-
return res(ctx.json(userWithoutWaitlistLotteryFlag))
65-
})
66-
)
67-
68-
render(
69-
<FormComponent
70-
values={{
71-
...formDefaults,
72-
jurisdictions: { id: "jurisdiction1" },
73-
listingAvailabilityQuestion: "openWaitlist",
74-
}}
75-
>
76-
<RankingsAndResults
77-
requiredFields={[]}
78-
whatToExpectEditor={null}
79-
whatToExpectAdditionalTextEditor={null}
80-
/>
81-
</FormComponent>
82-
)
83-
84-
await screen.findByText("Rankings & results")
85-
86-
const waitlistYesRadio = await screen.findByRole("radio", { name: "Yes" })
87-
await userEvent.click(waitlistYesRadio)
88-
89-
expect(
90-
screen.queryByText("How is the application review order determined?")
91-
).not.toBeInTheDocument()
92-
93-
expect(screen.queryByTestId("lottery-start-date")).not.toBeInTheDocument()
94-
expect(screen.queryByTestId("lottery-start-time")).not.toBeInTheDocument()
95-
expect(screen.queryByTestId("lottery-end-time")).not.toBeInTheDocument()
96-
})
34+
describe("RankingsAndResults enableWaitlistLottery", () => {
35+
afterEach(() => server.resetHandlers())
36+
afterAll(() => server.close())
37+
const userWithWaitlistLotteryFlag = {
38+
jurisdictions: [
39+
{
40+
id: "jurisdiction1",
41+
name: "jurisdictionWithWaitlistLottery",
42+
featureFlags: [
43+
{
44+
name: FeatureFlagEnum.enableWaitlistLottery,
45+
active: true,
46+
},
47+
],
48+
},
49+
],
50+
}
51+
const userWithoutWaitlistLotteryFlag = {
52+
jurisdictions: [
53+
{
54+
id: "jurisdiction1",
55+
name: "jurisdictionWithoutWaitlistLottery",
56+
featureFlags: [],
57+
},
58+
],
59+
}
60+
61+
it("should not show lottery fields when enableWaitlistLottery is false and waitlist is open", async () => {
62+
document.cookie = "access-token-available=True"
63+
server.use(
64+
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
65+
return res(ctx.json(userWithoutWaitlistLotteryFlag))
66+
})
67+
)
9768

98-
it("should show review order options when waitlist is open and feature flag is enabled", async () => {
99-
document.cookie = "access-token-available=True"
100-
server.use(
101-
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
102-
return res(ctx.json(userWithWaitlistLotteryFlag))
103-
})
104-
)
105-
106-
render(
107-
<FormComponent
108-
values={{
109-
...formDefaults,
110-
jurisdictions: { id: "jurisdiction1" },
111-
listingAvailabilityQuestion: "openWaitlist",
112-
}}
113-
>
114-
<RankingsAndResults
115-
requiredFields={[]}
116-
whatToExpectEditor={null}
117-
whatToExpectAdditionalTextEditor={null}
118-
/>
119-
</FormComponent>
120-
)
121-
122-
screen.getByRole("heading", { name: "Rankings & results" })
123-
124-
const waitlistYesRadio = await screen.findByRole("radio", { name: "Yes" })
125-
await userEvent.click(waitlistYesRadio)
126-
127-
await screen.findByText("How is the application review order determined?")
128-
129-
expect(screen.getByRole("radio", { name: /First come first serve/i })).toBeInTheDocument()
130-
expect(screen.getByRole("radio", { name: "Lottery" })).toBeInTheDocument()
131-
})
69+
render(
70+
<FormComponent
71+
values={{
72+
...formDefaults,
73+
jurisdictions: { id: "jurisdiction1" },
74+
listingAvailabilityQuestion: "openWaitlist",
75+
}}
76+
>
77+
<RankingsAndResults
78+
requiredFields={[]}
79+
whatToExpectEditor={null}
80+
whatToExpectAdditionalTextEditor={null}
81+
/>
82+
</FormComponent>
83+
)
13284

133-
it("should show review order options when availabilityQuestion is availableUnits and enableWaitlistLottery is false", () => {
134-
document.cookie = "access-token-available=True"
135-
server.use(
136-
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
137-
return res(ctx.json(userWithoutWaitlistLotteryFlag))
138-
})
139-
)
140-
141-
render(
142-
<FormComponent
143-
values={{
144-
...formDefaults,
145-
jurisdictions: { id: "jurisdiction1" },
146-
listingAvailabilityQuestion: "availableUnits",
147-
}}
148-
>
149-
<RankingsAndResults
150-
requiredFields={[]}
151-
whatToExpectEditor={null}
152-
whatToExpectAdditionalTextEditor={null}
153-
/>
154-
</FormComponent>
155-
)
156-
157-
screen.getByRole("heading", { name: "Rankings & results" })
158-
expect(screen.getByText("How is the application review order determined?")).toBeInTheDocument()
159-
160-
expect(screen.getByRole("radio", { name: /First come first serve/i })).toBeInTheDocument()
161-
expect(screen.getByRole("radio", { name: "Lottery" })).toBeInTheDocument()
162-
})
163-
})
164-
describe("Verifying text when selecting lottery radio button", () => {
165-
it("should show proper message when selecting lottery as a non admin user", async () => {
166-
process.env.showLottery = "true"
167-
render(
168-
<FormComponent>
169-
<RankingsAndResults
170-
requiredFields={[]}
171-
whatToExpectEditor={null}
172-
whatToExpectAdditionalTextEditor={null}
173-
/>
174-
</FormComponent>
175-
)
176-
177-
screen.getByRole("heading", { name: "Rankings & results" })
178-
const lotteryRadio = await screen.findByRole("radio", { name: "Lottery" })
179-
await userEvent.click(lotteryRadio)
180-
expect(
181-
screen.getByText(
182-
"Your lottery will be run in the Partners Portal. If you want to make alternative arrangements, please contact staff."
85+
await screen.findByText("Rankings & results")
86+
87+
const waitlistYesRadio = await screen.findByRole("radio", { name: "Yes" })
88+
await userEvent.click(waitlistYesRadio)
89+
90+
expect(
91+
screen.queryByText("How is the application review order determined?")
92+
).not.toBeInTheDocument()
93+
94+
expect(screen.queryByTestId("lottery-start-date")).not.toBeInTheDocument()
95+
expect(screen.queryByTestId("lottery-start-time")).not.toBeInTheDocument()
96+
expect(screen.queryByTestId("lottery-end-time")).not.toBeInTheDocument()
97+
})
98+
99+
it("should show review order options when waitlist is open and feature flag is enabled", async () => {
100+
document.cookie = "access-token-available=True"
101+
server.use(
102+
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
103+
return res(ctx.json(userWithWaitlistLotteryFlag))
104+
})
105+
)
106+
107+
render(
108+
<FormComponent
109+
values={{
110+
...formDefaults,
111+
jurisdictions: { id: "jurisdiction1" },
112+
listingAvailabilityQuestion: "openWaitlist",
113+
}}
114+
>
115+
<RankingsAndResults
116+
requiredFields={[]}
117+
whatToExpectEditor={null}
118+
whatToExpectAdditionalTextEditor={null}
119+
/>
120+
</FormComponent>
121+
)
122+
123+
screen.getByRole("heading", { name: "Rankings & results" })
124+
125+
const waitlistYesRadio = await screen.findByRole("radio", { name: "Yes" })
126+
await userEvent.click(waitlistYesRadio)
127+
128+
await screen.findByText("How is the application review order determined?")
129+
130+
expect(screen.getByRole("radio", { name: /First come first serve/i })).toBeInTheDocument()
131+
expect(screen.getByRole("radio", { name: "Lottery" })).toBeInTheDocument()
132+
})
133+
134+
it("should show review order options when availabilityQuestion is availableUnits and enableWaitlistLottery is false", () => {
135+
document.cookie = "access-token-available=True"
136+
server.use(
137+
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
138+
return res(ctx.json(userWithoutWaitlistLotteryFlag))
139+
})
140+
)
141+
142+
render(
143+
<FormComponent
144+
values={{
145+
...formDefaults,
146+
jurisdictions: { id: "jurisdiction1" },
147+
listingAvailabilityQuestion: "availableUnits",
148+
}}
149+
>
150+
<RankingsAndResults
151+
requiredFields={[]}
152+
whatToExpectEditor={null}
153+
whatToExpectAdditionalTextEditor={null}
154+
/>
155+
</FormComponent>
183156
)
184-
).toBeInTheDocument()
157+
158+
screen.getByRole("heading", { name: "Rankings & results" })
159+
expect(
160+
screen.getByText("How is the application review order determined?")
161+
).toBeInTheDocument()
162+
163+
expect(screen.getByRole("radio", { name: /First come first serve/i })).toBeInTheDocument()
164+
expect(screen.getByRole("radio", { name: "Lottery" })).toBeInTheDocument()
165+
})
185166
})
186-
it("should show proper message when selecting lottery as an admin user", async () => {
187-
process.env.showLottery = "true"
188-
render(
189-
<FormComponent>
190-
<RankingsAndResults
191-
isAdmin={true}
192-
listing={null}
193-
requiredFields={[]}
194-
whatToExpectEditor={null}
195-
whatToExpectAdditionalTextEditor={null}
196-
/>
197-
</FormComponent>
198-
)
199-
200-
screen.getByRole("heading", { name: "Rankings & results" })
201-
const lotteryRadio = await screen.findByRole("radio", { name: "Lottery" })
202-
await userEvent.click(lotteryRadio)
203-
expect(screen.getByText("Will the lottery be run in the partner portal?")).toBeInTheDocument()
167+
describe("Verifying text when selecting lottery radio button", () => {
168+
it("should show proper message when selecting lottery as a non admin user", async () => {
169+
process.env.showLottery = "true"
170+
render(
171+
<FormComponent>
172+
<RankingsAndResults
173+
requiredFields={[]}
174+
whatToExpectEditor={null}
175+
whatToExpectAdditionalTextEditor={null}
176+
/>
177+
</FormComponent>
178+
)
179+
180+
screen.getByRole("heading", { name: "Rankings & results" })
181+
const lotteryRadio = await screen.findByRole("radio", { name: "Lottery" })
182+
await userEvent.click(lotteryRadio)
183+
expect(
184+
screen.getByText(
185+
"Your lottery will be run in the Partners Portal. If you want to make alternative arrangements, please contact staff."
186+
)
187+
).toBeInTheDocument()
188+
})
189+
it("should show proper message when selecting lottery as an admin user", async () => {
190+
process.env.showLottery = "true"
191+
render(
192+
<FormComponent>
193+
<RankingsAndResults
194+
isAdmin={true}
195+
listing={null}
196+
requiredFields={[]}
197+
whatToExpectEditor={null}
198+
whatToExpectAdditionalTextEditor={null}
199+
/>
200+
</FormComponent>
201+
)
202+
203+
screen.getByRole("heading", { name: "Rankings & results" })
204+
const lotteryRadio = await screen.findByRole("radio", { name: "Lottery" })
205+
await userEvent.click(lotteryRadio)
206+
expect(screen.getByText("Will the lottery be run in the partner portal?")).toBeInTheDocument()
207+
})
204208
})
205209
})

0 commit comments

Comments
 (0)