Merged in fix/SW-2358-find-my-booking-logged-in-user (pull request #2572)
fix(SW-2358): Enabled anonymous booking view for logged in user * fix(SW-2358): Enabled anonymous booking view for logged in user * fix(SW-2358): Fixed test case for anonymous booking Approved-by: Matilda Landström
This commit is contained in:
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vitest"
|
||||
import accessBooking, {
|
||||
ACCESS_GRANTED,
|
||||
ERROR_BAD_REQUEST,
|
||||
ERROR_FORBIDDEN,
|
||||
ERROR_NOT_FOUND,
|
||||
ERROR_UNAUTHORIZED,
|
||||
} from "./accessBooking"
|
||||
@@ -87,7 +86,7 @@ describe("Access booking", () => {
|
||||
accessBooking(loggedOutGuest, "Booking", null, JSON.stringify(cookie))
|
||||
).toBe(ACCESS_GRANTED)
|
||||
})
|
||||
it("should prompt logout if user is logged in", () => {
|
||||
it("should enable access if user is logged in and fetching anonymous booking", () => {
|
||||
const cookie: AdditionalInfoCookieValue = {
|
||||
confirmationNumber: "123456789",
|
||||
firstName: "Anonymous",
|
||||
@@ -101,7 +100,7 @@ describe("Access booking", () => {
|
||||
authenticatedUser,
|
||||
JSON.stringify(cookie)
|
||||
)
|
||||
).toBe(ERROR_FORBIDDEN)
|
||||
).toBe(ACCESS_GRANTED)
|
||||
})
|
||||
it("should prompt for more if first name is missing", () => {
|
||||
const cookie: Partial<AdditionalInfoCookieValue> = {
|
||||
|
||||
@@ -42,21 +42,19 @@ function accessBooking(
|
||||
user.email.toLowerCase() === guest.email?.toLowerCase()
|
||||
) {
|
||||
return ACCESS_GRANTED
|
||||
} else {
|
||||
return ERROR_FORBIDDEN
|
||||
}
|
||||
}
|
||||
|
||||
const values =
|
||||
cookie && (JSON.parse(cookie) as Partial<AdditionalInfoCookieValue>)
|
||||
if (
|
||||
values &&
|
||||
values.firstName?.toLowerCase() === guest.firstName?.toLowerCase() &&
|
||||
values.email?.toLowerCase() === guest.email?.toLowerCase()
|
||||
) {
|
||||
return ACCESS_GRANTED
|
||||
} else {
|
||||
const values =
|
||||
cookie && (JSON.parse(cookie) as Partial<AdditionalInfoCookieValue>)
|
||||
if (
|
||||
values &&
|
||||
values.firstName?.toLowerCase() === guest.firstName?.toLowerCase() &&
|
||||
values.email?.toLowerCase() === guest.email?.toLowerCase()
|
||||
) {
|
||||
return ACCESS_GRANTED
|
||||
} else {
|
||||
return ERROR_BAD_REQUEST
|
||||
}
|
||||
return ERROR_BAD_REQUEST
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user