refactor: 💡 consolidate common steps into before hook

This commit is contained in:
Randall Morey committed 2020-06-16 10:05:16 -04:00
1 parent f2f0144e5b
commit e48af4bc9d
1 file changed
+20 -15
+20 -15
View File
@@ -7,10 +7,28 @@ module('Acceptance | breadcrumbs', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let project;
let hostCatalog;
let projectsURL;
let newProjectURL;
let projectURL;
let hostCatalogsURL;
let newHostCatalogURL;
let hostCatalogURL;
hooks.beforeEach(function () {
project = this.server.create('project');
hostCatalog = this.server.create('host-catalog');
projectsURL = `/orgs/1/projects`;
newProjectURL = `${projectsURL}/new`;
projectURL = `${projectsURL}/${project.id}`;
hostCatalogsURL = `${projectURL}/host-catalogs`;
newHostCatalogURL = `${hostCatalogsURL}/new`;
hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`;
});
test('can navigate via breadcrumbs to projects from project', async function (assert) {
assert.expect(2);
const project = this.server.create('project');
const projectURL = `/orgs/1/projects/${project.id}`;
await visit(projectURL);
assert.equal(currentURL(), projectURL, 'We begin on th expected page.');
await click(find('.rose-nav-breadcrumbs-link:first-child'));
@@ -19,7 +37,6 @@ module('Acceptance | breadcrumbs', function (hooks) {
test('can navigate via breadcrumbs to projects from new project', async function (assert) {
assert.expect(2);
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'));
@@ -28,9 +45,6 @@ module('Acceptance | breadcrumbs', function (hooks) {
test('can navigate via breadcrumbs to project from host catalogs', async function (assert) {
assert.expect(2);
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]);
@@ -39,11 +53,6 @@ module('Acceptance | breadcrumbs', function (hooks) {
test('can navigate via breadcrumbs to host catalogs from host catalog', async function (assert) {
assert.expect(2);
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]);
@@ -52,10 +61,6 @@ module('Acceptance | breadcrumbs', function (hooks) {
test('can navigate via breadcrumbs to host catalogs from new host catalog', async function (assert) {
assert.expect(2);
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]);