add cypress profile page spec
This commit is contained in:
parent
84ee24c2ee
commit
66ad7b1a0f
1 changed files with 86 additions and 0 deletions
86
frontend/blog_portal/cypress/e2e/profile_page.cy.ts
Normal file
86
frontend/blog_portal/cypress/e2e/profile_page.cy.ts
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
describe("profile page", function () {
|
||||
beforeEach(function () {
|
||||
cy.resetDb();
|
||||
cy.clearMail();
|
||||
cy.seedConfirmedUser({
|
||||
email: "alice@example.com",
|
||||
displayName: "alice",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
cy.seedConfirmedUser({
|
||||
email: "bob@example.com",
|
||||
displayName: "bob",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
cy.seedPostAs({
|
||||
email: "alice@example.com",
|
||||
password: "longenoughpassword",
|
||||
title: "Alice's only post",
|
||||
body: "Hello.",
|
||||
});
|
||||
});
|
||||
|
||||
it("shows posts to anonymous visitors without owner controls", function () {
|
||||
cy.visit("/users/alice");
|
||||
cy.contains("h1", "alice").should("be.visible");
|
||||
cy.contains(".post-card", "Alice's only post").should("be.visible");
|
||||
cy.contains("button", "New post").should("not.exist");
|
||||
cy.contains("button", "Promote to admin").should("not.exist");
|
||||
});
|
||||
|
||||
it("shows the New post button when viewing your own profile", function () {
|
||||
cy.loginViaApi({
|
||||
email: "alice@example.com",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
|
||||
cy.visit("/users/alice");
|
||||
cy.contains("button", "New post").should("be.visible");
|
||||
cy.contains("button", "Promote to admin").should("not.exist");
|
||||
});
|
||||
|
||||
it("hides the Promote button from non-admin viewers", function () {
|
||||
cy.loginViaApi({
|
||||
email: "bob@example.com",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
|
||||
cy.visit("/users/alice");
|
||||
cy.contains("button", "Promote to admin").should("not.exist");
|
||||
});
|
||||
|
||||
it("shows the Promote button to an admin viewing someone else", function () {
|
||||
cy.seedAdmin({
|
||||
email: "admin@example.com",
|
||||
displayName: "rootadmin",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
cy.loginViaApi({
|
||||
email: "admin@example.com",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
|
||||
cy.visit("/users/alice");
|
||||
cy.contains("button", "Promote to admin").should("be.visible");
|
||||
});
|
||||
|
||||
it("hides the Promote button when an admin views their own profile", function () {
|
||||
cy.seedAdmin({
|
||||
email: "admin@example.com",
|
||||
displayName: "rootadmin",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
cy.loginViaApi({
|
||||
email: "admin@example.com",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
|
||||
cy.visit("/users/rootadmin");
|
||||
cy.contains("button", "Promote to admin").should("not.exist");
|
||||
});
|
||||
|
||||
it("renders a not-found panel for unknown display names", function () {
|
||||
cy.visit("/users/nobody");
|
||||
cy.contains("h1", "User not found").should("be.visible");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue