Skip to content

Commit cc138b9

Browse files
authored
Merge pull request #2424 from microsoft/verify-add-configuration
Verify add configuration in launch.json file
2 parents bdae667 + 842fec0 commit cc138b9

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

test/smoke/suites/debugConfiguration.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for details.
33

4+
import * as fs from "fs";
5+
import * as path from "path";
46
import { Page } from "playwright";
57
import { SmokeTestLogger } from "./helper/smokeTestLogger";
68
import { app, screenshots } from "./main";
@@ -52,5 +54,78 @@ export function startDebugConfigurationTests(): void {
5254
);
5355
assert.notStrictEqual(rnOption, null);
5456
});
57+
58+
it("Complete debug configuration setup workflow", async () => {
59+
const launchFolderPath = path.join(
60+
__dirname,
61+
"..",
62+
"resources",
63+
"sampleReactNativeProject",
64+
);
65+
const vscodeFolderPath = path.join(launchFolderPath, ".vscode");
66+
if (!fs.existsSync(vscodeFolderPath)) {
67+
fs.mkdirSync(vscodeFolderPath);
68+
}
69+
70+
fs.writeFileSync(path.join(vscodeFolderPath, "launch.json"), JSON.stringify({}));
71+
72+
await initApp();
73+
74+
await ComponentHelper.openFileExplorer();
75+
const vscodeFolder = await ComponentHelper.WaitFileVisibleInFileExplorer(".vscode");
76+
if (!vscodeFolder) {
77+
throw new Error(
78+
"vscodeFolder is null. File '.vscode' was not found in the file explorer.",
79+
);
80+
}
81+
await vscodeFolder.click();
82+
await ElementHelper.clickElementByText("launch.json");
83+
84+
const debugAddConfigurationButton = await ElementHelper.WaitElementSelectorVisible(
85+
Element.debugAddConfigurationButtonSelector,
86+
3000,
87+
);
88+
await debugAddConfigurationButton.click();
89+
90+
const reactNativeButton = await ElementHelper.WaitElementSelectorVisible(
91+
Element.reactNativeButtonSelector,
92+
5000,
93+
);
94+
await reactNativeButton.click();
95+
96+
const debugApplicationButton = await ElementHelper.WaitElementSelectorVisible(
97+
Element.debugApplicationButtonSelector,
98+
1000,
99+
);
100+
await debugApplicationButton.click();
101+
102+
const androidButton = await ElementHelper.WaitElementSelectorVisible(
103+
Element.androidButtonSelector,
104+
1000,
105+
);
106+
await androidButton.click();
107+
108+
const applicationInDirectModeButton = await ElementHelper.WaitElementSelectorVisible(
109+
Element.applicationInDirectModeButtonSelector,
110+
1000,
111+
);
112+
await applicationInDirectModeButton.click();
113+
await ElementHelper.waitPageLoad("domcontentloaded");
114+
const configurationElement = await ElementHelper.TryFindElement(
115+
Element.configurationElementSelector,
116+
5000,
117+
);
118+
119+
let launchContent = await configurationElement?.textContent();
120+
if (launchContent) {
121+
launchContent = launchContent.replace(/\s/g, "");
122+
assert.ok(
123+
launchContent.includes("DebugAndroidHermes"),
124+
`Expected launchContent to include "Debug Android Hermes", but got: ${launchContent}`,
125+
);
126+
} else {
127+
assert.fail("Fail to set launch file configuration.");
128+
}
129+
});
55130
});
56131
}

test/smoke/suites/helper/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ export class Element {
1515
public static createLaunchConfigFileLinkClassName = "monaco-link";
1616
public static welcomeViewClassName = "welcome-view-content";
1717
public static vscodeMonacoButtonClassName = "monaco-button";
18+
public static debugAddConfigurationButtonSelector = ".floating-click-widget";
19+
public static androidButtonSelector = "div[aria-label='Android']";
20+
public static reactNativeButtonSelector = "div[aria-label='React Native, Enum']";
21+
public static debugApplicationButtonSelector =
22+
"div[aria-label='Debug application, Debug React Native application']";
23+
public static applicationInDirectModeButtonSelector =
24+
"div[aria-label='Application in direct mode(Hermes)']";
25+
public static configurationElementSelector = ".monaco-mouse-cursor-text";
1826
}

test/smoke/suites/helper/elementHelper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export class ElementHelper {
3131
await this.Page().click(`text=${text}`);
3232
}
3333

34+
public static async waitPageLoad(
35+
state: "load" | "domcontentloaded" | "networkidle" | undefined,
36+
) {
37+
await this.Page().waitForLoadState(state);
38+
}
39+
3440
public static async WaitElementClassNameVisible(
3541
className: string,
3642
timeout: number = 1000,

0 commit comments

Comments
 (0)