Skip to content

Commit

Permalink
Add Mink test for inline scripts in item statuses.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Aug 22, 2024
1 parent ceaa741 commit 5c87474
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@
<!-- avoid PHP Errors by creating each level separately -->
<mkdir dir="${themedir}" />
<mkdir dir="${themedir}/templates" />
<mkdir dir="${themedir}/templates/ajax" />
<mkdir dir="${contentdir}" />
<mkdir dir="${contentdir}/test" />
<mkdir dir="${contentdir}/test/sub" />
Expand All @@ -754,6 +755,16 @@ return [
'extends' =&gt; 'sandal',
];
</echo>

<copy file="${srcdir}/themes/bootstrap3/templates/ajax/status-full.phtml" tofile="${themedir}/templates/ajax/status-full.phtml" overwrite="true" />
<!-- Add a script for testing that inline scripts work -->
<echo file="${themedir}/templates/ajax/status-full.phtml" append="true">
&lt;div class="js-status-test hidden"&gt;&lt;/div&gt;
&lt;script nonce="foo"&gt;
document.querySelector('.js-status-test').classList.remove('hidden');
&lt;/script&gt;
</echo>

<echo file="${contentdir}/content.phtml">&lt;?php include $this-&gt;parentTemplate('content/content.phtml');?&gt;

&lt;div class="content-footer"&gt;Content page footer&lt;/div&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ public function testItemStatusFull(
string $expectedType,
string $multipleLocations
): void {
$config = $this->getConfigIniOverrides(true, $multipleLocations);
// Switch to the minktest theme:
$config['Site']['theme'] = 'minktest';
$this->changeConfigs(
[
'config' => $this->getConfigIniOverrides(true, $multipleLocations),
'config' => $config,
'Demo' => $this->getDemoIniOverrides($availability, $status, true),
]
);
Expand All @@ -222,6 +225,8 @@ public function testItemStatusFull(
// No extra items to care for:
$this->assertEquals('Main Library', $this->findCssAndGetText($page, '.result-body .fullLocation'));
}
$this->findCss($page, '.js-status-test');
$this->unFindCss($page, '.js-status-test.hidden');
}

/**
Expand Down

0 comments on commit 5c87474

Please sign in to comment.