Skip to content

Commit ac8fa63

Browse files
committed
fix: better checks
1 parent 7642003 commit ac8fa63

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

tests/suites/tenant/summary/ObjectSummary.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {Locator, Page} from '@playwright/test';
22

3+
import {isInViewport} from '../../../utils/dom';
34
import {VISIBILITY_TIMEOUT} from '../TenantPage';
45

56
import {ActionsMenu} from './ActionsMenu';
@@ -28,6 +29,7 @@ export class ObjectSummary {
2829
private infoExpandButton: Locator;
2930
private summaryCollapseButton: Locator;
3031
private summaryExpandButton: Locator;
32+
private overviewWrapper: Locator;
3133

3234
constructor(page: Page) {
3335
this.tree = page.locator('.ydb-object-summary__tree');
@@ -59,6 +61,7 @@ export class ObjectSummary {
5961
this.summaryExpandButton = page.locator(
6062
'.ydb-object-summary__actions button[title="Expand"]',
6163
);
64+
this.overviewWrapper = page.locator('.ydb-object-summary__overview-wrapper');
6265
}
6366

6467
async collapseInfoPanel(): Promise<void> {
@@ -70,8 +73,19 @@ export class ObjectSummary {
7073
}
7174

7275
async isInfoPanelCollapsed(): Promise<boolean> {
73-
// When panel is collapsed, expand button should be visible
74-
return this.infoExpandButton.isVisible();
76+
const expandButtonVisible = await this.infoExpandButton.isVisible();
77+
if (!expandButtonVisible) {
78+
return false;
79+
}
80+
81+
const isVisible = await this.overviewWrapper.isVisible();
82+
if (!isVisible) {
83+
return true;
84+
}
85+
86+
// Check if it's actually in the viewport
87+
const elementInViewport = await isInViewport(this.overviewWrapper);
88+
return !elementInViewport;
7589
}
7690

7791
async isCreateDirectoryModalVisible(): Promise<boolean> {
@@ -242,7 +256,18 @@ export class ObjectSummary {
242256
}
243257

244258
async isSummaryCollapsed(): Promise<boolean> {
245-
// When summary is collapsed, expand button should be visible
246-
return this.summaryExpandButton.isVisible();
259+
const expandButtonVisible = await this.summaryExpandButton.isVisible();
260+
if (!expandButtonVisible) {
261+
return false;
262+
}
263+
264+
const isVisible = await this.tree.isVisible();
265+
if (!isVisible) {
266+
return true;
267+
}
268+
269+
// Check if it's actually in the viewport
270+
const elementInViewport = await isInViewport(this.tree);
271+
return !elementInViewport;
247272
}
248273
}

tests/utils/dom.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type {Locator} from '@playwright/test';
2+
3+
/**
4+
* Checks if an element is within the viewport
5+
* @param locator - Playwright locator for the element to check
6+
* @returns Promise<boolean> - true if the element is within viewport bounds
7+
*/
8+
export const isInViewport = async (locator: Locator): Promise<boolean> => {
9+
return locator.evaluate((el) => {
10+
const rect = el.getBoundingClientRect();
11+
return (
12+
rect.top >= 0 &&
13+
rect.left >= 0 &&
14+
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
15+
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
16+
);
17+
});
18+
};

0 commit comments

Comments
 (0)