Skip to content

Commit

Permalink
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 8 additions & 1 deletion e2e/consts.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export const IFRAME_SELECTOR = 'iframe[title="storybook-preview-iframe"]';
import { FrameLocator, Page } from '@playwright/test';

const IFRAME_SELECTOR = 'iframe[title="storybook-preview-iframe"]';

export const getIframeContent = (page: Page): FrameLocator => {
const content = page.frameLocator(IFRAME_SELECTOR);
return content;
};
10 changes: 5 additions & 5 deletions e2e/events.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { test, expect } from '@playwright/test';

import { IFRAME_SELECTOR } from './consts';
import { getIframeContent } from './consts';

test.beforeEach(async ({ page }) => {
await page.goto('/');
await page.getByRole('link', { name: 'Event - Params' }).click();
});

test("should trigger 'onMove' event with 'mousemove' event type when mouse hovers tilt element", async ({ page }) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByTestId('topMidLeft').hover({ position: { x: 10, y: 10 } });
await expect(content.getByTestId('evenDescription')).toHaveText(
@@ -17,7 +17,7 @@ test("should trigger 'onMove' event with 'mousemove' event type when mouse hover
});

test("should trigger 'onMove' event with 'autoreset' event type when mouse leaves tilt element", async ({ page }) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByTestId('topMidLeft').hover({ position: { x: 10, y: 10 } });
await content.getByText('Track events:').hover();
@@ -27,7 +27,7 @@ test("should trigger 'onMove' event with 'autoreset' event type when mouse leave
});

test("should trigger 'onEnter' event with 'mouseenter' event type when mouse enters tilt element", async ({ page }) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByLabel('onMove').uncheck();
await content.getByTestId('topMidLeft').hover({ position: { x: 10, y: 10 } });
@@ -37,7 +37,7 @@ test("should trigger 'onEnter' event with 'mouseenter' event type when mouse ent
});

test("should trigger 'onLeave' event with 'mouseleave' event type when mouse enters tilt element", async ({ page }) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByLabel('onMove').uncheck();
await content.getByTestId('topMidLeft').hover({ position: { x: 10, y: 10 } });
8 changes: 4 additions & 4 deletions e2e/on-move-params.spec.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test';

import { OnMoveParams } from 'index';

import { IFRAME_SELECTOR } from './consts';
import { getIframeContent } from './consts';

test.beforeEach(async ({ page }) => {
await page.goto('/');
@@ -12,7 +12,7 @@ test.beforeEach(async ({ page }) => {
test('should get max values of move params rendered when mouse is positioned at top left corner of tilt element', async ({
page,
}) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByTestId('topLeft').hover({ position: { x: 10, y: 10 } });
await expect(content.getByTestId('tiltAngleX')).toHaveText('-20.00° / -100.00%');
@@ -22,7 +22,7 @@ test('should get max values of move params rendered when mouse is positioned at
});

test('should get max values of move params when mouse is positioned at corners of tilt element', async ({ page }) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByTestId('topLeft').hover({ position: { x: 10, y: 10 } });

@@ -74,7 +74,7 @@ test('should get max values of move params when mouse is positioned at corners o
});

test('should get half of max value when mouse is positioned in the middle of tilt element', async ({ page }) => {
const content = page.frameLocator(IFRAME_SELECTOR);
const content = getIframeContent(page);

await content.getByTestId('topMidLeft').hover({ position: { x: 10, y: 10 } });

0 comments on commit 1464a86

Please sign in to comment.