From b3347759db98e81cde79b4cec60fd4947a5f006f 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 | 3 +++ app/templates/not-found.hbs | 6 ++++++ tests/acceptance/not-found-test.js | 32 +++++++++++++++++++++++++++++ tests/unit/routes/not-found-test.js | 12 +++++++++++ 5 files changed, 55 insertions(+) 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/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..2ce5d4274 --- /dev/null +++ b/app/routes/not-found.js @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class NotFoundRoute extends Route {} diff --git a/app/templates/not-found.hbs b/app/templates/not-found.hbs new file mode 100644 index 000000000..ab05afe08 --- /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/tests/acceptance/not-found-test.js b/tests/acceptance/not-found-test.js new file mode 100644 index 000000000..4561ce47e --- /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/unit/routes/not-found-test.js b/tests/unit/routes/not-found-test.js new file mode 100644 index 000000000..5e6006795 --- /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) { + let route = this.owner.lookup('route:not-found'); + + assert.ok(route); + }); +});