From 22d57420342b0573fdcf697c80f219f723adbc5e Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Tue, 21 Nov 2023 21:10:02 +0800 Subject: [PATCH] fix(next-drupal): fix "403 forbidden" jest failures Fixes #603 --- .lintstagedrc.json | 2 +- .../tests/__snapshots__/client.test.ts.snap | 2 +- packages/next-drupal/tests/client.test.ts | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 7db0bc75..b445e5ee 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,3 +1,3 @@ { - "*": "prettier --write" + "*": "prettier --write --ignore-unknown" } diff --git a/packages/next-drupal/tests/__snapshots__/client.test.ts.snap b/packages/next-drupal/tests/__snapshots__/client.test.ts.snap index 8198364d..31b9e41f 100644 --- a/packages/next-drupal/tests/__snapshots__/client.test.ts.snap +++ b/packages/next-drupal/tests/__snapshots__/client.test.ts.snap @@ -4990,7 +4990,7 @@ Object { } `; -exports[`getStaticPathsFromContext it returns static paths for multiple resoure types from context 1`] = ` +exports[`getStaticPathsFromContext it returns static paths for multiple resource types from context 1`] = ` Array [ Object { "locale": "en", diff --git a/packages/next-drupal/tests/client.test.ts b/packages/next-drupal/tests/client.test.ts index 011bfd35..3dc2b604 100644 --- a/packages/next-drupal/tests/client.test.ts +++ b/packages/next-drupal/tests/client.test.ts @@ -911,7 +911,7 @@ describe("getResource", () => { ) }) - test("it throws an error if revision access if forbidden", async () => { + test("it throws an error if revision access is forbidden", async () => { const client = new DrupalClient(BASE_URL) await expect( @@ -926,7 +926,7 @@ describe("getResource", () => { } ) ).rejects.toThrow( - "403 Forbidden\nThe current user is not allowed to GET the selected resource. The user does not have access to the requested version." + "401 Unauthorized\nNo authentication credentials provided." ) }) @@ -1093,7 +1093,7 @@ describe("getResourceByPath", () => { ) }) - test("it throws an error if revision access if forbidden", async () => { + test("it throws an error if revision access is forbidden", async () => { const client = new DrupalClient(BASE_URL) await expect( @@ -1107,7 +1107,7 @@ describe("getResourceByPath", () => { } ) ).rejects.toThrow( - "403 Forbidden\nThe current user is not allowed to GET the selected resource. The user does not have access to the requested version." + "401 Unauthorized\nNo authentication credentials provided." ) }) @@ -1324,7 +1324,7 @@ describe("getResourceFromContext", () => { ) }) - test("it throws an error if revision access if forbidden", async () => { + test("it throws an error if revision access is forbidden", async () => { const client = new DrupalClient(BASE_URL) const context: GetStaticPropsContext = { @@ -1343,7 +1343,7 @@ describe("getResourceFromContext", () => { }, }) ).rejects.toThrow( - "403 Forbidden\nThe current user is not allowed to GET the selected resource. The user does not have access to the requested version." + "401 Unauthorized\nNo authentication credentials provided." ) }) @@ -1895,7 +1895,7 @@ describe("getStaticPathsFromContext", () => { expect(paths).toMatchSnapshot() }) - test("it returns static paths for multiple resoure types from context", async () => { + test("it returns static paths for multiple resource types from context", async () => { const client = new DrupalClient(BASE_URL) const paths = await client.getStaticPathsFromContext( @@ -2608,7 +2608,7 @@ describe("getAuthFromContextAndOptions", () => { ) }) - test("if in preview and using the jwt plugin, t should use the access token from context even with global withAuth", async () => { + test("if in preview and using the jwt plugin, it should use the access token from context even with global withAuth", async () => { const client = new DrupalClient(BASE_URL, { auth: { clientId: "7795065e-8ad0-45eb-a64d-73d9f3a5e943",