mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:54:32 +00:00
test(browser): table-drive scroll and click error rewrites
This commit is contained in:
@@ -23,9 +23,20 @@ describe("pw-tools-core", () => {
|
|||||||
|
|
||||||
expect(scrollIntoViewIfNeeded).toHaveBeenCalledWith({ timeout: 500 });
|
expect(scrollIntoViewIfNeeded).toHaveBeenCalledWith({ timeout: 500 });
|
||||||
});
|
});
|
||||||
it("rewrites strict mode violations for scrollIntoView", async () => {
|
it.each([
|
||||||
|
{
|
||||||
|
name: "strict mode violations for scrollIntoView",
|
||||||
|
errorMessage: 'Error: strict mode violation: locator("aria-ref=1") resolved to 2 elements',
|
||||||
|
expectedMessage: /Run a new snapshot/i,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not-visible timeouts for scrollIntoView",
|
||||||
|
errorMessage: 'Timeout 5000ms exceeded. waiting for locator("aria-ref=1") to be visible',
|
||||||
|
expectedMessage: /not found or not visible/i,
|
||||||
|
},
|
||||||
|
])("rewrites $name", async ({ errorMessage, expectedMessage }) => {
|
||||||
const scrollIntoViewIfNeeded = vi.fn(async () => {
|
const scrollIntoViewIfNeeded = vi.fn(async () => {
|
||||||
throw new Error('Error: strict mode violation: locator("aria-ref=1") resolved to 2 elements');
|
throw new Error(errorMessage);
|
||||||
});
|
});
|
||||||
setPwToolsCoreCurrentRefLocator({ scrollIntoViewIfNeeded });
|
setPwToolsCoreCurrentRefLocator({ scrollIntoViewIfNeeded });
|
||||||
setPwToolsCoreCurrentPage({});
|
setPwToolsCoreCurrentPage({});
|
||||||
@@ -36,26 +47,22 @@ describe("pw-tools-core", () => {
|
|||||||
targetId: "T1",
|
targetId: "T1",
|
||||||
ref: "1",
|
ref: "1",
|
||||||
}),
|
}),
|
||||||
).rejects.toThrow(/Run a new snapshot/i);
|
).rejects.toThrow(expectedMessage);
|
||||||
});
|
});
|
||||||
it("rewrites not-visible timeouts for scrollIntoView", async () => {
|
it.each([
|
||||||
const scrollIntoViewIfNeeded = vi.fn(async () => {
|
{
|
||||||
throw new Error('Timeout 5000ms exceeded. waiting for locator("aria-ref=1") to be visible');
|
name: "strict mode violations into snapshot hints",
|
||||||
});
|
errorMessage: 'Error: strict mode violation: locator("aria-ref=1") resolved to 2 elements',
|
||||||
setPwToolsCoreCurrentRefLocator({ scrollIntoViewIfNeeded });
|
expectedMessage: /Run a new snapshot/i,
|
||||||
setPwToolsCoreCurrentPage({});
|
},
|
||||||
|
{
|
||||||
await expect(
|
name: "not-visible timeouts into snapshot hints",
|
||||||
mod.scrollIntoViewViaPlaywright({
|
errorMessage: 'Timeout 5000ms exceeded. waiting for locator("aria-ref=1") to be visible',
|
||||||
cdpUrl: "http://127.0.0.1:18792",
|
expectedMessage: /not found or not visible/i,
|
||||||
targetId: "T1",
|
},
|
||||||
ref: "1",
|
])("rewrites $name", async ({ errorMessage, expectedMessage }) => {
|
||||||
}),
|
|
||||||
).rejects.toThrow(/not found or not visible/i);
|
|
||||||
});
|
|
||||||
it("rewrites strict mode violations into snapshot hints", async () => {
|
|
||||||
const click = vi.fn(async () => {
|
const click = vi.fn(async () => {
|
||||||
throw new Error('Error: strict mode violation: locator("aria-ref=1") resolved to 2 elements');
|
throw new Error(errorMessage);
|
||||||
});
|
});
|
||||||
setPwToolsCoreCurrentRefLocator({ click });
|
setPwToolsCoreCurrentRefLocator({ click });
|
||||||
setPwToolsCoreCurrentPage({});
|
setPwToolsCoreCurrentPage({});
|
||||||
@@ -66,22 +73,7 @@ describe("pw-tools-core", () => {
|
|||||||
targetId: "T1",
|
targetId: "T1",
|
||||||
ref: "1",
|
ref: "1",
|
||||||
}),
|
}),
|
||||||
).rejects.toThrow(/Run a new snapshot/i);
|
).rejects.toThrow(expectedMessage);
|
||||||
});
|
|
||||||
it("rewrites not-visible timeouts into snapshot hints", async () => {
|
|
||||||
const click = vi.fn(async () => {
|
|
||||||
throw new Error('Timeout 5000ms exceeded. waiting for locator("aria-ref=1") to be visible');
|
|
||||||
});
|
|
||||||
setPwToolsCoreCurrentRefLocator({ click });
|
|
||||||
setPwToolsCoreCurrentPage({});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
mod.clickViaPlaywright({
|
|
||||||
cdpUrl: "http://127.0.0.1:18792",
|
|
||||||
targetId: "T1",
|
|
||||||
ref: "1",
|
|
||||||
}),
|
|
||||||
).rejects.toThrow(/not found or not visible/i);
|
|
||||||
});
|
});
|
||||||
it("rewrites covered/hidden errors into interactable hints", async () => {
|
it("rewrites covered/hidden errors into interactable hints", async () => {
|
||||||
const click = vi.fn(async () => {
|
const click = vi.fn(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user