-
Notifications
You must be signed in to change notification settings - Fork 5
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Testing Framework #488 #489 #490 #491 #492 #493
Open
Naseem77
wants to merge
6
commits into
staging
Choose a base branch
from
playwright-multi-usersTests
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.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
94e44af
Enhance Testing Framework #488 #489 #490 #491 #492
Naseem77 186643b
Applied navbar tests for all roles except Settings for admin
Naseem77 dd10c1c
Applied signOut tests for all roles
Naseem77 da1df94
fix logout locater for different user types
Naseem77 3682249
update signOut test, removed duplicated test in graph & #495
Naseem77 4664748
removed duplicated test, navbar settings button for other users
Naseem77 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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,8 @@ | ||
{ | ||
"queries": [ | ||
{ | ||
"name": "querySuccess1", | ||
"query": "graphName?query=unwind%20range(1%2C20)%20as%20x%20create%20(n%3Arider)-%5Be%3Arides%5D-%3E(m%3Ateam)%20return%20*" | ||
} | ||
] | ||
} |
This file contains 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
This file contains 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
This file contains 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,31 @@ | ||
import { Locator } from "@playwright/test"; | ||
import BasePage from "@/e2e/infra/ui/basePage"; | ||
import { waitForURL } from "@/e2e/infra/utils"; | ||
import urls from '../../config/urls.json' | ||
|
||
export class LoginPage extends BasePage { | ||
private get connectBtn(): Locator { | ||
return this.page.getByRole("button", { name : "Connect"}); | ||
} | ||
|
||
private get usernameInput(): Locator { | ||
return this.page.locator("//input[@id='username']"); | ||
} | ||
|
||
private get passwordInput(): Locator { | ||
return this.page.locator("//input[@id='password']"); | ||
} | ||
|
||
async clickOnConnect(): Promise<void> { | ||
await this.connectBtn.click(); | ||
await waitForURL(this.page, urls.graphUrl); | ||
} | ||
|
||
async connectWithCredentials(username: string, password: string): Promise<void> { | ||
await this.usernameInput.fill(username) | ||
await this.passwordInput.fill(password) | ||
await this.connectBtn.click(); | ||
await waitForURL(this.page, urls.graphUrl); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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,12 @@ | ||
export interface runQueryResponse { | ||
result: { | ||
metadata: { | ||
"Labels added": number; | ||
"Nodes created": number; | ||
"Relationships created": number; | ||
"Cached execution": number; | ||
"Query internal execution time": string; | ||
}; | ||
data: Array<Record<string, any>>; | ||
}; | ||
} |
This file contains 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 |
---|---|---|
@@ -1,15 +1,53 @@ | ||
import { test as setup } from "@playwright/test" | ||
import urls from '../config/urls.json' | ||
import BrowserWrapper from "../infra/ui/browserWrapper"; | ||
import { LoginPage } from "../logic/POM/loginPage"; | ||
import { ApiCalls } from "../logic/api/apiCalls"; | ||
import {user} from '../config/user.json' | ||
import SettingsUsersPage from "../logic/POM/settingsUsersPage"; | ||
|
||
const authFile = 'playwright/.auth/user.json' | ||
const adminAuthFile = 'playwright/.auth/admin.json' | ||
const readWriteAuthFile = 'playwright/.auth/readwriteuser.json' | ||
const readOnlyAuthFile = 'playwright/.auth/readonlyuser.json' | ||
|
||
setup("authentication", async ({ page }) => { | ||
setup("admin authentication", async () => { | ||
try { | ||
await page.goto(urls.loginUrl); | ||
await page.getByRole("button", { name: "Connect" }).click(); | ||
await page.waitForURL(urls.graphUrl); | ||
await page.context().storageState({ path: authFile }); | ||
const browserWrapper = new BrowserWrapper(); | ||
const loginPage = await browserWrapper.createNewPage(LoginPage, urls.loginUrl); | ||
await loginPage.clickOnConnect(); | ||
const context = browserWrapper.getContext(); | ||
await context!.storageState({ path: adminAuthFile }); | ||
|
||
const settings = await browserWrapper.createNewPage(SettingsUsersPage, urls.settingsUrl) | ||
await settings.navigateToUserTab(); | ||
await settings.addUser({userName: "readwriteuser", role: user.ReadWrite, password: user.password , confirmPassword: user.confirmPassword}); | ||
await settings.addUser({userName: "readonlyuser", role: user.ReadOnly, password: user.password , confirmPassword: user.confirmPassword}); | ||
} catch (error) { | ||
console.error("Error during authentication setup:", error); | ||
} | ||
}); | ||
|
||
|
||
setup("readwrite authentication", async () => { | ||
try { | ||
const browserWrapper = new BrowserWrapper(); | ||
const loginPage = await browserWrapper.createNewPage(LoginPage, urls.loginUrl); | ||
await loginPage.connectWithCredentials("readwriteuser", user.password) | ||
const context = browserWrapper.getContext(); | ||
await context!.storageState({ path: readWriteAuthFile }); | ||
} catch (error) { | ||
console.error("Error during additional setup:", error); | ||
} | ||
}); | ||
|
||
setup("readOnly authentication", async () => { | ||
try { | ||
const browserWrapper = new BrowserWrapper(); | ||
const loginPage = await browserWrapper.createNewPage(LoginPage, urls.loginUrl); | ||
await loginPage.connectWithCredentials("readonlyuser", user.password) | ||
const context = browserWrapper.getContext(); | ||
await context!.storageState({ path: readOnlyAuthFile }); | ||
} catch (error) { | ||
console.error("Error during additional setup:", error); | ||
} | ||
}); |
This file contains 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ import { ApiCalls } from "../logic/api/apiCalls"; | |
import { graphPage } from "../logic/POM/graphPage"; | ||
import urls from '../config/urls.json' | ||
import fs from 'fs'; | ||
import queryData from '../config/queries.json' | ||
|
||
test.describe('Graph Tests', () => { | ||
let browser : BrowserWrapper; | ||
|
@@ -18,37 +19,63 @@ test.describe('Graph Tests', () => { | |
await browser.closeBrowser(); | ||
}) | ||
|
||
test("Add graph via api -> verify display in UI test", async () => { | ||
const graph = await browser.createNewPage(graphPage, urls.graphUrl) | ||
const apiCall = new ApiCalls() | ||
const graphName = `graph_${Date.now()}` | ||
await apiCall.addGraph(graphName) | ||
await graph.refreshPage() | ||
const isVisible = await graph.verifyGraphExists(graphName) | ||
await graph.refreshPage() | ||
await graph.deleteGraph(graphName) | ||
expect(isVisible).toBe(true) | ||
}) | ||
const roles = [ | ||
{ name: 'admin' }, | ||
// { name: 'readwrite' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing roles? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
]; | ||
|
||
test("Add graph via UI -> remove graph via API -> Verify graph removal in UI test", async () => { | ||
const graph = await browser.createNewPage(graphPage, urls.graphUrl) | ||
const graphName = `graph_${Date.now()}` | ||
await graph.addGraph(graphName); | ||
const apiCall = new ApiCalls() | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
await apiCall.removeGraph(graphName); | ||
await graph.refreshPage() | ||
expect(await graph.verifyGraphExists(graphName)).toBe(false) | ||
|
||
}) | ||
|
||
test("Clicking the Export Data button -> verify the file has been successfully downloaded", async () => { | ||
const graph = await browser.createNewPage(graphPage, urls.graphUrl) | ||
const graphName = `graph_${Date.now()}` | ||
await graph.addGraph(graphName); | ||
const download = await graph.clickOnExportDataBtn(); | ||
const downloadPath = await download.path(); | ||
expect(fs.existsSync(downloadPath)).toBe(true); | ||
}) | ||
roles.forEach(role => { | ||
test(`@${role.name} Add graph via API -> verify display in UI test`, async () => { | ||
const graph = await browser.createNewPage(graphPage, urls.graphUrl); | ||
const apiCall = new ApiCalls(); | ||
const graphName = `graph_${Date.now()}`; | ||
await apiCall.addGraph(graphName); | ||
await graph.refreshPage(); | ||
const isVisible = await graph.verifyGraphExists(graphName); | ||
await graph.refreshPage(); | ||
await graph.deleteGraph(graphName); | ||
expect(isVisible).toBe(true); | ||
}); | ||
}); | ||
|
||
roles.forEach(role => { | ||
test(`@${role.name} Add graph via UI -> remove graph via API -> Verify graph removal in UI test`, async () => { | ||
const graph = await browser.createNewPage(graphPage, urls.graphUrl); | ||
const graphName = `graph_${Date.now()}`; | ||
await graph.addGraph(graphName); | ||
const apiCall = new ApiCalls(); | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
await apiCall.removeGraph(graphName); | ||
await graph.refreshPage(); | ||
expect(await graph.verifyGraphExists(graphName)).toBe(false); | ||
}); | ||
}); | ||
|
||
roles.forEach(role => { | ||
test(`@${role.name} Create graph -> click the Export Data button -> verify the file has been successfully downloaded`, async () => { | ||
const graph = await browser.createNewPage(graphPage, urls.graphUrl); | ||
const graphName = `graph_${Date.now()}`; | ||
await graph.addGraph(graphName); | ||
const download = await graph.clickOnExportDataBtn(); | ||
const downloadPath = await download.path(); | ||
expect(fs.existsSync(downloadPath)).toBe(true); | ||
}); | ||
}); | ||
|
||
roles.forEach(role => { | ||
test(`@${role.name} Query Test: Create a graph via API -> run a query via API and validate that the response data is correct`, async () => { | ||
const apiCall = new ApiCalls(); | ||
const graphName = `graph_${Date.now()}`; | ||
await apiCall.addGraph(graphName); | ||
const query = graphName + queryData.queries[0].query; | ||
const res = await apiCall.runQuery(query); | ||
|
||
expect( | ||
res.result && | ||
Array.isArray(res.result.metadata) && | ||
res.result.metadata.length >= 5 && | ||
Array.isArray(res.result.data) | ||
).toBe(true); | ||
}); | ||
}); | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it is different tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the BrowserWrapper functionally creates the page instead of using Playwright's built-in methods.