diff --git a/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_more_page.spec.js b/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_more_page.spec.js new file mode 100644 index 000000000..86a053cc8 --- /dev/null +++ b/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_more_page.spec.js @@ -0,0 +1,127 @@ +import { + addProduct, + chooseRestaurant, + closeRestaurantForToday, + connectToLocalInstance, + connectToSandbox, + launchApp, + symfonyConsole, +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; + +//FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) +describeif(device.getPlatform() === 'android')( + 'checkout for customer guest user; Time range changed modal', + () => { + beforeEach(async () => { + await launchApp(); + + if (device.getPlatform() === 'android') { + symfonyConsole( + 'coopcycle:fixtures:load -f cypress/fixtures/checkout.yml', + ); + symfonyConsole( + 'craue:setting:create --section="general" --name="guest_checkout_enabled" --value="1" --force', + ); + await connectToLocalInstance(); + } else { + //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) + await connectToSandbox(); + } + + // Enter address + await waitFor(element(by.id('askAddressAutocomplete'))) + .toExist() + .withTimeout(5000); + await element(by.id('askAddressAutocomplete')).typeText( + '91 rue de rivoli paris', + ); + await element(by.id('placeId:ChIJQ4sJbyFu5kcRbp6Sp6NLnog')).tap(); + + // List of restaurants + await expect(element(by.id('restaurantList'))).toBeVisible(); + await chooseRestaurant('Restaurant with cash on delivery'); + + // Restaurant page + await waitFor(element(by.id('restaurantData'))) + .toExist() + .withTimeout(5000); + await waitFor(element(by.id('menuItem:0:0'))) + .toExist() + .withTimeout(5000); + + // Add item + await addProduct('menuItem:0:0'); + + // Check if footer is present + await waitFor(element(by.id('cartFooter'))) + .toExist() + .withTimeout(5000); + await expect(element(by.id('cartFooter'))).toBeVisible(); + + // Add 2 more items + await addProduct('menuItem:0:1'); + await addProduct('menuItem:1:0'); + + await waitFor(element(by.id('cartSubmit'))) + .toBeVisible() + .withTimeout(5000); + await element(by.id('cartSubmit')).tap(); + }); + + describe('restaurant was closed while the customer had been on the More page', () => { + it(`should suggest to choose a new time range (Timing modal)`, async () => { + // Cart summary page + await element(by.id('cartSummarySubmit')).tap(); + + // Authentication page + await expect(element(by.id('loginUsername'))).toBeVisible(); + + try { + await element(by.id('guestCheckoutButton')).tap(); + } catch (e) {} + + // More infos page + await expect(element(by.id('guestCheckoutEmail'))).toBeVisible(); + await expect(element(by.id('checkoutTelephone'))).toBeVisible(); + await expect(element(by.id('moreInfosSubmit'))).toBeVisible(); + + await element(by.id('guestCheckoutEmail')).typeText( + 'e2e-mobile@demo.coopcycle.org', + ); + + // Append "\n" to make sure virtual keybord is hidden after entry + // https://github.com/wix/detox/issues/209 + await element(by.id('checkoutTelephone')).typeText('0612345678'); + await element(by.id('checkoutTelephone')).typeText('\n'); + + await closeRestaurantForToday( + 'restaurant_with_cash_on_delivery_owner', + '12345678', + ); + + await element(by.id('moreInfosSubmit')).tap(); + + // Time range changed modal + await waitFor(element(by.id('timeRangeChangedModal'))) + .toBeVisible() + .withTimeout(5000); + // Select a shipping time range + await element(by.id('setShippingTimeRange')).tap(); + + await element(by.id('moreInfosSubmit')).tap(); + + // Payment picker page + await expect( + element(by.id('paymentMethod-cash_on_delivery')), + ).toBeVisible(); + await element(by.id('paymentMethod-cash_on_delivery')).tap(); + + // Cash on delivery page + await waitFor(element(by.id('cashOnDeliverySubmit'))) + .toExist() + .withTimeout(5000); + }); + }); + }, +); diff --git a/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant.spec.js b/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_payment_page.spec.js similarity index 59% rename from e2e/foodtech/checkout/customer__guest/failure__closed_restaurant.spec.js rename to e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_payment_page.spec.js index 75c4d8a16..c425d319e 100644 --- a/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant.spec.js +++ b/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_payment_page.spec.js @@ -6,8 +6,8 @@ import { connectToSandbox, launchApp, symfonyConsole, -} from '../../../support/commands'; -import { describeif } from '../../../utils'; +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) describeif(device.getPlatform() === 'android')( @@ -69,84 +69,6 @@ describeif(device.getPlatform() === 'android')( await element(by.id('cartSubmit')).tap(); }); - describe('restaurant was closed while the customer had been on the Summary page', () => { - it(`should suggest to choose a new time range (Timing modal)`, async () => { - // Cart summary page - - await closeRestaurantForToday( - 'restaurant_with_cash_on_delivery_owner', - '12345678', - ); - - await element(by.id('cartSummarySubmit')).tap(); - - // Time range changed modal - await waitFor(element(by.id('timeRangeChangedModal'))) - .toBeVisible() - .withTimeout(5000); - // Select a shipping time range - await element(by.id('setShippingTimeRange')).tap(); - - await element(by.id('cartSummarySubmit')).tap(); - - // Authentication page - await expect(element(by.id('loginUsername'))).toBeVisible(); - }); - }); - - describe('restaurant was closed while the customer had been on the More page', () => { - it(`should suggest to choose a new time range (Timing modal)`, async () => { - // Cart summary page - await element(by.id('cartSummarySubmit')).tap(); - - // Authentication page - await expect(element(by.id('loginUsername'))).toBeVisible(); - - try { - await element(by.id('guestCheckoutButton')).tap(); - } catch (e) {} - - // More infos page - await expect(element(by.id('guestCheckoutEmail'))).toBeVisible(); - await expect(element(by.id('checkoutTelephone'))).toBeVisible(); - await expect(element(by.id('moreInfosSubmit'))).toBeVisible(); - - await element(by.id('guestCheckoutEmail')).typeText( - 'e2e-mobile@demo.coopcycle.org', - ); - - // Append "\n" to make sure virtual keybord is hidden after entry - // https://github.com/wix/detox/issues/209 - await element(by.id('checkoutTelephone')).typeText('0612345678'); - await element(by.id('checkoutTelephone')).typeText('\n'); - - await closeRestaurantForToday( - 'restaurant_with_cash_on_delivery_owner', - '12345678', - ); - - await element(by.id('moreInfosSubmit')).tap(); - - // Time range changed modal - await waitFor(element(by.id('timeRangeChangedModal'))) - .toBeVisible() - .withTimeout(5000); - // Select a shipping time range - await element(by.id('setShippingTimeRange')).tap(); - - await element(by.id('moreInfosSubmit')).tap(); - - // Payment picker page - await expect( - element(by.id('paymentMethod-cash_on_delivery')), - ).toBeVisible(); - await element(by.id('paymentMethod-cash_on_delivery')).tap(); - - // Cash on delivery page - await waitFor(element(by.id('cashOnDeliverySubmit'))).toExist().withTimeout(5000); - }); - }); - describe('restaurant was closed while the customer had been on the Payment page', () => { it(`should suggest to choose a new time range (Timing modal)`, async () => { // Cart summary page @@ -182,7 +104,9 @@ describeif(device.getPlatform() === 'android')( await element(by.id('paymentMethod-cash_on_delivery')).tap(); // Cash on delivery page - await waitFor(element(by.id('cashOnDeliverySubmit'))).toExist().withTimeout(5000); + await waitFor(element(by.id('cashOnDeliverySubmit'))) + .toExist() + .withTimeout(5000); await closeRestaurantForToday( 'restaurant_with_cash_on_delivery_owner', diff --git a/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_summary_page.spec.js b/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_summary_page.spec.js new file mode 100644 index 000000000..209dfdaec --- /dev/null +++ b/e2e/foodtech/checkout/customer__guest/failure__closed_restaurant/on_summary_page.spec.js @@ -0,0 +1,97 @@ +import { + addProduct, + chooseRestaurant, + closeRestaurantForToday, + connectToLocalInstance, + connectToSandbox, + launchApp, + symfonyConsole, +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; + +//FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) +describeif(device.getPlatform() === 'android')( + 'checkout for customer guest user; Time range changed modal', + () => { + beforeEach(async () => { + await launchApp(); + + if (device.getPlatform() === 'android') { + symfonyConsole( + 'coopcycle:fixtures:load -f cypress/fixtures/checkout.yml', + ); + symfonyConsole( + 'craue:setting:create --section="general" --name="guest_checkout_enabled" --value="1" --force', + ); + await connectToLocalInstance(); + } else { + //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) + await connectToSandbox(); + } + + // Enter address + await waitFor(element(by.id('askAddressAutocomplete'))) + .toExist() + .withTimeout(5000); + await element(by.id('askAddressAutocomplete')).typeText( + '91 rue de rivoli paris', + ); + await element(by.id('placeId:ChIJQ4sJbyFu5kcRbp6Sp6NLnog')).tap(); + + // List of restaurants + await expect(element(by.id('restaurantList'))).toBeVisible(); + await chooseRestaurant('Restaurant with cash on delivery'); + + // Restaurant page + await waitFor(element(by.id('restaurantData'))) + .toExist() + .withTimeout(5000); + await waitFor(element(by.id('menuItem:0:0'))) + .toExist() + .withTimeout(5000); + + // Add item + await addProduct('menuItem:0:0'); + + // Check if footer is present + await waitFor(element(by.id('cartFooter'))) + .toExist() + .withTimeout(5000); + await expect(element(by.id('cartFooter'))).toBeVisible(); + + // Add 2 more items + await addProduct('menuItem:0:1'); + await addProduct('menuItem:1:0'); + + await waitFor(element(by.id('cartSubmit'))) + .toBeVisible() + .withTimeout(5000); + await element(by.id('cartSubmit')).tap(); + }); + + describe('restaurant was closed while the customer had been on the Summary page', () => { + it(`should suggest to choose a new time range (Timing modal)`, async () => { + // Cart summary page + + await closeRestaurantForToday( + 'restaurant_with_cash_on_delivery_owner', + '12345678', + ); + + await element(by.id('cartSummarySubmit')).tap(); + + // Time range changed modal + await waitFor(element(by.id('timeRangeChangedModal'))) + .toBeVisible() + .withTimeout(5000); + // Select a shipping time range + await element(by.id('setShippingTimeRange')).tap(); + + await element(by.id('cartSummarySubmit')).tap(); + + // Authentication page + await expect(element(by.id('loginUsername'))).toBeVisible(); + }); + }); + }, +); diff --git a/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_more_page.spec.js b/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_more_page.spec.js new file mode 100644 index 000000000..7f8af0ccd --- /dev/null +++ b/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_more_page.spec.js @@ -0,0 +1,120 @@ +import { + addProduct, + chooseRestaurant, + closeRestaurantForToday, + connectToLocalInstance, + connectToSandbox, + launchApp, + symfonyConsole, +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; + +//FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) +describeif(device.getPlatform() === 'android')( + 'checkout for guest user; with validation failures', + () => { + beforeEach(async () => { + await launchApp(); + + if (device.getPlatform() === 'android') { + symfonyConsole( + 'coopcycle:fixtures:load -f cypress/fixtures/checkout.yml', + ); + symfonyConsole( + 'craue:setting:create --section="general" --name="guest_checkout_enabled" --value="1" --force', + ); + await connectToLocalInstance(); + } else { + //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) + await connectToSandbox(); + } + + // Enter address + await waitFor(element(by.id('askAddressAutocomplete'))) + .toExist() + .withTimeout(5000); + await element(by.id('askAddressAutocomplete')).typeText( + '91 rue de rivoli paris', + ); + await element(by.id('placeId:ChIJQ4sJbyFu5kcRbp6Sp6NLnog')).tap(); + + // List of restaurants + await expect(element(by.id('restaurantList'))).toBeVisible(); + await chooseRestaurant('Restaurant with cash on delivery'); + + // Restaurant page + await waitFor(element(by.id('restaurantData'))) + .toExist() + .withTimeout(5000); + await waitFor(element(by.id('menuItem:0:0'))) + .toExist() + .withTimeout(5000); + + // Add item + await addProduct('menuItem:0:0'); + + // Check if footer is present + await waitFor(element(by.id('cartFooter'))) + .toExist() + .withTimeout(5000); + await expect(element(by.id('cartFooter'))).toBeVisible(); + + // Add 2 more items + await addProduct('menuItem:0:1'); + await addProduct('menuItem:1:0'); + + await waitFor(element(by.id('cartSubmit'))) + .toBeVisible() + .withTimeout(5000); + await element(by.id('cartSubmit')).tap(); + + // Cart summary page + // Select a shipping time range + await element(by.id('shippingTimeRangeButton')).tap(); + // Timing modal page + await waitFor(element(by.id('dayPicker'))) + .toBeVisible() + .withTimeout(15000); + await element(by.id('setShippingTimeRange')).tap(); + }); + + describe('shippedAt time range became not valid while the customer had been on the More page', () => { + it(`show an error message (More page)`, async () => { + await element(by.id('cartSummarySubmit')).tap(); + + // Authentication page + await expect(element(by.id('loginUsername'))).toBeVisible(); + + try { + await element(by.id('guestCheckoutButton')).tap(); + } catch (e) {} + + // More infos page + await expect(element(by.id('guestCheckoutEmail'))).toBeVisible(); + await expect(element(by.id('checkoutTelephone'))).toBeVisible(); + await expect(element(by.id('moreInfosSubmit'))).toBeVisible(); + + await element(by.id('guestCheckoutEmail')).typeText( + 'e2e-mobile@demo.coopcycle.org', + ); + + // Append "\n" to make sure virtual keybord is hidden after entry + // https://github.com/wix/detox/issues/209 + await element(by.id('checkoutTelephone')).typeText('0612345678'); + await element(by.id('checkoutTelephone')).typeText('\n'); + + await closeRestaurantForToday( + 'restaurant_with_cash_on_delivery_owner', + '12345678', + ); + + await element(by.id('moreInfosSubmit')).tap(); + + // Error message + await waitFor(element(by.id('globalModal'))) + .toBeVisible() + .withTimeout(5000); + }); + }); + }, +); diff --git a/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid.spec.js b/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_payment_page.spec.js similarity index 67% rename from e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid.spec.js rename to e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_payment_page.spec.js index 3f1e37934..f8cbc7f64 100644 --- a/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid.spec.js +++ b/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_payment_page.spec.js @@ -6,8 +6,8 @@ import { connectToSandbox, launchApp, symfonyConsole, -} from '../../../support/commands'; -import { describeif } from '../../../utils'; +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) describeif(device.getPlatform() === 'android')( @@ -78,61 +78,6 @@ describeif(device.getPlatform() === 'android')( await element(by.id('setShippingTimeRange')).tap(); }); - describe('shippedAt time range became not valid while the customer had been on the Summary page', () => { - it(`show an error message (Summary page)`, async () => { - await closeRestaurantForToday( - 'restaurant_with_cash_on_delivery_owner', - '12345678', - ); - - await element(by.id('cartSummarySubmit')).tap(); - - // Error message - await waitFor(element(by.id('globalModal'))) - .toBeVisible() - .withTimeout(5000); - }); - }); - - describe('shippedAt time range became not valid while the customer had been on the More page', () => { - it(`show an error message (More page)`, async () => { - await element(by.id('cartSummarySubmit')).tap(); - - // Authentication page - await expect(element(by.id('loginUsername'))).toBeVisible(); - - try { - await element(by.id('guestCheckoutButton')).tap(); - } catch (e) {} - - // More infos page - await expect(element(by.id('guestCheckoutEmail'))).toBeVisible(); - await expect(element(by.id('checkoutTelephone'))).toBeVisible(); - await expect(element(by.id('moreInfosSubmit'))).toBeVisible(); - - await element(by.id('guestCheckoutEmail')).typeText( - 'e2e-mobile@demo.coopcycle.org', - ); - - // Append "\n" to make sure virtual keybord is hidden after entry - // https://github.com/wix/detox/issues/209 - await element(by.id('checkoutTelephone')).typeText('0612345678'); - await element(by.id('checkoutTelephone')).typeText('\n'); - - await closeRestaurantForToday( - 'restaurant_with_cash_on_delivery_owner', - '12345678', - ); - - await element(by.id('moreInfosSubmit')).tap(); - - // Error message - await waitFor(element(by.id('globalModal'))) - .toBeVisible() - .withTimeout(5000); - }); - }); - describe('shippedAt time range became not valid while the customer had been on the Payment page', () => { it(`show an error message (Payment page)`, async () => { await element(by.id('cartSummarySubmit')).tap(); @@ -167,7 +112,9 @@ describeif(device.getPlatform() === 'android')( await element(by.id('paymentMethod-cash_on_delivery')).tap(); // Cash on delivery page - await waitFor(element(by.id('cashOnDeliverySubmit'))).toExist().withTimeout(5000); + await waitFor(element(by.id('cashOnDeliverySubmit'))) + .toExist() + .withTimeout(5000); await closeRestaurantForToday( 'restaurant_with_cash_on_delivery_owner', diff --git a/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_summary_page.spec.js b/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_summary_page.spec.js new file mode 100644 index 000000000..f9cfeb0b4 --- /dev/null +++ b/e2e/foodtech/checkout/customer__guest/failure__shipping_time_range_not_valid/on_summary_page.spec.js @@ -0,0 +1,97 @@ +import { + addProduct, + chooseRestaurant, + closeRestaurantForToday, + connectToLocalInstance, + connectToSandbox, + launchApp, + symfonyConsole, +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; + +//FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) +describeif(device.getPlatform() === 'android')( + 'checkout for guest user; with validation failures', + () => { + beforeEach(async () => { + await launchApp(); + + if (device.getPlatform() === 'android') { + symfonyConsole( + 'coopcycle:fixtures:load -f cypress/fixtures/checkout.yml', + ); + symfonyConsole( + 'craue:setting:create --section="general" --name="guest_checkout_enabled" --value="1" --force', + ); + await connectToLocalInstance(); + } else { + //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) + await connectToSandbox(); + } + + // Enter address + await waitFor(element(by.id('askAddressAutocomplete'))) + .toExist() + .withTimeout(5000); + await element(by.id('askAddressAutocomplete')).typeText( + '91 rue de rivoli paris', + ); + await element(by.id('placeId:ChIJQ4sJbyFu5kcRbp6Sp6NLnog')).tap(); + + // List of restaurants + await expect(element(by.id('restaurantList'))).toBeVisible(); + await chooseRestaurant('Restaurant with cash on delivery'); + + // Restaurant page + await waitFor(element(by.id('restaurantData'))) + .toExist() + .withTimeout(5000); + await waitFor(element(by.id('menuItem:0:0'))) + .toExist() + .withTimeout(5000); + + // Add item + await addProduct('menuItem:0:0'); + + // Check if footer is present + await waitFor(element(by.id('cartFooter'))) + .toExist() + .withTimeout(5000); + await expect(element(by.id('cartFooter'))).toBeVisible(); + + // Add 2 more items + await addProduct('menuItem:0:1'); + await addProduct('menuItem:1:0'); + + await waitFor(element(by.id('cartSubmit'))) + .toBeVisible() + .withTimeout(5000); + await element(by.id('cartSubmit')).tap(); + + // Cart summary page + // Select a shipping time range + await element(by.id('shippingTimeRangeButton')).tap(); + // Timing modal page + await waitFor(element(by.id('dayPicker'))) + .toBeVisible() + .withTimeout(15000); + await element(by.id('setShippingTimeRange')).tap(); + }); + + describe('shippedAt time range became not valid while the customer had been on the Summary page', () => { + it(`show an error message (Summary page)`, async () => { + await closeRestaurantForToday( + 'restaurant_with_cash_on_delivery_owner', + '12345678', + ); + + await element(by.id('cartSummarySubmit')).tap(); + + // Error message + await waitFor(element(by.id('globalModal'))) + .toBeVisible() + .withTimeout(5000); + }); + }); + }, +); diff --git a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/more_page.spec.js b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/on_more_page.spec.js similarity index 100% rename from e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/more_page.spec.js rename to e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/on_more_page.spec.js diff --git a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/payment_page.spec.js b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/on_payment_page.spec.js similarity index 100% rename from e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/payment_page.spec.js rename to e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/on_payment_page.spec.js diff --git a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/summary_page.spec.js b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/on_summary_page.spec.js similarity index 100% rename from e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/summary_page.spec.js rename to e2e/foodtech/checkout/customer__role_user__logged_in/failure__closed_restaurant/on_summary_page.spec.js diff --git a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_more_page.spec.js b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_more_page.spec.js new file mode 100644 index 000000000..7b12cdf2f --- /dev/null +++ b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_more_page.spec.js @@ -0,0 +1,108 @@ +import { + addProduct, + authenticateWithCredentials, + chooseRestaurant, + closeRestaurantForToday, + connectToLocalInstance, + connectToSandbox, + launchApp, + symfonyConsole, +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; + +//FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) +describeif(device.getPlatform() === 'android')( + 'checkout for customer with existing account (role - user); logged in; with validation failures', + () => { + beforeEach(async () => { + await launchApp(); + + if (device.getPlatform() === 'android') { + symfonyConsole( + 'coopcycle:fixtures:load -f cypress/fixtures/checkout.yml', + ); + await connectToLocalInstance(); + } else { + //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) + await connectToSandbox(); + } + + await authenticateWithCredentials('bob', '12345678'); + + // Enter address + await waitFor(element(by.id('askAddressAutocomplete'))) + .toExist() + .withTimeout(5000); + await element(by.id('askAddressAutocomplete')).typeText( + '91 rue de rivoli paris', + ); + await element(by.id('placeId:ChIJQ4sJbyFu5kcRbp6Sp6NLnog')).tap(); + + // List of restaurants + await expect(element(by.id('restaurantList'))).toBeVisible(); + await chooseRestaurant('Restaurant with cash on delivery'); + + // Restaurant page + await waitFor(element(by.id('restaurantData'))) + .toExist() + .withTimeout(5000); + await waitFor(element(by.id('menuItem:0:0'))) + .toExist() + .withTimeout(5000); + + // Add item + await addProduct('menuItem:0:0'); + + // Check if footer is present + await waitFor(element(by.id('cartFooter'))) + .toExist() + .withTimeout(5000); + await expect(element(by.id('cartFooter'))).toBeVisible(); + + // Add 2 more items + await addProduct('menuItem:0:1'); + await addProduct('menuItem:1:0'); + + await waitFor(element(by.id('cartSubmit'))) + .toBeVisible() + .withTimeout(5000); + await element(by.id('cartSubmit')).tap(); + + // Cart summary page + // Select a shipping time range + await element(by.id('shippingTimeRangeButton')).tap(); + // Timing modal page + await waitFor(element(by.id('dayPicker'))) + .toBeVisible() + .withTimeout(15000); + await element(by.id('setShippingTimeRange')).tap(); + }); + + describe('shippedAt time range became not valid while the customer had been on the More page', () => { + it(`show an error message (More page)`, async () => { + await element(by.id('cartSummarySubmit')).tap(); + + // More infos page + await expect(element(by.id('checkoutTelephone'))).toBeVisible(); + await expect(element(by.id('moreInfosSubmit'))).toBeVisible(); + + // Append "\n" to make sure virtual keybord is hidden after entry + // https://github.com/wix/detox/issues/209 + await element(by.id('checkoutTelephone')).typeText('0612345678'); + await element(by.id('checkoutTelephone')).typeText('\n'); + + await closeRestaurantForToday( + 'restaurant_with_cash_on_delivery_owner', + '12345678', + ); + + await element(by.id('moreInfosSubmit')).tap(); + + // Error message + await waitFor(element(by.id('globalModal'))) + .toBeVisible() + .withTimeout(5000); + }); + }); + }, +); diff --git a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid.spec.js b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_payment_page.spec.js similarity index 69% rename from e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid.spec.js rename to e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_payment_page.spec.js index 9c9e5c958..cb25fc8bd 100644 --- a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid.spec.js +++ b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_payment_page.spec.js @@ -7,8 +7,8 @@ import { connectToSandbox, launchApp, symfonyConsole, -} from '../../../support/commands'; -import { describeif } from '../../../utils'; +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) describeif(device.getPlatform() === 'android')( @@ -78,49 +78,6 @@ describeif(device.getPlatform() === 'android')( await element(by.id('setShippingTimeRange')).tap(); }); - describe('shippedAt time range became not valid while the customer had been on the Summary page', () => { - it(`show an error message (Summary page)`, async () => { - await closeRestaurantForToday( - 'restaurant_with_cash_on_delivery_owner', - '12345678', - ); - - await element(by.id('cartSummarySubmit')).tap(); - - // Error message - await waitFor(element(by.id('globalModal'))) - .toBeVisible() - .withTimeout(5000); - }); - }); - - describe('shippedAt time range became not valid while the customer had been on the More page', () => { - it(`show an error message (More page)`, async () => { - await element(by.id('cartSummarySubmit')).tap(); - - // More infos page - await expect(element(by.id('checkoutTelephone'))).toBeVisible(); - await expect(element(by.id('moreInfosSubmit'))).toBeVisible(); - - // Append "\n" to make sure virtual keybord is hidden after entry - // https://github.com/wix/detox/issues/209 - await element(by.id('checkoutTelephone')).typeText('0612345678'); - await element(by.id('checkoutTelephone')).typeText('\n'); - - await closeRestaurantForToday( - 'restaurant_with_cash_on_delivery_owner', - '12345678', - ); - - await element(by.id('moreInfosSubmit')).tap(); - - // Error message - await waitFor(element(by.id('globalModal'))) - .toBeVisible() - .withTimeout(5000); - }); - }); - describe('shippedAt time range became not valid while the customer had been on the Payment page', () => { it(`show an error message (Payment page)`, async () => { await element(by.id('cartSummarySubmit')).tap(); @@ -143,7 +100,9 @@ describeif(device.getPlatform() === 'android')( await element(by.id('paymentMethod-cash_on_delivery')).tap(); // Cash on delivery page - await waitFor(element(by.id('cashOnDeliverySubmit'))).toExist().withTimeout(5000); + await waitFor(element(by.id('cashOnDeliverySubmit'))) + .toExist() + .withTimeout(5000); await closeRestaurantForToday( 'restaurant_with_cash_on_delivery_owner', diff --git a/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_summary_page.spec.js b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_summary_page.spec.js new file mode 100644 index 000000000..90634b637 --- /dev/null +++ b/e2e/foodtech/checkout/customer__role_user__logged_in/failure__shipping_time_range_not_valid/on_summary_page.spec.js @@ -0,0 +1,97 @@ +import { + addProduct, + authenticateWithCredentials, + chooseRestaurant, + closeRestaurantForToday, + connectToLocalInstance, + connectToSandbox, + launchApp, + symfonyConsole, +} from '../../../../support/commands'; +import { describeif } from '../../../../utils'; + +//FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) +describeif(device.getPlatform() === 'android')( + 'checkout for customer with existing account (role - user); logged in; with validation failures', + () => { + beforeEach(async () => { + await launchApp(); + + if (device.getPlatform() === 'android') { + symfonyConsole( + 'coopcycle:fixtures:load -f cypress/fixtures/checkout.yml', + ); + await connectToLocalInstance(); + } else { + //FIXME: run against local instance on iOS too (see https://github.com/coopcycle/coopcycle-ops/issues/97) + await connectToSandbox(); + } + + await authenticateWithCredentials('bob', '12345678'); + + // Enter address + await waitFor(element(by.id('askAddressAutocomplete'))) + .toExist() + .withTimeout(5000); + await element(by.id('askAddressAutocomplete')).typeText( + '91 rue de rivoli paris', + ); + await element(by.id('placeId:ChIJQ4sJbyFu5kcRbp6Sp6NLnog')).tap(); + + // List of restaurants + await expect(element(by.id('restaurantList'))).toBeVisible(); + await chooseRestaurant('Restaurant with cash on delivery'); + + // Restaurant page + await waitFor(element(by.id('restaurantData'))) + .toExist() + .withTimeout(5000); + await waitFor(element(by.id('menuItem:0:0'))) + .toExist() + .withTimeout(5000); + + // Add item + await addProduct('menuItem:0:0'); + + // Check if footer is present + await waitFor(element(by.id('cartFooter'))) + .toExist() + .withTimeout(5000); + await expect(element(by.id('cartFooter'))).toBeVisible(); + + // Add 2 more items + await addProduct('menuItem:0:1'); + await addProduct('menuItem:1:0'); + + await waitFor(element(by.id('cartSubmit'))) + .toBeVisible() + .withTimeout(5000); + await element(by.id('cartSubmit')).tap(); + + // Cart summary page + // Select a shipping time range + await element(by.id('shippingTimeRangeButton')).tap(); + // Timing modal page + await waitFor(element(by.id('dayPicker'))) + .toBeVisible() + .withTimeout(15000); + await element(by.id('setShippingTimeRange')).tap(); + }); + + describe('shippedAt time range became not valid while the customer had been on the Summary page', () => { + it(`show an error message (Summary page)`, async () => { + await closeRestaurantForToday( + 'restaurant_with_cash_on_delivery_owner', + '12345678', + ); + + await element(by.id('cartSummarySubmit')).tap(); + + // Error message + await waitFor(element(by.id('globalModal'))) + .toBeVisible() + .withTimeout(5000); + }); + }); + }, +);