Skip to content

Commit d3b4b64

Browse files
committed
fix: update tests
1 parent 2baf2ca commit d3b4b64

File tree

2 files changed

+111
-9
lines changed

2 files changed

+111
-9
lines changed

tests/suites/sidebar/Sidebar.ts

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,32 @@ export class Sidebar {
55
private logoButton: Locator;
66
private footer: Locator;
77
private settingsButton: Locator;
8-
private documentationButton: Locator;
8+
private informationButton: Locator;
99
private accountButton: Locator;
1010
private collapseButton: Locator;
1111
private drawer: Locator;
1212
private drawerMenu: Locator;
1313
private experimentsSection: Locator;
14+
private popupContent: Locator;
15+
private hotkeysButton: Locator;
16+
private hotkeysPanel: Locator;
1417

1518
constructor(page: Page) {
1619
this.sidebarContainer = page.locator('.gn-aside-header__aside-content');
1720
this.logoButton = this.sidebarContainer.locator('.gn-logo__btn-logo');
1821
this.footer = this.sidebarContainer.locator('.gn-aside-header__footer');
1922
this.drawer = page.locator('.gn-drawer');
23+
this.popupContent = page.locator('.g-popup__content');
24+
this.hotkeysButton = this.popupContent.locator('text=Keyboard shortcuts');
25+
this.hotkeysPanel = page.locator('.gn-hotkeys-panel__drawer-item');
2026
this.drawerMenu = page.locator('.gn-settings-menu');
2127
this.experimentsSection = this.drawerMenu
2228
.locator('.gn-settings-menu__item')
2329
.filter({hasText: 'Experiments'});
2430

2531
// Footer buttons with specific icons
2632
const footerItems = this.sidebarContainer.locator('.gn-footer-item');
27-
this.documentationButton = footerItems.filter({hasText: 'Documentation'});
33+
this.informationButton = footerItems.filter({hasText: 'Information'});
2834
this.settingsButton = footerItems
2935
.filter({hasText: 'Settings'})
3036
.locator('.gn-composite-bar-item__btn-icon');
@@ -49,8 +55,8 @@ export class Sidebar {
4955
return this.settingsButton.isVisible();
5056
}
5157

52-
async isDocumentationButtonVisible() {
53-
return this.documentationButton.isVisible();
58+
async isInformationButtonVisible() {
59+
return this.informationButton.isVisible();
5460
}
5561

5662
async isAccountButtonVisible() {
@@ -65,8 +71,34 @@ export class Sidebar {
6571
await this.settingsButton.click();
6672
}
6773

68-
async clickDocumentation() {
69-
await this.documentationButton.click();
74+
async clickInformation() {
75+
await this.informationButton.click();
76+
}
77+
78+
async isPopupVisible() {
79+
return this.popupContent.isVisible();
80+
}
81+
82+
async hasHotkeysButtonInPopup() {
83+
return this.hotkeysButton.isVisible();
84+
}
85+
86+
async clickHotkeysButton() {
87+
await this.hotkeysButton.click();
88+
}
89+
90+
async isHotkeysPanelVisible() {
91+
return this.hotkeysPanel.isVisible();
92+
}
93+
94+
async hasHotkeysPanelTitle() {
95+
const panelTitle = this.hotkeysPanel.locator('.kv-navigation__hotkeys-panel-title');
96+
return panelTitle.isVisible();
97+
}
98+
99+
async hasDocumentationInPopup() {
100+
const documentationElement = this.popupContent.locator('text=View documentation');
101+
return documentationElement.isVisible();
70102
}
71103

72104
async clickAccount() {

tests/suites/sidebar/sidebar.test.ts

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {expect, test} from '@playwright/test';
22

33
import {PageModel} from '../../models/PageModel';
4+
import {tenantName} from '../../utils/constants';
45
import {toggleExperiment} from '../../utils/toggleExperiment';
6+
import {TenantPage} from '../tenant/TenantPage';
57

68
import {Sidebar} from './Sidebar';
79

@@ -51,11 +53,52 @@ test.describe('Test Sidebar', async () => {
5153
expect(menuItems).toEqual(['General', 'Editor', 'Experiments', 'About']);
5254
});
5355

54-
test('Documentation button is visible and clickable', async ({page}) => {
56+
test('Information button is visible and clickable', async ({page}) => {
5557
const sidebar = new Sidebar(page);
5658
await sidebar.waitForSidebarToLoad();
57-
await expect(sidebar.isDocumentationButtonVisible()).resolves.toBe(true);
58-
await sidebar.clickDocumentation();
59+
await expect(sidebar.isInformationButtonVisible()).resolves.toBe(true);
60+
await sidebar.clickInformation();
61+
});
62+
63+
test('Information popup contains documentation and keyboard shortcuts', async ({page}) => {
64+
const sidebar = new Sidebar(page);
65+
await sidebar.waitForSidebarToLoad();
66+
67+
// Click the Information button to open the popup
68+
await sidebar.clickInformation();
69+
await page.waitForTimeout(500); // Wait for animation
70+
71+
// Check if the popup is visible
72+
await expect(sidebar.isPopupVisible()).resolves.toBe(true);
73+
74+
// Check if the popup contains Documentation
75+
await expect(sidebar.hasDocumentationInPopup()).resolves.toBe(true);
76+
77+
// Check if the popup contains Keyboard shortcuts button
78+
await expect(sidebar.hasHotkeysButtonInPopup()).resolves.toBe(true);
79+
});
80+
81+
test('Clicking hotkeys button in information popup opens hotkeys panel with title', async ({
82+
page,
83+
}) => {
84+
const sidebar = new Sidebar(page);
85+
await sidebar.waitForSidebarToLoad();
86+
87+
// Click the Information button to open the popup
88+
await sidebar.clickInformation();
89+
await page.waitForTimeout(500); // Wait for animation
90+
91+
// Check if the popup is visible
92+
await expect(sidebar.isPopupVisible()).resolves.toBe(true);
93+
94+
// Check if hotkeys button is visible and click it
95+
await expect(sidebar.hasHotkeysButtonInPopup()).resolves.toBe(true);
96+
await sidebar.clickHotkeysButton();
97+
await page.waitForTimeout(500); // Wait for animation
98+
99+
// Check if hotkeys panel is visible and has the title
100+
await expect(sidebar.isHotkeysPanelVisible()).resolves.toBe(true);
101+
await expect(sidebar.hasHotkeysPanelTitle()).resolves.toBe(true);
59102
});
60103

61104
test('Account button is visible and clickable', async ({page}) => {
@@ -65,6 +108,33 @@ test.describe('Test Sidebar', async () => {
65108
await sidebar.clickAccount();
66109
});
67110

111+
test('Pressing Ctrl+K in editor page opens hotkeys panel', async ({page}) => {
112+
// Open editor page
113+
const pageQueryParams = {
114+
schema: tenantName,
115+
database: tenantName,
116+
general: 'query',
117+
};
118+
119+
const tenantPage = new TenantPage(page);
120+
await tenantPage.goto(pageQueryParams);
121+
await page.waitForTimeout(1000); // Wait for page to load fully
122+
123+
// Create sidebar instance to check for hotkeys panel
124+
const sidebar = new Sidebar(page);
125+
126+
// Initially hotkeys panel should not be visible
127+
await expect(sidebar.isHotkeysPanelVisible()).resolves.toBe(false);
128+
129+
// Press Ctrl+K to open hotkeys panel
130+
await page.keyboard.press('Control+k');
131+
await page.waitForTimeout(500); // Wait for animation
132+
133+
// Check if hotkeys panel is visible and has the title
134+
await expect(sidebar.isHotkeysPanelVisible()).resolves.toBe(true);
135+
await expect(sidebar.hasHotkeysPanelTitle()).resolves.toBe(true);
136+
});
137+
68138
test('Sidebar can be collapsed and expanded', async ({page}) => {
69139
const sidebar = new Sidebar(page);
70140
await sidebar.waitForSidebarToLoad();

0 commit comments

Comments
 (0)