Skip to content

Commit 69338f2

Browse files
Anton StandrikAnton Standrik
authored andcommitted
chore: change trace and svg mutations to lazy query
1 parent 71956ec commit 69338f2

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed

tests/suites/sidebar/Sidebar.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import type {Locator, Page} from '@playwright/test';
2+
3+
export class Sidebar {
4+
private sidebarContainer: Locator;
5+
private logoButton: Locator;
6+
private footer: Locator;
7+
private settingsButton: Locator;
8+
private documentationButton: Locator;
9+
private accountButton: Locator;
10+
private collapseButton: Locator;
11+
12+
constructor(page: Page) {
13+
this.sidebarContainer = page.locator('.gn-aside-header__aside-content');
14+
this.logoButton = this.sidebarContainer.locator('.gn-logo__btn-logo');
15+
this.footer = this.sidebarContainer.locator('.gn-aside-header__footer');
16+
17+
// Footer buttons with specific icons
18+
const footerItems = this.sidebarContainer.locator('.gn-footer-item');
19+
this.documentationButton = footerItems.filter({hasText: 'Documentation'});
20+
this.settingsButton = footerItems
21+
.filter({hasText: 'Settings'})
22+
.locator('.gn-composite-bar-item__btn-icon');
23+
this.accountButton = footerItems.filter({hasText: 'Account'});
24+
25+
this.collapseButton = this.sidebarContainer.locator('.gn-collapse-button');
26+
}
27+
28+
async waitForSidebarToLoad() {
29+
await this.sidebarContainer.waitFor({state: 'visible'});
30+
}
31+
32+
async isSidebarVisible() {
33+
return this.sidebarContainer.isVisible();
34+
}
35+
36+
async isLogoButtonVisible() {
37+
return this.logoButton.isVisible();
38+
}
39+
40+
async isSettingsButtonVisible() {
41+
return this.settingsButton.isVisible();
42+
}
43+
44+
async isDocumentationButtonVisible() {
45+
return this.documentationButton.isVisible();
46+
}
47+
48+
async isAccountButtonVisible() {
49+
return this.accountButton.isVisible();
50+
}
51+
52+
async clickLogoButton() {
53+
await this.logoButton.click();
54+
}
55+
56+
async clickSettings() {
57+
await this.settingsButton.click();
58+
}
59+
60+
async clickDocumentation() {
61+
await this.documentationButton.click();
62+
}
63+
64+
async clickAccount() {
65+
await this.accountButton.click();
66+
}
67+
68+
async toggleCollapse() {
69+
await this.collapseButton.click();
70+
}
71+
72+
async isCollapsed() {
73+
const button = await this.collapseButton;
74+
const title = await button.getAttribute('title');
75+
return title === 'Expand';
76+
}
77+
78+
async getFooterItemsCount(): Promise<number> {
79+
return this.footer.locator('.gn-composite-bar-item').count();
80+
}
81+
82+
async isFooterItemVisible(index: number) {
83+
const items = this.footer.locator('.gn-composite-bar-item');
84+
return items.nth(index).isVisible();
85+
}
86+
87+
async clickFooterItem(index: number) {
88+
const items = this.footer.locator('.gn-composite-bar-item');
89+
await items.nth(index).click();
90+
}
91+
92+
async getFooterItemText(index: number): Promise<string> {
93+
const items = this.footer.locator('.gn-composite-bar-item');
94+
const item = items.nth(index);
95+
return item.locator('.gn-composite-bar-item__title-text').innerText();
96+
}
97+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {expect, test} from '@playwright/test';
2+
3+
import {PageModel} from '../../models/PageModel';
4+
5+
import {Sidebar} from './Sidebar';
6+
7+
test.describe('Test Sidebar', async () => {
8+
test.beforeEach(async ({page}) => {
9+
const basePage = new PageModel(page);
10+
const response = await basePage.goto();
11+
expect(response?.ok()).toBe(true);
12+
});
13+
14+
test('Sidebar is visible and loads correctly', async ({page}) => {
15+
const sidebar = new Sidebar(page);
16+
await sidebar.waitForSidebarToLoad();
17+
await expect(sidebar.isSidebarVisible()).resolves.toBe(true);
18+
});
19+
20+
test('Logo button is visible and clickable', async ({page}) => {
21+
const sidebar = new Sidebar(page);
22+
await sidebar.waitForSidebarToLoad();
23+
await expect(sidebar.isLogoButtonVisible()).resolves.toBe(true);
24+
await sidebar.clickLogoButton();
25+
});
26+
27+
test('Settings button is visible and clickable', async ({page}) => {
28+
const sidebar = new Sidebar(page);
29+
await sidebar.waitForSidebarToLoad();
30+
await expect(sidebar.isSettingsButtonVisible()).resolves.toBe(true);
31+
await sidebar.clickSettings();
32+
});
33+
34+
test('Documentation button is visible and clickable', async ({page}) => {
35+
const sidebar = new Sidebar(page);
36+
await sidebar.waitForSidebarToLoad();
37+
await expect(sidebar.isDocumentationButtonVisible()).resolves.toBe(true);
38+
await sidebar.clickDocumentation();
39+
});
40+
41+
test('Account button is visible and clickable', async ({page}) => {
42+
const sidebar = new Sidebar(page);
43+
await sidebar.waitForSidebarToLoad();
44+
await expect(sidebar.isAccountButtonVisible()).resolves.toBe(true);
45+
await sidebar.clickAccount();
46+
});
47+
48+
test('Sidebar can be collapsed and expanded', async ({page}) => {
49+
const sidebar = new Sidebar(page);
50+
await sidebar.waitForSidebarToLoad();
51+
52+
// Initially collapsed
53+
await expect(sidebar.isCollapsed()).resolves.toBe(true);
54+
55+
// Expand
56+
await sidebar.toggleCollapse();
57+
await page.waitForTimeout(500); // Wait for animation
58+
await expect(sidebar.isCollapsed()).resolves.toBe(false);
59+
60+
// Collapse
61+
await sidebar.toggleCollapse();
62+
await page.waitForTimeout(500); // Wait for animation
63+
await expect(sidebar.isCollapsed()).resolves.toBe(true);
64+
});
65+
66+
test('Footer items are visible', async ({page}) => {
67+
const sidebar = new Sidebar(page);
68+
await sidebar.waitForSidebarToLoad();
69+
70+
const itemsCount = await sidebar.getFooterItemsCount();
71+
expect(itemsCount).toBeGreaterThan(0);
72+
});
73+
});

0 commit comments

Comments
 (0)