Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a manual test suite #19

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/Application.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
component {
this.pdf.type = 'classic';
}
9 changes: 9 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This is the manual test suite for the PDF extension.

## Running tests

In the `test` folder:

- Install the most recently built extension by running `bin/install_extension.sh`
- Run `box start`. This should open a browser to the test suite page.
- Scroll down the page and make sure that each PDF looks like the reference image.
29 changes: 29 additions & 0 deletions test/bin/install_extension.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e

script_dir=$(cd `dirname $0` && pwd)
repo_root=${script_dir}/../../

cd "${repo_root}test"
lucee_home=$(box server info property=serverHomeDirectory)

if [ -z "${lucee_home}" ]; then
echo "ERROR: Could not find Lucee home directory"
exit 1
fi

deploy_dir=${lucee_home}/WEB-INF/lucee-server/deploy

echo "Found Lucee home directory at ${lucee_home}"
echo "Copying the following files to ${deploy_dir}:"
ls "${repo_root}"dist/*.lex

cp "${repo_root}"dist/*.lex "${deploy_dir}"

echo "Waiting for Lucee to install the extension..."
while ls "${deploy_dir}"/*.lex &> /dev/null; do
sleep 1
echo -n .
done
echo
echo "Extension installed"
57 changes: 57 additions & 0 deletions test/box.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"author":"",
"bugs":"",
"changelog":"",
"contributors":[],
"dependencies":{},
"description":"",
"devDependencies":{},
"documentation":"",
"homepage":"",
"ignore":[
"**/.*",
"/test/",
"/tests/"
],
"installPaths":{},
"instructions":"",
"keywords":[],
"license":[
{
"type":"",
"URL":""
}
],
"location":"ForgeboxStorage",
"name":"My Package",
"private":false,
"projectURL":"",
"repository":{
"type":"",
"URL":""
},
"scripts":{},
"shortDescription":"A sweet package",
"slug":"my-package",
"testbox":{
"bundles":"",
"directory":"tests.specs",
"labels":"",
"options":{},
"recurse":true,
"reporter":"",
"runner":[
{
"default":""
}
],
"testBundles":"",
"testSpecs":"",
"testSuites":"",
"verbose":true,
"watchDelay":500,
"watchPaths":"**.cfc"
},
"type":"modules",
"version":"0.0.0"
}
Binary file added test/expected_output/classic_basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/expected_output/classic_images.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/expected_output/modern_basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/expected_output/modern_section.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions test/index.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html>
<body>
<ul>
<li><a href="test_cases/classic_basic.cfm">Classic engine, basic</a></li>
<li><a href="test_cases/classic_images.cfm">Classic engine, with images</a></li>
<li><a href="test_cases/modern_basic.cfm">Modern engine, basic</a></li>
<li><a href="test_cases/modern_section.cfm">Modern engine, with sections</a></li>
<!--- <li><a href="classic_mixed_orientation.cfm">Classic engine, mixed orientation</a></li>
<li><a href="modern_mixed_orientation.cfm">Modern engine, mixed orientation</a></li> --->
</ul>

<div style="display: flex;">
<div style="text-align: center; width: 50%">Actual PDF Output</div>
<div style="text-align: center; width: 50%">Expected Output (screenshot)</div>
</div>

<script>
var body = document.querySelector('body');

document.querySelectorAll('li').forEach(li => {
var div = document.createElement('div');
div.style.display = 'flex';

var iframe = document.createElement('iframe');
iframe.src = li.querySelector('a').href;
iframe.style.width = '50%';
iframe.style.height = '1100px';
div.appendChild(iframe);

var img = document.createElement('img');
var imgName = li.querySelector('a').href
.replace(/^.*\//, '')
.replace(/cfm/, 'png');
img.src = `expected_output/${imgName}`;
img.style.display = 'inline-block';
img.style.width = '50%';
img.style.maxWidth = '870px';
div.appendChild(img);

body.append(div);
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions test/test_cases/classic_basic.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<cfdocument type="classic">
<div style="border: 1px solid blue; border-radius: 10px; padding: 10px;">
Classic engine has no support for border-radius, so the box should have rectilinear corners.
</div>
</cfdocument>
27 changes: 27 additions & 0 deletions test/test_cases/classic_images.cfm

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/test_cases/modern_basic.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<cfdocument type="modern">
<div style="border: 1px solid blue; border-radius: 10px; padding: 10px;">
Modern engine, as evidenced by the rounded corners of the box.
</div>
</cfdocument>
7 changes: 7 additions & 0 deletions test/test_cases/modern_section.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<cfdocument type="modern">
<cfdocumentsection>
<div style="border: 1px solid blue; border-radius: 10px; padding: 10px;">
Modern engine in a cfdocumentsection. Border corners should be rounded.
</div>
</cfdocumentsection>
</cfdocument>
4 changes: 4 additions & 0 deletions test/test_cases/support/_csubs_logo_inline.cfm

Large diffs are not rendered by default.

Binary file added test/test_cases/support/kitten.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/test_cases/support/puppy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.