UNPKG

@salesforce/pwa-kit-mcp

Version:

MCP server that helps you build Salesforce Commerce Cloud PWA Kit Composable Storefront

57 lines (56 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TestWithPlaywrightTool = void 0; var _siteTestPerformance = require("./site-test-performance"); var _siteTestAccessibility = require("./site-test-accessibility"); function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /* * Copyright (c) 2025, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ class TestWithPlaywrightTool { /** * Runs a Playwright test file by name (e.g., 'performance' or 'accessibility') * @param {string} testType - 'performance' or 'accessibility' * @param {string} siteUrl - Site URL to test * @returns {object} - Result of the test run */ run(testType, siteUrl) { return _asyncToGenerator(function* () { if (!siteUrl) { return { content: [{ type: 'text', text: 'Missing required argument: siteUrl (full site URL)' }] }; } switch (testType) { case 'performance': { return (0, _siteTestPerformance.runPerformanceTest)(siteUrl); } case 'accessibility': { return (0, _siteTestAccessibility.runAccessibilityTest)(siteUrl); } default: { const result = { content: [{ type: 'text', text: `Unsupported test type: ${testType}. Use 'performance' or 'accessibility'.` }] }; console.log('Unsupported test type result:', result); return result; } } })(); } } exports.TestWithPlaywrightTool = TestWithPlaywrightTool;