Skip to content

Commit f6f7b31

Browse files
authored
test: split local and remote debug test cases (#15082)
1 parent f0b02b1 commit f6f7b31

File tree

5 files changed

+176
-76
lines changed

5 files changed

+176
-76
lines changed

packages/tests/scripts/pvt.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
"da-action-openapi-none",
1919
"da-action-openapi-oauth"
2020
],
21-
"node-22": [
22-
"basic-bot-ts",
23-
"msgsa-ts"
21+
"node-22": [
22+
"basic-bot-ts-localdebug",
23+
"basic-bot-ts-remotedebug",
24+
"msgsa-ts-localdebug",
25+
"msgsa-ts-remotedebug"
2426
]
2527
},
2628
"ubuntu-latest": {

packages/tests/src/ui-test/templates/basic-bot-ts.test.ts renamed to packages/tests/src/ui-test/templates/basic-bot-ts-localdebug.test.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("Local Debug Tests", function () {
4040
let devtunnelProcess: ChildProcessWithoutNullStreams | null;
4141
let debugProcess: ChildProcess | null;
4242
let successFlagForLocal = false;
43-
let successFlagForRemote = false;
43+
const successFlagForRemote = true;
4444

4545
after(async function () {
4646
this.timeout(Timeout.finishTestCase);
@@ -151,60 +151,4 @@ describe("Local Debug Tests", function () {
151151
expect(successFlagForLocal, errorMessage).to.true;
152152
}
153153
);
154-
155-
it(
156-
"[auto] Remote debug for bot typescript project Tests",
157-
{
158-
testPlanCaseId: 14134645,
159-
author: "[email protected]",
160-
},
161-
async function () {
162-
const remoteDebugTestContext = new RemoteDebugTestContext("bot");
163-
const testRootFolder = remoteDebugTestContext.testRootFolder;
164-
const appName = remoteDebugTestContext.appName;
165-
const appNameCopySuffix = "copy";
166-
const newAppFolderName = appName + appNameCopySuffix;
167-
const projectPath = path.resolve(testRootFolder, newAppFolderName);
168-
await remoteDebugTestContext.before();
169-
const driver = VSBrowser.instance.driver;
170-
await createNewProject("bot", appName, { lang: Lang.TS });
171-
await provisionProject(appName, projectPath);
172-
try {
173-
await deployProject(projectPath, Timeout.botDeploy);
174-
const teamsAppId = await remoteDebugTestContext.getTeamsAppId(
175-
projectPath
176-
);
177-
const page = await initPage(
178-
remoteDebugTestContext.context!,
179-
teamsAppId,
180-
Env.username,
181-
Env.password,
182-
{
183-
projectPath: projectPath,
184-
env: "dev",
185-
teamsAppName: appName,
186-
searchApp: false,
187-
}
188-
);
189-
await driver.sleep(Timeout.longTimeWait);
190-
await validateEchoBot(page, { botCommand: "Hi" });
191-
successFlagForRemote = true;
192-
} catch (error) {
193-
//Close the folder and cleanup local sample project
194-
await execCommandIfExist(
195-
"Workspaces: Close Workspace",
196-
Timeout.webView
197-
);
198-
console.log(`[Successfully] start to clean up for ${projectPath}`);
199-
await remoteDebugTestContext.cleanUp(
200-
appName,
201-
projectPath,
202-
false,
203-
true,
204-
false
205-
);
206-
throw new Error("[Error]: " + error);
207-
}
208-
}
209-
);
210154
});
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
/**
5+
* @author Xiaofu Huang <[email protected]>
6+
*/
7+
import * as path from "path";
8+
import { startDebugging, waitForTerminal } from "../../utils/vscodeOperation";
9+
import { initPage, validateEchoBot } from "../../utils/playwrightOperation";
10+
import { LocalDebugTestContext } from "../localdebug/localdebugContext";
11+
import {
12+
Timeout,
13+
LocalDebugTaskLabel,
14+
DebugItemSelect,
15+
LocalDebugTaskInfo,
16+
Lang,
17+
} from "../../utils/constants";
18+
import { Env } from "../../utils/env";
19+
import { it } from "../../utils/it";
20+
import { validateFileExist } from "../../utils/commonUtils";
21+
import { ChildProcess, ChildProcessWithoutNullStreams } from "child_process";
22+
import { Executor } from "../../utils/executor";
23+
import { expect } from "chai";
24+
import { ModalDialog, VSBrowser } from "vscode-extension-tester";
25+
import { getScreenshotName } from "../../utils/nameUtil";
26+
import { initDebugPort } from "../../utils/commonUtils";
27+
import {
28+
RemoteDebugTestContext,
29+
provisionProject,
30+
deployProject,
31+
} from "../remotedebug/remotedebugContext";
32+
import {
33+
execCommandIfExist,
34+
createNewProject,
35+
} from "../../utils/vscodeOperation";
36+
import { log } from "console";
37+
38+
describe("Local Debug Tests", function () {
39+
this.timeout(Timeout.localAndRemoteTestCase);
40+
let devtunnelProcess: ChildProcessWithoutNullStreams | null;
41+
let debugProcess: ChildProcess | null;
42+
const successFlagForLocal = true;
43+
let successFlagForRemote = false;
44+
45+
after(async function () {
46+
this.timeout(Timeout.finishTestCase);
47+
setTimeout(() => {
48+
if (successFlagForLocal && successFlagForRemote) process.exit(0);
49+
else process.exit(1);
50+
}, 30000);
51+
});
52+
53+
it(
54+
"[auto] Remote debug for bot typescript project Tests",
55+
{
56+
testPlanCaseId: 14134645,
57+
author: "[email protected]",
58+
},
59+
async function () {
60+
const remoteDebugTestContext = new RemoteDebugTestContext("bot");
61+
const testRootFolder = remoteDebugTestContext.testRootFolder;
62+
const appName = remoteDebugTestContext.appName;
63+
const appNameCopySuffix = "copy";
64+
const newAppFolderName = appName + appNameCopySuffix;
65+
const projectPath = path.resolve(testRootFolder, newAppFolderName);
66+
await remoteDebugTestContext.before();
67+
const driver = VSBrowser.instance.driver;
68+
await createNewProject("bot", appName, { lang: Lang.TS });
69+
await provisionProject(appName, projectPath);
70+
try {
71+
await deployProject(projectPath, Timeout.botDeploy);
72+
const teamsAppId = await remoteDebugTestContext.getTeamsAppId(
73+
projectPath
74+
);
75+
const page = await initPage(
76+
remoteDebugTestContext.context!,
77+
teamsAppId,
78+
Env.username,
79+
Env.password,
80+
{
81+
projectPath: projectPath,
82+
env: "dev",
83+
teamsAppName: appName,
84+
searchApp: false,
85+
}
86+
);
87+
await driver.sleep(Timeout.longTimeWait);
88+
await validateEchoBot(page, { botCommand: "Hi" });
89+
successFlagForRemote = true;
90+
} catch (error) {
91+
//Close the folder and cleanup local sample project
92+
await execCommandIfExist(
93+
"Workspaces: Close Workspace",
94+
Timeout.webView
95+
);
96+
console.log(`[Successfully] start to clean up for ${projectPath}`);
97+
await remoteDebugTestContext.cleanUp(
98+
appName,
99+
projectPath,
100+
false,
101+
true,
102+
false
103+
);
104+
throw new Error("[Error]: " + error);
105+
}
106+
}
107+
);
108+
});

packages/tests/src/ui-test/templates/msgsa-ts.test.ts renamed to packages/tests/src/ui-test/templates/msgsa-ts-localdebug.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Debug Tests", function () {
2222
this.timeout(Timeout.localAndRemoteTestCase);
2323
const successFlag = {
2424
successFlagForLocal: false,
25-
successFlagForRemote: false,
25+
successFlagForRemote: true,
2626
};
2727
async function validationNpm(
2828
page: Page,
@@ -60,19 +60,4 @@ describe("Debug Tests", function () {
6060
});
6161
}
6262
);
63-
64-
it(
65-
"[auto] [TypeScript] Remote debug for Search-based message extension typescript project Tests",
66-
{
67-
testPlanCaseId: 14907800,
68-
author: "[email protected]",
69-
},
70-
async function () {
71-
await msgHappyPathTestForRemoteDebug("msgsa", {
72-
lang: Lang.TS,
73-
successFlag: successFlag,
74-
validationFn: validationNpm,
75-
});
76-
}
77-
);
7863
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
/**
5+
* @author Anne Fu <[email protected]>
6+
*/
7+
import { validateNpm } from "../../utils/playwrightOperation";
8+
import {
9+
Timeout,
10+
LocalDebugTaskLabel,
11+
LocalDebugTaskInfo,
12+
Lang,
13+
} from "../../utils/constants";
14+
import { it } from "../../utils/it";
15+
import {
16+
msgHappyPathTestForLocalDebug,
17+
msgHappyPathTestForRemoteDebug,
18+
} from "./MsgHappyPath";
19+
import { Page } from "playwright";
20+
21+
describe("Debug Tests", function () {
22+
this.timeout(Timeout.localAndRemoteTestCase);
23+
const successFlag = {
24+
successFlagForLocal: true,
25+
successFlagForRemote: false,
26+
};
27+
async function validationNpm(
28+
page: Page,
29+
options: {
30+
appName: string;
31+
}
32+
) {
33+
await validateNpm(page, {
34+
npmName: "axios",
35+
appName: options.appName,
36+
});
37+
}
38+
after(async function () {
39+
this.timeout(Timeout.finishTestCase);
40+
setTimeout(() => {
41+
if (successFlag.successFlagForLocal && successFlag.successFlagForRemote)
42+
process.exit(0);
43+
else process.exit(1);
44+
}, 30000);
45+
});
46+
47+
it(
48+
"[auto] [TypeScript] Remote debug for Search-based message extension typescript project Tests",
49+
{
50+
testPlanCaseId: 14907800,
51+
author: "[email protected]",
52+
},
53+
async function () {
54+
await msgHappyPathTestForRemoteDebug("msgsa", {
55+
lang: Lang.TS,
56+
successFlag: successFlag,
57+
validationFn: validationNpm,
58+
});
59+
}
60+
);
61+
});

0 commit comments

Comments
 (0)