tests: try to improve drag/drop stability

This commit is contained in:
Matthias 2024-10-01 07:10:48 +02:00
parent 89f58f8e03
commit 159a95d4e3

View File

@ -101,9 +101,21 @@ test.describe('Trade', () => {
await expect(page.getByText('Config reloaded successfully.')).toBeInViewport();
});
test('Trade page - drag and drop', async ({ page, browserName }) => {
await page.goto('/trade');
const multiPane = page.locator('.drag-header', { hasText: 'Multi Pane' });
await Promise.all([
page.goto('/trade'),
// Wait for network requests
// page.waitForResponse('**/ping'),
page.waitForResponse('**/status'),
page.waitForResponse('**/profit'),
page.waitForResponse('**/balance'),
// page.waitForResponse('**/trades'),
page.waitForResponse('**/whitelist'),
page.waitForResponse('**/blacklist'),
page.waitForResponse('**/locks'),
]);
// Wait for dynamic layout to settle
await page.waitForTimeout(1000);
const multiPane = await page.locator('.drag-header', { hasText: 'Multi Pane' });
const multiPanebb = await multiPane.boundingBox();
@ -112,7 +124,7 @@ test.describe('Trade', () => {
const chartHeader = await page.locator('.drag-header:has-text("Chart")');
// Click outside of popup to ensure it's closed
await chartHeader.click();
// await chartHeader.click();
await expect(multiPane).toBeInViewport();
await expect(chartHeader).toBeInViewport();
@ -126,27 +138,27 @@ test.describe('Trade', () => {
await page.mouse.up();
await expect(multiPane).toBeInViewport();
// Multipane wasn't moved.
if (browserName !== 'webkit') {
await expect(multiPanebb).toEqual(await multiPane.boundingBox());
} else {
// allow offset of 2%
const newMultiPaneBB = await multiPane.boundingBox();
if (newMultiPaneBB && multiPanebb) {
const xDiff = Math.abs((newMultiPaneBB.x - multiPanebb.x) / multiPanebb.x);
const yDiff = Math.abs((newMultiPaneBB.y - multiPanebb.y) / multiPanebb.y);
const widthDiff = Math.abs(
(newMultiPaneBB.width - multiPanebb.width) / multiPanebb.width,
);
const heightDiff = Math.abs(
(newMultiPaneBB.height - multiPanebb.height) / multiPanebb.height,
);
// if (browserName !== 'webkit') {
await expect(multiPanebb).toEqual(await multiPane.boundingBox());
// } else {
// // allow offset of 2%
// const newMultiPaneBB = await multiPane.boundingBox();
// if (newMultiPaneBB && multiPanebb) {
// const xDiff = Math.abs((newMultiPaneBB.x - multiPanebb.x) / multiPanebb.x);
// const yDiff = Math.abs((newMultiPaneBB.y - multiPanebb.y) / multiPanebb.y);
// const widthDiff = Math.abs(
// (newMultiPaneBB.width - multiPanebb.width) / multiPanebb.width,
// );
// const heightDiff = Math.abs(
// (newMultiPaneBB.height - multiPanebb.height) / multiPanebb.height,
// );
expect(xDiff).toBeLessThanOrEqual(0.02);
expect(yDiff).toBeLessThanOrEqual(0.02);
expect(widthDiff).toBeLessThanOrEqual(0.02);
expect(heightDiff).toBeLessThanOrEqual(0.02);
}
}
// expect(xDiff).toBeLessThanOrEqual(0.02);
// expect(yDiff).toBeLessThanOrEqual(0.02);
// expect(widthDiff).toBeLessThanOrEqual(0.02);
// expect(heightDiff).toBeLessThanOrEqual(0.02);
// }
// }
await expect(chartHeader).toBeInViewport();
// ChartHeader was moved down