Some checks failed
Deploy Application / deploy (push) Has been cancelled
92 lines
2.2 KiB
TypeScript
92 lines
2.2 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
/**
|
|
* LiveComponents: URL Management Tests
|
|
*
|
|
* Tests data-lc-push-url and data-lc-replace-url functionality
|
|
*/
|
|
test.describe('LiveComponents URL Management', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/');
|
|
});
|
|
|
|
test('should support push-url', async ({ page }) => {
|
|
const pushUrlButton = page.locator('[data-lc-push-url]').first();
|
|
const count = await pushUrlButton.count();
|
|
|
|
if (count === 0) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
const targetUrl = await pushUrlButton.getAttribute('data-lc-push-url');
|
|
const initialUrl = page.url();
|
|
|
|
// Click button
|
|
await pushUrlButton.click();
|
|
|
|
// Wait for URL update
|
|
await page.waitForTimeout(1000);
|
|
|
|
// URL should have changed (or stayed same if targetUrl is current)
|
|
const newUrl = page.url();
|
|
|
|
// At minimum, the action should have executed
|
|
expect(pushUrlButton).toBeVisible();
|
|
});
|
|
|
|
test('should support replace-url', async ({ page }) => {
|
|
const replaceUrlButton = page.locator('[data-lc-replace-url]').first();
|
|
const count = await replaceUrlButton.count();
|
|
|
|
if (count === 0) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
const targetUrl = await replaceUrlButton.getAttribute('data-lc-replace-url');
|
|
const initialUrl = page.url();
|
|
|
|
// Click button
|
|
await replaceUrlButton.click();
|
|
|
|
// Wait for URL update
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Button should still be visible
|
|
expect(replaceUrlButton).toBeVisible();
|
|
});
|
|
|
|
test('should handle browser back/forward', async ({ page }) => {
|
|
// Navigate to a page first
|
|
await page.goto('/');
|
|
|
|
// Find a button with push-url
|
|
const pushUrlButton = page.locator('[data-lc-push-url]').first();
|
|
const count = await pushUrlButton.count();
|
|
|
|
if (count === 0) {
|
|
test.skip();
|
|
return;
|
|
}
|
|
|
|
const initialUrl = page.url();
|
|
|
|
// Click button to push URL
|
|
await pushUrlButton.click();
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Go back
|
|
await page.goBack();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Should be back at initial URL (or close to it)
|
|
const backUrl = page.url();
|
|
expect(page.url()).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|