Skip to content

Commit

Permalink
test: 新增alicloud.api.quickOpenDocument命令测试
Browse files Browse the repository at this point in the history
  • Loading branch information
yini-chen committed Sep 4, 2024
1 parent 276dc8a commit a250992
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,15 @@ export class AlicloudApiCommands {
});

vscode.commands.registerCommand("alicloud.api.openDocument", (config) => {
new AlicloudAPIWebview().openTab(context.extensionUri, config, context);
try {
new AlicloudAPIWebview().openTab(context.extensionUri, config, context);
return "ok";
} catch (e) {
return e;
}
});

vscode.commands.registerCommand("alicloud.api.quickOpenDocument", (arg) => {
vscode.commands.registerCommand("alicloud.api.quickOpenDocument", async (arg) => {
const { apiName, product, version } = arg;
const specName = `${product}__${version}`;

Expand All @@ -255,14 +260,15 @@ export class AlicloudApiCommands {

const apiMeta = pontSpec?.apis[apiName];

vscode.commands.executeCommand("alicloud.api.openDocument", {
const result = await vscode.commands.executeCommand("alicloud.api.openDocument", {
specName,
apiName,
name: apiName,
spec: apiMeta,
pageType: "document",
schemaType: "api",
});
return result;
});

// 刷新问卷调查弹窗过期设置
Expand Down
8 changes: 8 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ suite("Extension Test Suite", () => {
console.log("alicloud.api.restart successfully executed");
assert.strictEqual("ok", result);
});

test("Test alicloud.api.quickOpenDocument command", async () => {
const args = [{ apiName: "RunInstances", product: "Ecs", version: "2014-05-26" }];

const result = await vscode.commands.executeCommand("alicloud.api.quickOpenDocument", args);
console.log("alicloud.api.quickOpenDocument successfully executed");
assert.strictEqual("ok", result);
});
});

0 comments on commit a250992

Please sign in to comment.