refactor(tests): update context menu action tests and drag-drop functionality

- Refactored context menu action tests for collections and requests to use sequential tagging.
- Improved readability and consistency in test structure and assertions.
- Updated drag-and-drop tests for cross-project interactions to enhance clarity and maintainability.
- Ensured proper handling of asynchronous operations and improved test reliability.
This commit is contained in:
Bob Qiu committed 2026-09-28 12:09:54 +08:00
1 parent e1b919ca32
commit fac7a81708
17 files changed
+738 -885

No files matched your search

+60 -1
View File
@@ -137,7 +137,7 @@ jobs:
working-directory: packages/insomnia-test
env:
INSOMNIA_BINARY: ${{ github.workspace }}/packages/insomnia/dist/linux-unpacked/insomnia
run: xvfb-run --auto-servernum npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: xvfb-run --auto-servernum npx playwright test --grep-invert '@sequential' --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload Playwright report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
@@ -147,3 +147,62 @@ jobs:
path: packages/insomnia-test/playwright-report/
retention-days: 7
if-no-files-found: ignore
# ---------------------------------------------------------------------------
# Run tests tagged @sequential with a single worker. These cases interfere with
# each other (or with the parallel shards above) when run concurrently, so
# they're isolated into their own single-threaded stage.
# ---------------------------------------------------------------------------
test-sequential:
needs: build
timeout-minutes: 30
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
packages: read
steps:
- name: Checkout repo
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: "24"
- name: Restore Insomnia binary
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: packages/insomnia/dist/linux-unpacked
key: insomnia-linux-unpacked-${{ github.sha }}
fail-on-cache-miss: true
- name: Install test dependencies
run: |
sed -i 's/patch-package && npm run verify-bundle-plugins -w insomnia && npm run install-libcurl-electron/patch-package/' package.json
npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Electron system dependencies
working-directory: packages/insomnia-test
run: npx playwright install-deps chromium
- name: Install ffmpeg (required for video recording)
working-directory: packages/insomnia-test
run: npx playwright install ffmpeg
- name: Run Playwright tests (@sequential, single worker)
working-directory: packages/insomnia-test
env:
INSOMNIA_BINARY: ${{ github.workspace }}/packages/insomnia/dist/linux-unpacked/insomnia
run: xvfb-run --auto-servernum npx playwright test --grep '@sequential' --workers=1
- name: Upload Playwright report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
if: ${{ !cancelled() }}
with:
name: playwright-report-sequential
path: packages/insomnia-test/playwright-report/
retention-days: 7
if-no-files-found: ignore
@@ -1,30 +1,19 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import {
expect,
getServerCommits,
GIT_CREDENTIAL,
test,
} from "../../misc/git-fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { expect, getServerCommits, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify committing changes in a Git Sync project appears in History", async ({
user,
}) => {
test('Verify committing changes in a Git Sync project appears in History', { tag: '@sequential' }, async ({ user }) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)), faker.string.alphanumeric(10));
const message = faker.string.alphanumeric(10);
const commit = await gitSyncFlow.commit(message);
@@ -32,5 +21,5 @@ test("Verify committing changes in a Git Sync project appears in History", async
expect(commit.message).toEqual(message);
expect(commit.id).toBeDefined();
expect(serverCommits.some((c) => c.id === commit.id)).toBe(false);
expect(serverCommits.some(c => c.id === commit.id)).toBe(false);
});
@@ -1,25 +1,15 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import {
expect,
getServerBranches,
GIT_CREDENTIAL,
test,
} from "../../misc/git-fixtures";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { expect, getServerBranches, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Project } from '../../models/project';
test("Verify creating a new branch in a Git Sync project switches to it", async ({
user,
}) => {
test('Verify creating a new branch in a Git Sync project switches to it', { tag: '@sequential' }, async ({ user }) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
const { gitSyncPage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Git), GIT_CREDENTIAL.name);
const branchName = faker.string.alphanumeric(10);
await gitSyncFlow.createBranch(branchName);
@@ -1,33 +1,27 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import {
expect,
getServerBranches,
GIT_CREDENTIAL,
test,
} from "../../misc/git-fixtures";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { expect, getServerBranches, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Project } from '../../models/project';
test("Verify deleting a branch checks out master and removes it from the list", async ({
user,
}) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
const { gitSyncPage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
test(
'Verify deleting a branch checks out master and removes it from the list',
{ tag: '@sequential' },
async ({ user }) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
const { gitSyncPage } = user.pageManager;
const branchName = faker.string.alphanumeric(10);
await gitSyncFlow.createBranch(branchName);
await gitSyncFlow.deleteBranch(branchName);
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Git), GIT_CREDENTIAL.name);
const currentBranch = await gitSyncPage.getCurrentBranch();
const serverBranches = await getServerBranches();
const branchName = faker.string.alphanumeric(10);
await gitSyncFlow.createBranch(branchName);
await gitSyncFlow.deleteBranch(branchName);
expect(currentBranch).toBe("master");
expect(serverBranches).toEqual(["master"]);
});
const currentBranch = await gitSyncPage.getCurrentBranch();
const serverBranches = await getServerBranches();
expect(currentBranch).toBe('master');
expect(serverBranches).toEqual(['master']);
},
);
@@ -1,41 +1,38 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import {
expect,
getServerBranches,
GIT_CREDENTIAL,
test,
} from "../../misc/git-fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { expect, getServerBranches, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify merging a branch carries its committed changes into the current branch", async ({
user,
}) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
test(
'Verify merging a branch carries its committed changes into the current branch',
{ tag: '@sequential' },
async ({ user }) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const branchName = faker.string.alphanumeric(10);
await gitSyncFlow.createBranch(branchName);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
await gitSyncFlow.commit(faker.string.alphanumeric(10));
await gitSyncFlow.switchBranch("master");
await gitSyncFlow.mergeBranch(branchName);
const branchName = faker.string.alphanumeric(10);
await gitSyncFlow.createBranch(branchName);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
await gitSyncFlow.commit(faker.string.alphanumeric(10));
await gitSyncFlow.switchBranch('master');
await gitSyncFlow.mergeBranch(branchName);
const node = await workspacePage.findItemNode(collection);
const serverBranches = await getServerBranches();
const node = await workspacePage.findItemNode(collection);
const serverBranches = await getServerBranches();
expect(node).toBeDefined();
expect(serverBranches).toEqual(["master"]);
});
expect(node).toBeDefined();
expect(serverBranches).toEqual(['master']);
},
);
@@ -1,26 +1,22 @@
import * as fs from "node:fs";
import * as os from "node:os";
import path from "node:path";
import * as fs from 'node:fs';
import * as os from 'node:os';
import path from 'node:path';
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import { expect, test } from "../../misc/git-fixtures";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { expect, test } from '../../misc/git-fixtures';
import { Project } from '../../models/project';
test("Verify adopting an existing local folder as a Git project runs git init in it", async ({
user,
}) => {
const { workspaceFlow } = user.flowManager;
test(
'Verify adopting an existing local folder as a Git project runs git init in it',
{ tag: '@sequential' },
async ({ user }) => {
const { workspaceFlow } = user.flowManager;
const folderPath = fs.mkdtempSync(
path.join(os.tmpdir(), "insomnia-open-local-folder-"),
);
await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git, folderPath),
);
const folderPath = fs.mkdtempSync(path.join(os.tmpdir(), 'insomnia-open-local-folder-'));
await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Git, folderPath));
await expect
.poll(() => fs.existsSync(path.join(folderPath, ".git")))
.toBe(true);
});
await expect.poll(() => fs.existsSync(path.join(folderPath, '.git'))).toBe(true);
},
);
@@ -1,38 +1,24 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import {
expect,
getServerBranches,
getServerCommits,
GIT_CREDENTIAL,
test,
} from "../../misc/git-fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { expect, getServerBranches, getServerCommits, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify pushing committed changes to the remote succeeds", async ({
user,
}) => {
test('Verify pushing committed changes to the remote succeeds', { tag: '@sequential' }, async ({ user }) => {
const { gitSyncFlow, preferencesFlow, workspaceFlow } = user.flowManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)), faker.string.alphanumeric(10));
const commit = await gitSyncFlow.commitAndPush(faker.string.alphanumeric(10));
const branches = await getServerBranches();
const commits = await getServerCommits();
expect(branches).toContain("master");
expect(commits).toContainEqual(
expect.objectContaining({ id: commit.id, message: commit.message }),
);
expect(branches).toContain('master');
expect(commits).toContainEqual(expect.objectContaining({ id: commit.id, message: commit.message }));
});
@@ -1,35 +1,35 @@
import * as fs from "node:fs";
import * as os from "node:os";
import path from "node:path";
import * as fs from 'node:fs';
import * as os from 'node:os';
import path from 'node:path';
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../enums/project-types";
import { DEFAULT_TIMEOUT } from "../../misc/fixtures";
import { expect, GIT_CREDENTIAL, test } from "../../misc/git-fixtures";
import { Project } from "../../models/project";
import { ProjectType } from '../../enums/project-types';
import { DEFAULT_TIMEOUT } from '../../misc/fixtures';
import { expect, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Project } from '../../models/project';
test("Verify relocating a Git Sync project's repository shows an error when the destination folder already exists", async ({
user,
}) => {
const { preferencesFlow, workspaceFlow } = user.flowManager;
const { projectSettingsPage } = user.pageManager;
test(
"Verify relocating a Git Sync project's repository shows an error when the destination folder already exists",
{ tag: '@sequential' },
async ({ user }) => {
const { preferencesFlow, workspaceFlow } = user.flowManager;
const { projectSettingsPage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
await workspaceFlow.openSettings(project);
const destinationDir = fs.mkdtempSync(
path.join(os.tmpdir(), "insomnia-relocate-collision-"),
);
fs.writeFileSync(path.join(destinationDir, "existing-file.txt"), "");
await projectSettingsPage.relocateRepository(destinationDir);
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
await workspaceFlow.openSettings(project);
const destinationDir = fs.mkdtempSync(path.join(os.tmpdir(), 'insomnia-relocate-collision-'));
fs.writeFileSync(path.join(destinationDir, 'existing-file.txt'), '');
await projectSettingsPage.relocateRepository(destinationDir);
await expect
.poll(() => projectSettingsPage.getRelocationError(), {
timeout: DEFAULT_TIMEOUT,
})
.toMatch(/already has files in it and isn't a git repository/i);
});
await expect
.poll(() => projectSettingsPage.getRelocationError(), {
timeout: DEFAULT_TIMEOUT,
})
.toMatch(/already has files in it and isn't a git repository/i);
},
);
@@ -1,77 +1,67 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { TreeNodeType } from "../../enums/tree-node-types";
import { HTTP_SERVER } from "../../misc/fixtures";
import { expect, GIT_CREDENTIAL, test } from "../../misc/git-fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { HttpMethod } from '../../enums/http-method';
import { ProjectType } from '../../enums/project-types';
import { TreeNodeType } from '../../enums/tree-node-types';
import { HTTP_SERVER } from '../../misc/fixtures';
import { expect, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify dragging a request out of a Git Sync collection into an empty Git Sync collection", async ({
user,
}) => {
const { workspaceFlow, httpRequestFlow, preferencesFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
test(
'Verify dragging a request out of a Git Sync collection into an empty Git Sync collection',
{ tag: '@sequential' },
async ({ user }) => {
const { workspaceFlow, httpRequestFlow, preferencesFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const sourceCollection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const emptyCollection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const draggedRequest = await httpRequestFlow.create(sourceCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const sourceCollection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const emptyCollection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const draggedRequest = await httpRequestFlow.create(sourceCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const sourceCollectionNode = (await workspacePage.findItemNode(
sourceCollection,
TreeNodeType.Workspace,
))!;
const emptyCollectionNode = (await workspacePage.findItemNode(
emptyCollection,
TreeNodeType.Workspace,
))!;
const draggedRequestNode = (await workspacePage.findItemNode(
{ name: draggedRequest.name, id: draggedRequest.id },
TreeNodeType.Request,
sourceCollectionNode,
))!;
const emptyCollectionPlaceholder = {
_id: `empty-collection-${emptyCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
const sourceCollectionNode = (await workspacePage.findItemNode(sourceCollection, TreeNodeType.Workspace))!;
const emptyCollectionNode = (await workspacePage.findItemNode(emptyCollection, TreeNodeType.Workspace))!;
const draggedRequestNode = (await workspacePage.findItemNode(
{ name: draggedRequest.name, id: draggedRequest.id },
TreeNodeType.Request,
sourceCollectionNode,
))!;
const emptyCollectionPlaceholder = {
_id: `empty-collection-${emptyCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(draggedRequestNode);
await workspacePage.dragOver(emptyCollectionPlaceholder, 0.5, 0.5);
const indicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterDrag = await workspacePage.getTree();
const sourceCollectionChildrenAfter = treeAfterDrag
.flatten()
.find((n) => n._id === sourceCollectionNode._id)!.children;
const emptyCollectionChildrenAfter = treeAfterDrag
.flatten()
.find((n) => n._id === emptyCollectionNode._id)!.children;
await workspacePage.startDrag(draggedRequestNode);
await workspacePage.dragOver(emptyCollectionPlaceholder, 0.5, 0.5);
const indicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterDrag = await workspacePage.getTree();
const sourceCollectionChildrenAfter = treeAfterDrag
.flatten()
.find(n => n._id === sourceCollectionNode._id)!.children;
const emptyCollectionChildrenAfter = treeAfterDrag.flatten().find(n => n._id === emptyCollectionNode._id)!.children;
expect(indicator?.isValid).toBe(true);
expect(
sourceCollectionChildrenAfter.some((n) => n._id === draggedRequestNode._id),
).toBe(false);
expect(
emptyCollectionChildrenAfter.some((n) => n._id === draggedRequestNode._id),
).toBe(true);
});
expect(indicator?.isValid).toBe(true);
expect(sourceCollectionChildrenAfter.some(n => n._id === draggedRequestNode._id)).toBe(false);
expect(emptyCollectionChildrenAfter.some(n => n._id === draggedRequestNode._id)).toBe(true);
},
);
@@ -1,25 +1,18 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { expect, HTTP_SERVER,test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { HttpMethod } from '../../enums/http-method';
import { ProjectType } from '../../enums/project-types';
import { expect, 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 manipulates request headers and body via insomnia.request", async ({
user,
}) => {
test('Verify pre-request script manipulates request headers and body via insomnia.request', async ({ user }) => {
const { httpRequestFlow, workspaceFlow } = user.flowManager;
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
);
const project = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const collection = await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)));
const headerValue = faker.string.alphanumeric(10);
const rawContent = faker.string.alphanumeric(10);
@@ -38,30 +31,26 @@ test("Verify pre-request script manipulates request headers and body via insomni
expect(response.statusCode).toBe(200);
expect(response.body).toMatchObject({
data: rawContent,
headers: expect.objectContaining({ "x-hello": headerValue }),
headers: expect.objectContaining({ 'x-hello': headerValue }),
});
});
test("Verify pre-request script sets bearer auth via insomnia.request.auth", async ({
user,
}) => {
const { httpRequestFlow, workspaceFlow } = user.flowManager;
test(
'Verify pre-request script sets bearer auth via insomnia.request.auth',
{ tag: '@sequential' },
async ({ user }) => {
const { httpRequestFlow, workspaceFlow } = user.flowManager;
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
);
const project = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const collection = await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)));
const token = faker.string.alphanumeric(10);
const prefix = faker.string.alpha(8);
const request = await httpRequestFlow.create(collection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Post,
url,
preRequestScript: `
const token = faker.string.alphanumeric(10);
const prefix = faker.string.alpha(8);
const request = await httpRequestFlow.create(collection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Post,
url,
preRequestScript: `
insomnia.request.auth.update({
type: 'bearer',
bearer: [
@@ -70,29 +59,23 @@ test("Verify pre-request script sets bearer auth via insomnia.request.auth", asy
],
}, 'bearer');
`,
});
const response = await httpRequestFlow.send(request);
});
const response = await httpRequestFlow.send(request);
expect(response.statusCode).toBe(200);
expect(response.body).toMatchObject({
headers: expect.objectContaining({
authorization: `${prefix} ${token}`,
}),
});
});
expect(response.statusCode).toBe(200);
expect(response.body).toMatchObject({
headers: expect.objectContaining({
authorization: `${prefix} ${token}`,
}),
});
},
);
test("Verify pre-request script sets basic auth via insomnia.request.auth", async ({
user,
}) => {
test('Verify pre-request script sets basic auth via insomnia.request.auth', async ({ user }) => {
const { httpRequestFlow, workspaceFlow } = user.flowManager;
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
);
const project = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const collection = await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)));
const username = faker.string.alphanumeric(10);
const password = faker.string.alphanumeric(10);
@@ -112,10 +95,7 @@ test("Verify pre-request script sets basic auth via insomnia.request.auth", asyn
});
const response = await httpRequestFlow.send(request);
const expectedEncodedCredentials = Buffer.from(
`${username}:${password}`,
"utf8",
).toString("base64");
const expectedEncodedCredentials = Buffer.from(`${username}:${password}`, 'utf8').toString('base64');
expect(response.statusCode).toBe(200);
expect(response.body).toMatchObject({
headers: expect.objectContaining({
@@ -1,28 +1,29 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { DEFAULT_TIMEOUT,expect, test } from "../../misc/fixtures";
import { DEFAULT_TIMEOUT, expect, test } from '../../misc/fixtures';
test("Verify configuring a Konnect PAT closes the settings modal, shows the Sync Konnect button, and leaves the Projects tab usable", async ({
user,
}) => {
const { konnectPage, workspacePage } = user.pageManager;
test(
'Verify configuring a Konnect PAT closes the settings modal, shows the Sync Konnect button, and leaves the Projects tab usable',
{ tag: '@sequential' },
async ({ user }) => {
const { konnectPage, workspacePage } = user.pageManager;
await konnectPage.openTab();
const introVisibleBeforeConfigure = await konnectPage.isIntroCardVisible();
await konnectPage.clickConfigure();
await konnectPage.setPat(`kpat_${faker.string.alphanumeric(20)}`);
await konnectPage.clickConnectAndSync();
const settingsModalOpenAfterConnect =
await konnectPage.isSettingsModalOpen();
await expect
.poll(() => konnectPage.isSyncButtonVisible(), {
timeout: DEFAULT_TIMEOUT,
})
.toBe(true);
await konnectPage.openTab();
const introVisibleBeforeConfigure = await konnectPage.isIntroCardVisible();
await konnectPage.clickConfigure();
await konnectPage.setPat(`kpat_${faker.string.alphanumeric(20)}`);
await konnectPage.clickConnectAndSync();
const settingsModalOpenAfterConnect = await konnectPage.isSettingsModalOpen();
await expect
.poll(() => konnectPage.isSyncButtonVisible(), {
timeout: DEFAULT_TIMEOUT,
})
.toBe(true);
await konnectPage.openProjectsTab();
await workspacePage.navigate();
await konnectPage.openProjectsTab();
await workspacePage.navigate();
expect(introVisibleBeforeConfigure).toBe(true);
expect(settingsModalOpenAfterConnect).toBe(false);
});
expect(introVisibleBeforeConfigure).toBe(true);
expect(settingsModalOpenAfterConnect).toBe(false);
},
);
@@ -1,48 +1,39 @@
import * as fs from "node:fs";
import path from "node:path";
import * as fs from 'node:fs';
import path from 'node:path';
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { ProjectType } from "../../../enums/project-types";
import { DEFAULT_TIMEOUT,expect, test } from "../../../misc/fixtures";
import { Collection } from "../../../models/collection";
import { Project } from "../../../models/project";
import { ProjectType } from '../../../enums/project-types';
import { DEFAULT_TIMEOUT, expect, test } from '../../../misc/fixtures';
import { Collection } from '../../../models/collection';
import { Project } from '../../../models/project';
test("Verify a plugin's context-menu action shows the Collection's name and type in a modal", async ({
user,
}) => {
test.fail(true, "INS-3521");
test(
"Verify a plugin's context-menu action shows the Collection's name and type in a modal",
{ tag: '@sequential' },
async ({ user }) => {
test.fail(true, 'INS-3521');
const { appFlow, workspaceFlow } = user.flowManager;
const { preferencesPage, workspacePage } = user.pageManager;
const { appFlow, workspaceFlow } = user.flowManager;
const { preferencesPage, workspacePage } = user.pageManager;
const actionLabel = "Show Collection Info";
const dataPath = await appFlow.getDataPath();
const pluginDir = path.join(dataPath, "plugins", `insomnia-plugin-test`);
fs.mkdirSync(pluginDir, { recursive: true });
fs.copyFileSync(
path.join(__dirname, "plugin-package.json"),
path.join(pluginDir, "package.json"),
);
fs.copyFileSync(
path.join(__dirname, "plugin-main.js"),
path.join(pluginDir, "main.js"),
);
await preferencesPage.reloadPlugins();
const actionLabel = 'Show Collection Info';
const dataPath = await appFlow.getDataPath();
const pluginDir = path.join(dataPath, 'plugins', `insomnia-plugin-test`);
fs.mkdirSync(pluginDir, { recursive: true });
fs.copyFileSync(path.join(__dirname, 'plugin-package.json'), path.join(pluginDir, 'package.json'));
fs.copyFileSync(path.join(__dirname, 'plugin-main.js'), path.join(pluginDir, 'main.js'));
await preferencesPage.reloadPlugins();
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
);
const project = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const collection = await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)));
await workspacePage.clickItemContextMenu(collection.name, actionLabel);
const dialog = user.page.getByRole("dialog");
await expect(dialog).toBeVisible({ timeout: DEFAULT_TIMEOUT });
const dialogText = await dialog.innerText();
await workspacePage.clickItemContextMenu(collection.name, actionLabel);
const dialog = user.page.getByRole('dialog');
await expect(dialog).toBeVisible({ timeout: DEFAULT_TIMEOUT });
const dialogText = await dialog.innerText();
expect(dialogText).toContain(collection.name);
expect(dialogText).toContain("Collection");
});
expect(dialogText).toContain(collection.name);
expect(dialogText).toContain('Collection');
},
);
@@ -1,56 +1,47 @@
import * as fs from "node:fs";
import path from "node:path";
import * as fs from 'node:fs';
import path from 'node:path';
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../../enums/http-method";
import { ProjectType } from "../../../enums/project-types";
import { DEFAULT_TIMEOUT,expect, HTTP_SERVER, test } from "../../../misc/fixtures";
import { Collection } from "../../../models/collection";
import type { HttpRequest } from "../../../models/http-request";
import { Project } from "../../../models/project";
import { HttpMethod } from '../../../enums/http-method';
import { ProjectType } from '../../../enums/project-types';
import { DEFAULT_TIMEOUT, expect, HTTP_SERVER, test } from '../../../misc/fixtures';
import { Collection } from '../../../models/collection';
import type { HttpRequest } from '../../../models/http-request';
import { Project } from '../../../models/project';
test("Verify a plugin's context-menu action shows the target item's name and type in a modal", async ({
user,
}) => {
test.fail(true, "INS-3521");
test(
"Verify a plugin's context-menu action shows the target item's name and type in a modal",
{ tag: '@sequential' },
async ({ user }) => {
test.fail(true, 'INS-3521');
const { appFlow, workspaceFlow, httpRequestFlow } = user.flowManager;
const { preferencesPage, workspacePage } = user.pageManager;
const { appFlow, workspaceFlow, httpRequestFlow } = user.flowManager;
const { preferencesPage, workspacePage } = user.pageManager;
const actionLabel = "Show Item Info";
const dataPath = await appFlow.getDataPath();
const pluginDir = path.join(dataPath, "plugins", `insomnia-plugin-test`);
fs.mkdirSync(pluginDir, { recursive: true });
fs.copyFileSync(
path.join(__dirname, "plugin-package.json"),
path.join(pluginDir, "package.json"),
);
fs.copyFileSync(
path.join(__dirname, "plugin-main.js"),
path.join(pluginDir, "main.js"),
);
await preferencesPage.reloadPlugins();
const actionLabel = 'Show Item Info';
const dataPath = await appFlow.getDataPath();
const pluginDir = path.join(dataPath, 'plugins', `insomnia-plugin-test`);
fs.mkdirSync(pluginDir, { recursive: true });
fs.copyFileSync(path.join(__dirname, 'plugin-package.json'), path.join(pluginDir, 'package.json'));
fs.copyFileSync(path.join(__dirname, 'plugin-main.js'), path.join(pluginDir, 'main.js'));
await preferencesPage.reloadPlugins();
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
);
const requestName = faker.string.alphanumeric(10);
await httpRequestFlow.create(collection, {
name: requestName,
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
} as HttpRequest);
const project = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const collection = await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)));
const requestName = faker.string.alphanumeric(10);
await httpRequestFlow.create(collection, {
name: requestName,
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
} as HttpRequest);
await workspacePage.clickItemContextMenu(requestName, actionLabel);
const dialog = user.page.getByRole("dialog");
await expect(dialog).toBeVisible({ timeout: DEFAULT_TIMEOUT });
const dialogText = await dialog.innerText();
await workspacePage.clickItemContextMenu(requestName, actionLabel);
const dialog = user.page.getByRole('dialog');
await expect(dialog).toBeVisible({ timeout: DEFAULT_TIMEOUT });
const dialogText = await dialog.innerText();
expect(dialogText).toContain(requestName);
expect(dialogText).toContain(HttpMethod.Get);
});
expect(dialogText).toContain(requestName);
expect(dialogText).toContain(HttpMethod.Get);
},
);
@@ -1,116 +1,95 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { TreeNodeType } from "../../enums/tree-node-types";
import { HTTP_SERVER } from "../../misc/fixtures";
import { expect, GIT_CREDENTIAL, test } from "../../misc/git-fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { HttpMethod } from '../../enums/http-method';
import { ProjectType } from '../../enums/project-types';
import { TreeNodeType } from '../../enums/tree-node-types';
import { HTTP_SERVER } from '../../misc/fixtures';
import { expect, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify dragging a request between a Cloud project and a Git project moves it in both directions", async ({
user,
}) => {
test.fail(true, "INS-3844");
test(
'Verify dragging a request between a Cloud project and a Git project moves it in both directions',
{ tag: '@sequential' },
async ({ user }) => {
test.fail(true, 'INS-3844');
const { workspaceFlow, httpRequestFlow, preferencesFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspaceFlow, httpRequestFlow, preferencesFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const gitProject = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const gitCollection = await workspaceFlow.create(
gitProject,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const cloudProject = (await workspaceFlow.getProject({
name: "Personal Workspace",
}))!;
const cloudCollection = await workspaceFlow.create(
cloudProject,
new Collection(faker.string.alphanumeric(10)),
);
const request = await httpRequestFlow.create(gitCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const gitProject = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const gitCollection = await workspaceFlow.create(
gitProject,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const cloudProject = (await workspaceFlow.getProject({
name: 'Personal Workspace',
}))!;
const cloudCollection = await workspaceFlow.create(cloudProject, new Collection(faker.string.alphanumeric(10)));
const request = await httpRequestFlow.create(gitCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const gitProjectNode = (await workspacePage.findItemNode(
gitProject,
TreeNodeType.Project,
))!;
const cloudProjectNode = (await workspacePage.findItemNode(
cloudProject,
TreeNodeType.Project,
))!;
await workspacePage.expand(gitProjectNode);
await workspacePage.expand(cloudProjectNode);
const gitCollectionNode = (await workspacePage.findItemNode(
gitCollection,
TreeNodeType.Workspace,
))!;
const cloudCollectionNode = (await workspacePage.findItemNode(
cloudCollection,
TreeNodeType.Workspace,
))!;
const requestNode = (await workspacePage.findItemNode(
{ name: request.name, id: request.id },
TreeNodeType.Request,
gitCollectionNode,
))!;
const emptyCloudCollectionPlaceholder = {
_id: `empty-collection-${cloudCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
const gitProjectNode = (await workspacePage.findItemNode(gitProject, TreeNodeType.Project))!;
const cloudProjectNode = (await workspacePage.findItemNode(cloudProject, TreeNodeType.Project))!;
await workspacePage.expand(gitProjectNode);
await workspacePage.expand(cloudProjectNode);
const gitCollectionNode = (await workspacePage.findItemNode(gitCollection, TreeNodeType.Workspace))!;
const cloudCollectionNode = (await workspacePage.findItemNode(cloudCollection, TreeNodeType.Workspace))!;
const requestNode = (await workspacePage.findItemNode(
{ name: request.name, id: request.id },
TreeNodeType.Request,
gitCollectionNode,
))!;
const emptyCloudCollectionPlaceholder = {
_id: `empty-collection-${cloudCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyCloudCollectionPlaceholder, 0.5, 0.5);
const gitToCloudIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterGitToCloud = await workspacePage.getTree();
const gitCollectionChildrenAfterMove = treeAfterGitToCloud
.flatten()
.find((n) => n._id === gitCollectionNode._id)!.children;
const cloudCollectionChildrenAfterMove = treeAfterGitToCloud
.flatten()
.find((n) => n._id === cloudCollectionNode._id)!.children;
const emptyGitCollectionPlaceholder = {
_id: `empty-collection-${gitCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyCloudCollectionPlaceholder, 0.5, 0.5);
const gitToCloudIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterGitToCloud = await workspacePage.getTree();
const gitCollectionChildrenAfterMove = treeAfterGitToCloud
.flatten()
.find(n => n._id === gitCollectionNode._id)!.children;
const cloudCollectionChildrenAfterMove = treeAfterGitToCloud
.flatten()
.find(n => n._id === cloudCollectionNode._id)!.children;
const emptyGitCollectionPlaceholder = {
_id: `empty-collection-${gitCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyGitCollectionPlaceholder, 0.5, 0.5);
const cloudToGitIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterCloudToGit = await workspacePage.getTree();
const cloudCollectionChildrenAfterMoveBack = treeAfterCloudToGit
.flatten()
.find((n) => n._id === cloudCollectionNode._id)!.children;
const gitCollectionChildrenAfterMoveBack = treeAfterCloudToGit
.flatten()
.find((n) => n._id === gitCollectionNode._id)!.children;
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyGitCollectionPlaceholder, 0.5, 0.5);
const cloudToGitIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterCloudToGit = await workspacePage.getTree();
const cloudCollectionChildrenAfterMoveBack = treeAfterCloudToGit
.flatten()
.find(n => n._id === cloudCollectionNode._id)!.children;
const gitCollectionChildrenAfterMoveBack = treeAfterCloudToGit
.flatten()
.find(n => n._id === gitCollectionNode._id)!.children;
expect(gitToCloudIndicator?.isValid).toBe(true);
expect(
gitCollectionChildrenAfterMove.some((n) => n._id === requestNode._id),
).toBe(false);
expect(
cloudCollectionChildrenAfterMove.some((n) => n._id === requestNode._id),
).toBe(true);
expect(cloudToGitIndicator?.isValid).toBe(true);
expect(
cloudCollectionChildrenAfterMoveBack.some((n) => n._id === requestNode._id),
).toBe(false);
expect(
gitCollectionChildrenAfterMoveBack.some((n) => n._id === requestNode._id),
).toBe(true);
});
expect(gitToCloudIndicator?.isValid).toBe(true);
expect(gitCollectionChildrenAfterMove.some(n => n._id === requestNode._id)).toBe(false);
expect(cloudCollectionChildrenAfterMove.some(n => n._id === requestNode._id)).toBe(true);
expect(cloudToGitIndicator?.isValid).toBe(true);
expect(cloudCollectionChildrenAfterMoveBack.some(n => n._id === requestNode._id)).toBe(false);
expect(gitCollectionChildrenAfterMoveBack.some(n => n._id === requestNode._id)).toBe(true);
},
);
@@ -1,112 +1,86 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { TreeNodeType } from "../../enums/tree-node-types";
import { expect, HTTP_SERVER, test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { HttpMethod } from '../../enums/http-method';
import { ProjectType } from '../../enums/project-types';
import { TreeNodeType } from '../../enums/tree-node-types';
import { expect, HTTP_SERVER, test } from '../../misc/fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify dragging a request between a Cloud project and a Local project moves it in both directions", async ({
user,
}) => {
test.fail(true, "INS-3844");
test(
'Verify dragging a request between a Cloud project and a Local project moves it in both directions',
{ tag: '@sequential' },
async ({ user }) => {
test.fail(true, 'INS-3844');
const { workspaceFlow, httpRequestFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const { workspaceFlow, httpRequestFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
const localProject = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const localCollection = await workspaceFlow.create(
localProject,
new Collection(faker.string.alphanumeric(10)),
);
const cloudProject = (await workspaceFlow.getProject({
name: "Personal Workspace",
}))!;
const cloudCollection = await workspaceFlow.create(
cloudProject,
new Collection(faker.string.alphanumeric(10)),
);
const request = await httpRequestFlow.create(localCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const localProject = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const localCollection = await workspaceFlow.create(localProject, new Collection(faker.string.alphanumeric(10)));
const cloudProject = (await workspaceFlow.getProject({
name: 'Personal Workspace',
}))!;
const cloudCollection = await workspaceFlow.create(cloudProject, new Collection(faker.string.alphanumeric(10)));
const request = await httpRequestFlow.create(localCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const localProjectNode = (await workspacePage.findItemNode(
localProject,
TreeNodeType.Project,
))!;
const cloudProjectNode = (await workspacePage.findItemNode(
cloudProject,
TreeNodeType.Project,
))!;
await workspacePage.expand(localProjectNode);
await workspacePage.expand(cloudProjectNode);
const localCollectionNode = (await workspacePage.findItemNode(
localCollection,
TreeNodeType.Workspace,
))!;
const cloudCollectionNode = (await workspacePage.findItemNode(
cloudCollection,
TreeNodeType.Workspace,
))!;
const requestNode = (await workspacePage.findItemNode(
{ name: request.name, id: request.id },
TreeNodeType.Request,
localCollectionNode,
))!;
const emptyCloudCollectionPlaceholder = {
_id: `empty-collection-${cloudCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
const localProjectNode = (await workspacePage.findItemNode(localProject, TreeNodeType.Project))!;
const cloudProjectNode = (await workspacePage.findItemNode(cloudProject, TreeNodeType.Project))!;
await workspacePage.expand(localProjectNode);
await workspacePage.expand(cloudProjectNode);
const localCollectionNode = (await workspacePage.findItemNode(localCollection, TreeNodeType.Workspace))!;
const cloudCollectionNode = (await workspacePage.findItemNode(cloudCollection, TreeNodeType.Workspace))!;
const requestNode = (await workspacePage.findItemNode(
{ name: request.name, id: request.id },
TreeNodeType.Request,
localCollectionNode,
))!;
const emptyCloudCollectionPlaceholder = {
_id: `empty-collection-${cloudCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyCloudCollectionPlaceholder, 0.5, 0.5);
const localToCloudIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterLocalToCloud = await workspacePage.getTree();
const localCollectionChildrenAfterMove = treeAfterLocalToCloud
.flatten()
.find((n) => n._id === localCollectionNode._id)!.children;
const cloudCollectionChildrenAfterMove = treeAfterLocalToCloud
.flatten()
.find((n) => n._id === cloudCollectionNode._id)!.children;
const emptyLocalCollectionPlaceholder = {
_id: `empty-collection-${localCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyCloudCollectionPlaceholder, 0.5, 0.5);
const localToCloudIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterLocalToCloud = await workspacePage.getTree();
const localCollectionChildrenAfterMove = treeAfterLocalToCloud
.flatten()
.find(n => n._id === localCollectionNode._id)!.children;
const cloudCollectionChildrenAfterMove = treeAfterLocalToCloud
.flatten()
.find(n => n._id === cloudCollectionNode._id)!.children;
const emptyLocalCollectionPlaceholder = {
_id: `empty-collection-${localCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyLocalCollectionPlaceholder, 0.5, 0.5);
const cloudToLocalIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterCloudToLocal = await workspacePage.getTree();
const cloudCollectionChildrenAfterMoveBack = treeAfterCloudToLocal
.flatten()
.find((n) => n._id === cloudCollectionNode._id)!.children;
const localCollectionChildrenAfterMoveBack = treeAfterCloudToLocal
.flatten()
.find((n) => n._id === localCollectionNode._id)!.children;
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyLocalCollectionPlaceholder, 0.5, 0.5);
const cloudToLocalIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterCloudToLocal = await workspacePage.getTree();
const cloudCollectionChildrenAfterMoveBack = treeAfterCloudToLocal
.flatten()
.find(n => n._id === cloudCollectionNode._id)!.children;
const localCollectionChildrenAfterMoveBack = treeAfterCloudToLocal
.flatten()
.find(n => n._id === localCollectionNode._id)!.children;
expect(localToCloudIndicator?.isValid).toBe(true);
expect(
localCollectionChildrenAfterMove.some((n) => n._id === requestNode._id),
).toBe(false);
expect(
cloudCollectionChildrenAfterMove.some((n) => n._id === requestNode._id),
).toBe(true);
expect(cloudToLocalIndicator?.isValid).toBe(true);
expect(
cloudCollectionChildrenAfterMoveBack.some((n) => n._id === requestNode._id),
).toBe(false);
expect(
localCollectionChildrenAfterMoveBack.some((n) => n._id === requestNode._id),
).toBe(true);
});
expect(localToCloudIndicator?.isValid).toBe(true);
expect(localCollectionChildrenAfterMove.some(n => n._id === requestNode._id)).toBe(false);
expect(cloudCollectionChildrenAfterMove.some(n => n._id === requestNode._id)).toBe(true);
expect(cloudToLocalIndicator?.isValid).toBe(true);
expect(cloudCollectionChildrenAfterMoveBack.some(n => n._id === requestNode._id)).toBe(false);
expect(localCollectionChildrenAfterMoveBack.some(n => n._id === requestNode._id)).toBe(true);
},
);
@@ -1,114 +1,91 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { TreeNodeType } from "../../enums/tree-node-types";
import { HTTP_SERVER } from "../../misc/fixtures";
import { expect, GIT_CREDENTIAL, test } from "../../misc/git-fixtures";
import { Collection } from "../../models/collection";
import { Project } from "../../models/project";
import { HttpMethod } from '../../enums/http-method';
import { ProjectType } from '../../enums/project-types';
import { TreeNodeType } from '../../enums/tree-node-types';
import { HTTP_SERVER } from '../../misc/fixtures';
import { expect, GIT_CREDENTIAL, test } from '../../misc/git-fixtures';
import { Collection } from '../../models/collection';
import { Project } from '../../models/project';
test("Verify dragging a request between a Local project and a Git project moves it in both directions", async ({
user,
}) => {
const { workspaceFlow, httpRequestFlow, preferencesFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
test(
'Verify dragging a request between a Local project and a Git project moves it in both directions',
{ tag: '@sequential' },
async ({ user }) => {
const { workspaceFlow, httpRequestFlow, preferencesFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const localProject = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const localCollection = await workspaceFlow.create(
localProject,
new Collection(faker.string.alphanumeric(10)),
);
const gitProject = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const gitCollection = await workspaceFlow.create(
gitProject,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const request = await httpRequestFlow.create(localCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
await preferencesFlow.addGitCredential(GIT_CREDENTIAL);
const localProject = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const localCollection = await workspaceFlow.create(localProject, new Collection(faker.string.alphanumeric(10)));
const gitProject = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Git),
GIT_CREDENTIAL.name,
);
const gitCollection = await workspaceFlow.create(
gitProject,
new Collection(faker.string.alphanumeric(10)),
faker.string.alphanumeric(10),
);
const request = await httpRequestFlow.create(localCollection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const localProjectNode = (await workspacePage.findItemNode(
localProject,
TreeNodeType.Project,
))!;
const gitProjectNode = (await workspacePage.findItemNode(
gitProject,
TreeNodeType.Project,
))!;
await workspacePage.expand(localProjectNode);
await workspacePage.expand(gitProjectNode);
const localCollectionNode = (await workspacePage.findItemNode(
localCollection,
TreeNodeType.Workspace,
))!;
const gitCollectionNode = (await workspacePage.findItemNode(
gitCollection,
TreeNodeType.Workspace,
))!;
const requestNode = (await workspacePage.findItemNode(
{ name: request.name, id: request.id },
TreeNodeType.Request,
localCollectionNode,
))!;
const emptyGitCollectionPlaceholder = {
_id: `empty-collection-${gitCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
const localProjectNode = (await workspacePage.findItemNode(localProject, TreeNodeType.Project))!;
const gitProjectNode = (await workspacePage.findItemNode(gitProject, TreeNodeType.Project))!;
await workspacePage.expand(localProjectNode);
await workspacePage.expand(gitProjectNode);
const localCollectionNode = (await workspacePage.findItemNode(localCollection, TreeNodeType.Workspace))!;
const gitCollectionNode = (await workspacePage.findItemNode(gitCollection, TreeNodeType.Workspace))!;
const requestNode = (await workspacePage.findItemNode(
{ name: request.name, id: request.id },
TreeNodeType.Request,
localCollectionNode,
))!;
const emptyGitCollectionPlaceholder = {
_id: `empty-collection-${gitCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyGitCollectionPlaceholder, 0.5, 0.5);
const localToGitIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterLocalToGit = await workspacePage.getTree();
const localCollectionChildrenAfterMove = treeAfterLocalToGit
.flatten()
.find((n) => n._id === localCollectionNode._id)!.children;
const gitCollectionChildrenAfterMove = treeAfterLocalToGit
.flatten()
.find((n) => n._id === gitCollectionNode._id)!.children;
const emptyLocalCollectionPlaceholder = {
_id: `empty-collection-${localCollection.id}`,
name: "",
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyGitCollectionPlaceholder, 0.5, 0.5);
const localToGitIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterLocalToGit = await workspacePage.getTree();
const localCollectionChildrenAfterMove = treeAfterLocalToGit
.flatten()
.find(n => n._id === localCollectionNode._id)!.children;
const gitCollectionChildrenAfterMove = treeAfterLocalToGit
.flatten()
.find(n => n._id === gitCollectionNode._id)!.children;
const emptyLocalCollectionPlaceholder = {
_id: `empty-collection-${localCollection.id}`,
name: '',
type: TreeNodeType.Unknown,
children: [],
};
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyLocalCollectionPlaceholder, 0.5, 0.5);
const gitToLocalIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterGitToLocal = await workspacePage.getTree();
const localCollectionChildrenAfterMoveBack = treeAfterGitToLocal
.flatten()
.find((n) => n._id === localCollectionNode._id)!.children;
const gitCollectionChildrenAfterMoveBack = treeAfterGitToLocal
.flatten()
.find((n) => n._id === gitCollectionNode._id)!.children;
await workspacePage.startDrag(requestNode);
await workspacePage.dragOver(emptyLocalCollectionPlaceholder, 0.5, 0.5);
const gitToLocalIndicator = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
const treeAfterGitToLocal = await workspacePage.getTree();
const localCollectionChildrenAfterMoveBack = treeAfterGitToLocal
.flatten()
.find(n => n._id === localCollectionNode._id)!.children;
const gitCollectionChildrenAfterMoveBack = treeAfterGitToLocal
.flatten()
.find(n => n._id === gitCollectionNode._id)!.children;
expect(localToGitIndicator?.isValid).toBe(true);
expect(
localCollectionChildrenAfterMove.some((n) => n._id === requestNode._id),
).toBe(false);
expect(
gitCollectionChildrenAfterMove.some((n) => n._id === requestNode._id),
).toBe(true);
expect(gitToLocalIndicator?.isValid).toBe(true);
expect(
gitCollectionChildrenAfterMoveBack.some((n) => n._id === requestNode._id),
).toBe(false);
expect(
localCollectionChildrenAfterMoveBack.some((n) => n._id === requestNode._id),
).toBe(true);
});
expect(localToGitIndicator?.isValid).toBe(true);
expect(localCollectionChildrenAfterMove.some(n => n._id === requestNode._id)).toBe(false);
expect(gitCollectionChildrenAfterMove.some(n => n._id === requestNode._id)).toBe(true);
expect(gitToLocalIndicator?.isValid).toBe(true);
expect(gitCollectionChildrenAfterMoveBack.some(n => n._id === requestNode._id)).toBe(false);
expect(localCollectionChildrenAfterMoveBack.some(n => n._id === requestNode._id)).toBe(true);
},
);
@@ -1,179 +1,138 @@
import { faker } from "@faker-js/faker";
import { faker } from '@faker-js/faker';
import { HttpMethod } from "../../enums/http-method";
import { ProjectType } from "../../enums/project-types";
import { TreeNodeType } from "../../enums/tree-node-types";
import { expect, HTTP_SERVER,test } from "../../misc/fixtures";
import { Collection } from "../../models/collection";
import { Folder } from "../../models/folder";
import { Project } from "../../models/project";
import { HttpMethod } from '../../enums/http-method';
import { ProjectType } from '../../enums/project-types';
import { TreeNodeType } from '../../enums/tree-node-types';
import { expect, HTTP_SERVER, test } from '../../misc/fixtures';
import { Collection } from '../../models/collection';
import { Folder } from '../../models/folder';
import { Project } from '../../models/project';
const WINDOW_WIDTH = 1512;
const WINDOW_HEIGHT = 859;
test("Verify dragging an item into a folder via its name region reparents it", async ({
user,
insomnia,
}) => {
const { workspaceFlow, folderFlow, httpRequestFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
test(
'Verify dragging an item into a folder via its name region reparents it',
{ tag: '@sequential' },
async ({ user, insomnia }) => {
const { workspaceFlow, folderFlow, httpRequestFlow } = user.flowManager;
const { workspacePage } = user.pageManager;
await insomnia.evaluate(
({ BrowserWindow }, { width, height }) => {
const mainWindow = BrowserWindow.getAllWindows().find((w) =>
w.isVisible(),
);
mainWindow?.unmaximize();
mainWindow?.setSize(width, height);
},
{ width: WINDOW_WIDTH, height: WINDOW_HEIGHT },
);
await insomnia.evaluate(
({ BrowserWindow }, { width, height }) => {
const mainWindow = BrowserWindow.getAllWindows().find(w => w.isVisible());
mainWindow?.unmaximize();
mainWindow?.setSize(width, height);
},
{ width: WINDOW_WIDTH, height: WINDOW_HEIGHT },
);
const project = await workspaceFlow.create(
new Project(faker.string.alphanumeric(10), ProjectType.Local),
);
const collection = await workspaceFlow.create(
project,
new Collection(faker.string.alphanumeric(10)),
);
const destinationFolder = await folderFlow.create(
collection,
new Folder(faker.string.alphanumeric(10)),
);
const standaloneRequest = await httpRequestFlow.create(collection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const populatedFolder = await folderFlow.create(
collection,
new Folder(faker.string.alphanumeric(10)),
);
const populatedFolderChild1 = await httpRequestFlow.create(
populatedFolder,
{
const project = await workspaceFlow.create(new Project(faker.string.alphanumeric(10), ProjectType.Local));
const collection = await workspaceFlow.create(project, new Collection(faker.string.alphanumeric(10)));
const destinationFolder = await folderFlow.create(collection, new Folder(faker.string.alphanumeric(10)));
const standaloneRequest = await httpRequestFlow.create(collection, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
},
);
const populatedFolderChild2 = await httpRequestFlow.create(
populatedFolder,
{
});
const populatedFolder = await folderFlow.create(collection, new Folder(faker.string.alphanumeric(10)));
const populatedFolderChild1 = await httpRequestFlow.create(populatedFolder, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
},
);
});
const populatedFolderChild2 = await httpRequestFlow.create(populatedFolder, {
name: faker.string.alphanumeric(10),
method: HttpMethod.Get,
url: `${HTTP_SERVER}/get`,
});
const destinationFolderNode = (await workspacePage.findItemNode(
{ name: destinationFolder.name, id: destinationFolder.id },
TreeNodeType.Folder,
))!;
const standaloneRequestNode = (await workspacePage.findItemNode(
{ name: standaloneRequest.name, id: standaloneRequest.id },
TreeNodeType.Request,
))!;
const populatedFolderNode = (await workspacePage.findItemNode(
{ name: populatedFolder.name, id: populatedFolder.id },
TreeNodeType.Folder,
))!;
const populatedFolderChildrenBefore = populatedFolderNode.children.map(
(c) => c._id,
);
const destinationFolderNode = (await workspacePage.findItemNode(
{ name: destinationFolder.name, id: destinationFolder.id },
TreeNodeType.Folder,
))!;
const standaloneRequestNode = (await workspacePage.findItemNode(
{ name: standaloneRequest.name, id: standaloneRequest.id },
TreeNodeType.Request,
))!;
const populatedFolderNode = (await workspacePage.findItemNode(
{ name: populatedFolder.name, id: populatedFolder.id },
TreeNodeType.Folder,
))!;
const populatedFolderChildrenBefore = populatedFolderNode.children.map(c => c._id);
await workspacePage.startDrag(standaloneRequestNode);
await workspacePage.dragOver(destinationFolderNode, 0.7, 0.95);
const indicatorForStandaloneRequest = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
await workspacePage.expand(destinationFolderNode);
const treeAfterFirstDrag = await workspacePage.getTree();
const destinationFolderAfterFirstDrag = treeAfterFirstDrag
.flatten()
.find((n) => n._id === destinationFolderNode._id)!;
await workspacePage.startDrag(standaloneRequestNode);
await workspacePage.dragOver(destinationFolderNode, 0.7, 0.95);
const indicatorForStandaloneRequest = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
await workspacePage.expand(destinationFolderNode);
const treeAfterFirstDrag = await workspacePage.getTree();
const destinationFolderAfterFirstDrag = treeAfterFirstDrag
.flatten()
.find(n => n._id === destinationFolderNode._id)!;
await workspacePage.startDrag(populatedFolderNode);
await workspacePage.dragOver(destinationFolderNode, 0.7, 0.95);
const indicatorForPopulatedFolder = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
await workspacePage.expand(destinationFolderNode);
const treeAfterSecondDrag = await workspacePage.getTree();
const destinationFolderAfterSecondDrag = treeAfterSecondDrag
.flatten()
.find((n) => n._id === destinationFolderNode._id)!;
const populatedFolderAfterSecondDrag = treeAfterSecondDrag
.flatten()
.find((n) => n._id === populatedFolderNode._id)!;
const collectionNode = (await workspacePage.findItemNode(
collection,
TreeNodeType.Workspace,
))!;
const collectionChildrenAfterSecondDrag = treeAfterSecondDrag
.flatten()
.find((n) => n._id === collectionNode._id)!.children;
await workspacePage.startDrag(populatedFolderNode);
await workspacePage.dragOver(destinationFolderNode, 0.7, 0.95);
const indicatorForPopulatedFolder = await workspacePage.getDropIndicator();
await workspacePage.releaseDrag();
await workspacePage.expand(destinationFolderNode);
const treeAfterSecondDrag = await workspacePage.getTree();
const destinationFolderAfterSecondDrag = treeAfterSecondDrag
.flatten()
.find(n => n._id === destinationFolderNode._id)!;
const populatedFolderAfterSecondDrag = treeAfterSecondDrag.flatten().find(n => n._id === populatedFolderNode._id)!;
const collectionNode = (await workspacePage.findItemNode(collection, TreeNodeType.Workspace))!;
const collectionChildrenAfterSecondDrag = treeAfterSecondDrag
.flatten()
.find(n => n._id === collectionNode._id)!.children;
const populatedFolderChild1Node = (await workspacePage.findItemNode(
{ name: populatedFolderChild1.name, id: populatedFolderChild1.id },
TreeNodeType.Request,
))!;
const populatedFolderChild1Node = (await workspacePage.findItemNode(
{ name: populatedFolderChild1.name, id: populatedFolderChild1.id },
TreeNodeType.Request,
))!;
await workspacePage.clickNode(standaloneRequestNode);
const breadcrumbForStandaloneRequest =
await workspacePage.waitForBreadcrumbSettled([
await workspacePage.clickNode(standaloneRequestNode);
const breadcrumbForStandaloneRequest = await workspacePage.waitForBreadcrumbSettled([
project.name,
collection.name,
destinationFolder.name,
standaloneRequest.name,
]);
await workspacePage.clickNode(populatedFolderChild1Node);
const breadcrumbForPopulatedFolderChild =
await workspacePage.waitForBreadcrumbSettled([
await workspacePage.clickNode(populatedFolderChild1Node);
const breadcrumbForPopulatedFolderChild = await workspacePage.waitForBreadcrumbSettled([
project.name,
collection.name,
"...",
'...',
populatedFolderChild1.name,
]);
expect(indicatorForStandaloneRequest?.isValid).toBe(true);
expect(indicatorForStandaloneRequest?.folderName).toBe(
destinationFolder.name,
);
expect(
destinationFolderAfterFirstDrag.children.some(
(c) => c._id === standaloneRequestNode._id,
),
).toBe(true);
expect(indicatorForPopulatedFolder?.isValid).toBe(true);
expect(indicatorForPopulatedFolder?.folderName).toBe(
destinationFolder.name,
);
expect(
destinationFolderAfterSecondDrag.children.some(
(c) => c._id === populatedFolderNode._id,
),
).toBe(true);
expect(populatedFolderAfterSecondDrag.children.map((c) => c._id)).toEqual(
populatedFolderChildrenBefore,
);
expect(populatedFolderAfterSecondDrag.children.map((c) => c._id)).toEqual([
populatedFolderChild2.id,
populatedFolderChild1.id,
]);
expect(
collectionChildrenAfterSecondDrag.some(
(n) => n._id === populatedFolderChild1.id || n._id === populatedFolderChild2.id,
),
).toBe(false);
expect(breadcrumbForStandaloneRequest).toEqual([
project.name,
collection.name,
destinationFolder.name,
standaloneRequest.name,
]);
expect(breadcrumbForPopulatedFolderChild).toEqual([
project.name,
collection.name,
"...",
populatedFolderChild1.name,
]);
});
expect(indicatorForStandaloneRequest?.isValid).toBe(true);
expect(indicatorForStandaloneRequest?.folderName).toBe(destinationFolder.name);
expect(destinationFolderAfterFirstDrag.children.some(c => c._id === standaloneRequestNode._id)).toBe(true);
expect(indicatorForPopulatedFolder?.isValid).toBe(true);
expect(indicatorForPopulatedFolder?.folderName).toBe(destinationFolder.name);
expect(destinationFolderAfterSecondDrag.children.some(c => c._id === populatedFolderNode._id)).toBe(true);
expect(populatedFolderAfterSecondDrag.children.map(c => c._id)).toEqual(populatedFolderChildrenBefore);
expect(populatedFolderAfterSecondDrag.children.map(c => c._id)).toEqual([
populatedFolderChild2.id,
populatedFolderChild1.id,
]);
expect(
collectionChildrenAfterSecondDrag.some(
n => n._id === populatedFolderChild1.id || n._id === populatedFolderChild2.id,
),
).toBe(false);
expect(breadcrumbForStandaloneRequest).toEqual([
project.name,
collection.name,
destinationFolder.name,
standaloneRequest.name,
]);
expect(breadcrumbForPopulatedFolderChild).toEqual([
project.name,
collection.name,
'...',
populatedFolderChild1.name,
]);
},
);