Skip to content

Commit c428b71

Browse files
joshua-salsadigitalJoshua Fernandes
andauthored
Issue #3469582 by joshua1234511: Alert content type - Page visibility validation issue. (#1294)
Co-authored-by: Joshua Fernandes <“[email protected]”>
1 parent 3d5dedc commit c428b71

File tree

5 files changed

+80
-3
lines changed

5 files changed

+80
-3
lines changed

tests/behat/features/content_type.civictheme_alert.view.feature

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ Feature: CivicTheme Alert content type render
88
| 999992 | [TEST] Test alert title all pages | 1 | error | | [TEST] Test alert body all pages | [relative:-1 day#Y-m-d\TH:i:s] | [relative:+10 days#Y-m-d\TH:i:s] |
99
| 999993 | [TEST] Test dismissing alert title all pages | 1 | error | | [TEST] Test dismissing alert body all pages | [relative:-1 day#Y-m-d\TH:i:s] | [relative:+10 days#Y-m-d\TH:i:s] |
1010
| 999994 | [TEST] Test alert title all pages future | 1 | error | | [TEST] Test alert body all pages future | [relative:+2 days#Y-m-d\TH:i:s] | [relative:+10 days#Y-m-d\TH:i:s] |
11+
| 999995 | [TEST] Test alert title visibility | 1 | error | | [TEST] Test alert body visibility | [relative:-1 day#Y-m-d\TH:i:s] | [relative:+10 days#Y-m-d\TH:i:s] |
1112

1213
Given civictheme_page content:
13-
| title | status |
14-
| [TEST] Test alerts on pages | 1 |
14+
| title | status |
15+
| [TEST] Test alerts on pages | 1 |
16+
| [TEST] Test alert visibility | 1 |
1517

1618
@api @javascript
1719
Scenario: Alerts can be viewed on homepage
@@ -118,3 +120,60 @@ Feature: CivicTheme Alert content type render
118120
And I wait for AJAX to finish
119121
Then I should see the text "[TEST] Test alert body all pages"
120122
And I should not see the text "[TEST] Test alert body all pages future"
123+
124+
@api @javascript
125+
Scenario: Alerts visibility
126+
Given I am logged in as a user with the "Site Administrator" role
127+
When I edit civictheme_alert "[TEST] Test alert title visibility"
128+
And I fill in "Page visibility" with:
129+
"""
130+
/test-alert/*
131+
/test-alert-page
132+
/test-random-alert-page
133+
"""
134+
And I press "Save"
135+
When I edit civictheme_page "[TEST] Test alert visibility"
136+
And I uncheck the box "Generate automatic URL alias"
137+
Then I fill in the following:
138+
| edit-path-0-alias | /test-alert/test-1 |
139+
And I press "Save"
140+
When I visit "/test-alert/test-1"
141+
And wait 5 second
142+
And I wait for AJAX to finish
143+
Then I should see the text "[TEST] Test alert body visibility"
144+
When I edit civictheme_page "[TEST] Test alert visibility"
145+
And I uncheck the box "Generate automatic URL alias"
146+
Then I fill in the following:
147+
| edit-path-0-alias | /test-alert/test-2 |
148+
And I press "Save"
149+
When I visit "/test-alert/test-2"
150+
And wait 5 second
151+
And I wait for AJAX to finish
152+
Then I should see the text "[TEST] Test alert body visibility"
153+
When I edit civictheme_page "[TEST] Test alert visibility"
154+
And I uncheck the box "Generate automatic URL alias"
155+
Then I fill in the following:
156+
| edit-path-0-alias | /test-alert-page |
157+
And I press "Save"
158+
When I visit "/test-alert-page"
159+
And wait 5 second
160+
And I wait for AJAX to finish
161+
Then I should see the text "[TEST] Test alert body visibility"
162+
When I edit civictheme_page "[TEST] Test alert visibility"
163+
And I uncheck the box "Generate automatic URL alias"
164+
Then I fill in the following:
165+
| edit-path-0-alias | /test-alerts |
166+
And I press "Save"
167+
When I visit "/test-alerts"
168+
And wait 5 second
169+
And I wait for AJAX to finish
170+
Then I should not see the text "[TEST] Test alert body visibility"
171+
When I edit civictheme_page "[TEST] Test alert visibility"
172+
And I uncheck the box "Generate automatic URL alias"
173+
Then I fill in the following:
174+
| edit-path-0-alias | /test-random-alert-page |
175+
And I press "Save"
176+
When I visit "/test-random-alert-page"
177+
And wait 5 second
178+
And I wait for AJAX to finish
179+
Then I should see the text "[TEST] Test alert body visibility"

web/themes/contrib/civictheme/civictheme.post_update.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,15 @@ function civictheme_post_update_import_subject_card_view_mode(): void {
771771
\Drupal::classResolver(CivicthemeUpdateHelper::class)->createConfigs($view_mode_configs, $config_path);
772772

773773
}
774+
775+
/**
776+
* Update alert api view to strip tags from visibility validation.
777+
*
778+
* @SuppressWarnings(PHPMD.StaticAccess)
779+
*/
780+
function civictheme_post_update_alert_visibility_validation(): string {
781+
$view_config = \Drupal::configFactory()->getEditable('views.view.civictheme_alerts');
782+
$view_config->set('display.default.display_options.fields.field_c_n_alert_page_visibility.alter.strip_tags', TRUE);
783+
$view_config->save();
784+
return (string) (new TranslatableMarkup('Updated alert api view to strip tags from visibility validation.'));
785+
}

web/themes/contrib/civictheme/config/install/views.view.civictheme_alerts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ display:
173173
more_link: false
174174
more_link_text: ''
175175
more_link_path: ''
176-
strip_tags: false
176+
strip_tags: true
177177
trim: false
178178
preserve_tags: ''
179179
html: false

web/themes/contrib/civictheme/tests/src/Functional/Update/CivicthemeUpdatePathBareTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public function testUpdates(): void {
123123

124124
$this->assertSession()->pageTextContains('Update add_background_promo_component');
125125
$this->assertSession()->pageTextContains("Added Background field to Promo Component.");
126+
127+
$this->assertSession()->pageTextContains('Update alert_visibility_validation');
128+
$this->assertSession()->pageTextContains("Updated alert api view to strip tags from visibility validation.");
126129
}
127130

128131
}

web/themes/contrib/civictheme/tests/src/Functional/Update/CivicthemeUpdatePathFilledTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public function testUpdates(): void {
122122

123123
$this->assertSession()->pageTextContains('Update add_background_promo_component');
124124
$this->assertSession()->pageTextContains("Added Background field to Promo Component.");
125+
126+
$this->assertSession()->pageTextContains('Update alert_visibility_validation');
127+
$this->assertSession()->pageTextContains("Updated alert api view to strip tags from visibility validation.");
125128
}
126129

127130
}

0 commit comments

Comments
 (0)