Skip to content

Commit

Permalink
Issue #3469582 by joshua1234511: Alert content type - Page visibility…
Browse files Browse the repository at this point in the history
… validation issue. (#1294)

Co-authored-by: Joshua Fernandes <“joshua.1234511@yahoo.in”>
  • Loading branch information
joshua-salsadigital and Joshua Fernandes authored Sep 19, 2024
1 parent 3d5dedc commit c428b71
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 3 deletions.
63 changes: 61 additions & 2 deletions tests/behat/features/content_type.civictheme_alert.view.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Feature: CivicTheme Alert content type render
| 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] |
| 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] |
| 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] |
| 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] |

Given civictheme_page content:
| title | status |
| [TEST] Test alerts on pages | 1 |
| title | status |
| [TEST] Test alerts on pages | 1 |
| [TEST] Test alert visibility | 1 |

@api @javascript
Scenario: Alerts can be viewed on homepage
Expand Down Expand Up @@ -118,3 +120,60 @@ Feature: CivicTheme Alert content type render
And I wait for AJAX to finish
Then I should see the text "[TEST] Test alert body all pages"
And I should not see the text "[TEST] Test alert body all pages future"

@api @javascript
Scenario: Alerts visibility
Given I am logged in as a user with the "Site Administrator" role
When I edit civictheme_alert "[TEST] Test alert title visibility"
And I fill in "Page visibility" with:
"""
/test-alert/*
/test-alert-page
/test-random-alert-page
"""
And I press "Save"
When I edit civictheme_page "[TEST] Test alert visibility"
And I uncheck the box "Generate automatic URL alias"
Then I fill in the following:
| edit-path-0-alias | /test-alert/test-1 |
And I press "Save"
When I visit "/test-alert/test-1"
And wait 5 second
And I wait for AJAX to finish
Then I should see the text "[TEST] Test alert body visibility"
When I edit civictheme_page "[TEST] Test alert visibility"
And I uncheck the box "Generate automatic URL alias"
Then I fill in the following:
| edit-path-0-alias | /test-alert/test-2 |
And I press "Save"
When I visit "/test-alert/test-2"
And wait 5 second
And I wait for AJAX to finish
Then I should see the text "[TEST] Test alert body visibility"
When I edit civictheme_page "[TEST] Test alert visibility"
And I uncheck the box "Generate automatic URL alias"
Then I fill in the following:
| edit-path-0-alias | /test-alert-page |
And I press "Save"
When I visit "/test-alert-page"
And wait 5 second
And I wait for AJAX to finish
Then I should see the text "[TEST] Test alert body visibility"
When I edit civictheme_page "[TEST] Test alert visibility"
And I uncheck the box "Generate automatic URL alias"
Then I fill in the following:
| edit-path-0-alias | /test-alerts |
And I press "Save"
When I visit "/test-alerts"
And wait 5 second
And I wait for AJAX to finish
Then I should not see the text "[TEST] Test alert body visibility"
When I edit civictheme_page "[TEST] Test alert visibility"
And I uncheck the box "Generate automatic URL alias"
Then I fill in the following:
| edit-path-0-alias | /test-random-alert-page |
And I press "Save"
When I visit "/test-random-alert-page"
And wait 5 second
And I wait for AJAX to finish
Then I should see the text "[TEST] Test alert body visibility"
12 changes: 12 additions & 0 deletions web/themes/contrib/civictheme/civictheme.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,15 @@ function civictheme_post_update_import_subject_card_view_mode(): void {
\Drupal::classResolver(CivicthemeUpdateHelper::class)->createConfigs($view_mode_configs, $config_path);

}

/**
* Update alert api view to strip tags from visibility validation.
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
function civictheme_post_update_alert_visibility_validation(): string {
$view_config = \Drupal::configFactory()->getEditable('views.view.civictheme_alerts');
$view_config->set('display.default.display_options.fields.field_c_n_alert_page_visibility.alter.strip_tags', TRUE);
$view_config->save();
return (string) (new TranslatableMarkup('Updated alert api view to strip tags from visibility validation.'));
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ display:
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
strip_tags: true
trim: false
preserve_tags: ''
html: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public function testUpdates(): void {

$this->assertSession()->pageTextContains('Update add_background_promo_component');
$this->assertSession()->pageTextContains("Added Background field to Promo Component.");

$this->assertSession()->pageTextContains('Update alert_visibility_validation');
$this->assertSession()->pageTextContains("Updated alert api view to strip tags from visibility validation.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public function testUpdates(): void {

$this->assertSession()->pageTextContains('Update add_background_promo_component');
$this->assertSession()->pageTextContains("Added Background field to Promo Component.");

$this->assertSession()->pageTextContains('Update alert_visibility_validation');
$this->assertSession()->pageTextContains("Updated alert api view to strip tags from visibility validation.");
}

}

0 comments on commit c428b71

Please sign in to comment.