Skip to content

Commit

Permalink
add waits for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uziab committed Oct 27, 2024
1 parent 36c664f commit 27308ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/testing-kit/src/__TESTS__/button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '../buttons/Button'; // Assuming you have this Button cl

test('should fire a click event and log to console', async ({ page }) => {
// Navigate to the Storybook page with the component
await page.goto('/?path=/story/buttons-button--overview');
await page.goto('/?path=/story/buttons-button--overview', {timeout: 60000});
// Locate the iframe where the button is rendered
const frame = page.frameLocator("[id='storybook-preview-iframe']");
const button = new Button(page, frame.locator('button[data-testid="button"]'), 'Button');
Expand Down
10 changes: 8 additions & 2 deletions packages/testing-kit/src/__TESTS__/buttonGroup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ test.describe("ButtonGroup Class with Storybook", () => {
test.beforeEach(async ({ page }) => {
// Navigate to the Storybook story where the ButtonGroup component is rendered
await page.goto("/?path=/story/buttons-buttongroup--default");

//TODO - find a better way to wait for the storybook to load
// Locate the iframe where the Storybook component is rendered
const frame = page.frameLocator("[id='storybook-preview-iframe']");

// Locate the button group inside the iframe
const buttonGroupLocator = frame.locator('div[data-testid="button-group"]');

while (await button.locator.isVisible() === false) {
await page.waitForTimeout(30000);
await page.reload();
if (await buttonGroupLocator.locator.isVisible() === true) {
break;
}
}
// Initialize ButtonGroup with the Playwright page and locator
buttonGroup = new ButtonGroup(page, buttonGroupLocator, "Test Button Group");
});
Expand Down
2 changes: 1 addition & 1 deletion packages/testing-kit/src/__TESTS__/dropdown.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";
import { DropDown } from "../inputs/DropDown";

test.describe("menuButton Class with Storybook", () => {
test.describe("dropdown Class with Storybook", () => {
let Dropdown;

test.beforeEach(async ({ page }) => {
Expand Down

0 comments on commit 27308ec

Please sign in to comment.