mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-26 17:09:09 +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 CRUD on simple inputs and default image", () => {
|
||||||
|
|
||||||
describe("test create 1 new review", async () => {
|
describe("test create 10 new reviews", 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();
|
|
||||||
|
|
||||||
// create a new review
|
for (var i=0; i < 10; i++) {
|
||||||
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
|
it("create 1 new review", async () => {
|
||||||
let save_btn = await page.$("#save-btn");
|
|
||||||
await save_btn.click();
|
|
||||||
await page.waitForNavigation();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("check details page", async () => {
|
// Click the button to create a new review
|
||||||
// check the details page for correctness
|
let create_btn = await page.$("#create-btn");
|
||||||
let expected = {
|
await create_btn.click();
|
||||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
await page.waitForNavigation();
|
||||||
imgAlt: "sample alt",
|
|
||||||
mealName: "sample name",
|
// create a new review
|
||||||
comments: "sample comment",
|
let review = {
|
||||||
restaurant: "sample restaurant",
|
imgAlt: "sample alt",
|
||||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
mealName: "sample name",
|
||||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
comments: "sample comment",
|
||||||
}
|
restaurant: "sample restaurant",
|
||||||
await checkCorrectness(page, "d", expected);
|
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||||
});
|
rating: 1
|
||||||
|
}
|
||||||
it("check home page", async () => {
|
|
||||||
// Click the button to return to the home page
|
await setReviewForm(page, review);
|
||||||
let home_btn = await page.$("#home-btn");
|
|
||||||
home_btn.click();
|
// Click the save button to save updates
|
||||||
await page.waitForNavigation();
|
let save_btn = await page.$("#save-btn");
|
||||||
|
await save_btn.click();
|
||||||
// Get the review card again and get its shadowRoot
|
await page.waitForNavigation();
|
||||||
let review_card = await page.$("review-card");
|
});
|
||||||
let shadowRoot = await review_card.getProperty("shadowRoot");
|
|
||||||
|
it("check details page", async () => {
|
||||||
let expected = {
|
// check the details page for correctness
|
||||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
let expected = {
|
||||||
imgAlt: "sample alt",
|
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||||
mealName: "sample name",
|
imgAlt: "sample alt",
|
||||||
comments: "sample comment",
|
mealName: "sample name",
|
||||||
restaurant: "sample restaurant",
|
comments: "sample comment",
|
||||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
restaurant: "sample restaurant",
|
||||||
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
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);
|
}
|
||||||
});
|
await checkCorrectness(page, "d", expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("test read 1 review after refresh", async () => {
|
it("check home page", async () => {
|
||||||
it("refresh page", async () => {
|
// Click the button to return to the home page
|
||||||
// Reload the page
|
let home_btn = await page.$("#home-btn");
|
||||||
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
|
home_btn.click();
|
||||||
});
|
await page.waitForNavigation();
|
||||||
|
|
||||||
it("check details page", async () => {
|
// Get the review card again and get its shadowRoot
|
||||||
// click review card
|
let review_card = await page.$("review-card");
|
||||||
let review_card = await page.$("review-card");
|
let shadowRoot = await review_card.getProperty("shadowRoot");
|
||||||
await review_card.click();
|
|
||||||
await page.waitForNavigation();
|
let expected = {
|
||||||
|
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
||||||
// check the details page for correctness
|
imgAlt: "sample alt",
|
||||||
let expected = {
|
mealName: "sample name",
|
||||||
imgSrc: "http://localhost:8080/assets/images/icons/plate_with_cutlery.png",
|
comments: "sample comment",
|
||||||
imgAlt: "sample alt",
|
restaurant: "sample restaurant",
|
||||||
mealName: "sample name",
|
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
||||||
comments: "sample comment",
|
rating: "http://localhost:8080/assets/images/icons/1-star.svg"
|
||||||
restaurant: "sample restaurant",
|
}
|
||||||
tags: ["tag 0", "tag 1", "tag 2", "tag 3", "tag 4"],
|
await checkCorrectness(shadowRoot, "a", expected);
|
||||||
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();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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