Commit 61345a38 authored by Chris Shantz's avatar Chris Shantz
Browse files

Updated tests and composer to match 8.x-3.x.

parent b9ed4693
......@@ -673,17 +673,20 @@ class UwWcmsBasicTest extends BrowserTestBase {
$blocks = [
'Blockquote',
'Call to action',
'CodePen',
'Copy text',
'Facebook',
'Facts and figures',
'Full width image',
'Google Maps',
'Image gallery',
'Instagram',
'Mailman subscription',
'PowerBI',
'Related links',
'Timeline',
'Facebook',
'Instagram',
'Remote video',
'Tableau visualization',
'Timeline',
'Twitter',
];
......@@ -710,27 +713,88 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->assertSession()->pageTextNotContains('Generate automatic URL alias');
$this->assertSession()->pageTextNotContains('URL alias');
// Test Tableau block.
if ($block === 'Tableau visualization') {
// Create Tableau block.
$edit = [
'edit-settings-label' => $this->randomString(),
'edit-settings-block-form-field-uw-tbl-server' => 'Public',
'edit-settings-block-form-field-uw-tbl-site-name-0-value' => $this->randomString(),
'edit-settings-block-form-field-uw-tbl-tableau-name-0-value' => $this->randomString(),
'edit-settings-block-form-field-uw-tbl-tableau-height-0-value' => rand(100, 1000),
'edit-settings-block-form-field-uw-tbl-display-tabs' => 'Yes',
];
$this->submitForm($edit, 'Add block');
// Test that the appropriate Tableau block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="host_url" and @value="https://public.tableau.com/"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="site_root" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-site-name-0-value'] . '"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="name" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-tableau-name-0-value'] . '"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="tabs" and @value="yes"]');
$this->assertFieldByXPath('//div[@class="uw-tableau__wrapper"]/script');
$this->assertRaw("vizElement.style.height = '" . $edit['edit-settings-block-form-field-uw-tbl-tableau-height-0-value'] . "px';");
// Test specific blocks.
switch ($block) {
case 'CodePen':
// Create CodePen block.
$edit = [
'edit-settings-label' => $this->randomString(),
// Letters only, 6-7 characters.
'edit-settings-block-form-field-codepen-id-0-value' => substr(preg_replace('/[^a-zA-Z]+/', '', $this->randomMachineName(24)), 0, 7),
'edit-settings-block-form-field-codepen-username-0-value' => $this->randomMachineName(),
'edit-settings-block-form-field-codepen-displayed-author-0-value' => $this->randomString(),
// Double-quote not possible because it will make the XPath invalid
// later in this test. In normal use, double-quote would be allowed.
'edit-settings-block-form-field-codepen-displayed-title-0-value' => str_replace('"', '', $this->randomString()),
'edit-settings-block-form-field-codepen-default-tabs' => 'result',
'edit-settings-block-form-field-codepen-pixel-height-0-value' => rand(150, 1000),
];
$this->submitForm($edit, 'Add block');
// Test that the CodePen block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//div[@class="uw-codepen"]/div[
@class="codepen"
and @data-height="' . $edit['edit-settings-block-form-field-codepen-pixel-height-0-value'] . '"
and @data-theme-id="dark"
and @data-slug-hash="' . $edit['edit-settings-block-form-field-codepen-id-0-value'] . '"
and @data-default-tab="' . $edit['edit-settings-block-form-field-codepen-default-tabs'] . '"
and @data-user="' . $edit['edit-settings-block-form-field-codepen-username-0-value'] . '"
and @data-pen-title="' . $edit['edit-settings-block-form-field-codepen-displayed-title-0-value'] . '"
and @data-preview="true"
]/a[@href="https://codepen.io/' . $edit['edit-settings-block-form-field-codepen-username-0-value'] . '/pen/' . $edit['edit-settings-block-form-field-codepen-id-0-value'] . '/"]');
$this->assertFieldByXPath('//div[@class="uw-codepen"]/script[@src="https://static.codepen.io/assets/embed/ei.js"]');
break;
case 'Google Maps':
// Create Google Maps block.
$edit = [
'edit-settings-label' => $this->randomString(),
'edit-settings-block-form-field-gmaps-embedded-url-0-uri' => 'https://www.google.com/maps/embed?pb=' . $this->randomMachineName(),
'edit-settings-block-form-field-gmaps-height-0-value' => rand(150, 1000),
];
$this->submitForm($edit, 'Add block');
// Test that the Google Maps block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//div[@class="uw-google-maps"]/div[text()="Enable JavaScript to view map."]');
$this->assertFieldByXPath('//div[@class="uw-google-maps"]/iframe[@height="' . $edit['edit-settings-block-form-field-gmaps-height-0-value'] . '" and @src="' . $edit['edit-settings-block-form-field-gmaps-embedded-url-0-uri'] . '"]');
break;
case 'PowerBI':
// Create PowerBI block.
$edit = [
'edit-settings-label' => $this->randomString(),
'edit-settings-block-form-field-uw-powerbi-url-0-value' => 'https://app.powerbi.com/' . $this->randomMachineName(),
];
$this->submitForm($edit, 'Add block');
// Test that the PowerBI block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//div[@class="uw-powerbi"]/iframe[@src="' . $edit['edit-settings-block-form-field-uw-powerbi-url-0-value'] . '"]');
break;
case 'Tableau visualization':
// Create Tableau block.
$edit = [
'edit-settings-label' => $this->randomString(),
'edit-settings-block-form-field-uw-tbl-server' => 'Public',
'edit-settings-block-form-field-uw-tbl-site-name-0-value' => $this->randomMachineName(),
'edit-settings-block-form-field-uw-tbl-tableau-name-0-value' => $this->randomMachineName(),
'edit-settings-block-form-field-uw-tbl-tableau-height-0-value' => rand(100, 1000),
'edit-settings-block-form-field-uw-tbl-display-tabs' => 'Yes',
];
$this->submitForm($edit, 'Add block');
// Test that the appropriate Tableau block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="host_url" and @value="https://public.tableau.com/"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="site_root" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-site-name-0-value'] . '"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="name" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-tableau-name-0-value'] . '"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="tabs" and @value="yes"]');
$this->assertFieldByXPath('//div[@class="uw-tableau__wrapper"]/script');
$this->assertRaw("vizElement.style.height = '" . $edit['edit-settings-block-form-field-uw-tbl-tableau-height-0-value'] . "px';");
break;
}
}
......@@ -966,8 +1030,10 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Check site information menu links.
$site_links = [
base_path() . 'admin/content-access' => 'Content access',
base_path() . 'admin/config/search/redirect/404' => 'Fix 404 pages',
base_path() . 'admin/structure/menu' => 'Menus',
base_path() . 'admin/config/user-interface/shortcut' => 'Shortcuts',
base_path() . 'admin/config/search/redirect' => 'Redirects',
'mailto:rt-ist-wcms@rt.uwaterloo.ca' => 'Submit request',
'https://uwaterloo.ca/web-resources/wcms-users/training-and-support/wcms-how-documents' => 'WCMS how-to documents',
];
......@@ -1133,22 +1199,22 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->drupalLogin($this->drupalUsers['administrator']);
// Test case 1:
// Make sure manage fields of uw para fact figure
// includes 'Small caption' with value 'small'.
// includes 'Small highlight' with value 'small'.
$this->drupalGet('admin/structure/paragraphs_type/uw_para_fact_figure/fields/paragraph.uw_para_fact_figure.field_uw_ff_info');
$this->assertSession()->statusCodeEquals(200);
$smallcaption = $this->assertSession()->optionExists('default_value_input[field_uw_ff_info][0][style]', 'small');
$this->assertTrue($smallcaption);
$this->assertEquals('Small caption', $smallcaption->getText());
$smallhighlight = $this->assertSession()->optionExists('default_value_input[field_uw_ff_info][0][style]', 'small');
$this->assertTrue($smallhighlight);
$this->assertEquals('Small highlight', $smallhighlight->getText());
// Test case 2:
// Make sure adding facts and figures block, the config
// block includes 'Small cation' with value 'small'.
// block includes 'Small highlight' with value 'small'.
$this->drupalGet('node/1/layout');
$this->assertSession()->statusCodeEquals(200);
$this->clickLink('Add block');
$this->clickLink('Facts and figures');
$smallcaption = $this->assertSession()->optionExists('settings[block_form][field_uw_ff_fact_figure][0][subform][field_uw_fact_figure][0][subform][field_uw_ff_info][0][style]', 'small');
$this->assertTrue($smallcaption);
$this->assertEquals('Small caption', $smallcaption->getText());
$smallhighlight = $this->assertSession()->optionExists('settings[block_form][field_uw_ff_fact_figure][0][subform][field_uw_fact_figure][0][subform][field_uw_ff_info][0][style]', 'small');
$this->assertTrue($smallhighlight);
$this->assertEquals('Small highlight', $smallhighlight->getText());
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment