-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Cypress Test | Search using username | User Tab (#6478)
* Username search cypress test * import error
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
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,39 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; | ||
import LoginPage from "../../pageobject/Login/LoginPage"; | ||
import { UserPage } from "../../pageobject/Users/UserSearch"; | ||
|
||
describe("Asset Tab", () => { | ||
const userPage = new UserPage(); | ||
const usernameToTest = "devdoctor"; | ||
const currentuser = "devdistrictadmin"; | ||
const loginPage = new LoginPage(); | ||
before(() => { | ||
loginPage.loginAsDisctrictAdmin(); | ||
cy.saveLocalStorage(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.restoreLocalStorage(); | ||
cy.awaitUrl("/users"); | ||
}); | ||
|
||
it("Search by username", () => { | ||
userPage.checkSearchInputVisibility(); | ||
userPage.typeInSearchInput(usernameToTest); | ||
userPage.checkUrlForUsername(usernameToTest); | ||
userPage.checkUsernameText(usernameToTest); | ||
userPage.checkUsernameBadgeVisibility(true); | ||
userPage.clearSearchInput(); | ||
userPage.checkUsernameBadgeVisibility(false); | ||
userPage.typeInSearchInput(usernameToTest); | ||
userPage.checkUsernameText(usernameToTest); | ||
userPage.clickRemoveIcon(); | ||
userPage.checkUsernameBadgeVisibility(false); | ||
userPage.checkUsernameText(currentuser); | ||
}); | ||
afterEach(() => { | ||
cy.saveLocalStorage(); | ||
}); | ||
}); |
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,37 @@ | ||
// UserPage.ts | ||
export class UserPage { | ||
// Element selectors | ||
searchByUsernameInput = "#search-by-username"; | ||
usernameText = "#username"; | ||
usernameBadge = "[data-testid='Username']"; | ||
removeIcon = "#removeicon"; | ||
|
||
checkSearchInputVisibility() { | ||
cy.get(this.searchByUsernameInput).should("be.visible"); | ||
} | ||
|
||
typeInSearchInput(text: string) { | ||
cy.get(this.searchByUsernameInput).click().type(text); | ||
} | ||
|
||
clearSearchInput() { | ||
cy.get(this.searchByUsernameInput).click().clear(); | ||
} | ||
|
||
checkUrlForUsername(username: string) { | ||
cy.url().should("include", `username=${username}`); | ||
} | ||
|
||
checkUsernameText(username: string) { | ||
cy.get(this.usernameText).should("have.text", username); | ||
} | ||
|
||
checkUsernameBadgeVisibility(shouldBeVisible: boolean) { | ||
const assertion = shouldBeVisible ? "be.visible" : "not.be.visible"; | ||
cy.get(this.usernameBadge).should(assertion); | ||
} | ||
|
||
clickRemoveIcon() { | ||
cy.get(this.removeIcon).click(); | ||
} | ||
} |
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