-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cypress: User Avatar Modification (#10592)
- Loading branch information
1 parent
9b82db3
commit 5ffc6b3
Showing
6 changed files
with
89 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,22 @@ | ||
import { UserAvatar } from "@/pageObject/Users/UserAvatar"; | ||
|
||
describe("User Profile Avatar Modification", () => { | ||
const userAvatar = new UserAvatar("teststaff4"); | ||
beforeEach(() => { | ||
cy.loginByApi("teststaff4"); | ||
cy.visit("/"); | ||
}); | ||
it("should modify an avatar", () => { | ||
userAvatar | ||
.navigateToProfile() | ||
.interceptUploadAvatarRequest() | ||
.clickChangeAvatarButton() | ||
.uploadAvatar() | ||
.clickSaveAvatarButton() | ||
.verifyUploadAvatarApiCall() | ||
.interceptDeleteAvatarRequest() | ||
.clickChangeAvatarButton() | ||
.clickDeleteAvatarButton() | ||
.verifyDeleteAvatarApiCall(); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,59 @@ | ||
export class UserAvatar { | ||
username: string; | ||
constructor(username: string) { | ||
this.username = username; | ||
} | ||
|
||
navigateToProfile() { | ||
cy.visit(`/users/${this.username}`); | ||
return this; | ||
} | ||
|
||
interceptUploadAvatarRequest() { | ||
cy.intercept("POST", `/api/v1/users/${this.username}/profile_picture/`).as( | ||
"uploadAvatar", | ||
); | ||
return this; | ||
} | ||
|
||
clickChangeAvatarButton() { | ||
cy.verifyAndClickElement('[data-cy="change-avatar"]', "Change Avatar"); | ||
return this; | ||
} | ||
|
||
uploadAvatar() { | ||
cy.get('input[title="changeFile"]').selectFile( | ||
"cypress/fixtures/avatar.jpg", | ||
{ force: true }, | ||
); | ||
return this; | ||
} | ||
|
||
clickSaveAvatarButton() { | ||
cy.verifyAndClickElement('[data-cy="save-cover-image"]', "Save"); | ||
return this; | ||
} | ||
|
||
verifyUploadAvatarApiCall() { | ||
cy.wait("@uploadAvatar").its("response.statusCode").should("eq", 200); | ||
return this; | ||
} | ||
|
||
interceptDeleteAvatarRequest() { | ||
cy.intercept( | ||
"DELETE", | ||
`/api/v1/users/${this.username}/profile_picture/`, | ||
).as("deleteAvatar"); | ||
return this; | ||
} | ||
|
||
clickDeleteAvatarButton() { | ||
cy.verifyAndClickElement('[data-cy="delete-avatar"]', "Delete"); | ||
return this; | ||
} | ||
|
||
verifyDeleteAvatarApiCall() { | ||
cy.wait("@deleteAvatar").its("response.statusCode").should("eq", 204); | ||
return this; | ||
} | ||
} |
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