-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(default-theme): test 2e2 with playwright (#1779)
- Loading branch information
Showing
44 changed files
with
998 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import faker from "faker"; | ||
import { Page, expect } from "@playwright/test"; | ||
|
||
export async function fillRegistrationForm({ page }: { page: Page }) { | ||
await expect(page.locator("#Salutation")).toContainText("Not specified"); | ||
|
||
// Fill [data-testid="registration-first-name-input"] [data-testid="registration-first-name-input"] | ||
await page.fill( | ||
'[data-testid="registration-first-name-input"] [data-testid="registration-first-name-input"]', | ||
faker.name.firstName() | ||
); | ||
|
||
// Fill [data-testid="registration-last-name-input"] [data-testid="registration-last-name-input"] | ||
await page.fill( | ||
'[data-testid="registration-last-name-input"] [data-testid="registration-last-name-input"]', | ||
faker.name.lastName() | ||
); | ||
|
||
// Click [data-testid="guest-registration-checkbox"] div | ||
await page.click('[data-testid="guest-registration-checkbox"] div'); | ||
|
||
// Fill [data-testid="registration-email-input"] [data-testid="registration-email-input"] | ||
await page.fill( | ||
'[data-testid="registration-email-input"] [data-testid="registration-email-input"]', | ||
faker.internet.email() | ||
); | ||
|
||
// Fill [data-testid="registration-street-input"] [data-testid="registration-street-input"] | ||
await page.fill( | ||
'[data-testid="registration-street-input"] [data-testid="registration-street-input"]', | ||
faker.address.streetName() | ||
); | ||
|
||
// Fill [data-testid="registration-zipcode-input"] [data-testid="registration-zipcode-input"] | ||
await page.fill( | ||
'[data-testid="registration-zipcode-input"] [data-testid="registration-zipcode-input"]', | ||
faker.address.zipCode() | ||
); | ||
|
||
// Fill [data-testid="registration-city-input"] [data-testid="registration-city-input"] | ||
await page.fill( | ||
'[data-testid="registration-city-input"] [data-testid="registration-city-input"]', | ||
faker.address.cityName() | ||
); | ||
|
||
// Click [data-testid="register-button"] | ||
await page.click('[data-testid="register-button"]'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { PlaywrightTestConfig } from "@playwright/test"; | ||
|
||
const baseURL = process.env.BASE_URL || "http://localhost:3000"; | ||
console.error("Test for base url: ", baseURL); | ||
const config: PlaywrightTestConfig = { | ||
use: { | ||
baseURL, | ||
}, | ||
timeout: 120000, | ||
retries: 2, | ||
}; | ||
export default config; |
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
packages/default-theme/__e2e__/specs/desktopHappyPathExistingUser.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
test.use({ | ||
viewport: { | ||
width: 1920, | ||
height: 1080, | ||
}, | ||
}); | ||
|
||
test("[DESKTOP] Happy path logged in user", async ({ page, baseURL }) => { | ||
await page.goto('/'); | ||
|
||
await page.click('[data-testid="login-icon"]'); | ||
// Fill [data-testid="email-input"] [data-testid="email-input"] | ||
await page.fill( | ||
'[data-testid="email-input"] [data-testid="email-input"]', | ||
"1d7b9fef36a34367ad02993594db3fc9rlegros@example.com" | ||
); | ||
// Fill [data-testid="password-input"] [data-testid="password-input"] | ||
await page.fill( | ||
'[data-testid="password-input"] [data-testid="password-input"]', | ||
"shopware" | ||
); | ||
// Click [data-testid="submit-login-button"] | ||
await page.click('[data-testid="submit-login-button"]'); | ||
|
||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="top-navigation"] a'), | ||
]); | ||
|
||
await Promise.all([ | ||
page.hover('[data-testid="product-card"]'), | ||
page.click('[data-testid="product-card"] .sf-product-card__add-button'), | ||
]); | ||
|
||
await page.click('[data-testid="cart-icon"]'); | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="goToCheckout-button"]'), | ||
]); | ||
|
||
await page.click( | ||
'[data-testid="checkout-payment-method-Cash-on-delivery"] div' | ||
); | ||
await page.click( | ||
'[data-testid="checkout-payment-method-Cash-on-delivery"] .is-active' | ||
); | ||
|
||
// Click [data-testid="termsAgreementCheckbox"] div | ||
await page.click('[data-testid="termsAgreementCheckbox"] div'); | ||
|
||
// Click [data-testid="place-my-order"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="place-my-order"]'), | ||
]); | ||
|
||
await page.click('h2:has-text("Thank you")'); | ||
}); |
76 changes: 76 additions & 0 deletions
76
packages/default-theme/__e2e__/specs/desktopHappyPathGuestUser.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { test } from "@playwright/test"; | ||
import { fillRegistrationForm } from "../helpers/testHelpers"; | ||
|
||
test.use({ | ||
viewport: { | ||
width: 1920, | ||
height: 1080, | ||
}, | ||
}); | ||
|
||
test("[DESKTOP] Happy path guest user", async ({ page }) => { | ||
// Go to / | ||
await page.goto("/"); | ||
|
||
// Click [data-testid="search-bar"] | ||
await page.click('[data-testid="search-bar"]'); | ||
|
||
// Fill [data-testid="search-bar"] | ||
await page.fill('[data-testid="search-bar"]', "aaa"); | ||
|
||
// Click [data-testid="quicksearch-result"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="quicksearch-result"]'), | ||
]); | ||
|
||
// Click [data-testid="button-addToCart"] | ||
await page.click('[data-testid="button-addToCart"]'); | ||
|
||
// Click [data-testid="cart-icon"] | ||
await page.click('[data-testid="cart-icon"]'); | ||
|
||
// Click text=Total items 1 | ||
await page.click("text=Total items 1"); | ||
|
||
// Click [data-testid="goToCheckout-button"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="goToCheckout-button"]'), | ||
]); | ||
|
||
await fillRegistrationForm({ page }); | ||
|
||
// Click text=Shipping methods | ||
await page.click("text=Shipping methods"); | ||
|
||
await page.click( | ||
'[data-testid="checkout-payment-method-Cash-on-delivery"] div' | ||
); | ||
await page.click( | ||
'[data-testid="checkout-payment-method-Cash-on-delivery"] .is-active' | ||
); | ||
|
||
// Check if we can submit order without agreeing to Terms | ||
// Click [data-testid="place-my-order"] | ||
await page.click('[data-testid="place-my-order"]'); | ||
// Click text=This field is required | ||
await page.click("text=This field is required"); | ||
// Click [data-testid="termsAgreementCheckbox"] div | ||
await page.click('[data-testid="termsAgreementCheckbox"] div'); | ||
|
||
// Click [data-testid="place-my-order"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="place-my-order"]'), | ||
]); | ||
|
||
// Click h2:has-text("Thank you") | ||
await page.click('h2:has-text("Thank you")'); | ||
|
||
// Click text=Payment method Cash on delivery | ||
await page.click("text=Payment method Cash on delivery"); | ||
|
||
// Close page | ||
await page.close(); | ||
}); |
File renamed without changes.
74 changes: 74 additions & 0 deletions
74
packages/default-theme/__e2e__/specs/mobileHappyPathGuestUser.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { test } from "@playwright/test"; | ||
import { fillRegistrationForm } from "../helpers/testHelpers"; | ||
|
||
test.use({ | ||
viewport: { | ||
width: 320, | ||
height: 480, | ||
}, | ||
}); | ||
|
||
test("[MOBILE] Happy path guest user", async ({ page }) => { | ||
// Go to / | ||
await page.goto("/"); | ||
|
||
// Click [data-testid="search-bar"] | ||
await page.click('[data-testid="search-bar"]'); | ||
|
||
// Fill [data-testid="search-bar"] | ||
await page.fill('[data-testid="search-bar"]', "aaa"); | ||
|
||
// Press Enter | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.press('[data-testid="search-bar"]', "Enter"), | ||
]); | ||
|
||
// Click img[alt="Levis X-star Wars Galaxy Far Away Pullover Hoodie Junior"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="product-card"] img'), | ||
]); | ||
|
||
// Click [data-testid="button-addToCart"] | ||
await page.click('[data-testid="button-addToCart"]'); | ||
|
||
// Click [aria-label="Go to Cart"] | ||
await page.click('[aria-label="Go to Cart"]'); | ||
|
||
// Click [data-testid="goToCheckout-button"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="goToCheckout-button"]'), | ||
]); | ||
|
||
await fillRegistrationForm({ page }); | ||
|
||
// Click text=Shipping methods | ||
await page.click("text=Shipping methods"); | ||
|
||
await page.click( | ||
'[data-testid="checkout-payment-method-Cash-on-delivery"] div' | ||
); | ||
await page.click( | ||
'[data-testid="checkout-payment-method-Cash-on-delivery"] .is-active' | ||
); | ||
|
||
// Click [data-testid="termsAgreementCheckbox"] div | ||
await page.click('[data-testid="termsAgreementCheckbox"] div'); | ||
|
||
// Click [data-testid="place-my-order"] | ||
await Promise.all([ | ||
page.waitForNavigation(), | ||
page.click('[data-testid="place-my-order"]'), | ||
]); | ||
|
||
// Click h2:has-text("Thank you") | ||
await page.click('h2:has-text("Thank you")'); | ||
|
||
// Click text=Payment method Cash on delivery | ||
await page.click("text=Payment method Cash on delivery"); | ||
|
||
// Close page | ||
await page.close(); | ||
}); |
File renamed without changes.
Oops, something went wrong.