Skip to content

Commit

Permalink
update auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiequach committed Dec 31, 2024
1 parent fbdb989 commit 1e1b3e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mocks/mockEnv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const NYPL_LOGIN_URL = "https://login.nypl.org/auth/login?redirect_uri=";
export const NYPL_LOGIN_URL = "login.nypl.org";
export const API_URL = "https://backend.msw";
export const FULFILL_PATH = "/fulfill/9351827";
export const LIMITED_ACCESS_EDITION_PATH = "/edition/6977884";
Expand Down
16 changes: 8 additions & 8 deletions playwright/integration/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ test.beforeEach(async ({ context }) => {
test.afterEach(() => server.resetHandlers());
test.afterAll(() => server.close());

test.skip("Cookie authentication", () => {
test("redirects to NYPL log in page with no cookie", async ({ page }) => {
test.describe("Cookie authentication", () => {
test("redirects to NYPL login page with no cookie", async ({ page }) => {
await page.goto(`${LIMITED_ACCESS_EDITION_PATH}`);
await page.getByTestId(LOGIN_TO_READ_TEST_ID).click();
await page.waitForURL(`**${NYPL_LOGIN_URL}**`);
await page.waitForURL(/.*login.nypl.org.*/);
const url = new URL(page.url());
const redirectUri = url.searchParams.get("redirect_uri");
const service = url.searchParams.get("service");

expect(redirectUri).toContain(LIMITED_ACCESS_EDITION_PATH);
expect(service).toContain(NYPL_LOGIN_URL);
});

test("redirects to NYPL login page with expired cookie", async ({
Expand All @@ -34,11 +34,11 @@ test.skip("Cookie authentication", () => {

await page.goto(`${LIMITED_ACCESS_EDITION_PATH}`);
await page.getByTestId(LOGIN_TO_READ_TEST_ID).click();
await page.waitForURL(`**${NYPL_LOGIN_URL}**`);
await page.waitForURL(/.*login.nypl.org.*/);
const url = new URL(page.url());
const redirectUri = url.searchParams.get("redirect_uri");
const service = url.searchParams.get("service");

expect(redirectUri).toContain(LIMITED_ACCESS_EDITION_PATH);
expect(service).toContain(NYPL_LOGIN_URL);
});

// TODO: logging in from localhost does not work
Expand Down

0 comments on commit 1e1b3e5

Please sign in to comment.