Skip to content

Commit

Permalink
test: add open api documentation test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan_Chen committed Sep 12, 2024
1 parent bce2cf3 commit 49c7154
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/e2e/tests/openApiDocumentation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { expect, test } from '../baseTest';
import { Timeout, VSCode } from '../utils/constants';
import VscodeOperator from '../utils/vscodeOperator';

test('Open API Documentation test', { tag: ["@26611999"] }, async ({ workbox }) => {
//set test timeout
test.setTimeout(120000);

await workbox.waitForTimeout(Timeout.PREPARE_TEST);
// wait API Center extension installed on VS Code.
expect(await VscodeOperator.isSideTabItemExist(workbox, "API Center")).toBeTruthy();
await VscodeOperator.activeSideTab(workbox, VSCode.TAB_API_CENTER, Timeout.PREPARE_EXT);

//expand and validate tree items
await VscodeOperator.clickTreeItemChildLinkByText(workbox, "Teams Cloud - E2E Testing with TTL = 1 Days", "Teams Cloud - E2E Testing with TTL = 1 Days");
expect(await VscodeOperator.isTreeItemExist(workbox, "apicentertest001")).toBeTruthy();
await VscodeOperator.clickTreeItem(workbox, "apicentertest001");
await VscodeOperator.clickTreeItemChildLinkByText(workbox, "APIs", "APIs");
expect(await VscodeOperator.isTreeItemExist(workbox, "callback-example")).toBeTruthy();
await VscodeOperator.clickTreeItem(workbox, "callback-example");
expect(await VscodeOperator.isTreeItemExist(workbox, "Versions")).toBeTruthy();
await VscodeOperator.clickTreeItem(workbox, "Versions");
expect(await VscodeOperator.isTreeItemExist(workbox, "1-0-0")).toBeTruthy();
await VscodeOperator.clickTreeItem(workbox, "1-0-0");
expect(await VscodeOperator.isTreeItemExist(workbox, "Definitions")).toBeTruthy();
await VscodeOperator.clickTreeItem(workbox, "Definitions");
expect(await VscodeOperator.isTreeItemExist(workbox, "openapi")).toBeTruthy();

// right click on openapi and select "Open API Documentation"
await VscodeOperator.rightClickTreeItem(workbox, "openapi");
await VscodeOperator.clickMenuItem(workbox, "Open API Documentation");
});
2 changes: 2 additions & 0 deletions src/test/e2e/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class VSCode {
public static readonly ENTER = "Enter";
//toolbar
public static readonly Toolbar = "toolbar";
// menu items
public static readonly MENU_ITEM = "menuitem";
}

export class APICenter {
Expand Down
12 changes: 12 additions & 0 deletions src/test/e2e/utils/vscodeOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ export default class VscodeOperator {
await page.waitForTimeout(Timeout.CLICK_LONG_WAIT);
}

static async rightClickTreeItem(page: Page, treeItemName: string) {
await page.getByRole(VSCode.TREE_ITEM, { name: treeItemName }).locator(VSCode.LINK).click({
button: 'right'
});
await page.waitForTimeout(Timeout.CLICK_WAIT);
}

static async clickMenuItem(page: Page, menuItemName: string) {
await page.getByRole(VSCode.MENU_ITEM, { name: menuItemName }).locator("span.action-label").click();
await page.waitForTimeout(Timeout.PREPARE_EXT);
}

static async clickTreeItemChildLinkByText(page: Page, treeItemName: string, linkName: string) {
await page.getByRole(VSCode.TREE_ITEM, { name: treeItemName }).locator(VSCode.LINK).filter({ hasText: linkName }).click();
await page.waitForTimeout(Timeout.CLICK_LONG_WAIT);
Expand Down

0 comments on commit 49c7154

Please sign in to comment.