@vibe/testkit
Version:
Vibe e2e testing toolkit
33 lines • 1.78 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { test } from "@playwright/test";
/**
* Presses a key on the page (e.g., Escape)
* @param {Page} page - The Playwright page object
* @param {string} key - The key to press (e.g., 'Escape', 'Enter')
* @returns {Promise<void>}
*/
export const pressKey = (page, key) => __awaiter(void 0, void 0, void 0, function* () {
yield test.step(`Pressing key ${key}`, () => __awaiter(void 0, void 0, void 0, function* () {
yield page.keyboard.press(key);
}));
});
/**
* Drags an element from one location and drops it to another
* @param {Locator} sourceLocator - The locator of the element to drag
* @param {Locator} targetLocator - The locator of the element to drop to
* @returns {Promise<void>}
*/
export const dragAndDrop = (sourceLocator, targetLocator) => __awaiter(void 0, void 0, void 0, function* () {
yield test.step(`Dragging and dropping ${sourceLocator.toString()} to ${targetLocator.toString()}`, () => __awaiter(void 0, void 0, void 0, function* () {
yield sourceLocator.dragTo(targetLocator);
}));
});
//# sourceMappingURL=common-actions.js.map