You are here

public function PromotionTest::testCreatePromotionOfferTypeSelection in Commerce Core 8.2

Tests updating the offer type when creating a promotion.

File

modules/promotion/tests/src/FunctionalJavascript/PromotionTest.php, line 276

Class

PromotionTest
Tests the admin UI for promotions.

Namespace

Drupal\Tests\commerce_promotion\FunctionalJavascript

Code

public function testCreatePromotionOfferTypeSelection() {
  $this
    ->drupalGet('admin/commerce/promotions');
  $this
    ->clickLink('Add promotion');
  $offer_config_xpath = '//div[@data-drupal-selector="edit-offer-0-target-plugin-configuration"]';
  $offer_config_container = $this
    ->xpath($offer_config_xpath);
  $this
    ->assertEmpty($offer_config_container);
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('offer[0][target_plugin_id]', 'order_item_percentage_off');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $offer_config_container = $this
    ->xpath($offer_config_xpath);
  $this
    ->assertNotEmpty($offer_config_container);
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('offer[0][target_plugin_id]', '');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $offer_config_container = $this
    ->xpath($offer_config_xpath);
  $this
    ->assertEmpty($offer_config_container);
}