- Problems with data (server.js)
- UI Validations or non-validations
- Check that the Data is there
- Better validations of Comments
- Better validations of upvotes (optional)
Ensure Every service is Stopped () Set server to default
Start:
- Node Back-end
- Front-end
- Bridge Service
mvn compile exec:java -Dexec.mainClass=MainContainer -Dexec.args="test"
Given I already have old comments for the article "learn-german"
Given('I already have old comments for the article {string}', (text) => {
let calls = {
callContent: {
addComment: {
class: 'com.bridgeservice.demo.backend.MyBlogBackEnd',
method: 'addCommentToArticle',
args: ['http://localhost:8000/', faker.person.fullName(), faker.lorem.paragraph(), text],
},
},
}
cy.task('bridgeService', calls).then((result) => {
expect(result.returnValues).to.not.be.empty
expect(result.returnValues.addComment).to.equal(true);
})
});
Ensuring data is there
Given there is an article "learn-german" in the system
Given("there is an article {string} in the system", (text) => {
let call = {
callContent: {
article: {
class: "com.bridgeservice.demo.backend.MyBlogBackEnd",
method: "fetchArticle",
args: ["http://localhost:8000/", text],
},
},
};
cy.task("bridgeService", call).then((result) => {
expect(result.returnValues.article).to.not.be.empty;
});
});
Ensuring comments are there (Add to "I should be able to add a comment"):
let call = {
callContent: {
article: {
class: "com.bridgeservice.demo.backend.MyBlogBackEnd",
method: "fetchLastComment",
args: ["http://localhost:8000/", this.selectedArticle],
},
},
};
cy.task("bridgeService", call).then((result) => {
expect(result.returnValues.article).to.not.be.empty;
const resultData = result.returnValues.article;
expect(Object.keys(resultData)).to.include.members(["postedBy", "text"]);
expect(resultData.postedBy).to.equal(name);
expect(resultData.text).to.equal(text);
});
Ensuring upvote has been successfull:
Then("I should successfully upvote the article", () => {
let call = {
callContent: {
article: {
class: "com.bridgeservice.demo.backend.MyBlogBackEnd",
method: "fetchArticle",
args: ["http://localhost:8000/", this.selectedArticle],
},
},
};
cy.task("bridgeService", call)
.then((result) => {
expect(result.returnValues.article).to.not.be.empty;
expect(result.returnValues.article.upvotes).to.be.a("number");
return result.returnValues.article.upvotes;
})
.then((votesBefore) => {
//Add backend check
cy.get('button[data-testid="upvote-button"]')
.should("exist")
.click()
.then(() => {
cy.task("bridgeService", call).then((result2) => {
expect(result2.returnValues.article).to.not.be.empty;
expect(result2.returnValues.article.upvotes).to.equal(
votesBefore + 1
);
});
});
});