From 1eb54fb561b06c74caf18f46402602bac2fff9d8 Mon Sep 17 00:00:00 2001 From: shabaraba Date: Tue, 30 Jul 2024 13:06:00 +0900 Subject: [PATCH] feat(rest-api-client): add a method of app.addPlugins --- .../rest-api-client/src/client/AppClient.ts | 12 ++++++++++++ .../src/client/__tests__/app/Plugins.test.ts | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/packages/rest-api-client/src/client/AppClient.ts b/packages/rest-api-client/src/client/AppClient.ts index cf7c416bef..832a7a56a1 100644 --- a/packages/rest-api-client/src/client/AppClient.ts +++ b/packages/rest-api-client/src/client/AppClient.ts @@ -667,4 +667,16 @@ export class AppClient extends BaseClient { }); return this.client.get(path, rest); } + + public addPlugins(params: { + app: AppID; + ids: string[]; + revision?: Revision; + }): Promise<{ revision: string }> { + const path = this.buildPathWithGuestSpaceId({ + endpointName: "app/plugins", + preview: true, + }); + return this.client.post(path, params); + } } diff --git a/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts b/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts index a3d3fc9fdc..fa734ea17d 100644 --- a/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts +++ b/packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts @@ -49,4 +49,22 @@ describe("AppClient: plugins", () => { }); }); }); + + describe("addPlugins", () => { + const params = { app: APP_ID, ids: ["abc", "xyz"], revision: 1 }; + beforeEach(async () => { + await appClient.addPlugins(params); + }); + it("should pass the path to the http client", () => { + expect(mockClient.getLogs()[0].path).toBe( + "/k/v1/preview/app/plugins.json", + ); + }); + it("should send a post request", () => { + expect(mockClient.getLogs()[0].method).toBe("post"); + }); + it("should pass the param to the http client", () => { + expect(mockClient.getLogs()[0].params).toEqual(params); + }); + }); });