mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-09 21:24:44 +00:00
added for loops to tests
This commit is contained in:
parent
3b1b0cfd57
commit
5d331c3800
@ -39,206 +39,229 @@ describe("test App end to end", async () => {
|
||||
|
||||
describe("test CRUD on simple inputs and default image", () => {
|
||||
|
||||
describe("test create 1 new review", async () => {
|
||||
it("create 1 new review", async () => {
|
||||
// Click the button to create a new review
|
||||
let create_btn = await page.$("#create-btn");
|
||||
await create_btn.click();
|
||||
await page.waitForNavigation();
|
||||
describe("test create 10 new reviews", async () => {
|
||||
|
||||
// create a new review
|
||||
let review = {
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: 1
|
||||
}
|
||||
await setReviewForm(page, review);
|
||||
for (var i=0; i < 10; i++) {
|
||||
|
||||
// Click the save button to save updates
|
||||
let save_btn = await page.$("#save-btn");
|
||||
await save_btn.click();
|
||||
await page.waitForNavigation();
|
||||
});
|
||||
it("create 1 new review", async () => {
|
||||
|
||||
it("check details page", async () => {
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(page, "d", expected);
|
||||
});
|
||||
|
||||
it("check home page", async () => {
|
||||
// Click the button to return to the home page
|
||||
let home_btn = await page.$("#home-btn");
|
||||
home_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Get the review card again and get its shadowRoot
|
||||
let review_card = await page.$("review-card");
|
||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(shadowRoot, "a", expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("test read 1 review after refresh", async () => {
|
||||
it("refresh page", async () => {
|
||||
// Reload the page
|
||||
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
|
||||
});
|
||||
|
||||
it("check details page", async () => {
|
||||
// click review card
|
||||
let review_card = await page.$("review-card");
|
||||
await review_card.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(page, "d", expected);
|
||||
});
|
||||
|
||||
it("check home page", async () => {
|
||||
// Click the button to return to the home page
|
||||
let home_btn = await page.$("#home-btn");
|
||||
home_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Get the review card again and get its shadowRoot
|
||||
let review_card = await page.$("review-card");
|
||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(shadowRoot, "a", expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("test update 1 review", async () => {
|
||||
|
||||
it("update 1 review", async () => {
|
||||
|
||||
// Get the only review card and click it
|
||||
let review_card = await page.$("review-card");
|
||||
await review_card.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Click the button to show update form
|
||||
let update_btn = await page.$("#update-btn");
|
||||
await update_btn.click();
|
||||
|
||||
// create a new review
|
||||
let review = {
|
||||
imgAlt: "updated alt",
|
||||
mealName: "updated name",
|
||||
comments: "updated comment",
|
||||
restaurant: "updated restaurant",
|
||||
tags: ["tag -0", "tag -1", "tag -2", "tag -3", "tag -4", "tag -5"],
|
||||
rating: 5
|
||||
}
|
||||
await setReviewForm(page, review);
|
||||
|
||||
// Click the save button to save updates
|
||||
let save_btn = await page.$("#save-btn");
|
||||
await save_btn.click();
|
||||
await page.waitForNavigation();
|
||||
});
|
||||
|
||||
it("check details page", async () => {
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "updated alt",
|
||||
mealName: "updated name",
|
||||
comments: "updated comment",
|
||||
restaurant: "updated restaurant",
|
||||
tags: ["tag -0", "tag -1", "tag -2", "tag -3", "tag -4", "tag -5"],
|
||||
rating: "http://localhost:8080/assets/images/icons/5-star.svg"
|
||||
}
|
||||
await checkCorrectness(page, "d", expected);
|
||||
});
|
||||
|
||||
it("check home page", async () => {
|
||||
// Click the button to return to the home page
|
||||
let home_btn = await page.$("#home-btn");
|
||||
home_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Get the review card again and get its shadowRoot
|
||||
let review_card = await page.$("review-card");
|
||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "updated alt",
|
||||
mealName: "updated name",
|
||||
comments: "updated comment",
|
||||
restaurant: "updated restaurant",
|
||||
tags: ["tag -0", "tag -1", "tag -2", "tag -3", "tag -4", "tag -5"],
|
||||
rating: "http://localhost:8080/assets/images/icons/5-star.svg"
|
||||
}
|
||||
await checkCorrectness(shadowRoot, "a", expected);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("test delete 1 review", async () => {
|
||||
it("delete 1 review", async () => {
|
||||
// Get the only review card and click it
|
||||
let review_card = await page.$("review-card");
|
||||
await review_card.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
page.on('dialog', async dialog => {
|
||||
console.log(dialog.message());
|
||||
await dialog.accept();
|
||||
// Click the button to create a new review
|
||||
let create_btn = await page.$("#create-btn");
|
||||
await create_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// create a new review
|
||||
let review = {
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: 1
|
||||
}
|
||||
|
||||
await setReviewForm(page, review);
|
||||
|
||||
// Click the save button to save updates
|
||||
let save_btn = await page.$("#save-btn");
|
||||
await save_btn.click();
|
||||
await page.waitForNavigation();
|
||||
});
|
||||
|
||||
it("check details page", async () => {
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(page, "d", expected);
|
||||
});
|
||||
|
||||
it("check home page", async () => {
|
||||
// Click the button to return to the home page
|
||||
let home_btn = await page.$("#home-btn");
|
||||
home_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Get the review card again and get its shadowRoot
|
||||
let review_card = await page.$("review-card");
|
||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(shadowRoot, "a", expected);
|
||||
});
|
||||
|
||||
// Get the delete button and click it
|
||||
let delete_btn = await page.$("#delete-btn");
|
||||
await delete_btn.click();
|
||||
await page.waitForNavigation();
|
||||
}
|
||||
|
||||
// Check that the card was correctly removed (there should be no remaining cards)
|
||||
review_card = await page.$("#review-card");
|
||||
assert.strictEqual(review_card, null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("test read 10 reviews after refresh", async () => {
|
||||
|
||||
for (var i=0; i < 10; i++) {
|
||||
|
||||
it("refresh page", async () => {
|
||||
// Reload the page
|
||||
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
|
||||
});
|
||||
|
||||
it("check details page", async () => {
|
||||
// click review card
|
||||
let review_card = await page.$("review-card");
|
||||
await review_card.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(page, "d", expected);
|
||||
});
|
||||
|
||||
it("check home page", async () => {
|
||||
// Click the button to return to the home page
|
||||
let home_btn = await page.$("#home-btn");
|
||||
home_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Get the review card again and get its shadowRoot
|
||||
let review_card = await page.$("review-card");
|
||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "sample alt",
|
||||
mealName: "sample name",
|
||||
comments: "sample comment",
|
||||
restaurant: "sample restaurant",
|
||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||
}
|
||||
await checkCorrectness(shadowRoot, "a", expected);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
describe("test update 10 reviews", async () => {
|
||||
|
||||
for (var i=0; i < 10; i++) {
|
||||
|
||||
it("update 1 review", async () => {
|
||||
|
||||
// Get the only review card and click it
|
||||
let review_card = await page.$("review-card");
|
||||
await review_card.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Click the button to show update form
|
||||
let update_btn = await page.$("#update-btn");
|
||||
await update_btn.click();
|
||||
|
||||
// create a new review
|
||||
let review = {
|
||||
imgAlt: "updated alt",
|
||||
mealName: "updated name",
|
||||
comments: "updated comment",
|
||||
restaurant: "updated restaurant",
|
||||
tags: ["tag -0", "tag -1", "tag -2", "tag -3", "tag -4", "tag -5"],
|
||||
rating: 5
|
||||
}
|
||||
await setReviewForm(page, review);
|
||||
|
||||
// Click the save button to save updates
|
||||
let save_btn = await page.$("#save-btn");
|
||||
await save_btn.click();
|
||||
await page.waitForNavigation();
|
||||
});
|
||||
|
||||
it("check details page", async () => {
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "updated alt",
|
||||
mealName: "updated name",
|
||||
comments: "updated comment",
|
||||
restaurant: "updated restaurant",
|
||||
tags: ["tag -0", "tag -1", "tag -2", "tag -3", "tag -4", "tag -5"],
|
||||
rating: "http://localhost:8080/assets/images/icons/5-star.svg"
|
||||
}
|
||||
await checkCorrectness(page, "d", expected);
|
||||
});
|
||||
|
||||
it("check home page", async () => {
|
||||
// Click the button to return to the home page
|
||||
let home_btn = await page.$("#home-btn");
|
||||
home_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Get the review card again and get its shadowRoot
|
||||
let review_card = await page.$("review-card");
|
||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||
|
||||
// check the details page for correctness
|
||||
let expected = {
|
||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||
imgAlt: "updated alt",
|
||||
mealName: "updated name",
|
||||
comments: "updated comment",
|
||||
restaurant: "updated restaurant",
|
||||
tags: ["tag -0", "tag -1", "tag -2", "tag -3", "tag -4", "tag -5"],
|
||||
rating: "http://localhost:8080/assets/images/icons/5-star.svg"
|
||||
}
|
||||
await checkCorrectness(shadowRoot, "a", expected);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
describe("test delete 10 reviews", async () => {
|
||||
|
||||
for (var i=0; i < 10; i++) {
|
||||
|
||||
it("delete 1 review", async () => {
|
||||
// Get the only review card and click it
|
||||
let review_card = await page.$("review-card");
|
||||
await review_card.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
page.on('dialog', async dialog => {
|
||||
console.log(dialog.message());
|
||||
await dialog.accept();
|
||||
});
|
||||
|
||||
// Get the delete button and click it
|
||||
let delete_btn = await page.$("#delete-btn");
|
||||
await delete_btn.click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
// Check that the card was correctly removed (there should be no remaining cards)
|
||||
review_card = await page.$("#review-card");
|
||||
assert.strictEqual(review_card, null);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user