Skip to content
Snippets Groups Projects

ISTWCMS-4799: use wcmsadmi@uwaterloo.ca for the site email

Merged Kevin Paxman requested to merge feature/ISTWCMS-4799-kpaxman-default_site_mail into 8.x-3.x
Files
3
@@ -98,6 +98,141 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->redirectsTest();
$this->uwLdapTest();
$this->ckeditorButtonsTest();
$this->bannerBlockTest();
}
/**
* Tests for Custom block banner.
*/
private function bannerBlockTest() {
$this->drupalLogin($this->drupalUsers['uw_role_site_manager']);
$this->drupalGet('node/1/layout');
$this->assertSession()->statusCodeEquals(200);
$this->clickLink('Add block');
$this->clickLink('Banner images');
// Check 'Banner' group.
// Banner is required.
$banner_required = $this->getSession()->getPage()->find('xpath', "//strong[contains(text(), 'Banner')]");
$this->assertEquals('form-required', $banner_required->getAttribute('class'));
$this->assertEquals('edit-settings-block-form-field-uw-banner-item', $banner_required->getParent()->getAttribute('data-drupal-selector'));
// 'No Banner added yet' exists.
$this->assertSession()->pageTextContains('No Banner added yet.');
// The help texts exist.
$this->assertSession()->pageTextContains('You may add 1 to 8 banners. If more than one banner is added, they will be displayed in a carousel. For ideal display, all banners should have the same dimensions.');
$this->assertSession()->pageTextContains('Note that all options beyond a single image banner are unsupported at this time, and are provided for future use.');
// Check 'Add Image banner', 'Add Local video banner'
// and 'Add Vimeo video banner'.
$elements = [
'Image',
'Local video',
'Vimeo video',
];
foreach ($elements as $element) {
$this->assertTrue($this->xpath('//input[@type="submit" and @value="Add ' . $element . ' banner"]'), 'Add banner using ' . $element);
}
// Check 'Settings' group.
// 'Settings' is required.
$settings_required = $this->getSession()->getPage()->find('xpath', "//span[contains(text(), 'Settings')]");
$classes = explode(' ', $settings_required->getParent()->getParent()->getAttribute('class'));
$class_required_fields = in_array('required-fields', $classes);
$this->assertTrue($class_required_fields);
// 'Slide speed' is required.
$slide_speed_required = $this->getSession()->getPage()->find('xpath', "//label[contains(text(), 'Slide speed')]");
$this->assertEquals('js-form-required form-required', $slide_speed_required->getAttribute('class'));
$this->assertFieldByXPath('//input[@value="7000" and @name="settings[block_form][field_uw_slide_speed][0][value]"]', NULL, 'Default value is 7000ms.');
$this->assertSession()->pageTextContains('Enter the time, in milliseconds, that should elapse between slides when the slideshow is playing.');
// 'Transition speed' is required.
$slide_speed_required = $this->getSession()->getPage()->find('xpath', "//label[contains(text(), 'Transition speed')]");
$this->assertEquals('js-form-required form-required', $slide_speed_required->getAttribute('class'));
$this->assertFieldByXPath('//input[@value="400" and @name="settings[block_form][field_uw_transition_speed][0][value]"]', NULL, 'Default value is 400ms.');
$this->assertSession()->pageTextContains('Enter the time, in milliseconds, the banner transition should take to complete.');
// Autoplay is checked by default.
$this->assertSession()->checkboxChecked('edit-settings-block-form-field-uw-autoplay-value');
$this->assertSession()->pageTextContains('Controls whether or not the slideshow starts immediately on page load.');
// 'Text overlay style' is required.
$text_style = $this->getSession()->getPage()->find('xpath', "//label[contains(text(), 'Text overlay style')]");
$this->assertEquals('js-form-required form-required', $text_style->getAttribute('class'));
// The selected list match the expected list.
$expected_options = [
'full-width' => 'Full banner width, bottom, theme colour background ("FDSU" style)',
'inset' => 'Inset from banner, bottom, black background ("home page" style)',
'split' => 'Split top and bottom, black and white backgrounds ("single page" style)',
'full-overlay' => 'Full black overlay, centered text ("conference" style)',
];
$options = $this->getOptions('settings[block_form][field_uw_text_overlay_style]');
foreach ($expected_options as $key => $expected_option) {
$this->assertEqual($options[$key], $expected_option);
}
// Full banner is selected as default.
$this->assertFieldByXPath('//option[@value="full-width" and @selected="selected"]', NULL, 'Full banner width, bottom, theme colour background ("FDSU" style) is selected.');
$this->assertSession()->pageTextContains('Note that all options other than "FDSU" style are unsupported at this time, and are provided for future use.');
// Click 'Add Image banner'.
$this->click('#edit-settings-block-form-field-uw-banner-item-add-more-add-more-button-uw-para-image-banner');
$image = $this->getSession()->getPage()->find('xpath', "//span[contains(text(), 'Image')]");
$this->assertEquals('fieldset-legend js-form-required form-required', $image->getAttribute('class'));
$this->assertSession()->pageTextContains('No media items are selected.');
$this->assertSession()->buttonExists('Add media');
$fields = [
'Link' => 'Provide an optional link for this banner.',
'Big text' => 'Big text appears at a larger size, and, if both are set, above the small text.',
'Small text' => 'Small text appears at a smaller size, and, if both are set, below the big text.',
];
foreach ($fields as $key => $field) {
$this->assertSession()->fieldExists($key);
$this->assertSession()->pageTextContains($field);
}
// Click 'Add Local video banner'.
$this->click('#edit-settings-block-form-field-uw-banner-item-add-more-add-more-button-uw-para-local-video-banner');
$local_video = $this->getSession()->getPage()->find('xpath', "//span[contains(text(), 'Video')]");
$this->assertEquals('fieldset-legend js-form-required form-required', $local_video->getAttribute('class'));
$this->assertSession()->pageTextContains('No media items are selected.');
$this->assertSession()->buttonExists('Add media');
$fallback_iamge = $this->getSession()->getPage()->find('xpath', "//span[contains(text(), 'Fallback image')]");
$this->assertEquals('fieldset-legend js-form-required form-required', $fallback_iamge->getAttribute('class'));
$this->assertSession()->pageTextContains('No media items are selected.');
$this->assertSession()->buttonExists('Add media');
$fields = [
'Link' => 'Provide an optional link for this banner.',
'Big text' => 'Big text appears at a larger size, and, if both are set, above the small text.',
'Small text' => 'Small text appears at a smaller size, and, if both are set, below the big text.',
];
foreach ($fields as $key => $field) {
$this->assertSession()->fieldExists($key);
$this->assertSession()->pageTextContains($field);
}
// Click 'Add Vimeo video banner'.
$this->click('#edit-settings-block-form-field-uw-banner-item-add-more-add-more-button-uw-para-vimeo-video-banner');
$vimeo_video = $this->getSession()->getPage()->find('xpath', "//span[contains(text(), 'Vimeo video')]");
$this->assertEquals('fieldset-legend js-form-required form-required', $vimeo_video->getAttribute('class'));
$this->assertSession()->pageTextContains('No media items are selected.');
$this->assertSession()->buttonExists('Add media');
$this->assertSession()->linkExists('media add page');
$vimeo_video = $this->getSession()->getPage()->find('xpath', "//label[contains(text(), 'Use existing media')]");
$this->assertEquals('js-form-required form-required', $vimeo_video->getAttribute('class'));
$this->assertSession()->fieldExists('settings[block_form][field_uw_banner_item][2][subform][field_uw_ban_fallback_image][0][target_id]');
$this->assertSession()->linkExists('media list');
$fields = [
'Link' => 'Provide an optional link for this banner.',
'Big text' => 'Big text appears at a larger size, and, if both are set, above the small text.',
'Small text' => 'Small text appears at a smaller size, and, if both are set, below the big text.',
];
foreach ($fields as $key => $field) {
$this->assertSession()->fieldExists($key);
$this->assertSession()->pageTextContains($field);
}
}
/**
Loading