@browserstack/mcp-server 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/apiClient.d.ts +8 -5
- package/dist/lib/apiClient.js +77 -15
- package/dist/lib/device-cache.d.ts +3 -1
- package/dist/lib/device-cache.js +4 -0
- package/dist/lib/inmemory-store.d.ts +5 -1
- package/dist/lib/inmemory-store.js +10 -1
- package/dist/lib/instrumentation.js +6 -3
- package/dist/lib/utils.d.ts +75 -2
- package/dist/lib/utils.js +20 -0
- package/dist/lib/version-resolver.js +30 -14
- package/dist/tools/add-percy-snapshots.d.ts +0 -1
- package/dist/tools/add-percy-snapshots.js +11 -6
- package/dist/tools/appautomate-utils/appium-sdk/config-generator.d.ts +7 -1
- package/dist/tools/appautomate-utils/appium-sdk/config-generator.js +46 -26
- package/dist/tools/appautomate-utils/appium-sdk/constants.d.ts +1 -1
- package/dist/tools/appautomate-utils/appium-sdk/constants.js +24 -3
- package/dist/tools/appautomate-utils/appium-sdk/handler.js +16 -2
- package/dist/tools/appautomate-utils/appium-sdk/languages/java.d.ts +2 -0
- package/dist/tools/appautomate-utils/appium-sdk/languages/java.js +63 -29
- package/dist/tools/appautomate-utils/appium-sdk/types.d.ts +2 -1
- package/dist/tools/appautomate-utils/appium-sdk/types.js +10 -1
- package/dist/tools/appautomate-utils/native-execution/constants.d.ts +2 -1
- package/dist/tools/appautomate-utils/native-execution/constants.js +24 -2
- package/dist/tools/appautomate.js +15 -2
- package/dist/tools/automate-utils/fetch-screenshots.js +4 -1
- package/dist/tools/list-test-files.d.ts +1 -1
- package/dist/tools/list-test-files.js +43 -19
- package/dist/tools/percy-sdk.js +33 -6
- package/dist/tools/percy-snapshot-utils/constants.d.ts +0 -6
- package/dist/tools/percy-snapshot-utils/constants.js +0 -15
- package/dist/tools/rca-agent-utils/constants.d.ts +1 -1
- package/dist/tools/rca-agent-utils/constants.js +2 -2
- package/dist/tools/rca-agent-utils/rca-data.d.ts +1 -1
- package/dist/tools/rca-agent-utils/rca-data.js +2 -2
- package/dist/tools/rca-agent-utils/types.d.ts +3 -3
- package/dist/tools/rca-agent.d.ts +1 -1
- package/dist/tools/run-percy-scan.js +51 -10
- package/dist/tools/sdk-utils/bstack/configUtils.d.ts +8 -4
- package/dist/tools/sdk-utils/bstack/configUtils.js +74 -20
- package/dist/tools/sdk-utils/bstack/constants.d.ts +1 -1
- package/dist/tools/sdk-utils/bstack/constants.js +7 -9
- package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +1 -1
- package/dist/tools/sdk-utils/bstack/sdkHandler.js +19 -9
- package/dist/tools/sdk-utils/common/constants.d.ts +6 -5
- package/dist/tools/sdk-utils/common/constants.js +8 -7
- package/dist/tools/sdk-utils/common/device-validator.d.ts +25 -0
- package/dist/tools/sdk-utils/common/device-validator.js +375 -0
- package/dist/tools/sdk-utils/common/schema.d.ts +32 -8
- package/dist/tools/sdk-utils/common/schema.js +62 -3
- package/dist/tools/sdk-utils/common/utils.d.ts +1 -1
- package/dist/tools/sdk-utils/common/utils.js +14 -2
- package/dist/tools/sdk-utils/handler.d.ts +1 -0
- package/dist/tools/sdk-utils/handler.js +59 -14
- package/dist/tools/sdk-utils/percy-automate/constants.d.ts +4 -4
- package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -4
- package/dist/tools/sdk-utils/percy-bstack/handler.js +5 -1
- package/dist/tools/sdk-utils/percy-web/constants.d.ts +22 -20
- package/dist/tools/sdk-utils/percy-web/constants.js +39 -0
- package/dist/tools/sdk-utils/percy-web/handler.js +3 -1
- package/package.json +2 -2
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { getBrowserStackAuth } from "../lib/get-auth.js";
|
|
2
2
|
import { fetchPercyToken } from "./sdk-utils/percy-web/fetchPercyToken.js";
|
|
3
|
+
import { storedPercyResults } from "../lib/inmemory-store.js";
|
|
4
|
+
import { getFrameworkTestCommand, PERCY_FALLBACK_STEPS, } from "./sdk-utils/percy-web/constants.js";
|
|
5
|
+
import path from "path";
|
|
3
6
|
export async function runPercyScan(args, config) {
|
|
4
7
|
const { projectName, integrationType, instruction } = args;
|
|
5
8
|
const authorization = getBrowserStackAuth(config);
|
|
6
9
|
const percyToken = await fetchPercyToken(projectName, authorization, {
|
|
7
10
|
type: integrationType,
|
|
8
11
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
// Check if we have stored data and project matches
|
|
13
|
+
const stored = storedPercyResults.get();
|
|
14
|
+
// Compute if we have updated files to run
|
|
15
|
+
const hasUpdatedFiles = checkForUpdatedFiles(stored, projectName);
|
|
16
|
+
const updatedFiles = hasUpdatedFiles ? getUpdatedFiles(stored) : [];
|
|
17
|
+
// Build steps array with conditional spread
|
|
18
|
+
const steps = [
|
|
19
|
+
generatePercyTokenInstructions(percyToken),
|
|
20
|
+
...(hasUpdatedFiles ? generateUpdatedFilesSteps(stored, updatedFiles) : []),
|
|
21
|
+
...(instruction && !hasUpdatedFiles
|
|
22
|
+
? generateInstructionSteps(instruction)
|
|
23
|
+
: []),
|
|
24
|
+
...(!hasUpdatedFiles ? PERCY_FALLBACK_STEPS : []),
|
|
25
|
+
];
|
|
19
26
|
const instructionContext = steps
|
|
20
27
|
.map((step, index) => `${index + 1}. ${step}`)
|
|
21
28
|
.join("\n\n");
|
|
@@ -35,3 +42,37 @@ export PERCY_TOKEN="${percyToken}"
|
|
|
35
42
|
|
|
36
43
|
(For Windows: use 'setx PERCY_TOKEN "${percyToken}"' or 'set PERCY_TOKEN=${percyToken}' as appropriate.)`;
|
|
37
44
|
}
|
|
45
|
+
const toAbs = (p) => p ? path.resolve(p) : undefined;
|
|
46
|
+
function checkForUpdatedFiles(stored, // storedPercyResults structure
|
|
47
|
+
projectName) {
|
|
48
|
+
const projectMatches = stored?.projectName === projectName;
|
|
49
|
+
return (projectMatches &&
|
|
50
|
+
stored?.testFiles &&
|
|
51
|
+
Object.values(stored.testFiles).some((status) => status === true));
|
|
52
|
+
}
|
|
53
|
+
function getUpdatedFiles(stored) {
|
|
54
|
+
const updatedFiles = [];
|
|
55
|
+
const fileStatusMap = stored.testFiles;
|
|
56
|
+
Object.entries(fileStatusMap).forEach(([filePath, status]) => {
|
|
57
|
+
if (status === true) {
|
|
58
|
+
updatedFiles.push(filePath);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return updatedFiles;
|
|
62
|
+
}
|
|
63
|
+
function generateUpdatedFilesSteps(stored, updatedFiles) {
|
|
64
|
+
const filesToRun = updatedFiles.map(toAbs).filter(Boolean);
|
|
65
|
+
const { detectedLanguage, detectedTestingFramework } = stored;
|
|
66
|
+
const exampleCommand = getFrameworkTestCommand(detectedLanguage, detectedTestingFramework);
|
|
67
|
+
return [
|
|
68
|
+
`Run only the updated files with Percy:\n` +
|
|
69
|
+
`Example: ${exampleCommand} <file1> <file2> ...`,
|
|
70
|
+
`Updated files to run:\n${filesToRun.join("\n")}`,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
function generateInstructionSteps(instruction) {
|
|
74
|
+
return [
|
|
75
|
+
`Use the provided test command with Percy:\n${instruction}`,
|
|
76
|
+
`If this command fails or is incorrect, fall back to the default approach below.`,
|
|
77
|
+
];
|
|
78
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ValidatedEnvironment } from "../common/device-validator.js";
|
|
2
|
+
import { BrowserStackConfig } from "../../../lib/types.js";
|
|
3
|
+
export declare function generateBrowserStackYMLInstructions(config: {
|
|
4
|
+
validatedEnvironments?: ValidatedEnvironment[];
|
|
5
|
+
platforms?: string[];
|
|
6
|
+
enablePercy?: boolean;
|
|
7
|
+
projectName: string;
|
|
8
|
+
}, browserStackConfig: BrowserStackConfig): string;
|
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getBrowserStackAuth } from "../../../lib/get-auth.js";
|
|
2
|
+
export function generateBrowserStackYMLInstructions(config, browserStackConfig) {
|
|
3
|
+
const enablePercy = config.enablePercy || false;
|
|
4
|
+
const projectName = config.projectName || "BrowserStack Automate Build";
|
|
5
|
+
// Get credentials from config
|
|
6
|
+
const authString = getBrowserStackAuth(browserStackConfig);
|
|
7
|
+
const [username, accessKey] = authString.split(":");
|
|
8
|
+
// Generate platform configurations using the utility function
|
|
9
|
+
const platformConfigs = generatePlatformConfigs(config);
|
|
10
|
+
const stepTitle = "Create a browserstack.yml file in the project root with your validated device configurations:If already exists, update it with the following content for devices and project details.";
|
|
11
|
+
const buildName = `${projectName}-Build`;
|
|
5
12
|
let ymlContent = `
|
|
6
13
|
# ======================
|
|
7
14
|
# BrowserStack Reporting
|
|
8
15
|
# ======================
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
|
|
17
|
+
userName: ${username}
|
|
18
|
+
accessKey: ${accessKey}
|
|
19
|
+
|
|
11
20
|
# TODO: Replace these sample values with your actual project details
|
|
12
|
-
|
|
21
|
+
projectName: ${projectName}
|
|
22
|
+
buildName: ${buildName}
|
|
13
23
|
|
|
14
24
|
# =======================================
|
|
15
25
|
# Platforms (Browsers / Devices to test)
|
|
16
|
-
#
|
|
26
|
+
# =======================================`;
|
|
27
|
+
ymlContent += `
|
|
17
28
|
# Platforms object contains all the browser / device combinations you want to test on.
|
|
18
|
-
# Generate this on the basis of the following platforms requested by the user:
|
|
19
|
-
# Requested platforms: ${desiredPlatforms}
|
|
20
29
|
platforms:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
browserVersion: latest
|
|
25
|
-
|
|
30
|
+
${platformConfigs}`;
|
|
31
|
+
ymlContent += `
|
|
32
|
+
|
|
26
33
|
# =======================
|
|
27
34
|
# Parallels per Platform
|
|
28
35
|
# =======================
|
|
29
36
|
# The number of parallel threads to be used for each platform set.
|
|
30
37
|
# BrowserStack's SDK runner will select the best strategy based on the configured value
|
|
31
|
-
#
|
|
32
|
-
# Example 1 - If you have configured 3 platforms and set \`parallelsPerPlatform\` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
|
|
33
|
-
#
|
|
34
|
-
# Example 2 - If you have configured 1 platform and set \`parallelsPerPlatform\` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
|
|
38
|
+
# The number of parallel threads to be used for each platform set.
|
|
35
39
|
parallelsPerPlatform: 1
|
|
36
40
|
|
|
37
41
|
# =================
|
|
@@ -58,9 +62,59 @@ percyCaptureMode: manual`;
|
|
|
58
62
|
}
|
|
59
63
|
return `
|
|
60
64
|
---STEP---
|
|
61
|
-
|
|
65
|
+
${stepTitle}
|
|
62
66
|
|
|
63
67
|
\`\`\`yaml${ymlContent}
|
|
64
68
|
\`\`\`
|
|
65
69
|
\n`;
|
|
66
70
|
}
|
|
71
|
+
function generatePlatformConfigs(config) {
|
|
72
|
+
if (config.validatedEnvironments && config.validatedEnvironments.length > 0) {
|
|
73
|
+
// Generate platforms array from validated environments
|
|
74
|
+
const platforms = config.validatedEnvironments.map((env) => {
|
|
75
|
+
if (env.platform === "windows" || env.platform === "macos") {
|
|
76
|
+
// Desktop configuration
|
|
77
|
+
return {
|
|
78
|
+
os: env.platform === "windows" ? "Windows" : "OS X",
|
|
79
|
+
osVersion: env.osVersion,
|
|
80
|
+
browserName: env.browser,
|
|
81
|
+
browserVersion: env.browserVersion || "latest",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// Mobile configuration (android/ios)
|
|
86
|
+
return {
|
|
87
|
+
deviceName: env.deviceName,
|
|
88
|
+
osVersion: env.osVersion,
|
|
89
|
+
browserName: env.browser,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
// Convert platforms to YAML format
|
|
94
|
+
return platforms
|
|
95
|
+
.map((platform) => {
|
|
96
|
+
if (platform.deviceName) {
|
|
97
|
+
// Mobile platform
|
|
98
|
+
return ` - deviceName: "${platform.deviceName}"
|
|
99
|
+
osVersion: "${platform.osVersion}"
|
|
100
|
+
browserName: ${platform.browserName}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Desktop platform
|
|
104
|
+
return ` - os: ${platform.os}
|
|
105
|
+
osVersion: "${platform.osVersion}"
|
|
106
|
+
browserName: ${platform.browserName}
|
|
107
|
+
browserVersion: ${platform.browserVersion}`;
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
.join("\n");
|
|
111
|
+
}
|
|
112
|
+
else if (config.platforms && config.platforms.length > 0) {
|
|
113
|
+
// Fallback to default platforms configuration
|
|
114
|
+
return ` - os: Windows
|
|
115
|
+
osVersion: 11
|
|
116
|
+
browserName: chrome
|
|
117
|
+
browserVersion: latest`;
|
|
118
|
+
}
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
@@ -2,7 +2,7 @@ import { ConfigMapping } from "../common/types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* ---------- PYTHON INSTRUCTIONS ----------
|
|
4
4
|
*/
|
|
5
|
-
export declare const pythonInstructions: (
|
|
5
|
+
export declare const pythonInstructions: () => {
|
|
6
6
|
setup: string;
|
|
7
7
|
run: string;
|
|
8
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ---------- PYTHON INSTRUCTIONS ----------
|
|
3
3
|
*/
|
|
4
|
-
export const pythonInstructions = (
|
|
4
|
+
export const pythonInstructions = () => {
|
|
5
5
|
const setup = `
|
|
6
6
|
---STEP---
|
|
7
7
|
|
|
@@ -9,20 +9,18 @@ Install the BrowserStack SDK:
|
|
|
9
9
|
\`\`\`bash
|
|
10
10
|
python3 -m pip install browserstack-sdk
|
|
11
11
|
\`\`\`
|
|
12
|
-
|
|
13
|
-
---STEP---
|
|
14
|
-
|
|
15
|
-
Setup the BrowserStack SDK with your credentials:
|
|
16
|
-
\`\`\`bash
|
|
17
|
-
browserstack-sdk setup --username "${username}" --key "${accessKey}"
|
|
18
|
-
\`\`\`
|
|
19
12
|
`;
|
|
20
13
|
const run = `
|
|
21
14
|
---STEP---
|
|
22
15
|
|
|
23
16
|
Run your tests on BrowserStack:
|
|
24
17
|
\`\`\`bash
|
|
25
|
-
browserstack-sdk
|
|
18
|
+
browserstack-sdk pytest -s tests/<example_test>.py
|
|
19
|
+
\`\`\`
|
|
20
|
+
|
|
21
|
+
Or run all tests in a directory:
|
|
22
|
+
\`\`\`bash
|
|
23
|
+
browserstack-sdk pytest <path-to-test-directory>
|
|
26
24
|
\`\`\`
|
|
27
25
|
`;
|
|
28
26
|
return { setup, run };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RunTestsInstructionResult } from "../common/types.js";
|
|
2
2
|
import { RunTestsOnBrowserStackInput } from "../common/schema.js";
|
|
3
3
|
import { BrowserStackConfig } from "../../../lib/types.js";
|
|
4
|
-
export declare function runBstackSDKOnly(input: RunTestsOnBrowserStackInput, config: BrowserStackConfig, isPercyAutomate?: boolean): RunTestsInstructionResult
|
|
4
|
+
export declare function runBstackSDKOnly(input: RunTestsOnBrowserStackInput, config: BrowserStackConfig, isPercyAutomate?: boolean): Promise<RunTestsInstructionResult>;
|
|
@@ -2,10 +2,14 @@ import { getBrowserStackAuth } from "../../../lib/get-auth.js";
|
|
|
2
2
|
import { getSDKPrefixCommand } from "./commands.js";
|
|
3
3
|
import { generateBrowserStackYMLInstructions } from "./configUtils.js";
|
|
4
4
|
import { getInstructionsForProjectConfiguration } from "../common/instructionUtils.js";
|
|
5
|
-
|
|
5
|
+
import { validateDevices } from "../common/device-validator.js";
|
|
6
|
+
export async function runBstackSDKOnly(input, config, isPercyAutomate = false) {
|
|
6
7
|
const steps = [];
|
|
7
8
|
const authString = getBrowserStackAuth(config);
|
|
8
9
|
const [username, accessKey] = authString.split(":");
|
|
10
|
+
// Validate devices against real BrowserStack device data
|
|
11
|
+
const tupleTargets = input.devices;
|
|
12
|
+
const validatedEnvironments = await validateDevices(tupleTargets || [], input.detectedBrowserAutomationFramework);
|
|
9
13
|
// Handle frameworks with unique setup instructions that don't use browserstack.yml
|
|
10
14
|
if (input.detectedBrowserAutomationFramework === "cypress" ||
|
|
11
15
|
input.detectedTestingFramework === "webdriverio") {
|
|
@@ -41,14 +45,6 @@ export function runBstackSDKOnly(input, config, isPercyAutomate = false) {
|
|
|
41
45
|
content: sdkSetupCommand,
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
|
-
const ymlInstructions = generateBrowserStackYMLInstructions(input.desiredPlatforms, false, input.projectName);
|
|
45
|
-
if (ymlInstructions) {
|
|
46
|
-
steps.push({
|
|
47
|
-
type: "instruction",
|
|
48
|
-
title: "Configure browserstack.yml",
|
|
49
|
-
content: ymlInstructions,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
48
|
const frameworkInstructions = getInstructionsForProjectConfiguration(input.detectedBrowserAutomationFramework, input.detectedTestingFramework, input.detectedLanguage, username, accessKey);
|
|
53
49
|
if (frameworkInstructions) {
|
|
54
50
|
if (frameworkInstructions.setup) {
|
|
@@ -58,6 +54,20 @@ export function runBstackSDKOnly(input, config, isPercyAutomate = false) {
|
|
|
58
54
|
content: frameworkInstructions.setup,
|
|
59
55
|
});
|
|
60
56
|
}
|
|
57
|
+
}
|
|
58
|
+
const ymlInstructions = generateBrowserStackYMLInstructions({
|
|
59
|
+
validatedEnvironments,
|
|
60
|
+
enablePercy: false,
|
|
61
|
+
projectName: input.projectName,
|
|
62
|
+
}, config);
|
|
63
|
+
if (ymlInstructions) {
|
|
64
|
+
steps.push({
|
|
65
|
+
type: "instruction",
|
|
66
|
+
title: "Configure browserstack.yml",
|
|
67
|
+
content: ymlInstructions,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (frameworkInstructions) {
|
|
61
71
|
if (frameworkInstructions.run && !isPercyAutomate) {
|
|
62
72
|
steps.push({
|
|
63
73
|
type: "instruction",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare const IMPORTANT_SETUP_WARNING = "IMPORTANT: DO NOT SKIP ANY STEP. All the setup steps described below MUST be executed regardless of any existing configuration or setup. This ensures proper BrowserStack SDK setup.";
|
|
2
|
-
export declare const SETUP_PERCY_DESCRIPTION = "Set up Percy visual testing for
|
|
2
|
+
export declare const SETUP_PERCY_DESCRIPTION = "Set up or expand Percy visual testing configuration with comprehensive coverage for existing projects that might have Percy integrated. This supports both Percy Web Standalone and Percy Automate. Example prompts: Expand percy coverage for this project {project_name}";
|
|
3
3
|
export declare const LIST_TEST_FILES_DESCRIPTION = "Lists all test files for a given set of directories.";
|
|
4
4
|
export declare const PERCY_SNAPSHOT_COMMANDS_DESCRIPTION = "Adds Percy snapshot commands to the specified test files.";
|
|
5
5
|
export declare const RUN_ON_BROWSERSTACK_DESCRIPTION = "Set up and run automated web-based tests on BrowserStack using the BrowserStack SDK. Use this tool for functional or integration test setup on BrowserStack only. For any visual testing or Percy integration, use the dedicated Percy setup tool. Example prompts: run this test on browserstack; set up this project for browserstack.";
|
|
6
|
-
export declare const SIMULATE_PERCY_CHANGE_DESCRIPTION = "
|
|
6
|
+
export declare const SIMULATE_PERCY_CHANGE_DESCRIPTION = "Integrate Percy visual testing into new projects and demonstrate visual change detection through a step-by-step simulation. This tool handles initial Percy integration, setup, and creates a working demonstration for new users. Primary tool for prompts like: \"Integrate percy for this project\", \"Integrate percy in this project {project_name}\"";
|
|
7
7
|
export declare const PERCY_REPLACE_REGEX: RegExp;
|
|
8
|
-
export declare const PERCY_SNAPSHOT_INSTRUCTION = "\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory
|
|
9
|
-
export declare const PERCY_SIMULATE_INSTRUCTION = "\nMANDATORY: Aggressive, Accurate Percy Snapshots Integration\n\nPrerequisite: Before making any code changes in the user's
|
|
10
|
-
export declare const PERCY_SIMULATION_DRIVER_INSTRUCTION = "\nMANDATORY: Step-by-Step Percy Visual Change Simulation\nYou MUST follow these steps with NO EXCEPTIONS:\n\nSTEP 1: At this case we have added Percy snapshot commands to the test files at the appropriate locations (e.g., after navigation, UI change, or significant state). \n- Use ONLY existing snapshot names.\n- Do NOT add any popup injection or visual changes yet.\n- Do NOT run any Percy builds at this stage.\n\nSTEP 2: Run ONE comprehensive baseline Percy build that executes ALL tests containing Percy snapshots in a SINGLE build. This creates one baseline build with all snapshots for comparison. Use a command like: npx percy exec -- python -m pytest tests/ -k 'test_name1 or test_name2 or test_name3' -v to run multiple specific tests in one build.\"\n\nSTEP 3: Modify your test to inject a visible UI change (such as a popup) IMMEDIATELY BEFORE an EXISTING snapshot command (e.g., before percy_snapshot(self.driver, \"screenshot name\")).\n- Do NOT add a new snapshot name for the popup.\n- The popup must appear in an existing snapshot, not a new one.\n- Add this popup code in some test files before the percy_snapshot command you've added, to display the visual changes.\n\n```Javascript\npopup_script = `\nvar popup = document.createElement('div');\npopup.id = 'percy-test-popup';\npopup.style.cssText = popup.style.cssText = `\n /* TODO: Add styles to make the popup large, centered, and visually noticeable.\n Suggested properties: position: fixed; top/left; transform; background; color; font-size; padding; z-index; animation, etc. */\n`;\npopup.innerHTML = 'PERCY TEST<br>VISUAL CHANGE<br>DETECTED!';\ndocument.body.appendChild(popup);\n`;\n\n# Insert this just before the EXISTING snapshot command:\ndriver.execute_script(popup_script)\npercy_snapshot(self.driver, \"Before Adding to Cart\") # (Do NOT change the snapshot name, keep existing one)\n```\n\nSTEP 4: Run a second Percy build.\n- The snapshot names must remain the same as in the baseline.\n- The visual change should now appear in the same snapshot as before.\n- Use the same build command you ran for the baseline.\n\nSTEP 5: Compare the two Percy builds to see the detected visual difference.\n\nSTEP 6: Now ask user if they want to
|
|
8
|
+
export declare const PERCY_SNAPSHOT_INSTRUCTION = "\nInvoke listTestFiles() with the provided directories from user to gather all test files in memory ---STEP---\nProcess files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:\n- Start with index 0\n- Then index 1 \n- Then index 2\n- Continue sequentially until the last index\n- DO NOT skip any index numbers\n- DO NOT jump to random indices like 10, 20, 30\n- DO NOT worry about time consuming and any constraints.\n- DO NOT STOP until you add commands in all the files or you reach end of the files.\n";
|
|
9
|
+
export declare const PERCY_SIMULATE_INSTRUCTION = "\nMANDATORY: Aggressive, Accurate Percy Snapshots Integration\n\nPrerequisite: Before making any code changes in the user's repository, create and switch to a new branch named browserstack-simulation. Stage all changes but do not commit them. If the repository has not been initialized yet, run git init first.\n\nYou MUST follow these steps with NO EXCEPTIONS:\n1. Identify 4-5 key test files in the project that are critical for visual testing.\n2. For EACH identified test file, analyze the code to find EVERY location where a Percy snapshot should be called (e.g., after each navigation, UI change, or significant state in tests).\n3. Insert snapshot calls at ALL such points, not just the first or most obvious one.\n\nIteratively update every selected test file with percy snapshot calls at all identified points, ensuring comprehensive coverage of visual changes.";
|
|
10
|
+
export declare const PERCY_SIMULATION_DRIVER_INSTRUCTION = "\nMANDATORY: Step-by-Step Percy Visual Change Simulation\nYou MUST follow these steps with NO EXCEPTIONS:\n\nSTEP 1: At this case we have added Percy snapshot commands to the test files at the appropriate locations (e.g., after navigation, UI change, or significant state). \n- Use ONLY existing snapshot names.\n- Do NOT add any popup injection or visual changes yet.\n- Do NOT run any Percy builds at this stage.\n\nSTEP 2: Run ONE comprehensive baseline Percy build that executes ALL tests containing Percy snapshots in a SINGLE build. This creates one baseline build with all snapshots for comparison. Use a command like: npx percy exec --label=mcp -- python -m pytest tests/ -k 'test_name1 or test_name2 or test_name3' -v to run multiple specific tests in one build.\"\n\nSTEP 3: Modify your test to inject a visible UI change (such as a popup) IMMEDIATELY BEFORE an EXISTING snapshot command (e.g., before percy_snapshot(self.driver, \"screenshot name\")).\n- Do NOT add a new snapshot name for the popup.\n- The popup must appear in an existing snapshot, not a new one.\n- Add this popup code in some test files before the percy_snapshot command you've added, to display the visual changes.\n\n```Javascript\npopup_script = `\nvar popup = document.createElement('div');\npopup.id = 'percy-test-popup';\npopup.style.cssText = popup.style.cssText = `\n /* TODO: Add styles to make the popup large, centered, and visually noticeable.\n Suggested properties: position: fixed; top/left; transform; background; color; font-size; padding; z-index; animation, etc. */\n`;\npopup.innerHTML = 'PERCY TEST<br>VISUAL CHANGE<br>DETECTED!';\ndocument.body.appendChild(popup);\n`;\n\n# Insert this just before the EXISTING snapshot command:\ndriver.execute_script(popup_script)\npercy_snapshot(self.driver, \"Before Adding to Cart\") # (Do NOT change the snapshot name, keep existing one)\n```\n\nSTEP 4: Run a second Percy build with same label and same test command as the baseline.\n- The snapshot names must remain the same as in the baseline.\n- The visual change should now appear in the same snapshot as before.\n- Use the same build command you ran for the baseline.\n\nSTEP 5: Compare the two Percy builds to see the detected visual difference.\n\nSTEP 6: Now ask user if they want to expand percy for other testcases? If yes, call the \"expandPercyVisualTesting\" tool to enable complete coverage for the entire project.\n\nCONSTRAINTS:\n- Do NOT run any builds until explicitly instructed in the steps.\n- Do NOT add new snapshot names\u2014only use existing ones.\n- Do NOT add popup injection until the baseline is established.\n- Visual changes must appear in EXISTING snapshots, not new ones.\n\nVALIDATION CHECKPOINTS (before proceeding to the next step):\n- Are you adding only snapshot commands (not running builds)?\n- Are you reusing existing snapshot names (not creating new ones)?\n- Have you established the baseline first (before adding visual changes)\n\nCRITICAL: \nDo NOT run tests separately or create multiple builds during baseline establishment. The goal is to have exactly TWO builds total: (1) baseline build with all original snapshots, (2) modified build with the same tests but visual changes injected.\n";
|
|
11
|
+
export declare const PERCY_VERIFICATION_REGEX: RegExp;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const IMPORTANT_SETUP_WARNING = "IMPORTANT: DO NOT SKIP ANY STEP. All the setup steps described below MUST be executed regardless of any existing configuration or setup. This ensures proper BrowserStack SDK setup.";
|
|
2
|
-
export const SETUP_PERCY_DESCRIPTION = "Set up Percy visual testing for
|
|
2
|
+
export const SETUP_PERCY_DESCRIPTION = "Set up or expand Percy visual testing configuration with comprehensive coverage for existing projects that might have Percy integrated. This supports both Percy Web Standalone and Percy Automate. Example prompts: Expand percy coverage for this project {project_name}";
|
|
3
3
|
export const LIST_TEST_FILES_DESCRIPTION = "Lists all test files for a given set of directories.";
|
|
4
4
|
export const PERCY_SNAPSHOT_COMMANDS_DESCRIPTION = "Adds Percy snapshot commands to the specified test files.";
|
|
5
5
|
export const RUN_ON_BROWSERSTACK_DESCRIPTION = "Set up and run automated web-based tests on BrowserStack using the BrowserStack SDK. Use this tool for functional or integration test setup on BrowserStack only. For any visual testing or Percy integration, use the dedicated Percy setup tool. Example prompts: run this test on browserstack; set up this project for browserstack.";
|
|
6
|
-
export const SIMULATE_PERCY_CHANGE_DESCRIPTION =
|
|
6
|
+
export const SIMULATE_PERCY_CHANGE_DESCRIPTION = `Integrate Percy visual testing into new projects and demonstrate visual change detection through a step-by-step simulation. This tool handles initial Percy integration, setup, and creates a working demonstration for new users. Primary tool for prompts like: "Integrate percy for this project", "Integrate percy in this project {project_name}"`;
|
|
7
7
|
export const PERCY_REPLACE_REGEX = /Invoke listTestFiles\(\) with the provided directories[\s\S]*?- DO NOT STOP until you add commands in all the files or you reach end of the files\./;
|
|
8
8
|
export const PERCY_SNAPSHOT_INSTRUCTION = `
|
|
9
|
-
Invoke listTestFiles() with the provided directories from user to gather all test files in memory
|
|
9
|
+
Invoke listTestFiles() with the provided directories from user to gather all test files in memory ---STEP---
|
|
10
10
|
Process files in STRICT sequential order using tool addPercySnapshotCommands() with below instructions:
|
|
11
11
|
- Start with index 0
|
|
12
12
|
- Then index 1
|
|
@@ -20,7 +20,7 @@ Process files in STRICT sequential order using tool addPercySnapshotCommands() w
|
|
|
20
20
|
export const PERCY_SIMULATE_INSTRUCTION = `
|
|
21
21
|
MANDATORY: Aggressive, Accurate Percy Snapshots Integration
|
|
22
22
|
|
|
23
|
-
Prerequisite: Before making any code changes in the user's
|
|
23
|
+
Prerequisite: Before making any code changes in the user's repository, create and switch to a new branch named browserstack-simulation. Stage all changes but do not commit them. If the repository has not been initialized yet, run git init first.
|
|
24
24
|
|
|
25
25
|
You MUST follow these steps with NO EXCEPTIONS:
|
|
26
26
|
1. Identify 4-5 key test files in the project that are critical for visual testing.
|
|
@@ -37,7 +37,7 @@ STEP 1: At this case we have added Percy snapshot commands to the test files at
|
|
|
37
37
|
- Do NOT add any popup injection or visual changes yet.
|
|
38
38
|
- Do NOT run any Percy builds at this stage.
|
|
39
39
|
|
|
40
|
-
STEP 2: Run ONE comprehensive baseline Percy build that executes ALL tests containing Percy snapshots in a SINGLE build. This creates one baseline build with all snapshots for comparison. Use a command like: npx percy exec -- python -m pytest tests/ -k 'test_name1 or test_name2 or test_name3' -v to run multiple specific tests in one build."
|
|
40
|
+
STEP 2: Run ONE comprehensive baseline Percy build that executes ALL tests containing Percy snapshots in a SINGLE build. This creates one baseline build with all snapshots for comparison. Use a command like: npx percy exec --label=mcp -- python -m pytest tests/ -k 'test_name1 or test_name2 or test_name3' -v to run multiple specific tests in one build."
|
|
41
41
|
|
|
42
42
|
STEP 3: Modify your test to inject a visible UI change (such as a popup) IMMEDIATELY BEFORE an EXISTING snapshot command (e.g., before percy_snapshot(self.driver, "screenshot name")).
|
|
43
43
|
- Do NOT add a new snapshot name for the popup.
|
|
@@ -61,14 +61,14 @@ driver.execute_script(popup_script)
|
|
|
61
61
|
percy_snapshot(self.driver, "Before Adding to Cart") # (Do NOT change the snapshot name, keep existing one)
|
|
62
62
|
\`\`\`
|
|
63
63
|
|
|
64
|
-
STEP 4: Run a second Percy build.
|
|
64
|
+
STEP 4: Run a second Percy build with same label and same test command as the baseline.
|
|
65
65
|
- The snapshot names must remain the same as in the baseline.
|
|
66
66
|
- The visual change should now appear in the same snapshot as before.
|
|
67
67
|
- Use the same build command you ran for the baseline.
|
|
68
68
|
|
|
69
69
|
STEP 5: Compare the two Percy builds to see the detected visual difference.
|
|
70
70
|
|
|
71
|
-
STEP 6: Now ask user if they want to
|
|
71
|
+
STEP 6: Now ask user if they want to expand percy for other testcases? If yes, call the "expandPercyVisualTesting" tool to enable complete coverage for the entire project.
|
|
72
72
|
|
|
73
73
|
CONSTRAINTS:
|
|
74
74
|
- Do NOT run any builds until explicitly instructed in the steps.
|
|
@@ -84,3 +84,4 @@ VALIDATION CHECKPOINTS (before proceeding to the next step):
|
|
|
84
84
|
CRITICAL:
|
|
85
85
|
Do NOT run tests separately or create multiple builds during baseline establishment. The goal is to have exactly TWO builds total: (1) baseline build with all original snapshots, (2) modified build with the same tests but visual changes injected.
|
|
86
86
|
`;
|
|
87
|
+
export const PERCY_VERIFICATION_REGEX = /\*\*✅ Verification:\*\*\nPlease verify that you have completed all[\s\S]*?double-check each step and ensure all commands executed successfully\./s;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface DesktopBrowserEntry {
|
|
2
|
+
os: string;
|
|
3
|
+
os_version: string;
|
|
4
|
+
browser: string;
|
|
5
|
+
browser_version: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MobileDeviceEntry {
|
|
8
|
+
os: "android" | "ios";
|
|
9
|
+
os_version: string;
|
|
10
|
+
display_name: string;
|
|
11
|
+
browsers?: Array<{
|
|
12
|
+
browser: string;
|
|
13
|
+
display_name?: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface ValidatedEnvironment {
|
|
17
|
+
platform: string;
|
|
18
|
+
osVersion: string;
|
|
19
|
+
browser?: string;
|
|
20
|
+
browserVersion?: string;
|
|
21
|
+
deviceName?: string;
|
|
22
|
+
notes?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function validateDevices(devices: Array<Array<string>>, framework?: string): Promise<ValidatedEnvironment[]>;
|
|
25
|
+
export declare function validateAppAutomateDevices(devices: Array<Array<string>>): Promise<ValidatedEnvironment[]>;
|