diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f1a76d4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +name: Test + +on: + push: + branches: ["main", "library-rework"] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + name: Test + runs-on: ${{matrix.os}} + defaults: + run: + shell: bash + strategy: + matrix: + include: + - build: linux + os: ubuntu-latest + rust: beta + target: x86_64-unknown-linux-musl + cross: false + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Install + run: npm i + + - name: Unit Test + run: npm run test + + - name: Behavior Test + run: ./test_ci.sh diff --git a/test_ci.sh b/test_ci.sh new file mode 100755 index 0000000..1c3518c --- /dev/null +++ b/test_ci.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIR + +GADGET_CLI=$(realpath "$SCRIPT_DIR/src/cli.js") + +npx -y toolproof --placeholders gadget_cli="$GADGET_CLI" \ No newline at end of file diff --git a/test_interactive.sh b/test_interactive.sh new file mode 100755 index 0000000..f6ec7f7 --- /dev/null +++ b/test_interactive.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIR + +GADGET_CLI=$(realpath "$SCRIPT_DIR/src/cli.js") + +npx -y toolproof --placeholders gadget_cli="$GADGET_CLI" --all -i diff --git a/toolproof_tests/demo.toolproof.yml b/toolproof_tests/demo.toolproof.yml new file mode 100644 index 0000000..0ff25fe --- /dev/null +++ b/toolproof_tests/demo.toolproof.yml @@ -0,0 +1,74 @@ +name: Text Example 1 + +steps: + - step: I have a ".eleventy.js" file with the content {js} + js: |- + const pluginRss = require("@11ty/eleventy-plugin-rss"); + + module.exports = function (eleventyConfig) { + eleventyConfig.setUseGitIgnore(false); + eleventyConfig.setDataDeepMerge(true); + + eleventyConfig.addCollection('nav', function (collectionApi) { + return collectionApi.getAll() + .filter((page) => page.data.show_in_navigation === true) + .sort((a, b) => a.data.navigation_order - b.data.navigation_order); + }); + + eleventyConfig.addPassthroughCopy('images'); + + eleventyConfig.addPlugin(pluginRss); + }; + - step: I have a "pages/index.njk" file with the content {njk} + njk: |- + --- + title: + call_to_action: Contact + permalink: / + --- +
+

This is the Justice template from CloudCannon. Justice is strong foundation for the web presence of a law firm or business. It's filled with fictitious example content to get you started.

+ +

Justice Law is professional representation. Practicing for over 50 years, our team have the knowledge and skills to get you results.

+
+ - step: I have a "staff-members/jane-doe.md" file with the content {md} + md: |- + --- + _uuid: 05589684-8d33-4d2f-8fde-460f9922d319 + name: Jane Doe + image: "https://placekitten.com/440/440?a=.png" + description: Jane has 19 years of experience in law, and specialises in property and business. + credentials: LLB + phone_extension: "02" + --- + - step: I have a "staff-members/john-doe.md" file with the content {md} + md: |- + --- + _uuid: 8c6c132e-1c21-413e-be81-874091df1841 + name: John Doe + image: "https://placebear.com/440/440?a=.png" + description: With an interest in employment law, John works tirelessly to improve workplaces. + credentials: LLB + phone_extension: "11" + --- + - I run "node %gadget_cli% ." + - stdout should contain "eleventy" + - snapshot: stdout + snapshot_content: |- + ╎{ + ╎ "ssg": "eleventy", + ╎ "source": "", + ╎ "collections_config": { + ╎ "pages": { + ╎ "path": "", + ╎ "name": "Pages", + ╎ "icon": "wysiwyg", + ╎ "filter": { + ╎ "base": "strict" + ╎ } + ╎ } + ╎ }, + ╎ "paths": { + ╎ "collections": "" + ╎ } + ╎} diff --git a/toolproof_tests/refs_example/demo_test.toolproof.yml b/toolproof_tests/refs_example/demo_test.toolproof.yml new file mode 100644 index 0000000..e304a44 --- /dev/null +++ b/toolproof_tests/refs_example/demo_test.toolproof.yml @@ -0,0 +1,38 @@ +name: Demo Test with Refs + +steps: + - ref: ./eleventy_config.toolproof.yml + - ref: ./staff_collection.toolproof.yml + - step: I have a "pages/index.njk" file with the content {njk} + njk: |- + --- + title: + call_to_action: Contact + permalink: / + --- +
+

This is the Justice template from CloudCannon. Justice is strong foundation for the web presence of a law firm or business. It's filled with fictitious example content to get you started.

+ +

Justice Law is professional representation. Practicing for over 50 years, our team have the knowledge and skills to get you results.

+
+ - I run "node %gadget_cli% ." + - stdout should contain "eleventy" + - snapshot: stdout + snapshot_content: |- + ╎{ + ╎ "ssg": "eleventy", + ╎ "source": "", + ╎ "collections_config": { + ╎ "pages": { + ╎ "path": "", + ╎ "name": "Pages", + ╎ "icon": "wysiwyg", + ╎ "filter": { + ╎ "base": "strict" + ╎ } + ╎ } + ╎ }, + ╎ "paths": { + ╎ "collections": "" + ╎ } + ╎} diff --git a/toolproof_tests/refs_example/eleventy_config.toolproof.yml b/toolproof_tests/refs_example/eleventy_config.toolproof.yml new file mode 100644 index 0000000..7654e08 --- /dev/null +++ b/toolproof_tests/refs_example/eleventy_config.toolproof.yml @@ -0,0 +1,22 @@ +name: 11ty Config Setup +type: reference + +steps: + - step: I have a ".eleventy.js" file with the content {js} + js: |- + const pluginRss = require("@11ty/eleventy-plugin-rss"); + + module.exports = function (eleventyConfig) { + eleventyConfig.setUseGitIgnore(false); + eleventyConfig.setDataDeepMerge(true); + + eleventyConfig.addCollection('nav', function (collectionApi) { + return collectionApi.getAll() + .filter((page) => page.data.show_in_navigation === true) + .sort((a, b) => a.data.navigation_order - b.data.navigation_order); + }); + + eleventyConfig.addPassthroughCopy('images'); + + eleventyConfig.addPlugin(pluginRss); + }; diff --git a/toolproof_tests/refs_example/staff_collection.toolproof.yml b/toolproof_tests/refs_example/staff_collection.toolproof.yml new file mode 100644 index 0000000..09c35a9 --- /dev/null +++ b/toolproof_tests/refs_example/staff_collection.toolproof.yml @@ -0,0 +1,24 @@ +name: Staff Collection Setup +type: reference + +steps: + - step: I have a "staff-members/jane-doe.md" file with the content {md} + md: |- + --- + _uuid: 05589684-8d33-4d2f-8fde-460f9922d319 + name: Jane Doe + image: "https://placekitten.com/440/440?a=.png" + description: Jane has 19 years of experience in law, and specialises in property and business. + credentials: LLB + phone_extension: "02" + --- + - step: I have a "staff-members/john-doe.md" file with the content {md} + md: |- + --- + _uuid: 8c6c132e-1c21-413e-be81-874091df1841 + name: John Doe + image: "https://placebear.com/440/440?a=.png" + description: With an interest in employment law, John works tirelessly to improve workplaces. + credentials: LLB + phone_extension: "11" + ---