|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | + |
| 4 | +import { Page } from "playwright"; |
| 5 | +import { SmokeTestLogger } from "./helper/smokeTestLogger"; |
| 6 | +import { app, screenshots } from "./main"; |
| 7 | +import * as assert from "assert"; |
| 8 | +import { ComponentHelper } from "./helper/componentHelper"; |
| 9 | +import { ElementHelper } from "./helper/elementHelper"; |
| 10 | +import { Element } from "./helper/constants"; |
| 11 | + |
| 12 | +export function startCDPNodeVersionCompatibilityTests(): void { |
| 13 | + describe("CDPNodeVersionCompatibilityTest", () => { |
| 14 | + async function initApp(): Promise<Page> { |
| 15 | + await app.launch(); |
| 16 | + return app.getMainPage(); |
| 17 | + } |
| 18 | + |
| 19 | + async function dispose() { |
| 20 | + if (this.currentTest?.state === "failed") { |
| 21 | + SmokeTestLogger.info("Test failed, taking screenshot ..."); |
| 22 | + await screenshots.takeScreenshots( |
| 23 | + this.currentTest.parent?.title || "Others", |
| 24 | + this.currentTest.title.replace(/\s+/g, "_"), |
| 25 | + ); |
| 26 | + } |
| 27 | + try { |
| 28 | + SmokeTestLogger.info(`Dispose test: "${this.currentTest.title}" ...`); |
| 29 | + if (app) { |
| 30 | + await app.close(); |
| 31 | + } |
| 32 | + } catch (error) { |
| 33 | + SmokeTestLogger.error(`Error while dispose: ${error}`); |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + afterEach(dispose); |
| 38 | + |
| 39 | + it("Verify Run and Debug tab is accessible for debugging operations", async () => { |
| 40 | + await initApp(); |
| 41 | + |
| 42 | + await ComponentHelper.openRunAndDebugTab(); |
| 43 | + await ElementHelper.WaitElementClassNameVisible( |
| 44 | + Element.runAndDebugTabButtonClassName, |
| 45 | + 5000, |
| 46 | + ); |
| 47 | + |
| 48 | + SmokeTestLogger.info("Run and Debug tab is accessible"); |
| 49 | + }); |
| 50 | + |
| 51 | + it("Verify command palette can access debug-related commands", async () => { |
| 52 | + await initApp(); |
| 53 | + |
| 54 | + await ComponentHelper.openCommandPalette(); |
| 55 | + await ElementHelper.WaitElementClassNameVisible(Element.commandPaletteClassName, 5000); |
| 56 | + |
| 57 | + await ElementHelper.inputText("debug"); |
| 58 | + const option = await ElementHelper.WaitElementSelectorVisible( |
| 59 | + Element.commandPaletteFocusedItemSelector, |
| 60 | + 5000, |
| 61 | + ); |
| 62 | + |
| 63 | + const value = await option.getAttribute("aria-label"); |
| 64 | + assert.ok(value?.toLowerCase().includes("debug")); |
| 65 | + SmokeTestLogger.info("Debug commands are available in command palette"); |
| 66 | + }); |
| 67 | + |
| 68 | + it("Verify React Native packager is available for debugging", async () => { |
| 69 | + await initApp(); |
| 70 | + |
| 71 | + await ComponentHelper.getReactNativePackager(); |
| 72 | + SmokeTestLogger.info("React Native packager is available for debugging"); |
| 73 | + }); |
| 74 | + }); |
| 75 | +} |
0 commit comments