Skip to content

Commit

Permalink
fix: git auto generate header issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
“sneha122” committed Apr 29, 2024
1 parent 0d03411 commit 769749d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const DEFAULT_API_ACTION_CONFIG: ApiActionConfig = {
httpVersion: DEFAULT_HTTP_VERSION_TYPE,
headers: EMPTY_KEY_VALUE_PAIRS.slice(),
queryParameters: EMPTY_KEY_VALUE_PAIRS.slice(),
autoGeneratedHeaders: [],
body: "",
bodyFormData: [],
formData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const DEFAULT_GRAPHQL_ACTION_CONFIG: ApiActionConfig = {
formData: {
apiContentType: POST_BODY_FORMAT_OPTIONS.JSON,
},
autoGeneratedHeaders: [],
pluginSpecifiedTemplates: [
{
// JSON smart substitution
Expand Down
52 changes: 52 additions & 0 deletions app/client/src/sagas/__tests__/ApiPaneSagas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { CreateApiActionDefaultsParams } from "entities/Action";
import { createDefaultApiActionPayload } from "sagas/ApiPaneSagas";

describe("tests the sagas in ApiPaneSagas", () => {
const inputPayload: CreateApiActionDefaultsParams = {
apiType: "graphql-plugin",
newActionName: "newName",
};

it("1. Bug 27941: Tests createDefaultApiActionPayload to return prepopulated empty array for autoGeneratedHeaders", function () {
const outputPayloadGenerator: Generator =
createDefaultApiActionPayload(inputPayload);

// Mocking getCurrentWorkspaceId selector
const workspaceIdSelectorEffect = outputPayloadGenerator.next().value;
workspaceIdSelectorEffect.payload.selector = jest.fn();
workspaceIdSelectorEffect.payload.selector.mockReturnValue(
"testWorkspaceId",
);

// Mock getPluginIdOfPackageName selector
const pluginIdSelectorEffect = outputPayloadGenerator.next().value;
pluginIdSelectorEffect.payload.selector = jest.fn();
pluginIdSelectorEffect.payload.selector.mockReturnValue("pluginId");

// Get actionconfig value now
const outputPayload = outputPayloadGenerator.next().value;
expect(outputPayload?.actionConfiguration.autoGeneratedHeaders).toEqual([]);
});

it("2. Bug 27941: Tests createDefaultApiActionPayload to return prepopulated empty array for autoGeneratedHeaders", function () {
inputPayload.apiType = "restapi-plugin";
const outputPayloadGenerator: Generator =
createDefaultApiActionPayload(inputPayload);

// Mocking getCurrentWorkspaceId selector
const workspaceIdSelectorEffect = outputPayloadGenerator.next().value;
workspaceIdSelectorEffect.payload.selector = jest.fn();
workspaceIdSelectorEffect.payload.selector.mockReturnValue(
"testWorkspaceId",
);

// Mock getPluginIdOfPackageName selector
const pluginIdSelectorEffect = outputPayloadGenerator.next().value;
pluginIdSelectorEffect.payload.selector = jest.fn();
pluginIdSelectorEffect.payload.selector.mockReturnValue("pluginId");

// Get actionconfig value now
const outputPayload = outputPayloadGenerator.next().value;
expect(outputPayload?.actionConfiguration.autoGeneratedHeaders).toEqual([]);
});
});

0 comments on commit 769749d

Please sign in to comment.