- Notifications
You must be signed in to change notification settings - Fork27
Add e2e tests#331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
Naseem77 wants to merge18 commits intostagingChoose a base branch fromadd-e2e-tests
base:staging
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Add e2e tests#331
Changes from1 commit
Commits
Show all changes
18 commits Select commitHold shift + click to select a range
4906b4c Add e2e Tests
Naseem771238be6 Add api calls/responses for logic layer
Naseem77d96ac6b adding pom for homePage
Naseem777b40625 adding auth setup
Naseem77783d9f4 add docker compose file for database connections
Naseem77862a87b add sidebar tests
Naseem77692efed add user profile tests
Naseem774d34598 update user profile tests
Naseem77a966b03 update auth setup - adding another user
Naseem771b880a4 add database tests
Naseem77f9e369c update playwright CI
Naseem77c124c2e update ci
Naseem77f6c751f update ci
Naseem772ddeb39 Update playwright.yml
Naseem772e65792 update ci
Naseem77d7233b7 update ci
Naseem77bfa04c1 Update playwright.yml
Naseem77610c3f5 update CI and tests
Naseem77File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
add sidebar tests
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit862a87b0d2914ff3e492898d3ecbf86c69ff2f56
There are no files selected for viewing
24 changes: 15 additions & 9 deletionsapp/src/components/layout/Sidebar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionapp/src/components/schema/SchemaViewer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsapp/src/components/ui/theme-toggle.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletionse2e/logic/pom/sidebar.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| import { Locator } from "@playwright/test"; | ||
| import { waitForElementToBeVisible } from "../../infra/utils"; | ||
| import { HomePage } from "./homePage"; | ||
| /** | ||
| * Sidebar class extends HomePage to have access to all page elements | ||
| * while providing sidebar-specific locators and methods. | ||
| * | ||
| * Additionally, since this extends HomePage, you can access: | ||
| * - All database-related methods (clickOnConnectDatabase, etc.) | ||
| * - All chat-related methods | ||
| * - All other page elements | ||
| */ | ||
| export class Sidebar extends HomePage { | ||
| // ==================== LAYER 1: SIDEBAR LOCATORS ==================== | ||
| private get sidebarToggleBtn(): Locator { | ||
| return this.page.getByTestId("sidebar-toggle"); | ||
| } | ||
| private get themeToggleBtn(): Locator { | ||
| return this.page.getByTestId("theme-toggle"); | ||
| } | ||
| private get schemaBtn(): Locator { | ||
| return this.page.getByTestId("schema-button"); | ||
| } | ||
| private get docsLink(): Locator { | ||
| return this.page.getByTestId("documentation-link"); | ||
| } | ||
| private get supportBtn(): Locator { | ||
| return this.page.getByTestId("support-link"); | ||
| } | ||
| private get schemaPanel(): Locator { | ||
| return this.page.getByTestId("schema-panel"); | ||
| } | ||
| // ==================== LAYER 2: INTERACT WITH VISIBLE ==================== | ||
| private async interactWithSidebarToggleBtn(): Promise<Locator> { | ||
| const isVisible = await waitForElementToBeVisible(this.sidebarToggleBtn); | ||
| if (!isVisible) throw new Error("Sidebar toggle is not visible!"); | ||
| return this.sidebarToggleBtn; | ||
| } | ||
| private async interactWithThemeToggleBtn(): Promise<Locator> { | ||
| const isVisible = await waitForElementToBeVisible(this.themeToggleBtn); | ||
| if (!isVisible) throw new Error("Theme toggle is not visible!"); | ||
| return this.themeToggleBtn; | ||
| } | ||
| private async interactWithSchemaBtn(): Promise<Locator> { | ||
| const isVisible = await waitForElementToBeVisible(this.schemaBtn); | ||
| if (!isVisible) throw new Error("Schema button is not visible!"); | ||
| return this.schemaBtn; | ||
| } | ||
| private async interactWithDocsLink(): Promise<Locator> { | ||
| const isVisible = await waitForElementToBeVisible(this.docsLink); | ||
| if (!isVisible) throw new Error("Documentation link is not visible!"); | ||
| return this.docsLink; | ||
| } | ||
| private async interactWithSupportBtn(): Promise<Locator> { | ||
| const isVisible = await waitForElementToBeVisible(this.supportBtn); | ||
| if (!isVisible) throw new Error("Support link is not visible!"); | ||
| return this.supportBtn; | ||
| } | ||
| // ==================== LAYER 3: HIGH-LEVEL ACTIONS ==================== | ||
| async clickOnSidebarToggle(): Promise<void> { | ||
| const element = await this.interactWithSidebarToggleBtn(); | ||
| await element.click(); | ||
| } | ||
| async clickOnThemeToggle(): Promise<void> { | ||
| const element = await this.interactWithThemeToggleBtn(); | ||
| await element.click(); | ||
| } | ||
| async clickOnSchemaButton(): Promise<void> { | ||
| const element = await this.interactWithSchemaBtn(); | ||
| await element.click(); | ||
| } | ||
| async clickOnDocumentationLink(): Promise<void> { | ||
| const element = await this.interactWithDocsLink(); | ||
| await element.click(); | ||
| } | ||
| async clickOnSupportLink(): Promise<void> { | ||
| const element = await this.interactWithSupportBtn(); | ||
| await element.click(); | ||
| } | ||
| // ==================== VERIFICATION METHODS ==================== | ||
| async isSidebarToggleVisible(): Promise<boolean> { | ||
| return await waitForElementToBeVisible(this.sidebarToggleBtn); | ||
| } | ||
| async isThemeToggleVisible(): Promise<boolean> { | ||
| return await waitForElementToBeVisible(this.themeToggleBtn); | ||
| } | ||
| async isSchemaButtonVisible(): Promise<boolean> { | ||
| return await waitForElementToBeVisible(this.schemaBtn); | ||
| } | ||
| async isDocumentationLinkVisible(): Promise<boolean> { | ||
| return await waitForElementToBeVisible(this.docsLink); | ||
| } | ||
| async isSupportLinkVisible(): Promise<boolean> { | ||
| return await waitForElementToBeVisible(this.supportBtn); | ||
| } | ||
| async getDocumentationLinkHref(): Promise<string | null> { | ||
| const element = await this.interactWithDocsLink(); | ||
| return await element.getAttribute('href'); | ||
| } | ||
| async getSupportLinkHref(): Promise<string | null> { | ||
| const element = await this.interactWithSupportBtn(); | ||
| return await element.getAttribute('href'); | ||
| } | ||
| async getCurrentTheme(): Promise<string | null> { | ||
| return await this.page.evaluate(() => { | ||
| return document.documentElement.getAttribute('data-theme'); | ||
| }); | ||
| } | ||
| async isSchemaPanelVisible(): Promise<boolean> { | ||
| return await waitForElementToBeVisible(this.schemaPanel); | ||
| } | ||
| } |
67 changes: 67 additions & 0 deletionse2e/tests/sidebar.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { getBaseUrl } from '../config/urls'; | ||
| import { Sidebar } from '../logic/pom/sidebar'; | ||
| import BrowserWrapper from '../infra/ui/browserWrapper'; | ||
| // Sidebar tests - uses authenticated storageState from auth.setup | ||
| test.describe('Left Sidebar Tests', () => { | ||
| let browser: BrowserWrapper; | ||
| test.beforeEach(async () => { | ||
| browser = new BrowserWrapper(); | ||
| }); | ||
| test.afterEach(async () => { | ||
| await browser.closeBrowser(); | ||
| }); | ||
| test('theme toggle changes theme between light and dark', async () => { | ||
| const sidebar = await browser.createNewPage(Sidebar, getBaseUrl()); | ||
| await browser.setPageToFullScreen(); | ||
| const initialTheme = await sidebar.getCurrentTheme(); | ||
| expect(initialTheme).toBe('dark'); | ||
| await sidebar.clickOnThemeToggle(); | ||
| const afterToggleTheme = await sidebar.getCurrentTheme(); | ||
| expect(afterToggleTheme).toBe('light'); | ||
| await sidebar.clickOnThemeToggle(); | ||
| const finalTheme = await sidebar.getCurrentTheme(); | ||
| expect(finalTheme).toBe('dark'); | ||
| }); | ||
| test('documentation link points to correct URL', async () => { | ||
| const sidebar = await browser.createNewPage(Sidebar, getBaseUrl()); | ||
| await browser.setPageToFullScreen(); | ||
| const docHref = await sidebar.getDocumentationLinkHref(); | ||
| expect(docHref).toBe('https://docs.falkordb.com/'); | ||
| }); | ||
| test('support link points to correct URL', async () => { | ||
| const sidebar = await browser.createNewPage(Sidebar, getBaseUrl()); | ||
| await browser.setPageToFullScreen(); | ||
| const supportHref = await sidebar.getSupportLinkHref(); | ||
| expect(supportHref).toBe('https://discord.com/invite/jyUgBweNQz'); | ||
| }); | ||
| test('schema button opens and closes schema panel', async () => { | ||
| const sidebar = await browser.createNewPage(Sidebar, getBaseUrl()); | ||
| await browser.setPageToFullScreen(); | ||
| const isInitiallyClosed = await sidebar.isSchemaPanelVisible(); | ||
| expect(isInitiallyClosed).toBeFalsy(); | ||
| await sidebar.clickOnSchemaButton(); | ||
| const isOpen = await sidebar.isSchemaPanelVisible(); | ||
| expect(isOpen).toBeTruthy(); | ||
| await sidebar.clickOnSchemaButton(); | ||
| const isClosedAgain = await sidebar.isSchemaPanelVisible(); | ||
| expect(isClosedAgain).toBeFalsy(); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.