Skip to content

Commit 759822f

Browse files
authored
SDK-3368: Feature flag problem details tests (#2526)
The end-to-end tests need to run against older supported versions of ESS, not all of which support problem details. By default, only the response status and title are checked, which are provided by default against any HTTP response. Problem details and instance are only checked if the environment variable E2E_TEST_FEATURE_PROBLEM_DETAILS is set to true.
1 parent 021e166 commit 759822f

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

e2e/node/resource.test.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22+
// Assertions are made conditionally on problem details responses because not all
23+
// servers support this feature.
24+
/* eslint-disable jest/no-conditional-expect */
25+
2226
import { File as NodeFile, Blob as NodeBlob } from "buffer";
2327
import {
2428
jest,
@@ -329,8 +333,10 @@ describe("Authenticated end-to-end", () => {
329333
expect(error.problemDetails.type).toBe(DEFAULT_TYPE);
330334
expect(error.problemDetails.title).toBe("Unauthorized");
331335
expect(error.problemDetails.status).toBe(401);
332-
expect(error.problemDetails.detail).toBeDefined();
333-
expect(error.problemDetails.instance).toBeDefined();
336+
if (env?.features?.PROBLEM_DETAILS === "true") {
337+
expect(error.problemDetails.detail).toBeDefined();
338+
expect(error.problemDetails.instance).toBeDefined();
339+
}
334340
});
335341

336342
it("can fetch getWellKnownSolid", async () => {
@@ -398,8 +404,10 @@ describe("Authenticated end-to-end", () => {
398404
expect(error.problemDetails.type).toBe(DEFAULT_TYPE);
399405
expect(error.problemDetails.title).toBe("Not Acceptable");
400406
expect(error.problemDetails.status).toBe(406);
401-
expect(error.problemDetails.detail).toBeDefined();
402-
expect(error.problemDetails.instance).toBeDefined();
407+
if (env?.features?.PROBLEM_DETAILS === "true") {
408+
expect(error.problemDetails.detail).toBeDefined();
409+
expect(error.problemDetails.instance).toBeDefined();
410+
}
403411
});
404412

405413
it("raises error creating a container if service returns an error response", async () => {
@@ -522,16 +530,20 @@ describe("Authenticated end-to-end", () => {
522530
expect(problemDetails.type).toBe(DEFAULT_TYPE);
523531
expect(problemDetails.title).toBe("Bad Request");
524532
expect(problemDetails.status).toBe(400);
525-
expect(problemDetails.detail).toBeDefined();
526-
expect(problemDetails.instance).toBeDefined();
533+
if (env?.features?.PROBLEM_DETAILS === "true") {
534+
expect(problemDetails.detail).toBeDefined();
535+
expect(problemDetails.instance).toBeDefined();
536+
}
527537
}
528538

529539
function expect405ProblemDetails(problemDetails: ProblemDetails) {
530540
expect(problemDetails.type).toBe(DEFAULT_TYPE);
531541
expect(problemDetails.title).toBe("Method Not Allowed");
532542
expect(problemDetails.status).toBe(405);
533-
expect(problemDetails.detail).toBeDefined();
534-
expect(problemDetails.instance).toBeDefined();
543+
if (env?.features?.PROBLEM_DETAILS === "true") {
544+
expect(problemDetails.detail).toBeDefined();
545+
expect(problemDetails.instance).toBeDefined();
546+
}
535547
}
536548

537549
function serverToRespondWithAn405Error() {

0 commit comments

Comments
 (0)