|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
3 | 3 |
|
| 4 | +import * as fs from "fs"; |
| 5 | +import * as path from "path"; |
4 | 6 | import { Page } from "playwright"; |
5 | 7 | import { SmokeTestLogger } from "./helper/smokeTestLogger"; |
6 | 8 | import { app, screenshots } from "./main"; |
@@ -52,5 +54,78 @@ export function startDebugConfigurationTests(): void { |
52 | 54 | ); |
53 | 55 | assert.notStrictEqual(rnOption, null); |
54 | 56 | }); |
| 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 | + }); |
55 | 130 | }); |
56 | 131 | } |
0 commit comments