Skip to content

Commit

Permalink
Add TTK Testtool to orderbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Corina Gum committed Nov 19, 2024
1 parent 3f95715 commit 85ad37a
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 25 deletions.
2 changes: 2 additions & 0 deletions js/samples/04.ai-apps/e.assistants-orderBot/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@ env/.env.*.user
env/.env.local
appPackage/build
.deployment
.localConfigs.testTool
devTools
28 changes: 14 additions & 14 deletions js/samples/04.ai-apps/e.assistants-orderBot/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
"type": "msedge",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"cascadeTerminateToConfigurations": [
"Attach to Local Service"
],
"cascadeTerminateToConfigurations": ["Attach to Local Service"],
"presentation": {
"group": "all",
"hidden": true
Expand All @@ -42,9 +40,7 @@
"type": "chrome",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"cascadeTerminateToConfigurations": [
"Attach to Local Service"
],
"cascadeTerminateToConfigurations": ["Attach to Local Service"],
"presentation": {
"group": "all",
"hidden": true
Expand All @@ -67,10 +63,7 @@
"compounds": [
{
"name": "Debug (Edge)",
"configurations": [
"Launch App (Edge)",
"Attach to Local Service"
],
"configurations": ["Launch App (Edge)", "Attach to Local Service"],
"preLaunchTask": "Start Teams App Locally",
"presentation": {
"group": "all",
Expand All @@ -80,16 +73,23 @@
},
{
"name": "Debug (Chrome)",
"configurations": [
"Launch App (Chrome)",
"Attach to Local Service"
],
"configurations": ["Launch App (Chrome)", "Attach to Local Service"],
"preLaunchTask": "Start Teams App Locally",
"presentation": {
"group": "all",
"order": 2
},
"stopAll": true
},
{
"name": "Debug in Test Tool",
"configurations": ["Attach to Local Service"],
"preLaunchTask": "Start Teams App (Test Tool)",
"presentation": {
"group": "local",
"order": 1
},
"stopAll": true
}
]
}
109 changes: 101 additions & 8 deletions js/samples/04.ai-apps/e.assistants-orderBot/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
"tasks": [
{
"label": "Start Teams App Locally",
"dependsOn": [
"Validate prerequisites",
"Start local tunnel",
"Provision",
"Deploy",
"Start application"
],
"dependsOn": ["Validate prerequisites", "Start local tunnel", "Provision", "Deploy", "Start application"],
"dependsOrder": "sequence"
},
{
Expand Down Expand Up @@ -100,6 +94,105 @@
"endsPattern": "restify listening to|Bot/ME service listening at|[nodemon] app crashed"
}
}
},
{
"label": "Start Teams App (Test Tool)",
"dependsOn": [
"Validate prerequisites (Test Tool)",
"Deploy (Test Tool)",
"Start application (Test Tool)",
"Start Test Tool"
],
"dependsOrder": "sequence"
},
{
// Check all required prerequisites.
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
"label": "Validate prerequisites (Test Tool)",
"type": "teamsfx",
"command": "debug-check-prerequisites",
"args": {
"prerequisites": [
"nodejs", // Validate if Node.js is installed.
"portOccupancy" // Validate available ports to ensure those debug ones are not occupied.
],
"portOccupancy": [
3978, // app service port
9239, // app inspector port for Node.js debugger
56150 // test tool port
]
}
},
{
// Build project.
// See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args.
"label": "Deploy (Test Tool)",
"type": "teamsfx",
"command": "deploy",
"args": {
"env": "testtool"
}
},
{
"label": "Start application (Test Tool)",
"type": "shell",
"command": "npm run dev:teamsfx:testtool",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "[nodemon] starting",
"endsPattern": "restify listening to|Bot/ME service listening at|[nodemon] app crashed"
}
}
},
{
"label": "Start Test Tool",
"type": "shell",
"command": "npm run dev:teamsfx:launch-testtool",
"isBackground": true,
"options": {
"env": {
"PATH": "${workspaceFolder}/devTools/teamsapptester/node_modules/.bin:${env:PATH}"
}
},
"windows": {
"options": {
"env": {
"PATH": "${workspaceFolder}/devTools/teamsapptester/node_modules/.bin;${env:PATH}"
}
}
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": ".*",
"endsPattern": "Listening on"
}
},
"presentation": {
"panel": "dedicated",
"reveal": "silent"
}
}
]
}
}
3 changes: 3 additions & 0 deletions js/samples/04.ai-apps/e.assistants-orderBot/env/.env.testtool
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TEAMSFX_ENV=testtool
ASSISTANT_ID=
SECRET_OPENAI_KEY=
8 changes: 5 additions & 3 deletions js/samples/04.ai-apps/e.assistants-orderBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"start": "tsc --build && node ./lib/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "nodemon --watch ./src -e ts --exec \"yarn start\"",
"dev:teamsfx": "nodemon --exec node --inspect=9239 --signal SIGINT -r ts-node/register ./src/index.ts"
"dev:teamsfx": "nodemon --exec node --inspect=9239 --signal SIGINT -r ts-node/register ./src/index.ts",
"dev:teamsfx:testtool": "env-cmd --silent -f .localConfigs.testTool npm run dev:teamsfx",
"dev:teamsfx:launch-testtool": "env-cmd --silent -f env/.env.testtool teamsapptester start"
},
"repository": {
"type": "git",
Expand All @@ -29,13 +31,13 @@
"restify": "~11.1.0"
},
"devDependencies": {
"@types/node": "^20.16.1",
"@types/jsonwebtoken": "^9.0.4",
"@types/node": "^20.16.1",
"@types/restify": "8.5.12",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.57.1",
"env-cmd": "^10.1.0",
"eslint": "^8.57.1",
"nodemon": "~3.0.1",
"prettier": "^3.3.3",
"rimraf": "^5.0.10",
Expand Down
27 changes: 27 additions & 0 deletions js/samples/04.ai-apps/e.assistants-orderBot/teamsapp.testtool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# yaml-language-server: $schema=https://aka.ms/teams-toolkit/v1.5/yaml.schema.json
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
# Visit https://aka.ms/teamsfx-actions for details on actions
version: v1.5

deploy:
# Install development tool(s)
- uses: devTool/install
with:
testTool:
version: ~0.2.1
symlinkDir: ./devTools/teamsapptester

# Run npm command
- uses: cli/runNpmCommand
with:
args: install --no-audit --workspaces=false

# Generate runtime environment variables
- uses: file/createOrUpdateEnvironmentFile
with:
target: ./.localConfigs.testTool
envs:
OPENAI_KEY: ${{SECRET_OPENAI_KEY}}
ASSISTANT_ID: ${{ASSISTANT_ID}}
# AZURE_OPENAI_KEY: ${{SECRET_AZURE_OPENAI_KEY}}
# AZURE_OPENAI_ENDPOINT: ${{SECRET_AZURE_OPENAI_ENDPOINT}}

0 comments on commit 85ad37a

Please sign in to comment.