UNPKG

@gravitywiz/playwright-plugin-gravity-wiz

Version:

Playwright plugin for testing WordPress and Gravity Wiz plugins

56 lines 2.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormHelpers = void 0; const wp_cli_1 = require("./wp-cli"); const path_1 = __importDefault(require("path")); class FormHelpers { constructor(page) { this.page = page; } /** * Imports the given Gravity Form export. */ async importForm(filename, formTitle) { let jsonPath = filename; // If just a filename is provided, assume it's in fixtures/forms if (path_1.default.basename(jsonPath) === jsonPath) { jsonPath = path_1.default.join('test-fixtures', 'forms', jsonPath); } // Add .json extension if not present if (path_1.default.extname(jsonPath) === '') { jsonPath += '.json'; } const scriptPath = path_1.default.join(__dirname, '..', '..', 'scripts', 'import-form.php'); const args = ['eval-file', scriptPath, jsonPath]; if (formTitle) { args.push(formTitle); } return (0, wp_cli_1.execaCommand)('wp', args); } /** * Imports the given Gravity Form entries export. */ async importEntries(formID, jsonPath) { let entriesPath = jsonPath; // If just a filename is provided, assume it's in fixtures/entries if (path_1.default.basename(entriesPath) === entriesPath) { entriesPath = path_1.default.join('cypress', 'fixtures', 'entries', entriesPath); } // Add .json extension if not present if (path_1.default.extname(entriesPath) === '') { entriesPath += '.json'; } return (0, wp_cli_1.execaCommand)('wp', [ 'gf', 'entry', 'import', formID.toString(), entriesPath, ]); } } exports.FormHelpers = FormHelpers; //# sourceMappingURL=form-helpers.js.map