UNPKG

@vibe/testkit

Version:
44 lines 2.04 kB
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"; import { Button } from "./Button"; /** * Class representing an icon button that extends the Button class. */ export class IconButton extends Button { /** * Create an IconButton. * @param {Page} page - The Playwright page object. * @param {Locator} locator - The locator for the IconButton element. * @param {string} elementReportName - The name for reporting purposes. * @param menuType - The type of menu associated with the button. */ constructor(page, locator, elementReportName, menuType) { super(page, locator, elementReportName); this.icon = new Button(this.page, this.locator, `${this.elementReportName} - Icon`); this.menu = menuType; } /** * Select an item from the icon button's menu. * @param {string} item - The item to select. * @returns {Promise<void>} */ selectItem(item) { return __awaiter(this, void 0, void 0, function* () { yield test.step(`Select ${item} from ${this.elementReportName}`, () => __awaiter(this, void 0, void 0, function* () { yield this.icon.click(); if (this.menu) { yield this.menu.selectItem(item); } }), { box: false }); }); } } //# sourceMappingURL=IconButton.js.map