Some checks failed
Deploy Application / deploy (push) Has been cancelled
91 lines
2.3 KiB
TypeScript
91 lines
2.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
/**
|
|
* LiveComponents: Scroll Behavior Tests
|
|
*
|
|
* Tests automatic scrolling after updates
|
|
*/
|
|
test.describe('LiveComponents Scroll Behavior', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/');
|
|
});
|
|
|
|
test('should support scroll after update', async ({ page }) => {
|
|
const scrollButton = page.locator('[data-lc-scroll="true"]').first();
|
|
const count = await scrollButton.count();
|
|
|
|
if (count === 0) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
// Scroll to top first
|
|
await page.evaluate(() => window.scrollTo(0, 0));
|
|
|
|
// Click button
|
|
await scrollButton.click();
|
|
|
|
// Wait for update and scroll
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Button should still be visible
|
|
expect(scrollButton).toBeVisible();
|
|
});
|
|
|
|
test('should support scroll-target', async ({ page }) => {
|
|
const scrollTargetButton = page.locator('[data-lc-scroll-target]').first();
|
|
const count = await scrollTargetButton.count();
|
|
|
|
if (count === 0) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
const targetSelector = await scrollTargetButton.getAttribute('data-lc-scroll-target');
|
|
if (!targetSelector) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
const targetElement = page.locator(targetSelector).first();
|
|
const targetExists = await targetElement.count() > 0;
|
|
|
|
if (!targetExists) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
// Click button
|
|
await scrollTargetButton.click();
|
|
|
|
// Wait for update and scroll
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Target should be visible
|
|
expect(targetElement).toBeVisible();
|
|
});
|
|
|
|
test('should support scroll-behavior', async ({ page }) => {
|
|
const smoothScrollButton = page.locator('[data-lc-scroll-behavior="smooth"]').first();
|
|
const instantScrollButton = page.locator('[data-lc-scroll-behavior="instant"]').first();
|
|
|
|
// Test smooth scroll
|
|
if (await smoothScrollButton.count() > 0) {
|
|
await smoothScrollButton.click();
|
|
await page.waitForTimeout(1000);
|
|
expect(smoothScrollButton).toBeVisible();
|
|
}
|
|
|
|
// Test instant scroll
|
|
if (await instantScrollButton.count() > 0) {
|
|
await instantScrollButton.click();
|
|
await page.waitForTimeout(1000);
|
|
expect(instantScrollButton).toBeVisible();
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|