Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cart & checkout block tests #104

Merged
merged 9 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e_api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ jobs:

# Override reports path specifically for this job
env:
SYSTEM_INFO: ./tests/pw/all-reports/test-artifact-api/playwright/systemInfo.json
API_TEST_RESULT: ./tests/pw/all-reports/test-artifact-api/playwright-report/api/summary-report/results.json
API_COVERAGE: ./tests/pw/all-reports/test-artifact-api/playwright-report/api/coverage-report/coverage.json
E2E_TEST_RESULT: ./tests/pw/all-reports/merged-summary.json
Expand Down
24 changes: 12 additions & 12 deletions tests/pw/pages/customerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,23 @@ export class CustomerPage extends BasePage {
async updateBillingFields(billingInfo: customer['customerInfo']['billing']) {
await this.clearAndType(customerAddress.billing.firstName, billingInfo.firstName);
await this.clearAndType(customerAddress.billing.lastName, billingInfo.lastName);
await this.clearAndType(customerAddress.billing.companyName, billingInfo.companyName);
if (DOKAN_PRO) {
await this.clearAndType(customerAddress.billing.euFields.companyID, billingInfo.companyId);
await this.clearAndType(customerAddress.billing.euFields.vatOrTaxNumber, billingInfo.vatNumber);
await this.clearAndType(customerAddress.billing.euFields.nameOfBank, billingInfo.bankName);
await this.clearAndType(customerAddress.billing.euFields.bankIban, billingInfo.bankIban);
}
await this.click(customerAddress.billing.countryOrRegion);
await this.clearAndType(customerAddress.billing.countryOrRegionInput, billingInfo.country);
await this.press(data.key.enter);
await this.click(customerAddress.billing.country);
await this.clearAndType(customerAddress.billing.countryInput, billingInfo.country);
await this.click(customerAddress.billing.countryValue(billingInfo.country));
await this.toHaveText(customerAddress.billing.selectedCountry, billingInfo.country);
await this.clearAndType(customerAddress.billing.streetAddress, billingInfo.street1);
await this.clearAndType(customerAddress.billing.streetAddress2, billingInfo.street2);
await this.clearAndType(customerAddress.billing.city, billingInfo.city);
await this.focus(customerAddress.billing.zipCode);
await this.click(customerAddress.billing.state);
await this.clearAndType(customerAddress.billing.stateInput, billingInfo.state);
await this.press(data.key.enter);
await this.click(customerAddress.billing.stateValue(billingInfo.state));
await this.toHaveText(customerAddress.billing.selectedState, billingInfo.state);
await this.clearAndType(customerAddress.billing.zipCode, billingInfo.zipCode);
await this.clearAndType(customerAddress.billing.phone, billingInfo.phone);
await this.clearAndType(customerAddress.billing.email, billingInfo.email);
Expand All @@ -188,17 +188,17 @@ export class CustomerPage extends BasePage {
async updateShippingFields(shippingInfo: customer['customerInfo']['shipping']): Promise<void> {
await this.clearAndType(customerAddress.shipping.firstName, shippingInfo.firstName);
await this.clearAndType(customerAddress.shipping.lastName, shippingInfo.lastName);
await this.clearAndType(customerAddress.shipping.companyName, shippingInfo.companyName);
await this.click(customerAddress.shipping.countryOrRegion);
await this.clearAndType(customerAddress.shipping.countryOrRegionInput, shippingInfo.country);
await this.press(data.key.enter);
await this.click(customerAddress.shipping.country);
await this.clearAndType(customerAddress.shipping.countryInput, shippingInfo.country);
await this.click(customerAddress.shipping.countryValue(shippingInfo.country));
await this.toHaveText(customerAddress.shipping.selectedCountry, shippingInfo.country);
await this.clearAndType(customerAddress.shipping.streetAddress, shippingInfo.street1);
await this.clearAndType(customerAddress.shipping.streetAddress2, shippingInfo.street2);
await this.clearAndType(customerAddress.shipping.city, shippingInfo.city);
await this.focus(customerAddress.shipping.zipCode);
await this.click(customerAddress.shipping.state);
await this.clearAndType(customerAddress.shipping.stateInput, shippingInfo.state);
await this.press(data.key.enter);
await this.click(customerAddress.shipping.stateValue(shippingInfo.state));
await this.toHaveText(customerAddress.shipping.selectedState, shippingInfo.state);
await this.clearAndType(customerAddress.shipping.zipCode, shippingInfo.zipCode);
}

Expand Down
31 changes: 19 additions & 12 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6913,22 +6913,25 @@ export const selector = {
editBillingAddress: '//h3[contains(text(),"Billing address")]/..//a[@class="edit"]',
firstName: '#billing_first_name',
lastName: '#billing_last_name',
companyName: '#billing_company',
euFields: {
companyID: '#billing_dokan_company_id_number',
vatOrTaxNumber: '#billing_dokan_vat_number',
nameOfBank: '#billing_dokan_bank_name',
bankIban: '#billing_dokan_bank_iban',
},
countryOrRegion: '(//span[@class="select2-selection__arrow"])[1]',
countryOrRegionInput: '.select2-search.select2-search--dropdown .select2-search__field',
countryOrRegionValues: '.select2-results ul li',
country: '//select[@id="billing_country"]/..//span[@class="select2-selection__arrow"]',
countryInput: '.select2-search.select2-search--dropdown .select2-search__field',
countryValues: '.select2-results ul li',
countryValue: (country: string) => `//li[contains(@class,"select2-results__option") and normalize-space(text())="${country}"]`,
selectedCountry: '//span[@id="select2-billing_country-container"]',
streetAddress: '#billing_address_1',
streetAddress2: '#billing_address_2',
city: '#billing_city',
state: '(//span[@class="select2-selection__arrow"])[2]',
state: '//select[@id="billing_state"]/..//span[@class="select2-selection__arrow"]',
stateInput: '.select2-search.select2-search--dropdown .select2-search__field',
stateValues: '.select2-results ul li',
stateValue: (state: string) => `//li[contains(@class,"select2-results__option")and normalize-space(text())="${state}"]`,
selectedState: '//span[@id="select2-billing_state-container"]',
zipCode: '#billing_postcode',
phone: '#billing_phone',
email: '#billing_email',
Expand All @@ -6942,16 +6945,19 @@ export const selector = {
editShippingAddress: '//h3[contains(text(),"Shipping address")]/..//a[@class="edit"]',
firstName: '#shipping_first_name',
lastName: '#shipping_last_name',
companyName: '#shipping_company',
countryOrRegion: '(//span[@class="select2-selection__arrow"])[1]',
countryOrRegionInput: '.select2-search.select2-search--dropdown .select2-search__field',
countryOrRegionValues: '.select2-results ul li',
country: '//select[@id="shipping_country"]/..//span[@class="select2-selection__arrow"]',
countryInput: '.select2-search.select2-search--dropdown .select2-search__field',
countryValues: '.select2-results ul li',
countryValue: (country: string) => `//li[contains(@class,"select2-results__option") and normalize-space(text())="${country}"]`,
selectedCountry: '//span[@id="select2-shipping_country-container"]',
streetAddress: '#shipping_address_1',
streetAddress2: '#shipping_address_2',
city: '#shipping_city',
state: '(//span[@class="select2-selection__arrow"])[2]',
state: '//select[@id="shipping_state"]/..//span[@class="select2-selection__arrow"]',
stateInput: '.select2-search.select2-search--dropdown .select2-search__field',
stateValues: '.select2-results ul li',
stateValue: (state: string) => `//li[contains(@class,"select2-results__option")and normalize-space(text())="${state}"]`,
selectedState: '//span[@id="select2-shipping_state-container"]',
zipCode: '#shipping_postcode',
saveAddress: '//button[@name="save_address"]',

Expand Down Expand Up @@ -8038,8 +8044,9 @@ export const selector = {
deliveryTimeInputHidden: '//input[@class="delivery-time-date-picker flatpickr-input"]',
deliveryDate: (date: string) => `//div[contains(@class,"flatpickr-calendar animate open")]//div[@class="dayContainer"]//span[contains(@class,"flatpickr-day") and @aria-label="${date}"]`,

timePicker: 'select.delivery-time-slot-picker',
locationPicker: 'select.delivery-store-location-picker',
timePicker: '//option[normalize-space()="Select time slot"]/..',
locationPicker: '//option[normalize-space()="Select store location"]/..',
storeLocation: 'div.store-address.vendor-info',

orderDetails: {
deliveryTimeDetails: 'div#dokan-delivery-time-slot-order-details',
Expand Down
7 changes: 4 additions & 3 deletions tests/pw/pages/vendorDeliveryTimePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,16 @@ export class VendorDeliveryTimePage extends CustomerPage {
await this.click(deliveryTimeCustomer.delivery);
await this.click(deliveryTimeCustomer.deliveryTimeInput);
await this.clickAndWaitForResponse(data.subUrls.api.dokan.deliveryTime, deliveryTimeCustomer.deliveryDate(deliveryTime.date));
await this.selectByNumber(deliveryTimeCustomer.timePicker, 1);
await this.selectByNumber(deliveryTimeCustomer.timePicker, 0);
break;

case 'store-pickup':
await this.click(deliveryTimeCustomer.storePickup);
await this.click(deliveryTimeCustomer.deliveryTimeInput);
await this.clickAndWaitForResponse(data.subUrls.api.dokan.deliveryTime, deliveryTimeCustomer.deliveryDate(deliveryTime.date));
await this.selectByNumber(deliveryTimeCustomer.timePicker, 1);
await this.selectByNumber(deliveryTimeCustomer.locationPicker, 1);
await this.selectByNumber(deliveryTimeCustomer.timePicker, 0);
await this.selectByNumber(deliveryTimeCustomer.locationPicker, 0);
await this.toBeVisible(deliveryTimeCustomer.storeLocation);
break;

default:
Expand Down
4 changes: 4 additions & 0 deletions tests/pw/tests/api/_env.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ setup.describe('setup woocommerce settings', () => {
await apiUtils.dispose();
});

setup('set woocommerce site visibility settings', { tag: ['@lite'] }, async () => {
await dbUtils.setOptionValue('woocommerce_coming_soon', 'no', false);
});

setup('set woocommerce settings', { tag: ['@lite'] }, async () => {
await apiUtils.updateBatchWcSettingsOptions('general', payloads.general);
await apiUtils.updateBatchWcSettingsOptions('account', payloads.account);
Expand Down
4 changes: 4 additions & 0 deletions tests/pw/tests/e2e/_env.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ setup.describe('setup woocommerce settings', () => {
await apiUtils.dispose();
});

setup('set woocommerce site visibility settings', { tag: ['@lite'] }, async () => {
await dbUtils.setOptionValue('woocommerce_coming_soon', 'no', false);
});

setup('set woocommerce settings', { tag: ['@lite'] }, async () => {
await apiUtils.updateBatchWcSettingsOptions('general', payloads.general);
await apiUtils.updateBatchWcSettingsOptions('account', payloads.account);
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/customer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ test.describe('Customer functionality test', () => {
await customer.customerBecomeVendor(data.customer.customerInfo);
});

test('customer can add billing details', { tag: ['@lite', '@customer'] }, async () => {
test.skip('customer can add billing details', { tag: ['@lite', '@customer'] }, async () => {
await customer.addBillingAddress(data.customer.customerInfo.billing);
});

test('customer can add shipping details', { tag: ['@lite', '@customer'] }, async () => {
test.skip('customer can add shipping details', { tag: ['@lite', '@customer'] }, async () => {
await customer.addShippingAddress(data.customer.customerInfo.shipping);
});

Expand Down
3 changes: 0 additions & 3 deletions tests/pw/tests/e2e/vendorDeliveryTime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,11 @@ test.describe('Vendor delivery time test', () => {
// customer

test('customer can buy product with delivery time', { tag: ['@pro', '@customer'] }, async () => {
test.skip(true, 'run when chart & checkout block pr is merged');
await customer.addProductToCart(data.predefined.simpleProduct.product1.name, 'single-product');
await customer.placeOrderWithDeliverTimeStorePickup('delivery-time', data.deliveryTime);
});

test('customer can buy product with store pickup', { tag: ['@pro', '@customer'] }, async () => {
test.skip(true, 'run when chart & checkout block pr is merged');
await dbUtils.setOptionValue(dbData.dokan.optionName.deliveryTime, { ...dbData.dokan.deliveryTimeSettings, allow_vendor_override_settings: 'off' }); // todo: resolve: previous test disable store pickup
await customer.addProductToCart(data.predefined.simpleProduct.product1.name, 'single-product');
await customer.placeOrderWithDeliverTimeStorePickup('store-pickup', data.deliveryTime);
});
Expand Down
Loading