fix: show file chip for the selected file in binary body (#4562)

Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Akash K
2024-11-27 15:05:35 +05:30
committed by GitHub
parent 5dccce39b4
commit 9cc1e47b39
11 changed files with 781 additions and 68 deletions

View File

@@ -1,7 +1,4 @@
import { HoppCollection } from "@hoppscotch/data";
import { entityReference } from "verzod";
import { describe, expect, test } from "vitest";
import { z } from "zod";
import {
transformWorkspaceCollections,
@@ -11,36 +8,13 @@ import {
TRANSFORMED_COLLECTIONS_WITHOUT_AUTH_HEADERS_AT_CERTAIN_LEVELS_MOCK,
TRANSFORMED_DEEPLY_NESTED_COLLECTIONS_WITH_AUTH_HEADERS_MOCK,
TRANSFORMED_ENVIRONMENT_MOCK,
TRANSFORMED_MULTIPLE_CHILD_COLLECTIONS_WITH_AUTH_HEADERS_MOCK,
WORKSPACE_COLLECTIONS_WITHOUT_AUTH_HEADERS_AT_CERTAIN_LEVELS_MOCK,
WORKSPACE_DEEPLY_NESTED_COLLECTIONS_WITH_AUTH_HEADERS_MOCK,
WORKSPACE_ENVIRONMENT_MOCK,
WORKSPACE_MULTIPLE_CHILD_COLLECTIONS_WITH_AUTH_HEADERS_MOCK,
} from "./fixtures/workspace-access.mock";
import TRANSFORMED_MULTIPLE_CHILD_COLLECTIONS_WITH_AUTH_HEADERS_MOCK from "../e2e/fixtures/collections/multiple-child-collections-auth-headers-coll.json";
// Helper function to validate against `HoppCollection` schema and apply relevant migrations
const migrateCollections = (collections: unknown[]): HoppCollection[] => {
const collectionSchemaParsedResult = z
.array(entityReference(HoppCollection))
.safeParse(collections);
if (!collectionSchemaParsedResult.success) {
throw new Error(
`Incoming collections failed schema validation: ${JSON.stringify(collections, null, 2)}`
);
}
return collectionSchemaParsedResult.data.map(
({ _ref_id, folders, ...rest }) => {
return {
...rest,
folders: migrateCollections(folders),
};
}
);
};
describe("workspace-access", () => {
describe("transformWorkspaceCollection", () => {
test("Successfully transforms collection data with deeply nested collections and authorization/headers set at each level to the `HoppCollection` format", () => {
@@ -52,15 +26,11 @@ describe("workspace-access", () => {
});
test("Successfully transforms collection data with multiple child collections and authorization/headers set at each level to the `HoppCollection` format", () => {
const migratedCollections = migrateCollections([
TRANSFORMED_MULTIPLE_CHILD_COLLECTIONS_WITH_AUTH_HEADERS_MOCK,
]);
expect(
transformWorkspaceCollections(
WORKSPACE_MULTIPLE_CHILD_COLLECTIONS_WITH_AUTH_HEADERS_MOCK
)
).toEqual(migratedCollections);
).toEqual(TRANSFORMED_MULTIPLE_CHILD_COLLECTIONS_WITH_AUTH_HEADERS_MOCK);
});
test("Adds the default value for `auth` & `header` fields while transforming collections without authorization/headers set at certain levels", () => {