-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
238 additions
and
5 deletions.
There are no files selected for viewing
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
89 changes: 89 additions & 0 deletions
89
packages/tests/src/ui-test/localdebug/localdebug-aichat-bot-py.test.ts
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,89 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
/** | ||
* @author Helly Zhang <v-helzha@microsoft.com> | ||
*/ | ||
import * as path from "path"; | ||
import { | ||
createEnvironmentWithPython, | ||
startDebugging, | ||
waitForTerminal, | ||
} from "../../utils/vscodeOperation"; | ||
import { | ||
initPage, | ||
validateWelcomeAndReplyBot, | ||
} from "../../utils/playwrightOperation"; | ||
import { LocalDebugTestContext } from "./localdebugContext"; | ||
import { | ||
Timeout, | ||
LocalDebugTaskLabel, | ||
DebugItemSelect, | ||
ValidationContent, | ||
LocalDebugTaskLabel2, | ||
} from "../../utils/constants"; | ||
import { Env } from "../../utils/env"; | ||
import { it } from "../../utils/it"; | ||
import { editDotEnvFile, validateFileExist } from "../../utils/commonUtils"; | ||
|
||
describe("Local Debug Tests", function () { | ||
this.timeout(Timeout.testCase); | ||
let localDebugTestContext: LocalDebugTestContext; | ||
|
||
beforeEach(async function () { | ||
// ensure workbench is ready | ||
this.timeout(Timeout.prepareTestCase); | ||
localDebugTestContext = new LocalDebugTestContext("aichat", "python"); | ||
await localDebugTestContext.before(); | ||
}); | ||
|
||
afterEach(async function () { | ||
this.timeout(Timeout.finishTestCase); | ||
await localDebugTestContext.after(false, true); | ||
}); | ||
|
||
it( | ||
"[auto] [Python] Local debug AI chat bot", | ||
{ | ||
testPlanCaseId: 27178071, | ||
author: "v-helzha@microsoft.com", | ||
}, | ||
async function () { | ||
const projectPath = path.resolve( | ||
localDebugTestContext.testRootFolder, | ||
localDebugTestContext.appName | ||
); | ||
validateFileExist(projectPath, "src/app.py"); | ||
const envPath = path.resolve(projectPath, "env", ".env.local.user"); | ||
editDotEnvFile(envPath, "SECRET_AZURE_OPENAI_API_KEY", "fake"); | ||
editDotEnvFile(envPath, "AZURE_OPENAI_ENDPOINT", "https://test.com"); | ||
editDotEnvFile(envPath, "AZURE_OPENAI_MODEL_DEPLOYMENT_NAME", "fake"); | ||
|
||
await createEnvironmentWithPython(); | ||
|
||
await startDebugging(DebugItemSelect.DebugInTeamsUsingChrome); | ||
|
||
await waitForTerminal(LocalDebugTaskLabel.StartLocalTunnel); | ||
await waitForTerminal( | ||
LocalDebugTaskLabel2.PythonDebugConsole, | ||
"Running on http://localhost:3978" | ||
); | ||
|
||
const teamsAppId = await localDebugTestContext.getTeamsAppId(); | ||
const page = await initPage( | ||
localDebugTestContext.context!, | ||
teamsAppId, | ||
Env.username, | ||
Env.password | ||
); | ||
await localDebugTestContext.validateLocalStateForBot(); | ||
await validateWelcomeAndReplyBot(page, { | ||
hasWelcomeMessage: false, | ||
hasCommandReplyValidation: true, | ||
botCommand: "helloWorld", | ||
expectedWelcomeMessage: ValidationContent.AiChatBotWelcomeInstruction, | ||
expectedReplyMessage: ValidationContent.AiBotErrorMessage, | ||
}); | ||
} | ||
); | ||
}); |
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
114 changes: 114 additions & 0 deletions
114
packages/tests/src/ui-test/remotedebug/remotedebug-aichat-bot-py-win-only.test.ts
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,114 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
/** | ||
* @author Helly Zhang <v-helzha@microsoft.com> | ||
*/ | ||
import * as path from "path"; | ||
import { VSBrowser } from "vscode-extension-tester"; | ||
import { Timeout, ValidationContent } from "../../utils/constants"; | ||
import { | ||
RemoteDebugTestContext, | ||
deployProject, | ||
provisionProject, | ||
} from "./remotedebugContext"; | ||
import { | ||
execCommandIfExist, | ||
createNewProject, | ||
} from "../../utils/vscodeOperation"; | ||
import { | ||
initPage, | ||
validateWelcomeAndReplyBot, | ||
} from "../../utils/playwrightOperation"; | ||
import { Env } from "../../utils/env"; | ||
import { it } from "../../utils/it"; | ||
import { editDotEnvFile, validateFileExist } from "../../utils/commonUtils"; | ||
import { RetryHandler } from "../../utils/retryHandler"; | ||
|
||
describe("Remote debug Tests", function () { | ||
this.timeout(Timeout.testAzureCase); | ||
let remoteDebugTestContext: RemoteDebugTestContext; | ||
let testRootFolder: string; | ||
let appName: string; | ||
const appNameCopySuffix = "copy"; | ||
let newAppFolderName: string; | ||
let projectPath: string; | ||
|
||
beforeEach(async function () { | ||
// ensure workbench is ready | ||
this.timeout(Timeout.prepareTestCase); | ||
remoteDebugTestContext = new RemoteDebugTestContext("aichat"); | ||
testRootFolder = remoteDebugTestContext.testRootFolder; | ||
appName = remoteDebugTestContext.appName; | ||
newAppFolderName = appName + appNameCopySuffix; | ||
projectPath = path.resolve(testRootFolder, newAppFolderName); | ||
await remoteDebugTestContext.before(); | ||
}); | ||
|
||
afterEach(async function () { | ||
this.timeout(Timeout.finishAzureTestCase); | ||
await remoteDebugTestContext.after(); | ||
|
||
//Close the folder and cleanup local sample project | ||
await execCommandIfExist("Workspaces: Close Workspace", Timeout.webView); | ||
console.log(`[Successfully] start to clean up for ${projectPath}`); | ||
await remoteDebugTestContext.cleanUp( | ||
appName, | ||
projectPath, | ||
false, | ||
true, | ||
false | ||
); | ||
}); | ||
|
||
it( | ||
"[auto][Python] Remote debug for ai chat bot project Tests", | ||
{ | ||
testPlanCaseId: 27178027, | ||
author: "v-helzha@microsoft.com", | ||
}, | ||
async function () { | ||
const driver = VSBrowser.instance.driver; | ||
await createNewProject("aichat", appName, "Python"); | ||
validateFileExist(projectPath, "src/app.py"); | ||
const envPath = path.resolve(projectPath, "env", ".env.dev.user"); | ||
editDotEnvFile(envPath, "SECRET_AZURE_OPENAI_API_KEY", "fake"); | ||
editDotEnvFile(envPath, "AZURE_OPENAI_ENDPOINT", "https://test.com"); | ||
editDotEnvFile(envPath, "AZURE_OPENAI_MODEL_DEPLOYMENT_NAME", "fake"); | ||
await provisionProject(appName, projectPath); | ||
await deployProject(projectPath, Timeout.botDeploy); | ||
const teamsAppId = await remoteDebugTestContext.getTeamsAppId( | ||
projectPath | ||
); | ||
const page = await initPage( | ||
remoteDebugTestContext.context!, | ||
teamsAppId, | ||
Env.username, | ||
Env.password | ||
); | ||
await driver.sleep(Timeout.longTimeWait); | ||
try { | ||
await validateWelcomeAndReplyBot(page, { | ||
hasWelcomeMessage: false, | ||
hasCommandReplyValidation: true, | ||
botCommand: "helloWorld", | ||
expectedWelcomeMessage: ValidationContent.AiChatBotWelcomeInstruction, | ||
expectedReplyMessage: ValidationContent.AiBotErrorMessage, | ||
}); | ||
} catch { | ||
await RetryHandler.retry(async () => { | ||
await deployProject(projectPath, Timeout.botDeploy); | ||
await driver.sleep(Timeout.longTimeWait); | ||
await validateWelcomeAndReplyBot(page, { | ||
hasWelcomeMessage: false, | ||
hasCommandReplyValidation: true, | ||
botCommand: "helloWorld", | ||
expectedWelcomeMessage: | ||
ValidationContent.AiChatBotWelcomeInstruction, | ||
expectedReplyMessage: ValidationContent.AiBotErrorMessage, | ||
}); | ||
}, 2); | ||
} | ||
} | ||
); | ||
}); |
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