@vibe/testkit
Version:
Vibe e2e testing toolkit
44 lines (36 loc) • 1.42 kB
text/typescript
import { test, expect, FrameLocator } from "@playwright/test";
import { Dropdown } from "../components";
import { dropdownStory } from "./utils/url-helper";
let frame: FrameLocator;
let dropdown: Dropdown;
const dropdownLocator = '[data-vibe="Dropdown"]';
const frameLocator = "[id='storybook-preview-iframe']";
test.describe("Testkit - Unit Tests - Dropdown", () => {
test.beforeEach(async ({ page }) => {
await page.goto(dropdownStory);
frame = page.frameLocator(frameLocator);
dropdown = new Dropdown(page, frame.locator(dropdownLocator), "Dropdown");
await page.reload();
await dropdown.waitForElementToBeVisible();
await dropdown.close();
});
test("should be able to open", async () => {
await dropdown.open();
const isOpen = await dropdown.isDropdownOpen();
expect(isOpen).toBe(true);
});
test("should be enabled by default", async () => {
await expect(dropdown.getLocator()).toBeEnabled();
});
test("should be visible by default", async () => {
await expect(dropdown.getLocator()).toBeVisible();
});
test("should count elements correctly", async () => {
const count = await dropdown.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test("should handle attribute retrieval", async () => {
const attributeValue = await dropdown.getAttributeValue("data-vibe");
expect(attributeValue).toContain("Dropdown");
});
});