Skip to content

Commit

Permalink
Add not-found route
Browse files Browse the repository at this point in the history
  • Loading branch information
bertdeblock committed Mar 5, 2021
1 parent 3c2d7ab commit b334775
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 3 additions & 0 deletions app/routes/not-found.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class NotFoundRoute extends Route {}
6 changes: 6 additions & 0 deletions app/templates/not-found.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{page-title "Page Not Found"}}

<div class="container text-center">
<h1>Page Not Found</h1>
<p>We couldn't find what you were looking for.</p>
</div>
32 changes: 32 additions & 0 deletions tests/acceptance/not-found-test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
12 changes: 12 additions & 0 deletions tests/unit/routes/not-found-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit b334775

Please sign in to comment.