From 94c0aeb0d6442450e1e85daf9ae1099eb9988b03 Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Fri, 5 Mar 2021 19:39:00 +0100 Subject: [PATCH] Add not-found route --- app/router.js | 2 + app/routes/not-found.js | 14 ++ app/templates/not-found.hbs | 6 + package-lock.json | 315 ++++++++++++++++++++++++++-- package.json | 1 + tests/acceptance/not-found-test.js | 32 +++ tests/fastboot/not-found-test.js | 14 ++ tests/unit/routes/not-found-test.js | 12 ++ 8 files changed, 373 insertions(+), 23 deletions(-) create mode 100644 app/routes/not-found.js create mode 100644 app/templates/not-found.hbs create mode 100644 tests/acceptance/not-found-test.js create mode 100644 tests/fastboot/not-found-test.js create mode 100644 tests/unit/routes/not-found-test.js diff --git a/app/router.js b/app/router.js index bc9ff74b0..83ee06ef7 100644 --- a/app/router.js +++ b/app/router.js @@ -52,6 +52,8 @@ Router.map(function () { this.route('payment-sent'); }); + this.route('not-found', { path: '/*path' }); + this.route('releases', function () { this.route('beta'); this.route('canary'); diff --git a/app/routes/not-found.js b/app/routes/not-found.js new file mode 100644 index 000000000..969fad2bb --- /dev/null +++ b/app/routes/not-found.js @@ -0,0 +1,14 @@ +import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; + +export default class NotFoundRoute extends Route { + @service fastboot; + + beforeModel() { + if (!this.fastboot.isFastBoot) { + return; + } + + this.fastboot.response.statusCode = 404; + } +} diff --git a/app/templates/not-found.hbs b/app/templates/not-found.hbs new file mode 100644 index 000000000..4cbaa2901 --- /dev/null +++ b/app/templates/not-found.hbs @@ -0,0 +1,6 @@ +{{page-title "Page Not Found"}} + +
+

Page Not Found

+

We couldn't find what you were looking for.

+
\ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1a207f227..2239de543 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "ember-cli-babel-polyfills": "^2.0.1", "ember-cli-dependency-checker": "^3.2.0", "ember-cli-fastboot": "^2.1.1", + "ember-cli-fastboot-testing": "^0.4.0", "ember-cli-head": "^1.0.0", "ember-cli-htmlbars": "^5.3.1", "ember-cli-inject-live-reload": "^2.0.2", @@ -6578,9 +6579,6 @@ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, - "dependencies": { - "graceful-fs": "^4.1.6" - }, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -8571,7 +8569,6 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.3.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -10740,7 +10737,6 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { - "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -11753,6 +11749,136 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/ember-cli-fastboot-testing": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/ember-cli-fastboot-testing/-/ember-cli-fastboot-testing-0.4.0.tgz", + "integrity": "sha512-WYzMgveWHTZxDAK2MN/0mHQHvA9nQQbr5m50S/AhtXQ2xH9MRiQD1KlmB5R78XcAvKexdF0oG4vSFd+yyTntjA==", + "dev": true, + "dependencies": { + "body-parser": "^1.18.3", + "ember-auto-import": "^1.2.15", + "ember-cli-babel": "^7.8.0", + "fastboot": "^3.0.3", + "json-fn": "^1.1.1", + "minimist": "^1.2.0", + "nock": "^12.0.3", + "resolve": "^1.10.0", + "whatwg-fetch": "^3.0.0" + }, + "engines": { + "node": "8.* || >= 10.*" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/ember-cli-fastboot-testing/node_modules/fastboot": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fastboot/-/fastboot-3.1.2.tgz", + "integrity": "sha512-yvhJfIRd4wWWACk+qjJxQI+WBIQ+pyQyp0/fxrQyA/cYJgZAXOHb+22zXJbJXaPku3fHS+gBl7crwovIkl8bhQ==", + "dev": true, + "dependencies": { + "chalk": "^3.0.0", + "cookie": "^0.4.0", + "debug": "^4.1.1", + "jsdom": "^16.2.2", + "resolve": "^1.15.0", + "simple-dom": "^1.4.0", + "source-map-support": "^0.5.16" + }, + "engines": { + "node": "10.* || >=12" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/ember-cli-fastboot-testing/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/ember-cli-fastboot-testing/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/ember-cli-fastboot/node_modules/broccoli-concat": { "version": "3.7.5", "resolved": "https://registry.npmjs.org/broccoli-concat/-/broccoli-concat-3.7.5.tgz", @@ -12848,7 +12974,6 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { - "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -17065,8 +17190,7 @@ "esprima": "^4.0.1", "estraverse": "^4.2.0", "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" + "optionator": "^0.8.1" }, "bin": { "escodegen": "bin/escodegen.js", @@ -17909,7 +18033,6 @@ "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", "dev": true, "dependencies": { - "@types/yauzl": "^2.9.1", "debug": "^4.1.1", "get-stream": "^5.1.0", "yauzl": "^2.10.0" @@ -19430,7 +19553,6 @@ "minimist": "^1.2.5", "neo-async": "^2.6.0", "source-map": "^0.6.1", - "uglify-js": "^3.1.4", "wordwrap": "^1.0.0" }, "bin": { @@ -20972,6 +21094,12 @@ "node": ">=4" } }, + "node_modules/json-fn": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/json-fn/-/json-fn-1.1.1.tgz", + "integrity": "sha1-QpPJGYpILWaX0zSm4yzQ0iESHoA=", + "dev": true + }, "node_modules/json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -21056,9 +21184,6 @@ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, - "dependencies": { - "graceful-fs": "^4.1.6" - }, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -22727,6 +22852,21 @@ "tslib": "^2.0.3" } }, + "node_modules/nock": { + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/nock/-/nock-12.0.3.tgz", + "integrity": "sha512-QNb/j8kbFnKCiyqi9C5DD0jH/FubFGj5rt9NQFONXwQm3IPB0CULECg/eS3AU1KgZb/6SwUa4/DTRKhVxkGABw==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.13", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", @@ -25290,6 +25430,15 @@ "node": "10.* || >= 12.*" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/proxy-addr": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", @@ -26413,9 +26562,6 @@ "integrity": "sha512-VoWt8DysFGDVRGWuHTqZzT02J0ASgjVq/hPs9QcBOGMd7B+jfTr/iqMVEyOi901rE3xq+Deq66GzIT1yt7sGwQ==", "dev": true, "peer": true, - "dependencies": { - "fsevents": "~2.3.1" - }, "bin": { "rollup": "dist/bin/rollup" }, @@ -30614,10 +30760,8 @@ "integrity": "sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==", "dev": true, "dependencies": { - "chokidar": "^3.4.1", "graceful-fs": "^4.1.2", - "neo-async": "^2.5.0", - "watchpack-chokidar2": "^2.0.1" + "neo-async": "^2.5.0" }, "optionalDependencies": { "chokidar": "^3.4.1", @@ -30677,7 +30821,6 @@ "anymatch": "^2.0.0", "async-each": "^1.0.1", "braces": "^2.3.2", - "fsevents": "^1.2.7", "glob-parent": "^3.1.0", "inherits": "^2.0.3", "is-binary-path": "^1.0.0", @@ -34284,10 +34427,8 @@ "integrity": "sha512-6+iaCMh/JXJaB2QWikqvGE9//wLEVYYwZd5sud8aLoLKog1Q75naZh2vlGVtg5Mq/NqpqGQvdIjJb3Bm+64AUQ==", "dev": true, "requires": { - "@oclif/config": "^1", "@oclif/errors": "^1.2.2", "@oclif/parser": "^3.8.3", - "@oclif/plugin-help": "^2", "debug": "^4.1.1", "semver": "^5.6.0" }, @@ -34505,7 +34646,6 @@ "integrity": "sha512-5vwpq6kbvwkQwKqAoOU3L72GZ3Ta8RRrewKj9OJRolx28KLJJ8Dg9Rf7obRwt5jQA9bkYd8gqzMTrI7H3xLfaw==", "dev": true, "requires": { - "@oclif/config": "^1.15.1", "@oclif/errors": "^1.3.3", "@oclif/parser": "^3.8.3", "@oclif/plugin-help": "^3", @@ -42316,6 +42456,111 @@ } } }, + "ember-cli-fastboot-testing": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/ember-cli-fastboot-testing/-/ember-cli-fastboot-testing-0.4.0.tgz", + "integrity": "sha512-WYzMgveWHTZxDAK2MN/0mHQHvA9nQQbr5m50S/AhtXQ2xH9MRiQD1KlmB5R78XcAvKexdF0oG4vSFd+yyTntjA==", + "dev": true, + "requires": { + "body-parser": "^1.18.3", + "ember-auto-import": "^1.2.15", + "ember-cli-babel": "^7.8.0", + "fastboot": "^3.0.3", + "json-fn": "^1.1.1", + "minimist": "^1.2.0", + "nock": "^12.0.3", + "resolve": "^1.10.0", + "whatwg-fetch": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "fastboot": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fastboot/-/fastboot-3.1.2.tgz", + "integrity": "sha512-yvhJfIRd4wWWACk+qjJxQI+WBIQ+pyQyp0/fxrQyA/cYJgZAXOHb+22zXJbJXaPku3fHS+gBl7crwovIkl8bhQ==", + "dev": true, + "requires": { + "chalk": "^3.0.0", + "cookie": "^0.4.0", + "debug": "^4.1.1", + "jsdom": "^16.2.2", + "resolve": "^1.15.0", + "simple-dom": "^1.4.0", + "source-map-support": "^0.5.16" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "ember-cli-get-component-path-option": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/ember-cli-get-component-path-option/-/ember-cli-get-component-path-option-1.0.0.tgz", @@ -49626,6 +49871,12 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, + "json-fn": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/json-fn/-/json-fn-1.1.1.tgz", + "integrity": "sha1-QpPJGYpILWaX0zSm4yzQ0iESHoA=", + "dev": true + }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -51175,6 +51426,18 @@ "tslib": "^2.0.3" } }, + "nock": { + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/nock/-/nock-12.0.3.tgz", + "integrity": "sha512-QNb/j8kbFnKCiyqi9C5DD0jH/FubFGj5rt9NQFONXwQm3IPB0CULECg/eS3AU1KgZb/6SwUa4/DTRKhVxkGABw==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.13", + "propagate": "^2.0.0" + } + }, "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", @@ -53252,6 +53515,12 @@ "integrity": "sha512-0qhWYyCV9TYDMSooYw1fShIb7R6hsWYja7JLqbeb1MvHqDTvP/uy/R1RsyVqDi6GCiHOI4G5p2Hpr3IA+/l/+Q==", "dev": true }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "proxy-addr": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", diff --git a/package.json b/package.json index f43c6d8ed..c292b0dc6 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "ember-cli-babel-polyfills": "^2.0.1", "ember-cli-dependency-checker": "^3.2.0", "ember-cli-fastboot": "^2.1.1", + "ember-cli-fastboot-testing": "^0.4.0", "ember-cli-head": "^1.0.0", "ember-cli-htmlbars": "^5.3.1", "ember-cli-inject-live-reload": "^2.0.2", diff --git a/tests/acceptance/not-found-test.js b/tests/acceptance/not-found-test.js new file mode 100644 index 000000000..0eb8807b7 --- /dev/null +++ b/tests/acceptance/not-found-test.js @@ -0,0 +1,32 @@ +import { visit } from '@ember/test-helpers'; +import percySnapshot from '@percy/ember'; +import { a11yAudit } from 'ember-a11y-testing/test-support'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { setupApplicationTest } from 'ember-qunit'; +import loadDefaultScenario from 'ember-website/mirage/scenarios/default'; +import { setupPageTitleTest } from 'ember-website/tests/helpers/page-title'; +import { module, test } from 'qunit'; + +module('Acceptance | not found', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + setupPageTitleTest(hooks); + + hooks.beforeEach(function () { + loadDefaultScenario(this.server); + }); + + test('Percy snapshot', async function (assert) { + await visit('/foo-bar-baz'); + await percySnapshot(assert); + + assert.ok(true); + }); + + test('Accessibility audit', async function (assert) { + await visit('/foo-bar-baz'); + await a11yAudit(); + + assert.hasPageTitle('Page Not Found - Ember.js'); + }); +}); diff --git a/tests/fastboot/not-found-test.js b/tests/fastboot/not-found-test.js new file mode 100644 index 000000000..d289add0b --- /dev/null +++ b/tests/fastboot/not-found-test.js @@ -0,0 +1,14 @@ +import { setup, visit } from 'ember-cli-fastboot-testing/test-support'; +import { module, test } from 'qunit'; + +module('FastBoot | not-found', function (hooks) { + setup(hooks); + + test('it returns the correct status code', async function (assert) { + const rootVisit = await visit('/'); + assert.equal(rootVisit.statusCode, 200); + + const fooVisit = await visit('/foo'); + assert.equal(fooVisit.statusCode, 404); + }); +}); diff --git a/tests/unit/routes/not-found-test.js b/tests/unit/routes/not-found-test.js new file mode 100644 index 000000000..bbac05b01 --- /dev/null +++ b/tests/unit/routes/not-found-test.js @@ -0,0 +1,12 @@ +import { setupTest } from 'ember-qunit'; +import { module, test } from 'qunit'; + +module('Unit | Route | not-found', function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + const route = this.owner.lookup('route:not-found'); + + assert.ok(route); + }); +});