test: 💍 use breadcrumbs acceptance tests for navigation

This commit is contained in:
Randall Morey committed 2020-06-16 09:40:03 -04:00
1 parent 8f9f017995
commit f2f0144e5b
1 file changed
+41 -57
+41 -57
View File
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { visit, currentURL, click, findAll } from '@ember/test-helpers';
import { visit, currentURL, click, find, findAll } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
@@ -7,75 +7,59 @@ module('Acceptance | breadcrumbs', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
test('visiting projects', async function (assert) {
test('can navigate via breadcrumbs to projects from project', async function (assert) {
assert.expect(2);
this.server.createList('project', 1);
await visit('/orgs/1/projects');
assert.equal(findAll('.rose-nav-breadcrumbs a').length, 1);
await click('.rose-nav-breadcrumbs a');
assert.equal(currentURL(), '/orgs/1/projects');
});
test('visiting project', async function (assert) {
assert.expect(2);
this.server.createList('project', 1);
const projectURL = `/orgs/1/projects/${this.server.db.projects[0].id}`;
const project = this.server.create('project');
const projectURL = `/orgs/1/projects/${project.id}`;
await visit(projectURL);
assert.equal(findAll('.rose-nav-breadcrumbs a').length, 2);
await visit(projectURL);
await click(findAll('.rose-nav-breadcrumbs a')[1]);
assert.equal(currentURL(), projectURL);
assert.equal(currentURL(), projectURL, 'We begin on th expected page.');
await click(find('.rose-nav-breadcrumbs-link:first-child'));
assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.');
});
test('visiting project creation', async function (assert) {
test('can navigate via breadcrumbs to projects from new project', async function (assert) {
assert.expect(2);
this.server.createList('project', 1);
const projectURL = '/orgs/1/projects/new';
await visit(projectURL);
assert.equal(findAll('.rose-nav-breadcrumbs a').length, 2);
await visit(projectURL);
await click(findAll('.rose-nav-breadcrumbs a')[1]);
assert.equal(currentURL(), projectURL);
const newProjectURL = `/orgs/1/projects/new`;
await visit(newProjectURL);
assert.equal(currentURL(), newProjectURL, 'We begin on th expected page.');
await click(find('.rose-nav-breadcrumbs-link:first-child'));
assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.');
});
test('visiting host catalogs', async function (assert) {
test('can navigate via breadcrumbs to project from host catalogs', async function (assert) {
assert.expect(2);
this.server.createList('project', 1);
this.server.createList('host-catalog', 1);
const hostcatalogsURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs`;
await visit(hostcatalogsURL);
assert.equal(findAll('.rose-nav-breadcrumbs a').length, 3);
await visit(hostcatalogsURL);
await click(findAll('.rose-nav-breadcrumbs a')[2]);
assert.equal(currentURL(), hostcatalogsURL);
const project = this.server.create('project');
const projectURL = `/orgs/1/projects/${project.id}`;
const hostCatalogsURL = `${projectURL}/host-catalogs`;
await visit(hostCatalogsURL);
assert.equal(currentURL(), hostCatalogsURL, 'We begin on th expected page.');
await click(findAll('.rose-nav-breadcrumbs-link')[1]);
assert.equal(currentURL(), projectURL, 'After navigating via breadcrumbs, we are one level up.');
});
test('visiting host catalog', async function (assert) {
test('can navigate via breadcrumbs to host catalogs from host catalog', async function (assert) {
assert.expect(2);
this.server.createList('project', 1);
this.server.createList('host-catalog', 1);
const hostcatalogURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs/${this.server.db.hostCatalogs[0].id}`;
await visit(hostcatalogURL);
assert.equal(findAll('.rose-nav-breadcrumbs a').length, 4);
await visit(hostcatalogURL);
await click(findAll('.rose-nav-breadcrumbs a')[3]);
assert.equal(currentURL(), hostcatalogURL);
const project = this.server.create('project');
const hostCatalog = this.server.create('host-catalog');
const projectURL = `/orgs/1/projects/${project.id}`;
const hostCatalogsURL = `${projectURL}/host-catalogs`;
const hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`;
await visit(hostCatalogURL);
assert.equal(currentURL(), hostCatalogURL, 'We begin on th expected page.');
await click(findAll('.rose-nav-breadcrumbs-link')[2]);
assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.');
});
test('visiting host catalog creation', async function (assert) {
test('can navigate via breadcrumbs to host catalogs from new host catalog', async function (assert) {
assert.expect(2);
this.server.createList('project', 1);
this.server.createList('host-catalog', 1);
const hostcatalogURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs/new`;
await visit(hostcatalogURL);
assert.equal(findAll('.rose-nav-breadcrumbs a').length, 4);
await visit(hostcatalogURL);
await click(findAll('.rose-nav-breadcrumbs a')[3]);
assert.equal(currentURL(), hostcatalogURL);
const project = this.server.create('project');
const projectURL = `/orgs/1/projects/${project.id}`;
const hostCatalogsURL = `${projectURL}/host-catalogs`;
const newHostCatalogURL = `${hostCatalogsURL}/new`;
await visit(newHostCatalogURL);
assert.equal(currentURL(), newHostCatalogURL, 'We begin on th expected page.');
await click(findAll('.rose-nav-breadcrumbs-link')[2]);
assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.');
});
});