diff --git a/e2e/config/queries.json b/e2e/config/queries.json new file mode 100644 index 0000000..15e1bed --- /dev/null +++ b/e2e/config/queries.json @@ -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*" + } + ] + } \ No newline at end of file diff --git a/e2e/config/urls.json b/e2e/config/urls.json index 0a35fb9..7889024 100644 --- a/e2e/config/urls.json +++ b/e2e/config/urls.json @@ -4,7 +4,8 @@ "LoginApiUrl": "http://localhost:3000/api/auth/providers", "deleteGraphUrl": "http://localhost:3000/api/graph/", "settingsConfig": "http://localhost:3000/api/graph?config=", - "settingsUsers": "http://localhost:3000/api/user" + "settingsUsers": "http://localhost:3000/api/user", + "runQueryUrl": "http://localhost:3000/api/graph/" }, "falkorDBWeb": "https://www.falkordb.com/", diff --git a/e2e/config/user.json b/e2e/config/user.json index bfccda8..f129c22 100644 --- a/e2e/config/user.json +++ b/e2e/config/user.json @@ -9,5 +9,10 @@ "readWrite": 2, "readOnly": 3 } - } + }, + "userRoles": [ + { "name": "Default", "role": "admin" }, + { "name": "readwriteuser", "role": "readwrite" }, + { "name": "readonlyuser", "role": "readonly" } + ] } \ No newline at end of file diff --git a/e2e/logic/POM/loginPage.ts b/e2e/logic/POM/loginPage.ts new file mode 100644 index 0000000..a017ce1 --- /dev/null +++ b/e2e/logic/POM/loginPage.ts @@ -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 { + await this.connectBtn.click(); + await waitForURL(this.page, urls.graphUrl); + } + + async connectWithCredentials(username: string, password: string): Promise { + await this.usernameInput.fill(username) + await this.passwordInput.fill(password) + await this.connectBtn.click(); + await waitForURL(this.page, urls.graphUrl); + } + +} \ No newline at end of file diff --git a/e2e/logic/POM/navBarComponent.ts b/e2e/logic/POM/navBarComponent.ts index 2d99623..58d6515 100644 --- a/e2e/logic/POM/navBarComponent.ts +++ b/e2e/logic/POM/navBarComponent.ts @@ -1,5 +1,5 @@ -import { Locator } from "playwright"; +import { Locator, Page } from "playwright"; import BasePage from "@/e2e/infra/ui/basePage"; import { waitForTimeOut, waitForURL } from "@/e2e/infra/utils"; import urls from '../../config/urls.json' @@ -34,8 +34,8 @@ export default class NavBarComponent extends BasePage { return this.page.locator("//button[@title='Settings']") } - private get DefaultButton(): Locator { - return this.page.getByRole("button", { name : "Default"}) + private get clickOnUser(): (user: string) => Locator { + return (user: string) => this.page.getByRole("button", { name : `${user}`}) } private get LogoutButton(): Locator { @@ -52,7 +52,7 @@ export default class NavBarComponent extends BasePage { async clickOnSchemasButton(): Promise { await this.schemaButton.click(); - await waitForTimeOut(this.page, 2000) + await waitForURL(this.page, urls.schemaUrl); } async clickOnHelpBtn(): Promise { @@ -69,14 +69,47 @@ export default class NavBarComponent extends BasePage { async clickOnSettingsBtn(): Promise { await this.settingsButton.click(); - await waitForTimeOut(this.page, 2000); + await waitForURL(this.page, urls.settingsUrl); } - async Logout(): Promise { + async isSettingsButtonEnabled(): Promise { + return await this.settingsButton.isEnabled(); + } + + async Logout(user: string): Promise { await this.page.waitForLoadState('networkidle'); - await this.DefaultButton.click() + await this.clickOnUser(user).click() await this.LogoutButton.click() await waitForURL(this.page, urls.loginUrl); } + async clickOnFalkor(): Promise { + await this.page.waitForLoadState('networkidle'); + const [newPage] = await Promise.all([ + this.page.waitForEvent('popup'), + this.clickOnFalkorLogo(), + ]); + return newPage + } + + async clickOnDocumentation(): Promise { + await this.page.waitForLoadState('networkidle'); + const [newPage] = await Promise.all([ + this.page.waitForEvent('popup'), + this.clickOnHelpBtn(), + this.clickOnDocumentationBtn(), + ]); + return newPage + } + + async clickOnSupport(): Promise { + await this.page.waitForLoadState('networkidle'); + const [newPage] = await Promise.all([ + this.page.waitForEvent('popup'), + this.clickOnHelpBtn(), + this.clickOnSupportBtn(), + ]); + return newPage + } + } \ No newline at end of file diff --git a/e2e/logic/api/apiCalls.ts b/e2e/logic/api/apiCalls.ts index 4367e29..852a9db 100644 --- a/e2e/logic/api/apiCalls.ts +++ b/e2e/logic/api/apiCalls.ts @@ -6,6 +6,7 @@ import { ModifySettingsRoleResponse } from "./responses/modifySettingsRoleRespon import { GetSettingsRoleValue } from "./responses/getSettingsRoleValue"; import { CreateUsersResponse } from "./responses/createUsersResponse"; import { DeleteUsersResponse } from "./responses/deleteUsersResponse"; +import { runQueryResponse } from "./responses/runQueryResponse"; export class ApiCalls{ @@ -50,4 +51,10 @@ export class ApiCalls{ const jsonData = await result.json(); return jsonData } + + async runQuery(query: string, data?: any): Promise{ + const result = await getRequest(urls.api.runQueryUrl + query, data) + const jsonData = await result.json(); + return jsonData + } } \ No newline at end of file diff --git a/e2e/logic/api/responses/runQueryResponse.ts b/e2e/logic/api/responses/runQueryResponse.ts new file mode 100644 index 0000000..68f9960 --- /dev/null +++ b/e2e/logic/api/responses/runQueryResponse.ts @@ -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>; + }; +} \ No newline at end of file diff --git a/e2e/tests/auth.setup.ts b/e2e/tests/auth.setup.ts index dfbefba..6c73e95 100644 --- a/e2e/tests/auth.setup.ts +++ b/e2e/tests/auth.setup.ts @@ -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); + } +}); \ No newline at end of file diff --git a/e2e/tests/graph.spec.ts b/e2e/tests/graph.spec.ts index f3f4e97..977444b 100644 --- a/e2e/tests/graph.spec.ts +++ b/e2e/tests/graph.spec.ts @@ -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' }, + ]; - 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); + }); + }); }) \ No newline at end of file diff --git a/e2e/tests/navBar.spec.ts b/e2e/tests/navBar.spec.ts index b6215d0..48d063d 100644 --- a/e2e/tests/navBar.spec.ts +++ b/e2e/tests/navBar.spec.ts @@ -1,33 +1,26 @@ -import { expect, test } from "@playwright/test" -import urls from '../config/urls.json' -import BrowserWrapper from "../infra/ui/browserWrapper" -import NavBarComponent from '../logic/POM/navBarComponent' +import { expect, test } from "@playwright/test"; +import urls from "../config/urls.json"; +import BrowserWrapper from "../infra/ui/browserWrapper"; +import NavBarComponent from "../logic/POM/navBarComponent"; -test.describe('NavBar Tests', () => { - let browser : BrowserWrapper; +const roles = [{ name: "admin" }, { name: "readwrite" }, { name: "readonly" }]; + +roles.forEach((role) => { + test.describe(`@${role.name} role, Navbar tests`, () => { + let browser: BrowserWrapper; test.beforeAll(async () => { - browser = new BrowserWrapper(); - }) + browser = new BrowserWrapper(); + }); test.afterAll(async () => { - await browser.closeBrowser(); - }) - + await browser.closeBrowser(); + }); test("Verify clicking on FalkorDB logo redirects to specified URL", async () => { const navBar = await browser.createNewPage(NavBarComponent, urls.graphUrl) - - const context = browser.getContext()!; - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - navBar.clickOnFalkorLogo(), - ]); - - await newPage.waitForLoadState('domcontentloaded'); - const newUrl = newPage.url(); - - expect(newUrl).toBe("https://www.falkordb.com/") + const page = await navBar.clickOnFalkor() + expect(page.url()).toBe("https://www.falkordb.com/") }) @@ -49,43 +42,33 @@ test.describe('NavBar Tests', () => { test("Verify clicking on help -> Documentation redirects to specified URL", async () => { const navBar = await browser.createNewPage(NavBarComponent, urls.graphUrl) - - const context = browser.getContext()!; - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - navBar.clickOnHelpBtn(), - navBar.clickOnDocumentationBtn(), - ]); - - await newPage.waitForLoadState('domcontentloaded'); - const newUrl = newPage.url(); - - expect(newUrl).toBe("https://docs.falkordb.com/") + const page = await navBar.clickOnDocumentation() + expect(page.url()).toBe("https://docs.falkordb.com/") }) test("Verify clicking on help -> Support redirects to specified URL", async () => { const navBar = await browser.createNewPage(NavBarComponent, urls.graphUrl) - - const context = browser.getContext()!; - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - navBar.clickOnHelpBtn(), - navBar.clickOnSupportBtn(), - ]); - - await newPage.waitForLoadState('domcontentloaded'); - const newUrl = newPage.url(); - - expect(newUrl).toBe("https://www.falkordb.com/contact-us/") + const page = await navBar.clickOnSupport() + expect(page.url()).toBe("https://www.falkordb.com/contact-us/") }) - test("Verify clicking on Settings redirects to specified URL", async () => { - const navBar = await browser.createNewPage(NavBarComponent, urls.graphUrl) - await navBar.clickOnSettingsBtn() - const newUrl = navBar.getCurrentURL() - expect(newUrl).toBe(urls.settingsUrl) - }) - -}) \ No newline at end of file + if(role.name === 'admin'){ + test("@admin Verify clicking on Settings redirects to specified URL", async () => { + const navBar = await browser.createNewPage(NavBarComponent, urls.graphUrl) + await navBar.clickOnSettingsBtn() + const newUrl = navBar.getCurrentURL() + expect(newUrl).toBe(urls.settingsUrl) + }) + } + + if(role.name === 'readwrite' || role.name === 'readonly'){ + test("Attempt to click on Settings does not result in a redirect", async () => { + const navBar = await browser.createNewPage(NavBarComponent, urls.graphUrl) + const result = await navBar.isSettingsButtonEnabled() + expect(result).toBe(false) + }) + } + }); +}); \ No newline at end of file diff --git a/e2e/tests/settingsConfig.spec.ts b/e2e/tests/settingsConfig.spec.ts index e861282..202f84c 100644 --- a/e2e/tests/settingsConfig.spec.ts +++ b/e2e/tests/settingsConfig.spec.ts @@ -18,7 +18,7 @@ test.describe('Settings Tests', () => { }) Data.inputDataRejectsZero.forEach(({ input, description, expected }) => { - test(`Modify ${roles.maxQueuedQueries} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.maxQueuedQueries} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.maxQueuedQueries, input) @@ -29,7 +29,7 @@ test.describe('Settings Tests', () => { }) Data.maxTimeOut.forEach(({ input, description, expected }) => { - test(`Modify ${roles.maxTimeOut} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.maxTimeOut} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.maxTimeOut, input) @@ -40,7 +40,7 @@ test.describe('Settings Tests', () => { }) Data.inputDataAcceptsZero.forEach(({ input, description, expected }) => { - test(`Modify ${roles.defaultTimeOut} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.defaultTimeOut} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.defaultTimeOut, input) @@ -51,7 +51,7 @@ test.describe('Settings Tests', () => { }) Data.inputDataAcceptsZero.forEach(({ input, description, expected }) => { - test(`Modify ${roles.resultSetSize} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.resultSetSize} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.resultSetSize, input) @@ -62,7 +62,7 @@ test.describe('Settings Tests', () => { }) Data.inputDataAcceptsZero.forEach(({ input, description, expected }) => { - test(`Modify ${roles.queryMemCapacity} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.queryMemCapacity} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.queryMemCapacity, input) @@ -74,7 +74,7 @@ test.describe('Settings Tests', () => { }) Data.inputDataAcceptsZero.forEach(({ input, description, expected }) => { - test(`Modify ${roles.vKeyMaxEntityCount} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.vKeyMaxEntityCount} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.vKeyMaxEntityCount, input) @@ -85,7 +85,7 @@ test.describe('Settings Tests', () => { }) Data.CMDData.forEach(({ input, description, expected }) => { - test(`Modify ${roles.cmdInfo} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.cmdInfo} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.cmdInfo, input) @@ -96,7 +96,7 @@ test.describe('Settings Tests', () => { }) Data.inputDataAcceptsZero.forEach(({ input, description, expected }) => { - test(`Modify ${roles.maxInfoQueries} via API validation via UI: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${roles.maxInfoQueries} via API validation via UI: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) const apiCall = new ApiCalls() await apiCall.modifySettingsRole(roles.maxInfoQueries, input) @@ -107,7 +107,7 @@ test.describe('Settings Tests', () => { }) Data.roleModificationData.forEach(({ role, input, description, expected }) => { - test(`Modify ${role} via UI validation via API: Input value: ${input} description: ${description}`, async () => { + test(`@admin Modify ${role} via UI validation via API: Input value: ${input} description: ${description}`, async () => { const settingsConfigPage = await browser.createNewPage(SettingsConfigPage, urls.settingsUrl) await settingsConfigPage.modifyRoleValue(role, input) const apiCall = new ApiCalls() diff --git a/e2e/tests/settingsUsers.spec.ts b/e2e/tests/settingsUsers.spec.ts index f225177..bf35d6d 100644 --- a/e2e/tests/settingsUsers.spec.ts +++ b/e2e/tests/settingsUsers.spec.ts @@ -16,7 +16,7 @@ test.describe('Settings Tests', () => { await browser.closeBrowser(); }) - test("Add one new user -> validating user exists in the users list", async () => { + test("@admin Add one new user -> validating user exists in the users list", async () => { const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); const username = `user_${Date.now()}` @@ -26,7 +26,7 @@ test.describe('Settings Tests', () => { expect(isVisible).toBe(true) }) - test("Add one user -> remove one user by hover -> Validate that the user has been removed", async () => { + test("@admin Add one user -> remove one user by hover -> Validate that the user has been removed", async () => { // Adding one user const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); @@ -41,7 +41,7 @@ test.describe('Settings Tests', () => { }) - test("Add one user -> change the role -> Validate that the user role have been changed", async () => { + test("@admin Add one user -> change the role -> Validate that the user role have been changed", async () => { // Adding one user const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); @@ -56,7 +56,7 @@ test.describe('Settings Tests', () => { }) - test("Add two users -> change their roles via checkbox -> Validate that the users roles have been changed", async () => { + test("@admin Add two users -> change their roles via checkbox -> Validate that the users roles have been changed", async () => { // Adding two user const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); @@ -77,7 +77,7 @@ test.describe('Settings Tests', () => { expect([userName1Role, userName2Role]).toEqual(["Read-Only", "Read-Only"]) }) - test("Add two users -> delete the two users by checkbox -> Validate that the users have been deleted", async () => { + test("@admin Add two users -> delete the two users by checkbox -> Validate that the users have been deleted", async () => { // Adding two user const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); @@ -106,7 +106,7 @@ test.describe('Settings Tests', () => { ]; searchData.forEach(({ invalidPassword, description }) => { - test(`Enter password for new user: ${invalidPassword} reason: ${description} `, async () => { + test(`@admin Enter password for new user: ${invalidPassword} reason: ${description} `, async () => { const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); const username = `user_${Date.now()}` @@ -118,7 +118,7 @@ test.describe('Settings Tests', () => { }); }) - test("Attempt to add a user without assigning a role -> Verify that the user has not been added", async () => { + test("@admin Attempt to add a user without assigning a role -> Verify that the user has not been added", async () => { const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); const username = `user_${Date.now()}` @@ -129,7 +129,7 @@ test.describe('Settings Tests', () => { expect(isVisible).toBe(false) }) - test("Attempt to delete the default admin user -> Verify that the user has not been deleted.", async () => { + test("@admin Attempt to delete the default admin user -> Verify that the user has not been deleted.", async () => { const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl) await settingsUsersPage.navigateToUserTab(); await settingsUsersPage.removeUserByCheckbox('default') @@ -137,19 +137,17 @@ test.describe('Settings Tests', () => { expect(isVisible).toBe(true) }) - test("API Test:Add user via API -> Validated user existing via API -> Delete user via API.", async () => { + test("@admin API Test:Add user via API -> Validated user existing via API -> Delete user via API.", async () => { const apiCall = new ApiCalls() const username = `user_${Date.now()}` - const password = user.password; - const role = user.ReadOnly - await apiCall.createUsers({username, password, role}) + await apiCall.createUsers({username, password: user.password, role: user.ReadOnly}) const users = await apiCall.getUsers() await apiCall.deleteUsers({"users":[{"username":`${username}`}]}) const User = users.result.find(user => user.username === username); expect(User?.username === username).toBe(true) }) // fail tests - test(`API Test: without passing a username, Attempt to add a user and validate the user was not added`, async () => { + test(`@admin API Test: without passing a username, Attempt to add a user and validate the user was not added`, async () => { const apiCall = new ApiCalls() const username = '' await apiCall.createUsers({ username: username, password: user.password, role: user.ReadOnly }); @@ -158,7 +156,7 @@ test.describe('Settings Tests', () => { expect(User).toBeUndefined(); }); - test(`API Test: without passing a role, Attempt to add a user and validate the user was not added`, async () => { + test(`@admin API Test: without passing a role, Attempt to add a user and validate the user was not added`, async () => { const apiCall = new ApiCalls() const username = `user_${Date.now()}` await apiCall.createUsers({ username: username, password: '', role: user.ReadOnly }); @@ -167,7 +165,7 @@ test.describe('Settings Tests', () => { expect(User).toBeUndefined(); }); - test(`API Test: without passing a password, Attempt to add a user and validate the user was not added`, async () => { + test(`@admin API Test: without passing a password, Attempt to add a user and validate the user was not added`, async () => { const apiCall = new ApiCalls() const username = `user_${Date.now()}` await apiCall.createUsers({username: username, password: user.password, role: ''}) diff --git a/e2e/tests/signOut.spec.ts b/e2e/tests/signOut.spec.ts index 573ff2c..9ce11b5 100644 --- a/e2e/tests/signOut.spec.ts +++ b/e2e/tests/signOut.spec.ts @@ -2,23 +2,26 @@ import { expect, test } from "@playwright/test"; import urls from '../config/urls.json' import BrowserWrapper from "../infra/ui/browserWrapper"; import navBarComponent from '../logic/POM/navBarComponent' +import roles from '../config/user.json' -test.describe('NavBar Tests', () => { - let browser : BrowserWrapper; +roles.userRoles.forEach((role) => { + test.describe(`@${role.role} SignOut Test`, () => { + let browser : BrowserWrapper; - test.beforeAll(async () => { - browser = new BrowserWrapper(); - }) + test.beforeAll(async () => { + browser = new BrowserWrapper(); + }) - test.afterAll(async () => { - await browser.closeBrowser(); - }) + test.afterAll(async () => { + await browser.closeBrowser(); + }) - test("Sign out Test", async () => { - const navBar = await browser.createNewPage(navBarComponent, urls.graphUrl) - await navBar.Logout(); - const newUrl = navBar.getCurrentURL(); - expect(newUrl).toBe(urls.loginUrl) - }) + test("Sign out Test", async () => { + const navBar = await browser.createNewPage(navBarComponent, urls.graphUrl) + await navBar.Logout(role.name); + const newUrl = navBar.getCurrentURL(); + expect(newUrl).toBe(urls.loginUrl) + }) + }) }) \ No newline at end of file diff --git a/playwright.config.ts b/playwright.config.ts index f41d1d1..b705a6f 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -36,21 +36,62 @@ export default defineConfig({ //Setup project {name: 'setup', testMatch: /.*\.setup\.ts/}, { - name: 'chromium', + name: '[Admin] Chromium', use: { ...devices['Desktop Chrome'], - storageState: 'playwright/.auth/user.json' + storageState: 'playwright/.auth/admin.json', }, - dependencies:['setup'] + dependencies: ['setup'], + grep: /@admin/, + }, + { + name: '[Admin] Firefox', + use: { + ...devices['Desktop Firefox'], + storageState: 'playwright/.auth/admin.json', + }, + dependencies: ['setup'], + grep: /@admin/, }, + // Read-Write user projects + { + name: '[Read-Write] - Chromium', + use: { + ...devices['Desktop Chrome'], + storageState: 'playwright/.auth/readwriteuser.json', + }, + dependencies: ['setup'], + grep: /@readwrite/, + }, + { + name: '[Read-Write] - Firefox', + use: { + ...devices['Desktop Firefox'], + storageState: 'playwright/.auth/readwriteuser.json', + }, + dependencies: ['setup'], + grep: /@readwrite/, + }, + + // // Read-Only user projects + { + name: '[Read-Only] - Chromium', + use: { + ...devices['Desktop Chrome'], + storageState: 'playwright/.auth/readonlyuser.json', + }, + dependencies: ['setup'], + grep: /@readonly/, + }, { - name: 'firefox', + name: '[Read-Only] - Firefox', use: { ...devices['Desktop Firefox'], - storageState: 'playwright/.auth/user.json' + storageState: 'playwright/.auth/readonlyuser.json', }, - dependencies:['setup'] + dependencies: ['setup'], + grep: /@readonly/, }, // {