Add tests and YAML configurations for environment variable sourcing and response handling

- Introduced new YAML files for global environments, project environment sources, and environment cascade collections.
- Implemented tests for variable source levels, modal editing, tooltip behavior, and response downloads.
- Enhanced pre-request scripts to handle client certificates and proxy updates.
- Verified caching behavior for prompt tags and response tag trigger behaviors.
This commit is contained in:
Bob Qiu committed 2026-11-04 17:33:39 +08:00
1 parent 29a7e6d458
commit c7603ccdaa
11 files changed
+106 -98

No files matched your search

@@ -1,10 +1,11 @@
import { faker } from "@faker-js/faker";
import { ProjectType } from "@package/enums/project-types";
import { test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { ProjectType } from "../../enums/project-types";
import { test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
test("Verify the project and collection environment pickers open and close independently", async ({
user,
}) => {
@@ -1,13 +1,14 @@
import { faker } from "@faker-js/faker";
import { HttpMethod } from "@package/enums/http-method";
import { ProjectType } from "@package/enums/project-types";
import { HTTP_SERVER, test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { EnvironmentKvPairDataType } from "@package/models/environment";
import { Folder } from "@package/models/folder";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { HTTP_SERVER, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { EnvironmentKvPairDataType } from "../../models/environment";
import { Folder } from "../../models/folder";
import { Project } from "../../models/project";
const sharedVariable = faker.string.alpha(8);
const subOnlyVariable = faker.string.alpha(9);
@@ -64,12 +65,12 @@ test("Verify a folder environment overrides sub and base environments for its re
const responseInFolder = await httpRequestFlow.send(requestInFolder);
const responseOutsideFolder = await httpRequestFlow.send(requestOutsideFolder);
expect(responseInFolder.statusBar.code).toBe(200);
expect(responseInFolder.preview).toMatchObject({
expect(responseInFolder.statusCode).toBe(200);
expect(responseInFolder.body).toMatchObject({
args: { shared: folderShared, subOnly: subSubOnly },
});
expect(responseOutsideFolder.statusBar.code).toBe(200);
expect(responseOutsideFolder.preview).toMatchObject({
expect(responseOutsideFolder.statusCode).toBe(200);
expect(responseOutsideFolder.body).toMatchObject({
args: { shared: subShared, subOnly: subSubOnly },
});
});
@@ -1,17 +1,18 @@
import path from "node:path";
import { faker } from "@faker-js/faker";
import { ProjectType } from "@package/enums/project-types";
import type { FlowManager } from "@package/flows/flow-manager";
import type { VariableSourceLanding } from "@package/flows/variable-source.flow";
import { test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
const cascadeFixture = path.join(import.meta.dirname, "environment-cascade-collection.yaml");
const globalCollectionFixture = path.join(import.meta.dirname, "collection-for-global-environments.yaml");
const globalEnvironmentFixture = path.join(import.meta.dirname, "global-environment.yaml");
import { ProjectType } from "../../../enums/project-types";
import { test } from "../../../misc/fixtures";
import { Collection } from "../../../models/collection";
import { Project } from "../../../models/project";
import type { FlowManager } from "../../../flows/flow-manager";
import type { VariableSourceLanding } from "../../../flows/variable-source.flow";
const cascadeFixture = path.join(__dirname, "environment-cascade-collection.yaml");
const globalCollectionFixture = path.join(__dirname, "collection-for-global-environments.yaml");
const globalEnvironmentFixture = path.join(__dirname, "global-environment.yaml");
interface Scenario {
id: string;
@@ -145,9 +146,9 @@ for (const scenario of scenarios) {
scenario.landingRow,
);
expect(response.statusBar.code).toBe(200);
expect(response.statusCode).toBe(200);
expect(
JSON.parse((response.preview as { data: string }).data)[scenario.field],
JSON.parse((response.body as { data: string }).data)[scenario.field],
).toBe(scenario.value);
expect(modal.source).toContain(scenario.source);
expect(modal.preview).toBe(scenario.value);
@@ -1,12 +1,13 @@
import path from "node:path";
import { faker } from "@faker-js/faker";
import { ProjectType } from "@package/enums/project-types";
import { test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { ProjectType } from "../../../enums/project-types";
import { test } from "../../../misc/fixtures";
import { Collection } from "../../../models/collection";
import { Project } from "../../../models/project";
test("Verify the tag modal's source follows the edited template and hides for non-variable content", async ({
user,
}) => {
@@ -18,7 +19,7 @@ test("Verify the tag modal's source follows the edited template and hides for no
);
await importFlow.importFile(
project,
path.join(import.meta.dirname, "environment-cascade-collection.yaml"),
path.join(__dirname, "environment-cascade-collection.yaml"),
);
const collection = new Collection("Environment Cascade");
await environmentFlow.activate(collection, "Base Environment");
@@ -29,10 +30,7 @@ test("Verify the tag modal's source follows the edited template and hides for no
"{{ _.subOnlyVar }}",
"subOnly_base",
);
await variableSourceFlow.selectModalVariable(
{ label: "-- Custom --" },
"Failed to render environment variables: 'my custom template logic'",
);
await variableSourceFlow.selectModalVariable({ label: "-- Custom --" });
const plainText = await variableSourceFlow.setModalTemplate("plain text", "plain text");
const inheritedKey = await variableSourceFlow.setModalTemplate("{{ constructor }}");
const padded = await variableSourceFlow.setModalTemplate("{{ _.subOnlyVar }}", "subOnly_base");
@@ -1,12 +1,13 @@
import path from "node:path";
import { faker } from "@faker-js/faker";
import { ProjectType } from "@package/enums/project-types";
import { test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { ProjectType } from "../../../enums/project-types";
import { test } from "../../../misc/fixtures";
import { Collection } from "../../../models/collection";
import { Project } from "../../../models/project";
test("Verify hovering an undefined variable swaps the tooltip to the render error instead of vanishing", async ({
user,
}) => {
@@ -18,7 +19,7 @@ test("Verify hovering an undefined variable swaps the tooltip to the render erro
);
await importFlow.importFile(
project,
path.join(import.meta.dirname, "collection-for-global-environments.yaml"),
path.join(__dirname, "collection-for-global-environments.yaml"),
);
const collection = new Collection("collection-for-global-environments");
await environmentFlow.activate(collection, "ExampleA");
@@ -44,7 +45,7 @@ test("Verify hovering the tooltip's own content keeps it visible", async ({ user
);
await importFlow.importFile(
project,
path.join(import.meta.dirname, "environment-cascade-collection.yaml"),
path.join(__dirname, "environment-cascade-collection.yaml"),
);
const collection = new Collection("Environment Cascade");
await environmentFlow.activate(collection, "Base Environment");
@@ -1,16 +1,17 @@
import path from "node:path";
import { faker } from "@faker-js/faker";
import { ProjectType } from "@package/enums/project-types";
import { test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
const cascadeFixture = path.join(import.meta.dirname, "environment-cascade-collection.yaml");
const globalCollectionFixture = path.join(import.meta.dirname, "collection-for-global-environments.yaml");
const globalEnvironmentFixture = path.join(import.meta.dirname, "global-environment.yaml");
const projectEnvironmentSourceFixture = path.join(import.meta.dirname, "project-environment-source.yaml");
import { ProjectType } from "../../../enums/project-types";
import { test } from "../../../misc/fixtures";
import { Collection } from "../../../models/collection";
import { Project } from "../../../models/project";
const cascadeFixture = path.join(__dirname, "environment-cascade-collection.yaml");
const globalCollectionFixture = path.join(__dirname, "collection-for-global-environments.yaml");
const globalEnvironmentFixture = path.join(__dirname, "global-environment.yaml");
const projectEnvironmentSourceFixture = path.join(__dirname, "project-environment-source.yaml");
test("Verify the tooltip's Open inside the Manage Environments modal selects the source environment, and works again after selecting another", async ({
user,
@@ -1,14 +1,15 @@
import path from "node:path";
import { faker } from "@faker-js/faker";
import { HttpMethod } from "@package/enums/http-method";
import { ProjectType } from "@package/enums/project-types";
import { certPath } from "@package/misc/certs";
import { DEFAULT_TIMEOUT, HTTP_SERVER_MTLS, test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { certPath } from "../../misc/certs";
import { DEFAULT_TIMEOUT, HTTP_SERVER_MTLS, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
const url = `${HTTP_SERVER_MTLS}/post`;
test("Verify pre-request script reads and replaces the client certificate via insomnia.request.certificate", async ({
@@ -19,7 +20,7 @@ test("Verify pre-request script reads and replaces the client certificate via in
await preferencesFlow.set({
validateSSL: false,
dataFolders: [path.join(import.meta.dirname, "../../misc/fixtures")],
dataFolders: [path.join(__dirname, "../../misc/fixtures")],
});
const project = await workspaceFlow.createProject(
@@ -53,14 +54,14 @@ test("Verify pre-request script reads and replaces the client certificate via in
});
const responseView = await httpRequestFlow.send(request);
expect(responseView.statusBar.code).toBe(200);
expect(responseView.statusCode).toBe(200);
await expect
.poll(() => responseView.console(), { timeout: DEFAULT_TIMEOUT })
.poll(() => responseView.console?.(), { timeout: DEFAULT_TIMEOUT })
.toContain("Adding SSL PEM certificate");
await expect
.poll(() => responseView.console(), { timeout: DEFAULT_TIMEOUT })
.poll(() => responseView.console?.(), { timeout: DEFAULT_TIMEOUT })
.toContain("Adding SSL KEY certificate");
await expect
.poll(() => responseView.console(), { timeout: DEFAULT_TIMEOUT })
.poll(() => responseView.console?.(), { timeout: DEFAULT_TIMEOUT })
.toContain("original cert:");
});
@@ -1,11 +1,12 @@
import { faker } from "@faker-js/faker";
import { HttpMethod } from "@package/enums/http-method";
import { ProjectType } from "@package/enums/project-types";
import { DEFAULT_TIMEOUT, HTTP_SERVER, test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { DEFAULT_TIMEOUT, HTTP_SERVER, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
const url = `${HTTP_SERVER}/post`;
test("Verify pre-request script reads the configured proxy and overrides it via insomnia.request.proxy", async ({
@@ -48,11 +49,11 @@ test("Verify pre-request script reads the configured proxy and overrides it via
});
const responseView = await httpRequestFlow.send(request);
expect(responseView.statusBar.code).toBeUndefined();
expect(responseView.statusCode).toBeUndefined();
await expect
.poll(() => responseView.console(), { timeout: DEFAULT_TIMEOUT })
.poll(() => responseView.console?.(), { timeout: DEFAULT_TIMEOUT })
.toContain("localhost:1111");
await expect
.poll(() => responseView.console(), { timeout: DEFAULT_TIMEOUT })
.poll(() => responseView.console?.(), { timeout: DEFAULT_TIMEOUT })
.toContain("Trying 127.0.0.1:8888");
});
@@ -3,14 +3,15 @@ import os from "node:os";
import path from "node:path";
import { faker } from "@faker-js/faker";
import { HttpMethod } from "@package/enums/http-method";
import { ProjectType } from "@package/enums/project-types";
import { ResponseExportOption } from "@package/enums/response-export-option";
import { DEFAULT_TIMEOUT, HTTP_SERVER, LONG_TIMEOUT, test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { ResponseExportOption } from "../../enums/response-export-option";
import { DEFAULT_TIMEOUT, HTTP_SERVER, LONG_TIMEOUT, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
const LARGE_RESPONSE_BYTES = 5 * 1024 * 1024;
test("Verify exporting a small JSON response as raw, prettified and HTTP debug files", async ({
@@ -1,12 +1,13 @@
import { faker } from "@faker-js/faker";
import { ContentType } from "@package/enums/content-type";
import { HttpMethod } from "@package/enums/http-method";
import { ProjectType } from "@package/enums/project-types";
import { HTTP_SERVER, test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { ContentType } from "../../enums/content-type";
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { HTTP_SERVER, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
test("Verify a prompt Tag Caches its Value Under the Storage Key Until it is Cleared", async ({
user,
}) => {
@@ -48,10 +49,10 @@ test("Verify a prompt Tag Caches its Value Under the Storage Key Until it is Cle
expect(previewBeforeSend.functionName).toBe("prompt");
expect(first.promptInputType).toBe("password");
expect(first.response.statusBar.code).toBe(200);
expect(first.response.preview).toMatchObject({ data: firstValue });
expect(cached.statusBar.code).toBe(200);
expect(cached.preview).toMatchObject({ data: firstValue });
expect(second.response.statusBar.code).toBe(200);
expect(second.response.preview).toMatchObject({ data: secondValue });
expect(first.response.statusCode).toBe(200);
expect(first.response.body).toMatchObject({ data: firstValue });
expect(cached.statusCode).toBe(200);
expect(cached.body).toMatchObject({ data: firstValue });
expect(second.response.statusCode).toBe(200);
expect(second.response.body).toMatchObject({ data: secondValue });
});
@@ -1,12 +1,13 @@
import { faker } from "@faker-js/faker";
import { ContentType } from "@package/enums/content-type";
import { HttpMethod } from "@package/enums/http-method";
import { ProjectType } from "@package/enums/project-types";
import { HTTP_SERVER, test } from "@package/misc/fixtures";
import { Collection } from "@package/models/collection";
import { Project } from "@package/models/project";
import { expect } from "@playwright/test";
import { ContentType } from "../../enums/content-type";
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { HTTP_SERVER, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
test("Verify the response Tag's Trigger Behavior Controls When its Dependency Request is Resent", async ({
user,
}) => {
@@ -53,10 +54,10 @@ test("Verify the response Tag's Trigger Behavior Controls When its Dependency Re
const always = await httpRequestFlow.send(alwaysRequest);
await expect(neverFailure).rejects.toThrow(/No responses for request/);
expect(noHistory.statusBar.code).toBe(200);
expect(noHistory.preview).toMatchObject({ data: marker });
expect(whenExpired.statusBar.code).toBe(200);
expect(whenExpired.preview).toMatchObject({ data: marker });
expect(always.statusBar.code).toBe(200);
expect(always.preview).toMatchObject({ data: marker });
expect(noHistory.statusCode).toBe(200);
expect(noHistory.body).toMatchObject({ data: marker });
expect(whenExpired.statusCode).toBe(200);
expect(whenExpired.body).toMatchObject({ data: marker });
expect(always.statusCode).toBe(200);
expect(always.body).toMatchObject({ data: marker });
});