Mike Aono d49afc25cf test(cypress): Cover "Pinned post" feature
* Implement cypress tests

- Start implementation of cypress tests for pinned posts

* Test that Admin can pin a post

- Tests the process of an admin pinning a post

* Resolve failing tests

- Fix ordering of posts immediately after pinning posts by reloading page
- Check that tests are pinned posts are displayed first for role user

* Refactor to seperate the initialization

- Of the post data created in the database during setup

* Fix toaster test

* test(cypress): Add missing parts for pin feature

* docs(cucumber): Link to admin 🥒 folder

* Follow @mattwr18's suggestions

* test(backend): Order pinned posts like frontend

@mattwr18 I think this was a false negative.

Co-authored-by: Robert Schäfer <git@roschaefer.de>
2020-01-23 20:30:12 +01:00

75 lines
1.9 KiB
JavaScript

import { When, Then } from "cypress-cucumber-preprocessor/steps";
const narratorAvatar =
"https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg";
When("I type in a comment with {int} characters", size => {
var c="";
for (var i = 0; i < size; i++) {
c += "c"
}
cy.get(".editor .ProseMirror").type(c);
});
Then("I click on the {string} button", text => {
cy.get("button")
.contains(text)
.click();
});
Then("my comment should be successfully created", () => {
cy.get(".iziToast-message").contains("Comment Submitted");
});
Then("I should see my comment", () => {
cy.get("div.comment p")
.should("contain", "Human Connection rocks")
.get(".user-avatar img")
.should("have.attr", "src")
.and("contain", narratorAvatar)
.get(".user-teaser > .info > .text")
.should("contain", "today at");
});
Then("I should see the entirety of my comment", () => {
cy.get("div.comment")
.should("not.contain", "show more")
});
Then("I should see an abreviated version of my comment", () => {
cy.get("div.comment")
.should("contain", "show more")
});
Then("the editor should be cleared", () => {
cy.get(".ProseMirror p").should("have.class", "is-empty");
});
When("I open the content menu of post {string}", (title)=> {
cy.contains('.post-card', title)
.find('.content-menu .base-button')
.click()
})
When("I click on 'Pin post'", (string)=> {
cy.get("a.ds-menu-item-link").contains("Pin post")
.click()
})
Then("there is no button to pin a post", () => {
cy.get("a.ds-menu-item-link")
.should('contain', "Report Post") // sanity check
.should('not.contain', "Pin post")
})
And("the post with title {string} has a ribbon for pinned posts", (title) => {
cy.get("article.post-card").contains(title)
.parent()
.find("div.ribbon.ribbon--pinned")
.should("contain", "Announcement")
})
Then("I see a toaster with {string}", (title) => {
cy.get(".iziToast-message").should("contain", title);
})