From dfb368432ba12df50a892d7d099dd4a884623905 Mon Sep 17 00:00:00 2001 From: Helly Zhang <49181894+hellyzh@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:24:18 +0800 Subject: [PATCH] test: update test case for getting started page (#12951) --- .../treeview/treeview-quickstart.test.ts | 103 +++++++++++++++--- packages/tests/src/utils/constants.ts | 2 + 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/packages/tests/src/ui-test/treeview/treeview-quickstart.test.ts b/packages/tests/src/ui-test/treeview/treeview-quickstart.test.ts index 447168852c..c7e1513f01 100644 --- a/packages/tests/src/ui-test/treeview/treeview-quickstart.test.ts +++ b/packages/tests/src/ui-test/treeview/treeview-quickstart.test.ts @@ -1,12 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + /** * @author Helly Zhang */ -import { By, EditorView, VSBrowser, WebView } from "vscode-extension-tester"; +import { + By, + EditorView, + InputBox, + VSBrowser, + WebView, +} from "vscode-extension-tester"; import { expect } from "chai"; import { execCommandIfExist } from "../../utils/vscodeOperation"; import { TreeViewTestContext } from "./treeviewContext"; -import { CommandPaletteCommands, Timeout } from "../../utils/constants"; -import { delay } from "../../utils/retryHandler"; +import { + CommandPaletteCommands, + CreateProjectQuestion, + Timeout, +} from "../../utils/constants"; +import { delay, RetryHandler } from "../../utils/retryHandler"; import { it } from "../../utils/it"; describe("Openning Quick Start Tests", function () { @@ -35,39 +48,95 @@ describe("Openning Quick Start Tests", function () { const driver = VSBrowser.instance.driver; await driver.sleep(Timeout.reloadWindow); await new EditorView().closeAllEditors(); + + // get started page for "Build a Notification Bot" + await RetryHandler.retry(async () => { + await execCommandIfExist("View: Toggle Full Screen"); + }); await execCommandIfExist( CommandPaletteCommands.QuickStartCommand, Timeout.webView ); + const input = await InputBox.create(); + await input.selectQuickPick(CreateProjectQuestion.BuildNotificationBot); + const webView = new WebView(); const element = await webView.findWebElement( By.className("category-description-container") ); - const text = await element.getText(); - expect(text).has.string("Get Started with Teams Toolkit"); + const type1Title = await element.getText(); + expect(type1Title).has.string(CreateProjectQuestion.BuildNotificationBot); - let button = await getExpandedButton( + // Check item "Get your environment ready" + const type1Item1 = await getExpandedButton( webView, false, "Get your environment ready" ); - const item = await button.findElement(By.css("h3")); - const itemContext = await item.getText(); - expect(itemContext).has.string("Get your environment ready"); - const button1 = await button?.findElement( + const type1Item1Button = await type1Item1?.findElement( By.css(".button-container .monaco-button") ); - const text1 = await button1.getText(); - expect(text1).has.string("Run Prerequisite Checker"); + const type1Item1ButtonValue = await type1Item1Button.getText(); + expect(type1Item1ButtonValue).has.string("Run Prerequisite Checker"); console.log('Found the button "Run Prerequisite Checker"'); - button = await getExpandedButton(webView, false, "Build your first app"); - const button2 = await button?.findElement( + + // Check item "Create a notification bot" + const type1Item2 = await getExpandedButton( + webView, + false, + "Create a notification bot" + ); + const type1Item2Button = await type1Item2?.findElement( + By.css(".button-container .monaco-button") + ); + const type1Item2ButtonValue = await type1Item2Button.getText(); + expect(type1Item2ButtonValue).has.string("Build a notification bot"); + console.log('Found the button "Build a notification bot"'); + + // get started page for "Build a Declarative Agent" + await execCommandIfExist( + CommandPaletteCommands.QuickStartCommand, + Timeout.webView + ); + const input2 = await InputBox.create(); + await input2.selectQuickPick(CreateProjectQuestion.BuildDeclarativeAgent); + + const webView2 = new WebView(); + + const element2 = await webView2.findWebElement( + By.className("category-description-container") + ); + const type2Title = await element2.getText(); + expect(type2Title).has.string( + CreateProjectQuestion.BuildDeclarativeAgent + ); + + // Check item "Get your environment ready" + const type2Item1 = await getExpandedButton( + webView, + false, + "Get your environment ready" + ); + const type2Item1Button = await type2Item1?.findElement( + By.css(".button-container .monaco-button") + ); + const type2Item1ButtonValue = await type2Item1Button.getText(); + expect(type2Item1ButtonValue).has.string("Check Copilot License"); + console.log('Found the button "Check Copilot License"'); + + // Check item "Build a declarative agent" + const type2Item2 = await getExpandedButton( + webView, + false, + "Build a declarative agent" + ); + const type2Item2Button = await type2Item2?.findElement( By.css(".button-container .monaco-button") ); - const text2 = await button2.getText(); - expect(text2).has.string("Create a New App"); - console.log('Found the button "Create a new app"'); + const type2Item2ButtonValue = await type2Item2Button.getText(); + expect(type2Item2ButtonValue).has.string("Build a declarative agent"); + console.log('Found the button "Build a declarative agent"'); } ); }); diff --git a/packages/tests/src/utils/constants.ts b/packages/tests/src/utils/constants.ts index 874d194a09..d589f108a2 100644 --- a/packages/tests/src/utils/constants.ts +++ b/packages/tests/src/utils/constants.ts @@ -489,6 +489,8 @@ export class CreateProjectQuestion { static readonly NewAddinApp = "Start with an Outlook add-in"; static readonly CreateNewSpfxSolution = "Create New SPFx Solution"; static readonly ImportExistingSpfxSolution = "Import Existing SPFx Solution"; + static readonly BuildNotificationBot = "Build a Notification Bot"; + static readonly BuildDeclarativeAgent = "Build a Declarative Agent"; } export class ValidationContent {