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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ beforeAll(() => {
mockTipTapEditor()
})

afterEach(() => server.resetHandlers())
afterAll(() => server.close())

describe("RankingsAndResults", () => {
const adminUserWithWaitlistLotteryFlag = {
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
const userWithWaitlistLotteryFlag = {
jurisdictions: [
{
id: "jurisdiction1",
Expand All @@ -48,8 +47,7 @@ describe("RankingsAndResults", () => {
},
],
}

const adminUserWithoutWaitlistLotteryFlag = {
const userWithoutWaitlistLotteryFlag = {
jurisdictions: [
{
id: "jurisdiction1",
Expand All @@ -63,7 +61,7 @@ describe("RankingsAndResults", () => {
document.cookie = "access-token-available=True"
server.use(
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
return res(ctx.json(adminUserWithoutWaitlistLotteryFlag))
return res(ctx.json(userWithoutWaitlistLotteryFlag))
})
)

Expand Down Expand Up @@ -101,7 +99,7 @@ describe("RankingsAndResults", () => {
document.cookie = "access-token-available=True"
server.use(
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
return res(ctx.json(adminUserWithWaitlistLotteryFlag))
return res(ctx.json(userWithWaitlistLotteryFlag))
})
)

Expand Down Expand Up @@ -131,4 +129,77 @@ describe("RankingsAndResults", () => {
expect(screen.getByRole("radio", { name: /First come first serve/i })).toBeInTheDocument()
expect(screen.getByRole("radio", { name: "Lottery" })).toBeInTheDocument()
})

it("should show review order options when availabilityQuestion is availableUnits and enableWaitlistLottery is false", () => {
document.cookie = "access-token-available=True"
server.use(
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
return res(ctx.json(userWithoutWaitlistLotteryFlag))
})
)

render(
<FormComponent
values={{
...formDefaults,
jurisdictions: { id: "jurisdiction1" },
listingAvailabilityQuestion: "availableUnits",
}}
>
<RankingsAndResults
requiredFields={[]}
whatToExpectEditor={null}
whatToExpectAdditionalTextEditor={null}
/>
</FormComponent>
)

screen.getByRole("heading", { name: "Rankings & results" })
expect(screen.getByText("How is the application review order determined?")).toBeInTheDocument()

expect(screen.getByRole("radio", { name: /First come first serve/i })).toBeInTheDocument()
expect(screen.getByRole("radio", { name: "Lottery" })).toBeInTheDocument()
})
})
describe("Verifying text when selecting lottery radio button", () => {
it("should show proper message when selecting lottery as a non admin user", async () => {
process.env.showLottery = "true"
render(
<FormComponent>
<RankingsAndResults
requiredFields={[]}
whatToExpectEditor={null}
whatToExpectAdditionalTextEditor={null}
/>
</FormComponent>
)

screen.getByRole("heading", { name: "Rankings & results" })
const lotteryRadio = await screen.findByRole("radio", { name: "Lottery" })
await userEvent.click(lotteryRadio)
expect(
screen.getByText(
"Your lottery will be run in the Partners Portal. If you want to make alternative arrangements, please contact staff."
)
).toBeInTheDocument()
})
it("should show proper message when selecting lottery as an admin user", async () => {
process.env.showLottery = "true"
render(
<FormComponent>
<RankingsAndResults
isAdmin={true}
listing={null}
requiredFields={[]}
whatToExpectEditor={null}
whatToExpectAdditionalTextEditor={null}
/>
</FormComponent>
)

screen.getByRole("heading", { name: "Rankings & results" })
const lotteryRadio = await screen.findByRole("radio", { name: "Lottery" })
await userEvent.click(lotteryRadio)
expect(screen.getByText("Will the lottery be run in the partner portal?")).toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ const RankingsAndResults = ({
selectedJurisdictionId
)

const showFSFCLotterySection = enableWaitlistLottery && waitlistOpen
const showFSFCLotterySection =
(enableWaitlistLottery && waitlistOpen) ||
(availabilityQuestion !== "openWaitlist" && !enableWaitlistLottery)

// Ensure the lottery fields only show when it's "available units" listing
const showLotteryFields =
Expand Down
Loading