Skip to content

Commit ed3c319

Browse files
author
Sabina Talipova
committed
MNT New Behat tests for toast messages
1 parent 8e6ffcf commit ed3c319

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

code/LeftAndMain.php

+5
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ public function redirect($url, $code = 302)
864864
if ($this->getRequest()->isAjax()) {
865865
$response = $this->getResponse();
866866
$response->addHeader('X-ControllerURL', $url);
867+
868+
/** Since in some cases we need to pass additional headers,
869+
* but we lose these headers (X-Pjax and X-Status) when we set new response
870+
* we should explicitly add them again from received request.
871+
**/
867872
if ($this->getRequest()->getHeader('X-Pjax') && !$response->getHeader('X-Pjax')) {
868873
$response->addHeader('X-Pjax', $this->getRequest()->getHeader('X-Pjax'));
869874
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Feature: Show toast messages
2+
As an author
3+
I want to see toast message in the CMS when I create, edit, delete, publish, unpublish, archive a record
4+
5+
Background:
6+
Given the "Company" "Company A" with "Category"="Other"
7+
And the "Company" "Company B" with "Category"="Other"
8+
And the "Company" "Company C" with "Category"="Other"
9+
And the "Employee" "Employee A" with "Company"="1"
10+
And the "Employee" "Employee B" with "Company"="1"
11+
And the "Employee" "Employee C" with "Company"="1"
12+
And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "Access to 'Test ModelAdmin' section" and "TEST_DATAOBJECT_EDIT"
13+
And I am logged in as a member of "EDITOR" group
14+
And I go to "/admin/test"
15+
16+
Scenario: I can see toast message when I successfully create or publish a record
17+
When I press the "Add Company" button
18+
And I fill in "Name" with "My Company"
19+
And I press the "Create" button
20+
Then I should see a "Saved Company "My Company" successfully" success toast
21+
And I fill in "Name" with "My New Company"
22+
And I wait for 5 seconds
23+
And I press the "Publish" button
24+
Then I should see a "Published Company "My New Company"" success toast
25+
26+
Scenario: I can see toast message when I successfully unpublish and archive a record
27+
When I click "Company B" in the "#Form_EditForm" element
28+
And I press the "Publish" button
29+
Then I should see a "Published Company "Company B"" success toast
30+
And I wait for 5 seconds
31+
And I click "More options" in the "#ActionMenus" element
32+
And I press the "Unpublish" button, confirming the dialog
33+
Then I should see a "Unpublished Company "Company B"" success toast
34+
And I wait for 5 seconds
35+
And I click "More options" in the "#ActionMenus" element
36+
And I press the "Archive" button, confirming the dialog
37+
And I should not see "Validation Error"
38+
And I should see a "Archived Company "Company B"" success toast
39+
And I should not see "Company B" in the "#Form_EditForm" element
40+
41+
Scenario: I can see toast message when I successfully delete a record
42+
When I click "Company A" in the "#Form_EditForm" element
43+
And I click "Employees" in the ".ui-tabs-nav" element
44+
Then I should see "Employee A" in the "#Form_ItemEditForm_Employees" element
45+
And I click "Employee A" in the "#Form_ItemEditForm_Employees" element
46+
And I press the "Delete" button, confirming the dialog
47+
Then I should see a "Deleted Employee "Employee A"" success toast
48+
Then I should not see "Employee A" in the "#Form_ItemEditForm_Employees" element
49+
50+
Scenario: I can see toast message when I have validation errors
51+
When I click "Company C" in the "#Form_EditForm" element
52+
And I fill in "Name" with ""
53+
And I press the "Save" button
54+
Then I should see "Validation Error"
55+
And I fill in "Name" with "New Company C"
56+
And I press the "Save" button
57+
Then I should see a "Saved Company "New Company C" successfully" success toast
58+
59+
Scenario: I can see toast message when I have validation errors when I edit a nested record
60+
When I click "Company A" in the "#Form_EditForm" element
61+
And I click "Employees" in the ".ui-tabs-nav" element
62+
Then I should see "Employee B" in the "#Form_ItemEditForm_Employees" element
63+
And I click "Employee B" in the "#Form_ItemEditForm_Employees" element
64+
And I fill in "Name" with ""
65+
And I press the "Save" button
66+
Then I should see "Validation Error"

0 commit comments

Comments
 (0)