From 68bcc6110611c696460eacddd2ce6a145f649948 Mon Sep 17 00:00:00 2001 From: ayachensiyuan <67082457+ayachensiyuan@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:44:09 +0800 Subject: [PATCH] test: add chef bot verify (#10857) * test: add chef bot verify --- packages/tests/scripts/randomCases.json | 3 +++ .../sample-localdebug-chef-bot.test.ts | 24 ++++++++++++++++++- .../sample-remotedebug-chef-bot.test.ts | 12 +++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/tests/scripts/randomCases.json b/packages/tests/scripts/randomCases.json index 20a0dba10f..4e2f3e83d2 100644 --- a/packages/tests/scripts/randomCases.json +++ b/packages/tests/scripts/randomCases.json @@ -49,6 +49,9 @@ }, "ubuntu-latest": { "node-18": [] + }, + "macos-latest": { + "node-18": [] } }, "cases": [ diff --git a/packages/tests/src/ui-test/samples/sample-localdebug-chef-bot.test.ts b/packages/tests/src/ui-test/samples/sample-localdebug-chef-bot.test.ts index 2d686c809d..8dbe95750c 100644 --- a/packages/tests/src/ui-test/samples/sample-localdebug-chef-bot.test.ts +++ b/packages/tests/src/ui-test/samples/sample-localdebug-chef-bot.test.ts @@ -5,9 +5,15 @@ * @author Ivan Chen */ -import { TemplateProject, LocalDebugTaskLabel } from "../../utils/constants"; +import { Page } from "playwright"; +import { + TemplateProject, + LocalDebugTaskLabel, + ValidationContent, +} from "../../utils/constants"; import { CaseFactory } from "./sampleCaseFactory"; import { SampledebugContext } from "./sampledebugContext"; +import { validateWelcomeAndReplyBot } from "../../utils/playwrightOperation"; import * as path from "path"; import * as fs from "fs"; import * as os from "os"; @@ -27,6 +33,22 @@ class ChefBotTestCase extends CaseFactory { fs.writeFileSync(envFile, OPENAI_API_KEY); console.log(`add OPENAI_API_KEY ${OPENAI_API_KEY} to .env.${env} file`); } + override async onValidate(page: Page): Promise { + console.log("Moked api key. Only verify happy path..."); + return await validateWelcomeAndReplyBot(page, { + hasCommandReplyValidation: true, + botCommand: "helloWorld", + expectedReplyMessage: ValidationContent.AiBotErrorMessage, + }); + } + public override async onCliValidate(page: Page): Promise { + console.log("Mocked api key. Only verify happy path..."); + return await validateWelcomeAndReplyBot(page, { + hasCommandReplyValidation: true, + botCommand: "helloWorld", + expectedReplyMessage: ValidationContent.AiBotErrorMessage, + }); + } } new ChefBotTestCase( diff --git a/packages/tests/src/ui-test/samples/sample-remotedebug-chef-bot.test.ts b/packages/tests/src/ui-test/samples/sample-remotedebug-chef-bot.test.ts index fc2e182526..05799c3b86 100644 --- a/packages/tests/src/ui-test/samples/sample-remotedebug-chef-bot.test.ts +++ b/packages/tests/src/ui-test/samples/sample-remotedebug-chef-bot.test.ts @@ -5,9 +5,11 @@ * @author Ivan Chen */ -import { TemplateProject } from "../../utils/constants"; +import { Page } from "playwright"; +import { TemplateProject, ValidationContent } from "../../utils/constants"; import { CaseFactory } from "./sampleCaseFactory"; import { SampledebugContext } from "./sampledebugContext"; +import { validateWelcomeAndReplyBot } from "../../utils/playwrightOperation"; import * as path from "path"; import * as fs from "fs"; import * as os from "os"; @@ -27,6 +29,14 @@ class ChefBotTestCase extends CaseFactory { fs.writeFileSync(envFile, OPENAI_API_KEY); console.log(`add OPENAI_API_KEY ${OPENAI_API_KEY} to .env.${env} file`); } + override async onValidate(page: Page): Promise { + console.log("Mocked api key. Only verify happy path..."); + return await validateWelcomeAndReplyBot(page, { + hasCommandReplyValidation: true, + botCommand: "helloWorld", + expectedReplyMessage: ValidationContent.AiBotErrorMessage, + }); + } } new ChefBotTestCase(