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, {
|
import accessBooking, {
|
||||||
ACCESS_GRANTED,
|
ACCESS_GRANTED,
|
||||||
ERROR_BAD_REQUEST,
|
ERROR_BAD_REQUEST,
|
||||||
ERROR_FORBIDDEN,
|
|
||||||
ERROR_NOT_FOUND,
|
ERROR_NOT_FOUND,
|
||||||
ERROR_UNAUTHORIZED,
|
ERROR_UNAUTHORIZED,
|
||||||
} from "./accessBooking"
|
} from "./accessBooking"
|
||||||
@@ -87,7 +86,7 @@ describe("Access booking", () => {
|
|||||||
accessBooking(loggedOutGuest, "Booking", null, JSON.stringify(cookie))
|
accessBooking(loggedOutGuest, "Booking", null, JSON.stringify(cookie))
|
||||||
).toBe(ACCESS_GRANTED)
|
).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 = {
|
const cookie: AdditionalInfoCookieValue = {
|
||||||
confirmationNumber: "123456789",
|
confirmationNumber: "123456789",
|
||||||
firstName: "Anonymous",
|
firstName: "Anonymous",
|
||||||
@@ -101,7 +100,7 @@ describe("Access booking", () => {
|
|||||||
authenticatedUser,
|
authenticatedUser,
|
||||||
JSON.stringify(cookie)
|
JSON.stringify(cookie)
|
||||||
)
|
)
|
||||||
).toBe(ERROR_FORBIDDEN)
|
).toBe(ACCESS_GRANTED)
|
||||||
})
|
})
|
||||||
it("should prompt for more if first name is missing", () => {
|
it("should prompt for more if first name is missing", () => {
|
||||||
const cookie: Partial<AdditionalInfoCookieValue> = {
|
const cookie: Partial<AdditionalInfoCookieValue> = {
|
||||||
|
|||||||
@@ -42,10 +42,9 @@ function accessBooking(
|
|||||||
user.email.toLowerCase() === guest.email?.toLowerCase()
|
user.email.toLowerCase() === guest.email?.toLowerCase()
|
||||||
) {
|
) {
|
||||||
return ACCESS_GRANTED
|
return ACCESS_GRANTED
|
||||||
} else {
|
|
||||||
return ERROR_FORBIDDEN
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
const values =
|
const values =
|
||||||
cookie && (JSON.parse(cookie) as Partial<AdditionalInfoCookieValue>)
|
cookie && (JSON.parse(cookie) as Partial<AdditionalInfoCookieValue>)
|
||||||
if (
|
if (
|
||||||
@@ -58,7 +57,6 @@ function accessBooking(
|
|||||||
return ERROR_BAD_REQUEST
|
return ERROR_BAD_REQUEST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ERROR_NOT_FOUND
|
return ERROR_NOT_FOUND
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user