diff --git a/core/modules/workflows/tests/src/FunctionalJavascript/WorkflowEditFormTest.php b/core/modules/workflows/tests/src/FunctionalJavascript/WorkflowEditFormTest.php index 0dc87fe..dbafff9 100644 --- a/core/modules/workflows/tests/src/FunctionalJavascript/WorkflowEditFormTest.php +++ b/core/modules/workflows/tests/src/FunctionalJavascript/WorkflowEditFormTest.php @@ -47,7 +47,8 @@ public function setUp() { * Test states operations uses a modal dialog. */ public function testWorkflowStatesForm() { - $this->drupalGet('admin/config/workflow/workflows/manage/test'); + $path = 'admin/config/workflow/workflows/manage/test'; + $this->drupalGet($path); // Assert that the state edit form is displayed in a modal. $this->click('[data-drupal-selector="edit-states-draft-operations"] a:contains(Edit)'); @@ -66,6 +67,19 @@ public function testWorkflowStatesForm() { $this->click('.ui-dialog-buttonpane button:contains(Cancel)'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertFalse($modal->isVisible(), 'Modal window closed.'); + // Assert that saving the state saves the state and that we are stil at the + // same path. + $this->click('[data-drupal-selector="edit-states-draft-operations"] a:contains(Edit)'); + $this->assertSession()->assertWaitOnAjaxRequest(); + $input = $this->assertSession()->elementExists('css', '#drupal-modal .form-item-label input[name="label"]'); + $input->setValue('Drafty'); + $save_button = $this->assertSession()->waitForElementVisible('css', '.ui-dialog-buttonpane .button--primary'); + $this->assertTrue($save_button->isVisible(), 'Save button found.'); + $save_button->click(); + $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->addressEquals($path); + $this->assertSession()->pageTextContains('Saved Drafty state.'); + // Assert that the state delete form is displayed in a modal. $this->click('[data-drupal-selector="edit-states-draft"] .dropbutton-toggle button'); @@ -81,15 +95,32 @@ public function testWorkflowStatesForm() { $this->click('.ui-dialog-buttonpane button:contains(Cancel)'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertFalse($modal->isVisible(), 'Modal window closed.'); + // Assert that deleting the state deletes the state and that we are stil at + // the same path. + $this->drupalGet($path); + $this->click('[data-drupal-selector="edit-states-draft"] .dropbutton-toggle button'); + $delete_button = $this->assertSession()->waitForElementVisible('css', '[data-drupal-selector="edit-states-draft"] a:contains(Delete)'); + $this->assertTrue($delete_button->isVisible(), 'Delete state button found.'); + $delete_button->click(); + $this->assertSession()->assertWaitOnAjaxRequest(); + $modal = $this->assertSession()->waitForElementVisible('css', '#drupal-modal'); + $this->assertTrue($modal->isVisible(), 'Modal window found.'); + $delete_button = $this->assertSession()->waitForElementVisible('css', '.ui-dialog-buttonpane .button--primary'); + $this->assertTrue($save_button->isVisible(), 'Delete button found.'); + $delete_button->click(); + $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->addressEquals($path); + $this->assertSession()->pageTextContains('State Drafty deleted.'); } /** * Test transitions operations uses a modal dialog. */ public function testWorkflowTransitionsForm() { - $this->drupalGet('admin/config/workflow/workflows/manage/test'); + $path = 'admin/config/workflow/workflows/manage/test'; + $this->drupalGet($path); - // Assert that the state edit form is displayed in a modal. + // Assert that the transition edit form is displayed in a modal. $this->click('[data-drupal-selector="edit-transitions-publish-operations"] a:contains(Edit)'); $this->assertSession()->assertWaitOnAjaxRequest(); $modal = $this->assertSession()->waitForElementVisible('css', '#drupal-modal'); @@ -113,6 +144,25 @@ public function testWorkflowTransitionsForm() { $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertFalse($modal->isVisible(), 'Modal window closed.'); + // Assert that saving the transition saves the transition and that we are + // stil at the same path. + $this->click('[data-drupal-selector="edit-transitions-publish-operations"] a:contains(Edit)'); + $this->assertSession()->assertWaitOnAjaxRequest(); + $modal = $this->assertSession()->waitForElementVisible('css', '#drupal-modal'); + $this->assertTrue($modal->isVisible(), 'Modal window found.'); + // Assert that the form errors are displayed in the modal. + // Empty the Label text input which is required. + $label_input = $this->assertSession()->elementExists('css', '#drupal-modal .form-item-label input[name="label"]'); + $label_input->setValue('Publishedlicius'); + $save_button = $this->assertSession()->waitForElementVisible('css', '.ui-dialog-buttonpane .button--primary'); + $this->assertTrue($save_button->isVisible(), 'Save button found.'); + $save_button->click(); + $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->addressEquals($path); + $this->assertSession()->pageTextContains('Saved Publishedlicius transition.'); + + + // Assert that the transition delete form is displayed in a modal. $this->click('[data-drupal-selector="edit-transitions-create-new-draft"] .dropbutton-toggle button'); $delete_button = $this->assertSession()->waitForElementVisible('css', '[data-drupal-selector="edit-transitions-create-new-draft"] a:contains(Delete)'); @@ -126,6 +176,20 @@ public function testWorkflowTransitionsForm() { $this->click('.ui-dialog-buttonpane button:contains(Cancel)'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertFalse($modal->isVisible(), 'Modal window closed.'); + + // Assert that deleting the transition deletes the transition and that we + // are stil at the same path. + $this->drupalGet($path); + $this->click('[data-drupal-selector="edit-transitions-create-new-draft"] .dropbutton-toggle button'); + $delete_button = $this->assertSession()->waitForElementVisible('css', '[data-drupal-selector="edit-transitions-create-new-draft"] a:contains(Delete)'); + $this->assertTrue($delete_button->isVisible(), 'Delete transition button found.'); + $delete_button->click(); + $delete_button = $this->assertSession()->waitForElementVisible('css', '.ui-dialog-buttonpane .button--primary'); + $this->assertTrue($save_button->isVisible(), 'Delete button found.'); + $delete_button->click(); + $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->addressEquals($path); + $this->assertSession()->pageTextContains('Create New Draft transition deleted.'); } }