nextjs-starter-medusa
71 строка · 2.4 Кб
1import { test, expect } from "../../index"2
3test.describe("Search tests", async () => {4test("Searching for a specific product returns the correct product page", async ({5productPage,6}) => {7const searchModal = productPage.searchModal8await searchModal.open()9await searchModal.searchInput.fill("Sweatshirt")10await searchModal.searchResult11.filter({ hasText: "Sweatshirt" })12.first()13.click()14await productPage.container.waitFor({ state: "visible" })15await expect(productPage.productTitle).toContainText("Sweatshirt")16})17
18test("An erroneous search returns an empty result", async ({19productPage,20}) => {21const searchModal = productPage.searchModal22await searchModal.open()23await searchModal.searchInput.fill("Does Not Sweatshirt")24await expect(searchModal.noSearchResultsContainer).toBeVisible()25})26
27test("User can search after an empty search result", async ({28productPage,29}) => {30const searchModal = productPage.searchModal31
32await searchModal.open()33await searchModal.searchInput.fill("Does Not Sweatshirt")34await expect(searchModal.noSearchResultsContainer).toBeVisible()35
36await searchModal.searchInput.fill("Sweat")37await expect(searchModal.searchResults).toBeVisible()38await expect(searchModal.searchResult.first()).toBeVisible()39})40
41test("Closing the search page returns user back to their current page", async ({42storePage,43productPage,44loginPage,45}) => {46const searchModal = storePage.searchModal47await test.step("Navigate to the store page and open and close search modal", async () => {48await storePage.goto()49await searchModal.open()50await searchModal.close()51await expect(storePage.container).toBeVisible()52})53
54await test.step("Navigate to the product page and open and close search modal", async () => {55await storePage.goto()56const product = await storePage.getProduct("Sweatshirt")57await product.locator.click()58await productPage.container.waitFor({ state: "visible" })59await searchModal.open()60await searchModal.close()61await expect(productPage.container).toBeVisible()62})63
64await test.step("Navigate to the login page and open and close search modal", async () => {65await loginPage.goto()66await searchModal.open()67await searchModal.close()68await expect(loginPage.container).toBeVisible()69})70})71})72