-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: create general purpose vscode operator function & finish select…
… azure tenant test case (#225) * feat: create general purpose vscode operator function & finish select azure tenant test case * test: select tenant use env * test: use dot env * test: add codecov ignore test folder * test: add codecov ignore test folder * test: add codecov ignore test folder * test: add codecov ignore test folder * test: debug * test: debug * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: yaml test * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: create general purpose vscode operator function & finish select azure tenant test case * test: change case name --------- Co-authored-by: Ivan_Chen <[email protected]>
- Loading branch information
1 parent
7974b72
commit 79b8a68
Showing
8 changed files
with
175 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { expect, test } from '../baseTest'; | ||
import { APICenter, Timeout, VSCode } from '../utils/constants'; | ||
import VscodeOperator from '../utils/vscodeOperator'; | ||
|
||
test('trigger generateAPIviaCICD with Azure DevOps', async ({ workbox }) => { | ||
await workbox.waitForTimeout(Timeout.PREPARE_TEST); | ||
// wait API Center extension installed on VS Code. | ||
await workbox.getByRole("tab", { name: "API Center" }).isVisible(); | ||
await workbox.getByRole("tab", { name: "API Center" }).locator('a').click(); | ||
expect(await VscodeOperator.isSideTabItemExist(workbox, "API Center")).toBeTruthy(); | ||
await VscodeOperator.activeSideTab(workbox, VSCode.TAB_API_CENTER); | ||
// trigger command palette. | ||
await workbox.keyboard.press('Control+Shift+KeyP'); | ||
await workbox.getByRole("combobox", { name: "INPUT" }).fill('>Azure API Center: Register API'); | ||
await workbox.getByRole('listbox').first().press('Enter'); | ||
await VscodeOperator.execCommandInCommandPalette(workbox, APICenter.REGISTER_API); | ||
// select the first option. | ||
await workbox.getByRole('option', { name: "CI/CD" }).locator('a').click(); | ||
await VscodeOperator.selectOptionByName(workbox, APICenter.CI_CD); | ||
// select the next option. | ||
await workbox.getByRole('option', { name: 'Azure DevOps' }).locator('a').click(); | ||
await workbox.getByRole("tab", { name: "Explorer" }).locator('a').click(); | ||
await VscodeOperator.selectOptionByName(workbox, APICenter.AZURE_DEVOPS); | ||
await VscodeOperator.activeSideTab(workbox, VSCode.TAB_EXPLORER); | ||
// check result. | ||
await expect(workbox.getByRole('treeitem', { name: 'register-api.yml' })).toHaveCount(1); | ||
expect(await VscodeOperator.isSideTabItemExist(workbox, "register-api.yml")).toBeTruthy(); | ||
}); | ||
|
||
test('trigger generateAPIviaCICD with GitHub', async ({ workbox }) => { | ||
await workbox.waitForTimeout(Timeout.PREPARE_TEST); | ||
// wait API Center extension installed on VS Code. | ||
await workbox.getByRole("tab", { name: "API Center" }).isVisible(); | ||
await workbox.getByRole("tab", { name: "API Center" }).locator('a').click(); | ||
expect(await VscodeOperator.isSideTabItemExist(workbox, "API Center")).toBeTruthy(); | ||
await VscodeOperator.activeSideTab(workbox, VSCode.TAB_API_CENTER); | ||
// trigger command palette. | ||
await workbox.keyboard.press('Control+Shift+KeyP'); | ||
await workbox.getByRole("combobox", { name: "INPUT" }).fill('>Azure API Center: Register API'); | ||
await workbox.getByRole('listbox').first().press('Enter'); | ||
await VscodeOperator.execCommandInCommandPalette(workbox, APICenter.REGISTER_API); | ||
// select the first option. | ||
await workbox.getByRole('option', { name: "CI/CD" }).locator('a').click(); | ||
await VscodeOperator.selectOptionByName(workbox, APICenter.CI_CD); | ||
// select the next option. | ||
await workbox.getByRole('option', { name: 'GitHub' }).locator('a').click(); | ||
await workbox.getByRole("tab", { name: "Explorer" }).locator('a').click(); | ||
await VscodeOperator.selectOptionByName(workbox, APICenter.GITHUB); | ||
await VscodeOperator.activeSideTab(workbox, VSCode.TAB_EXPLORER); | ||
// check result. | ||
await expect(workbox.getByRole('treeitem', { name: 'register-api.yml' })).toHaveCount(1); | ||
expect(await VscodeOperator.isSideTabItemExist(workbox, "register-api.yml")).toBeTruthy(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { expect, test } from '../baseTest'; | ||
import { APICenter, TestENV, Timeout, VSCode } from '../utils/constants'; | ||
import VscodeOperator from '../utils/vscodeOperator'; | ||
|
||
test('validate subscription', async ({ workbox }) => { | ||
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); | ||
expect(await VscodeOperator.isTreeItemExist(workbox, "Teams Cloud - E2E Testing with TTL = 1 Days")).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
export class Timeout { | ||
public static readonly CLICK_WAIT = 1000; | ||
public static readonly PREPARE_TEST = 5000; | ||
public static readonly PREPARE_EXT = 10000; | ||
public static readonly SHORT_WAIT = 5000; | ||
} | ||
|
||
export class VSCode { | ||
// cmd palette | ||
public static readonly CMD_PALETTE_KEY = "F1"; | ||
public static readonly CMD_PALETTE = "combobox"; | ||
public static readonly CMD_PALETTE_OPTION = "option"; | ||
public static readonly CMD_PALETTE_LIST = "listbox"; | ||
// side tabs | ||
public static readonly SIDE_TAB = "tab"; | ||
public static readonly TAB_EXPLORER = "Explorer"; | ||
public static readonly TAB_API_CENTER = "API Center"; | ||
// tree items | ||
public static readonly TREE_ITEM = "treeitem"; | ||
// elements | ||
public static readonly INPUT = "INPUT"; | ||
public static readonly LINK = "a"; | ||
// keys | ||
public static readonly ENTER = "Enter"; | ||
} | ||
|
||
export class APICenter { | ||
// commands | ||
public static readonly REGISTER_API = ">Azure API Center: Register API"; | ||
// tree items | ||
public static readonly SELECT_TENANT = "Select tenant..."; | ||
public static readonly SELECT_SUBS = "Select Subscriptions..."; | ||
// cicd | ||
public static readonly CI_CD = "CI/CD"; | ||
public static readonly AZURE_DEVOPS = "Azure DevOps"; | ||
public static readonly GITHUB = "GitHub"; | ||
public static readonly REGISTER_API_YML = "register-api.yml"; | ||
} | ||
|
||
export class TestENV { | ||
public static readonly AZURE_TENANT_NAME = process.env["AZURE_TENANT_NAME"] || "Microsoft"; | ||
public static readonly AZURE_TENANT_ID = process.env["AZURE_TENANT_ID"] || "72f988bf-86f1-41af-91ab-2d7cd011db47"; | ||
public static readonly AZURE_SUBSCRIPTION_NAME = process.env["AZURE_SUBSCRIPTION_NAME"] || "Teams Cloud - E2E Testing with TTL = 1 Days"; | ||
public static readonly AZURE_TENANT_ID_2 = process.env["AZURE_TENANT_ID"] || "af46c703-f714-4f4c-af42-835a673c2b13"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { Page } from '@playwright/test'; | ||
import { Timeout, VSCode } from '../utils/constants'; | ||
|
||
export default class VscodeOperator { | ||
static async execCommandInCommandPalette(page: Page, command: string) { | ||
await page.keyboard.press(VSCode.CMD_PALETTE_KEY); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
const cmdPalette = await VscodeOperator.getCMDPalette(page); | ||
await cmdPalette.fill(command); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
await page.getByRole(VSCode.CMD_PALETTE_LIST).first().press(VSCode.ENTER); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
} | ||
|
||
static async getCMDPalette(page: Page) { | ||
return page.getByRole(VSCode.CMD_PALETTE, { name: VSCode.INPUT }); | ||
} | ||
|
||
static async selectOptionByName(page: Page, option: string) { | ||
await page.getByRole(VSCode.CMD_PALETTE_OPTION, { name: option }).locator(VSCode.LINK).click(); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
} | ||
|
||
static async selectOptionByIndex(page: Page, index: number) { | ||
await page.getByRole(VSCode.CMD_PALETTE_OPTION).nth(index).locator(VSCode.LINK).click(); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
} | ||
|
||
static async activeSideTab(page: Page, tabName: string, timeout = Timeout.CLICK_WAIT) { | ||
await page.getByRole(VSCode.SIDE_TAB, { name: tabName }).locator(VSCode.LINK).click(); | ||
await page.waitForTimeout(timeout); | ||
} | ||
|
||
static async isSideTabItemExist(page: Page, tabName: string) { | ||
return await page.getByRole(VSCode.SIDE_TAB, { name: tabName }).isVisible(); | ||
} | ||
|
||
static async isTreeItemExist(page: Page, treeItemName: string) { | ||
return await page.getByRole(VSCode.TREE_ITEM, { name: treeItemName }).isVisible(); | ||
} | ||
|
||
static async clickTreeItem(page: Page, treeItemName: string) { | ||
await page.getByRole(VSCode.TREE_ITEM, { name: treeItemName }).locator(VSCode.LINK).click(); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
} | ||
|
||
static async getCheckallCheckbox(page: Page) { | ||
return await page.waitForSelector('input.quick-input-check-all[type="checkbox"]', { timeout: Timeout.SHORT_WAIT }); | ||
} | ||
|
||
static async checkallCheckbox(page: Page) { | ||
await (await VscodeOperator.getCheckallCheckbox(page)).check(); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
await (await VscodeOperator.getCMDPalette(page)).press(VSCode.ENTER); | ||
await page.waitForTimeout(Timeout.CLICK_WAIT); | ||
} | ||
} |