-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b30aca
commit 7e9fa94
Showing
9 changed files
with
264 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
4 changes: 2 additions & 2 deletions
4
tests-e2e/fixtures/MagentoBackOffice.js → tests-e2e/fixtures/base/BackOffice.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { CheckoutPage as BaseCheckoutPage } from "playwright-fixture-for-plugins"; | ||
|
||
/** | ||
* Checkout page | ||
*/ | ||
export default class CheckoutPage extends BaseCheckoutPage { | ||
|
||
/** | ||
* Init the locators with the locators available | ||
* | ||
* @returns {Object} | ||
*/ | ||
initLocators() { | ||
return { | ||
// ...super.initLocators(), | ||
// messageSuccess: () => this.page.locator('.message-success'), | ||
loader: () => this.page.locator('.loading-mask', { state: 'visible' }), | ||
email: () => this.page.locator('#customer-email'), | ||
firstName: () => this.page.locator('[name=firstname]'), | ||
lastName: () => this.page.locator('[name=lastname]'), | ||
// locator for selector [name="street[0]"] | ||
address1: () => this.page.locator('[name="street[0]"]'), | ||
country: () => this.page.locator('[name=country_id]'), | ||
state: () => this.page.locator('[name=region_id]'), | ||
city: () => this.page.locator('[name=city]'), | ||
postcode: () => this.page.locator('[name=postcode]'), | ||
phone: () => this.page.locator('[name=telephone]'), | ||
flatRateShipping: () => this.page.locator('[value="flatrate_flatrate"]'), | ||
continueButton: () => this.page.locator('.action.continue'), | ||
}; | ||
} | ||
|
||
/** | ||
* Provide the checkout URL | ||
* @param {Object} options | ||
* @returns {string} The checkout URL | ||
*/ | ||
checkoutUrl(options = {}) { | ||
return `${this.baseURL}/checkout/`; | ||
} | ||
|
||
/** | ||
* Fill the checkout page's form | ||
* @param {Object} options Contains the data to fill the form | ||
* @param {string} options.email Email | ||
* @param {string} options.firstName First name | ||
* @param {string} options.lastName Last name | ||
* @param {string} options.address1 Address first line | ||
* @param {string} options.country Typically a 2-letter ISO country code | ||
* @param {string} options.state Name of the state | ||
* @param {string} options.city Name of the city | ||
* @param {string} options.postcode Postcode | ||
* @param {string} options.phone Phone number | ||
* @param {string} options.shippingMethod Shipping method | ||
* @returns {Promise<void>} | ||
*/ | ||
async fillForm(options) { | ||
await this.fillShippingForm(options); | ||
await this.selectShippingMethod(options); | ||
await this.locators.continueButton().click(); | ||
// TODO: Implement the form filling | ||
} | ||
|
||
/** | ||
* Fill the shipping form | ||
* @param {Object} options | ||
* @param {string} options.email Email | ||
* @param {string} options.firstName First name | ||
* @param {string} options.lastName Last name | ||
* @param {string} options.address1 Address first line | ||
* @param {string} options.country Typically a 2-letter ISO country code | ||
* @param {string} options.state Name of the state | ||
* @param {string} options.city Name of the city | ||
* @param {string} options.postcode Postcode | ||
* @param {string} options.phone Phone number | ||
* @returns {Promise<void>} | ||
*/ | ||
async fillShippingForm(options) { | ||
await this.page.waitForURL(/#shipping/); | ||
await this.#waitForFinishLoading(); | ||
const { email, firstName, lastName, address1, country, state, city, postcode, phone } = options; | ||
// TODO: Implement the form filling | ||
await this.locators.email().fill(email); | ||
await this.locators.firstName().fill(firstName); | ||
await this.locators.lastName().fill(lastName); | ||
await this.locators.address1().fill(address1); | ||
await this.locators.country().selectOption(country); | ||
await this.locators.state().selectOption({ label: state }); | ||
await this.locators.city().fill(city); | ||
await this.locators.postcode().fill(postcode); | ||
await this.locators.phone().fill(phone); | ||
} | ||
|
||
/** | ||
* Select the shipping method | ||
* @param {Object} options | ||
* @param {string} options.shippingMethod Shipping method | ||
* @returns {Promise<void>} | ||
*/ | ||
async selectShippingMethod(options) { | ||
await this.page.waitForURL(/#shipping/); | ||
const { shippingMethod } = options; | ||
// TODO: Implement the method selection | ||
await this.#waitForFinishLoading(); | ||
this.locators.flatRateShipping().click(); | ||
} | ||
|
||
/** | ||
* Wait for the checkout to finish loading | ||
* @returns {Promise<void>} | ||
*/ | ||
async #waitForFinishLoading() { | ||
do { | ||
await this.expect(this.locators.loader().first()).toBeHidden(); | ||
} while ((await this.locators.loader()) > 0); | ||
} | ||
} |
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,58 @@ | ||
import { ProductPage as BaseProductPage } from "playwright-fixture-for-plugins"; | ||
|
||
/** | ||
* Product page | ||
*/ | ||
export default class ProductPage extends BaseProductPage { | ||
|
||
/** | ||
* Init the locators with the locators available | ||
* | ||
* @returns {Object} | ||
*/ | ||
initLocators() { | ||
return { | ||
...super.initLocators(), | ||
messageSuccess: () => this.page.locator('.message-success'), | ||
}; | ||
} | ||
|
||
/** | ||
* Provide the product URL | ||
* @param {Object} options | ||
* @param {string} options.slug The product slug | ||
* @returns {string} The product URL | ||
*/ | ||
productUrl(options) { | ||
const { slug } = options; | ||
return `${this.baseURL}/${slug}.html`; | ||
} | ||
|
||
/** | ||
* Provide the locator for the quantity input | ||
* | ||
* @param {Object} options | ||
* @returns {import("@playwright/test").Locator} | ||
*/ | ||
qtyLocator(options = {}) { | ||
return this.page.locator('#qty'); | ||
} | ||
/** | ||
* Provide the locator for adding to cart button | ||
* | ||
* @param {Object} options | ||
* @returns {import("@playwright/test").Locator} | ||
*/ | ||
addToCartLocator(options = {}) { | ||
return this.page.locator('#product-addtocart-button'); | ||
} | ||
|
||
/** | ||
* Wait for the product to be in the cart | ||
* @param {Object} options | ||
* @returns {Promise<void>} | ||
*/ | ||
async expectProductIsInCart(options = {}) { | ||
await this.locators.messageSuccess().waitFor({timeout: 10000}); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
tests-e2e/fixtures/MagentoSeQuraHelper.js → tests-e2e/fixtures/utils/SeQuraHelper.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { test } from '../fixtures/test'; | ||
|
||
test.describe('Product checkout', () => { | ||
|
||
test('All available seQura products appear in the checkout', async ({ helper, dataProvider, productPage, checkoutPage }) => { | ||
// Setup | ||
const { dummy_config } = helper.webhooks; | ||
const shopper = dataProvider.shopper(); | ||
await helper.executeWebhook({ webhook: dummy_config }); // Setup for physical products. | ||
|
||
// Execution | ||
await productPage.addToCart({ slug: 'push-it-messenger-bag', quantity: 1 }); | ||
await checkoutPage.goto(); | ||
await checkoutPage.fillForm(shopper); | ||
// -- | ||
|
||
// await productPage.addToCart({ slug: 'sunglasses', quantity: 1 }); | ||
|
||
// const helper = new SeQuraHelper(request, expect); | ||
// for (const version of ['classic', 'blocks']) { | ||
// await helper.executeWebhook({ webhook: helper.webhooks.CHECKOUT_VERSION, args: [{ name: 'version', value: version }] }); | ||
// await checkoutPage.goto(); | ||
// if (version === 'blocks') { | ||
// await checkoutPage.expectPaymentMethodsBeingReloaded(); | ||
// } | ||
// await checkoutPage.expectI1ToBeVisible(); | ||
// await checkoutPage.expectSp1ToBeVisible(); | ||
// await checkoutPage.expectPp3ToBeVisible(); | ||
// await checkoutPage.expectEducationPopupToWork('100.00'); | ||
// } | ||
}); | ||
|
||
// test('Make a successful payment using any shopper name', async ({ productPage, checkoutPage }) => { | ||
// await checkoutPage.setupForPhysicalProducts(); | ||
// await productPage.addToCart({ slug: 'sunglasses', quantity: 1 }); | ||
|
||
// await checkoutPage.goto(); | ||
// await checkoutPage.fillWithNonSpecialShopperName({}); | ||
// await checkoutPage.expectPaymentMethodsBeingReloaded(); | ||
// await checkoutPage.placeOrderUsingI1({ shopper: 'nonSpecial' }); | ||
// await checkoutPage.waitForOrderSuccess(); | ||
// }); | ||
|
||
// test('Make a 🍊 payment with "Review test approve" names', async ({ productPage, checkoutPage }) => { | ||
// await checkoutPage.setupForPhysicalProducts(); | ||
// await productPage.addToCart({ slug: 'sunglasses', quantity: 1 }); | ||
|
||
// await checkoutPage.goto(); | ||
// await checkoutPage.fillWithReviewTest({}); | ||
// await checkoutPage.expectPaymentMethodsBeingReloaded(); | ||
// await checkoutPage.placeOrderUsingI1({}); | ||
// await checkoutPage.waitForOrderOnHold(); | ||
// await checkoutPage.expectOrderChangeTo({ toStatus: 'wc-processing' }); | ||
// }); | ||
|
||
// test('Make a 🍊 payment with "Review test cancel" names', async ({ productPage, checkoutPage }) => { | ||
// await checkoutPage.setupForPhysicalProducts(); | ||
// await productPage.addToCart({ slug: 'sunglasses', quantity: 1 }); | ||
|
||
// await checkoutPage.goto(); | ||
// await checkoutPage.fillWithReviewTest({ shopper: 'cancel' }); | ||
// await checkoutPage.expectPaymentMethodsBeingReloaded(); | ||
// await checkoutPage.placeOrderUsingI1({}); | ||
// await checkoutPage.waitForOrderOnHold(); | ||
// await checkoutPage.expectOrderChangeTo({ toStatus: 'wc-cancelled' }); | ||
// }); | ||
}); |
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