test(insomnia-test): use SpecPage, ProjectPage and PreferencesVaultPage in workspace, document, app and preferences specs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Bob QiuandClaude Sonnet 5.5 committed 2026-11-04 17:34:15 +08:00
1 parent 98196009bb
commit 2c2ebb9bbb
8 files changed
+85 -85

No files matched your search

@@ -5,18 +5,18 @@ import { test } from "../../misc/fixtures";
test("Verify logging out shows the Scratch Pad and other login entry points, and choosing Scratch Pad opens its workspace with no Document creation entry", async ({
user,
}) => {
const { workspacePage } = user.pageManager;
const { workspacePage, projectPage } = user.pageManager;
await workspacePage.logOut();
const scratchPadEntryPointVisible = await workspacePage.isLoginEntryPointVisible(
await projectPage.logOut();
const scratchPadEntryPointVisible = await projectPage.isLoginEntryPointVisible(
"Use local Scratch Pad",
);
const emailEntryPointVisible = await workspacePage.isLoginEntryPointVisible(
const emailEntryPointVisible = await projectPage.isLoginEntryPointVisible(
"Continue with Email",
);
await workspacePage.clickUseLocalScratchPad();
await projectPage.clickUseLocalScratchPad();
const unlockFullFeaturesVisible =
await workspacePage.isUnlockFullFeaturesVisible();
await projectPage.isUnlockFullFeaturesVisible();
await user.page
.getByRole("button", { name: "Create", exact: false })
@@ -11,7 +11,7 @@ test("Verify Spec Editor Toolbar's Generate Menu, Format Switch, And Preview Tog
user,
}) => {
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const project = await workspaceFlow.createProject(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
@@ -32,15 +32,15 @@ test("Verify Spec Editor Toolbar's Generate Menu, Format Switch, And Preview Tog
}),
),
);
const formatBefore = await workspacePage.getFormat();
const formatBefore = await specPage.getFormat();
const otherFormat =
formatBefore === SpecFormat.JSON ? SpecFormat.YAML : SpecFormat.JSON;
await workspacePage.selectFormat(otherFormat);
const formatAfter = await workspacePage.getFormat();
await specPage.selectFormat(otherFormat);
const formatAfter = await specPage.getFormat();
const previewBefore = await workspacePage.isPreviewOpen();
const previewAfterOpen = await workspacePage.togglePreview();
const previewAfterClose = await workspacePage.togglePreview();
const previewBefore = await specPage.isPreviewOpen();
const previewAfterOpen = await specPage.togglePreview();
const previewAfterClose = await specPage.togglePreview();
expect(collection.version).toBe("OpenAPI 3.0.0");
expect(formatAfter).toBe(otherFormat);
@@ -54,7 +54,7 @@ test("Verify Spec Editor Toolbar's Format Switch And Preview Toggle With A YAML
user,
}) => {
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const project = await workspaceFlow.createProject(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
@@ -77,15 +77,15 @@ paths:
`,
),
);
const formatBefore = await workspacePage.getFormat();
await workspacePage.selectFormat(SpecFormat.JSON);
const formatJson = await workspacePage.getFormat();
await workspacePage.selectFormat(SpecFormat.YAML);
const formatYaml = await workspacePage.getFormat();
const formatBefore = await specPage.getFormat();
await specPage.selectFormat(SpecFormat.JSON);
const formatJson = await specPage.getFormat();
await specPage.selectFormat(SpecFormat.YAML);
const formatYaml = await specPage.getFormat();
const previewBefore = await workspacePage.isPreviewOpen();
const previewAfterOpen = await workspacePage.togglePreview();
const previewAfterClose = await workspacePage.togglePreview();
const previewBefore = await specPage.isPreviewOpen();
const previewAfterOpen = await specPage.togglePreview();
const previewAfterClose = await specPage.togglePreview();
expect(collection.version).toBe("OpenAPI 3.0.0");
expect(formatBefore).toBe(SpecFormat.YAML);
@@ -23,7 +23,7 @@ test("Verify Spec Outline Sidebar Lists Every Section And Jumps To The Matching
user,
}) => {
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const s = buildSpec();
const project = await workspaceFlow.createProject(
@@ -62,29 +62,29 @@ test("Verify Spec Outline Sidebar Lists Every Section And Jumps To The Matching
),
);
const infoKeys = await workspacePage.getOutlineEntryKeys("info");
const serverKeys = await workspacePage.getOutlineEntryKeys("servers");
const pathKeys = await workspacePage.getOutlineEntryKeys("paths");
const schemaKeys = await workspacePage.getOutlineEntryKeys("schemas");
const parameterKeys = await workspacePage.getOutlineEntryKeys("parameters");
const securityKeys = await workspacePage.getOutlineEntryKeys("securitySchemes");
const infoKeys = await specPage.getOutlineEntryKeys("info");
const serverKeys = await specPage.getOutlineEntryKeys("servers");
const pathKeys = await specPage.getOutlineEntryKeys("paths");
const schemaKeys = await specPage.getOutlineEntryKeys("schemas");
const parameterKeys = await specPage.getOutlineEntryKeys("parameters");
const securityKeys = await specPage.getOutlineEntryKeys("securitySchemes");
await workspacePage.clickOutlineEntry("info", "title");
const infoTitle = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("info", "license");
const infoLicense = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("servers", 1);
const server = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("paths", s.pathB);
const pathRow = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("paths", s.pathA, HttpMethod.Post);
const pathMethod = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("schemas", s.schemaB);
const schema = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("parameters", s.parameter);
const parameter = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("securitySchemes", s.securityScheme);
const security = await workspacePage.getEditorSelection();
await specPage.clickOutlineEntry("info", "title");
const infoTitle = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("info", "license");
const infoLicense = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("servers", 1);
const server = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("paths", s.pathB);
const pathRow = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("paths", s.pathA, HttpMethod.Post);
const pathMethod = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("schemas", s.schemaB);
const schema = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("parameters", s.parameter);
const parameter = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("securitySchemes", s.securityScheme);
const security = await specPage.getEditorSelection();
expect(infoKeys).toEqual([
"info.title",
@@ -115,7 +115,7 @@ test("Verify Spec Outline Sidebar Lists Every Section And Jumps To The Matching
user,
}) => {
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const s = buildSpec();
const project = await workspaceFlow.createProject(
@@ -171,27 +171,27 @@ components:
),
);
const infoKeys = await workspacePage.getOutlineEntryKeys("info");
const serverKeys = await workspacePage.getOutlineEntryKeys("servers");
const pathKeys = await workspacePage.getOutlineEntryKeys("paths");
const schemaKeys = await workspacePage.getOutlineEntryKeys("schemas");
const parameterKeys = await workspacePage.getOutlineEntryKeys("parameters");
const securityKeys = await workspacePage.getOutlineEntryKeys("securitySchemes");
const infoKeys = await specPage.getOutlineEntryKeys("info");
const serverKeys = await specPage.getOutlineEntryKeys("servers");
const pathKeys = await specPage.getOutlineEntryKeys("paths");
const schemaKeys = await specPage.getOutlineEntryKeys("schemas");
const parameterKeys = await specPage.getOutlineEntryKeys("parameters");
const securityKeys = await specPage.getOutlineEntryKeys("securitySchemes");
await workspacePage.clickOutlineEntry("info", "license");
const infoLicense = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("servers", 1);
const server = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("paths", s.pathB);
const pathRow = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("paths", s.pathA, HttpMethod.Post);
const pathMethod = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("schemas", s.schemaB);
const schema = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("parameters", s.parameter);
const parameter = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("securitySchemes", s.securityScheme);
const security = await workspacePage.getEditorSelection();
await specPage.clickOutlineEntry("info", "license");
const infoLicense = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("servers", 1);
const server = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("paths", s.pathB);
const pathRow = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("paths", s.pathA, HttpMethod.Post);
const pathMethod = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("schemas", s.schemaB);
const schema = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("parameters", s.parameter);
const parameter = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("securitySchemes", s.securityScheme);
const security = await specPage.getEditorSelection();
expect(infoKeys).toEqual([
"info.title",
@@ -223,7 +223,7 @@ test("Verify Spec Outline Sidebar Jumps To The Line Of A Scalar Info Value In A
test.fail(true, "INS-4007");
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const title = faker.commerce.productName();
const version = faker.system.semver();
@@ -249,10 +249,10 @@ paths:
),
);
await workspacePage.clickOutlineEntry("info", "title");
const infoTitle = await workspacePage.getEditorSelection();
await workspacePage.clickOutlineEntry("info", "version");
const infoVersion = await workspacePage.getEditorSelection();
await specPage.clickOutlineEntry("info", "title");
const infoTitle = await specPage.getEditorSelection();
await specPage.clickOutlineEntry("info", "version");
const infoVersion = await specPage.getEditorSelection();
expect(infoTitle.text).toBe(`title: ${title}`);
expect(infoVersion.text).toBe(`version: ${version}`);
@@ -11,7 +11,7 @@ test("Verify Spectral Lint Errors Surface With A Line Reference", async ({
user,
}) => {
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const project = await workspaceFlow.createProject(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
@@ -23,7 +23,7 @@ test("Verify Spectral Lint Errors Surface With A Line Reference", async ({
);
const requestPath = `/${faker.word.sample()}`;
await workspacePage.setSpecification(
await specPage.setSpecification(
JSON.stringify({
openapi: "3.0.0",
info: { title: faker.commerce.productName(), version: "1.0.0" },
@@ -34,7 +34,7 @@ test("Verify Spectral Lint Errors Surface With A Line Reference", async ({
);
const baseline = await workspaceFlow.getLintState();
await workspacePage.setSpecification(
await specPage.setSpecification(
JSON.stringify({
openapi: "3.0.0",
info: { version: "1.0.0" },
@@ -57,7 +57,7 @@ test("Verify Spectral Lint Errors Surface With A Line Reference In A YAML Spec",
user,
}) => {
const { workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const project = await workspaceFlow.createProject(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
@@ -69,7 +69,7 @@ test("Verify Spectral Lint Errors Surface With A Line Reference In A YAML Spec",
);
const requestPath = `/${faker.word.sample()}`;
await workspacePage.setSpecification(
await specPage.setSpecification(
`openapi: 3.0.0
info:
title: ${faker.commerce.productName()}
@@ -84,7 +84,7 @@ paths:
);
const baseline = await workspaceFlow.getLintState();
await workspacePage.setSpecification(
await specPage.setSpecification(
`openapi: 3.0.0
info:
version: 1.0.0
@@ -9,9 +9,9 @@ test("Verify a new vault key can be generated and persists across reopening Pref
const generatedKey = await preferencesFlow.generateVaultKey();
const { preferencesPage } = user.pageManager;
const { preferencesPage, preferencesVaultPage } = user.pageManager;
await preferencesPage.open();
const redisplayedKey = await preferencesPage.getVaultKey();
const redisplayedKey = await preferencesVaultPage.getVaultKey();
await preferencesPage.close();
expect(generatedKey.length).toBeGreaterThan(0);
@@ -19,9 +19,9 @@ testWithVaultSalt(
await preferencesFlow.enterVaultKey("invalidVaultKey");
const resetKey = await preferencesFlow.resetVaultKey();
const { preferencesPage } = user.pageManager;
const { preferencesPage, preferencesVaultPage } = user.pageManager;
await preferencesPage.open();
const displayedKey = await preferencesPage.getVaultKey();
const displayedKey = await preferencesVaultPage.getVaultKey();
await preferencesPage.close();
expect(invalidKeyError).toBe(
@@ -41,9 +41,9 @@ test("Verify collection/request create and delete persist correctly while offlin
await user.page.reload({ waitUntil: "networkidle" });
const gotCollectionA = await workspaceFlow.getCollection(collectionA.name);
const gotRequestA = await httpRequestFlow.get(requestA.name, collectionA);
const gotRequestA = await httpRequestFlow.get(requestA.name);
const gotCollectionB = await workspaceFlow.getCollection(collectionB.name);
const gotRequestB = await httpRequestFlow.get(requestB.name, collectionB);
const gotRequestB = await httpRequestFlow.get(requestB.name);
expect(gotCollectionA).toBeDefined();
expect(gotRequestA).toBeUndefined();
@@ -13,7 +13,7 @@ test("Verify sidebar reorder behaves unchanged and persists across views when sw
user,
}) => {
const { workspaceFlow, folderFlow, httpRequestFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspacePage, specPage } = user.pageManager;
const project = await workspaceFlow.createProject(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
@@ -63,7 +63,7 @@ test("Verify sidebar reorder behaves unchanged and persists across views when sw
);
await workspacePage.clickNode(collectionNode);
await workspacePage.navigateSpec();
await specPage.navigate();
await httpRequestFlow.get(folderChild.name);
const treeAfterViewSwitch = await workspacePage.getTree();
const collectionChildrenAfterViewSwitch = treeAfterViewSwitch