Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions test/smoke/suites/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import { Page } from "playwright";
import { SmokeTestLogger } from "./helper/smokeTestLogger";
import { app, screenshots } from "./main";
import assert = require("assert");
import { ElementHelper } from "./helper/elementHelper";
import { Element } from "./helper/constants";
import { ComponentHelper } from "./helper/componentHelper";
import { TimeoutConstants } from "./helper/timeoutConstants";
import { BaseSmokeTest } from "./helper/baseSmokeTest";
export function startCommandPaletteTests(): void {
describe("CommandPaletteTest", () => {
async function initApp(): Promise<Page> {
await app.launch();
return app.getMainPage();
}

async function dispose() {
if (this.currentTest?.state === "failed") {
SmokeTestLogger.info("Test failed, taking screenshot ...");
await screenshots.takeScreenshots(
this.currentTest.parent?.title || "Others",
this.currentTest.title.replace(/\s+/g, "_"),
);
}
try {
SmokeTestLogger.info(`Dispose test: "${this.currentTest.title}" ...`);
if (app) {
await app.close();
}
} catch (error) {
SmokeTestLogger.error(`Error while dispose: ${error}`);
}
}

afterEach(dispose);
afterEach(BaseSmokeTest.dispose);

it("Verify react native command is visible in command palette", async () => {
const text = "React Native: Start Packager";
await initApp();
await BaseSmokeTest.initApp();

await ComponentHelper.openCommandPalette();
await ElementHelper.WaitElementClassNameVisible(
Expand Down
33 changes: 4 additions & 29 deletions test/smoke/suites/debugConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,22 @@

import * as fs from "fs";
import * as path from "path";
import { Page } from "playwright";
import { SmokeTestLogger } from "./helper/smokeTestLogger";
import { app, screenshots } from "./main";
import assert = require("assert");
import { ElementHelper } from "./helper/elementHelper";
import { Element } from "./helper/constants";
import { ComponentHelper } from "./helper/componentHelper";
import { TimeoutConstants } from "./helper/timeoutConstants";
import { BaseSmokeTest } from "./helper/baseSmokeTest";

export function startDebugConfigurationTests(): void {
describe("DebugConfigurationTest", () => {
async function initApp(): Promise<Page> {
await app.launch();
return app.getMainPage();
}

async function dispose() {
if (this.currentTest?.state === "failed") {
SmokeTestLogger.info("Test failed, taking screenshot ...");
await screenshots.takeScreenshots(
this.currentTest.parent?.title || "Others",
this.currentTest.title.replace(/\s+/g, "_"),
);
}
try {
SmokeTestLogger.info(`Dispose test: "${this.currentTest.title}" ...`);
if (app) {
await app.close();
}
} catch (error) {
SmokeTestLogger.error(`Error while dispose: ${error}`);
}
}

afterEach(dispose);
afterEach(BaseSmokeTest.dispose);

it("Verify extension debugger is visible in select debugger list", async () => {
const createLaunchFile = "create a launch.json file";
const rnOptionText = "More React Native options...";

await initApp();
await BaseSmokeTest.initApp();

await ComponentHelper.openRunAndDebugTab();
await ElementHelper.WaitElementClassNameVisible(Element.welcomeViewClassName);
Expand All @@ -70,7 +45,7 @@ export function startDebugConfigurationTests(): void {

fs.writeFileSync(path.join(vscodeFolderPath, "launch.json"), JSON.stringify({}));

await initApp();
await BaseSmokeTest.initApp();

await ComponentHelper.openFileExplorer();
const vscodeFolder = await ComponentHelper.WaitFileVisibleInFileExplorer(".vscode");
Expand Down
31 changes: 3 additions & 28 deletions test/smoke/suites/fileExplorer.test.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import { Page } from "playwright";
import { SmokeTestLogger } from "./helper/smokeTestLogger";
import { app, screenshots } from "./main";
import { CommonHelper } from "./helper/commonHelper";
import { ComponentHelper } from "./helper/componentHelper";
import assert = require("assert");
import { BaseSmokeTest } from "./helper/baseSmokeTest";

export function startFileExplorerTests(): void {
describe("FileExplorerTest", () => {
async function initApp(): Promise<Page> {
await app.launch();
return app.getMainPage();
}

async function dispose() {
if (this.currentTest?.state === "failed") {
SmokeTestLogger.info("Test failed, taking screenshot ...");
await screenshots.takeScreenshots(
this.currentTest.parent?.title || "Others",
this.currentTest.title.replace(/\s+/g, "_"),
);
}
try {
SmokeTestLogger.info(`Dispose test: "${this.currentTest.title}" ...`);
if (app) {
await app.close();
}
} catch (error) {
SmokeTestLogger.error(`Error while dispose: ${error}`);
}
}

afterEach(dispose);
afterEach(BaseSmokeTest.dispose);

it("Verify .vscode folder will be created when extension is activated", async () => {
const projectName = "sampleReactNativeProject";
const folderName = ".vscode";
await CommonHelper.findAndDeleteVSCodeSettingsDirectory(projectName);

await initApp();
await BaseSmokeTest.initApp();

await ComponentHelper.openFileExplorer();
const folder = await ComponentHelper.WaitFileVisibleInFileExplorer(folderName);
Expand Down
41 changes: 41 additions & 0 deletions test/smoke/suites/networkInspector.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import assert = require("assert");
import { BaseSmokeTest } from "./helper/baseSmokeTest";
import { ComponentHelper } from "./helper/componentHelper";
import { Element } from "./helper/constants";
import { ElementHelper } from "./helper/elementHelper";
import { TimeoutConstants } from "./helper/timeoutConstants";

export function startNetworkInspectorTests(): void {
describe("NetworkInspectorTest", () => {
afterEach(BaseSmokeTest.dispose);

it("Verify network inspector commands are visible in command palette", async () => {
await BaseSmokeTest.initApp();

const expectedCommands = [
"React Native: Run Network Inspector",
"React Native: Stop Network Inspector",
];

for (const command of expectedCommands) {
await ComponentHelper.openCommandPalette();
await ElementHelper.WaitElementClassNameVisible(
Element.commandPaletteClassName,
TimeoutConstants.COMMAND_PALETTE_TIMEOUT,
);

await ElementHelper.inputText(command);
const option = await ElementHelper.WaitElementSelectorVisible(
Element.commandPaletteFocusedItemSelector,
TimeoutConstants.COMMAND_PALETTE_TIMEOUT,
);

const value = await option.getAttribute("aria-label");
assert.ok(value?.includes(command), `Command '${command}' is not visible`);
}
});
});
}
34 changes: 5 additions & 29 deletions test/smoke/suites/packager.test.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import { Page } from "playwright";
import { SmokeTestLogger } from "./helper/smokeTestLogger";
import { app, screenshots } from "./main";
import assert = require("assert");
import { ComponentHelper } from "./helper/componentHelper";
import { TimeoutConstants } from "./helper/timeoutConstants";
import { BaseSmokeTest } from "./helper/baseSmokeTest";
import { SmokeTestLogger } from "./helper/smokeTestLogger";

export function startPackagerTests(): void {
describe("PackagerTest", () => {
async function initApp(): Promise<Page> {
await app.launch();
return app.getMainPage();
}

async function dispose() {
if (this.currentTest?.state === "failed") {
SmokeTestLogger.info("Test failed, taking screenshot ...");
await screenshots.takeScreenshots(
this.currentTest.parent?.title || "Others",
this.currentTest.title.replace(/\s+/g, "_"),
);
}
try {
SmokeTestLogger.info(`Dispose test: "${this.currentTest.title}" ...`);
if (app) {
await app.close();
}
} catch (error) {
SmokeTestLogger.error(`Error while dispose: ${error}`);
}
}

afterEach(dispose);
afterEach(BaseSmokeTest.dispose);

it("Verify react-native packager state is changed correctly when start and stop metro", async () => {
await initApp();
await BaseSmokeTest.initApp();

let packager = await ComponentHelper.getReactNativePackager();
let currentState = await packager.getAttribute("aria-label");
Expand Down Expand Up @@ -65,7 +41,7 @@ export function startPackagerTests(): void {

it("Verify Clean & Restart Packager command works correctly", async function () {
this.timeout(TimeoutConstants.PACKAGER_CLEAN_RESTART_TIMEOUT); // 5 minutes timeout for clean restart
await initApp();
await BaseSmokeTest.initApp();

// Execute Clean & Restart Packager command
// The command should handle starting the packager if it's not already running
Expand Down
2 changes: 2 additions & 0 deletions test/smoke/suites/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { smokeTestFail } from "./helper/utilities";
import { startPackagerTests } from "./packager.test";
import { startVsixExistenceTest } from "./vsixbuild.test";
import { startLogGrammarTests } from "./logGrammar.test";
import { startNetworkInspectorTests } from "./networkInspector.test";

export function startSmokeTests(setup: () => Promise<void>, cleanUp: () => Promise<void>): void {
// Guard: if mocha BDD hooks are absent, do not attempt to register tests
Expand Down Expand Up @@ -42,6 +43,7 @@ export function startSmokeTests(setup: () => Promise<void>, cleanUp: () => Promi
startCommandPaletteTests();
startFileExplorerTests();
startPackagerTests();
startNetworkInspectorTests();
startActionBarTests();
startDebugConfigurationTests();
startCDPNodeVersionCompatibilityTests();
Expand Down
Loading