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 13, 2024
1 parent aff5d01 commit e5566ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .api-center-rules/apicentertest001/functions/greeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Validate(input, options, context) {
return [{ message: `Hello ${input}.` }];
}
9 changes: 9 additions & 0 deletions .api-center-rules/apicentertest001/ruleset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: [[spectral:oas, all]]
functions:
- greeting
rules:
greetingRule:
message: "{{error}}"
given: "$.greeting.firstName"
then:
function: greeting
40 changes: 20 additions & 20 deletions src/test/e2e/tests/openApiDocumentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 }) => {
test('Open API Documentation test', async ({ workbox }) => {
console.log("[start] Open API Documentation test");
//set test timeout
test.setTimeout(120000);
Expand All @@ -14,26 +14,26 @@ test('Open API Documentation test', { tag: ["@26611999"] }, async ({ workbox })
// 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);
await workbox.waitForTimeout(Timeout.PREPARE_EXT);
expect(await VscodeOperator.isTreeItemExist(workbox, "Teams Cloud - E2E Testing with TTL = 1 Days")).toBeTruthy();

//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");
expect(await VscodeOperator.isTreeItemExist(workbox, "APIs")).toBeTruthy();
expect(await VscodeOperator.isTreeItemExist(workbox, "Environments")).toBeTruthy();
expect(await VscodeOperator.isTreeItemExist(workbox, "Rules")).toBeTruthy();
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, "Deployments")).toBeTruthy();
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();
//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");
expect(await VscodeOperator.isTreeItemExist(workbox, "APIs")).toBeTruthy();
expect(await VscodeOperator.isTreeItemExist(workbox, "Environments")).toBeTruthy();
expect(await VscodeOperator.isTreeItemExist(workbox, "Rules")).toBeTruthy();
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, "Deployments")).toBeTruthy();
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");
Expand Down

0 comments on commit e5566ec

Please sign in to comment.