Merge pull request #61 from hashicorp/chore-mocks
Integrate mock orgs and auth methods with core ui
This commit is contained in:
20 files changed
+121
-23
No files matched your search
@@ -4,7 +4,7 @@ import { attr } from '@ember-data/model';
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export default class GeneratedOrganizationModel extends BaseModel {
|
||||
export default class GeneratedAuthMethodModel extends BaseModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
@@ -34,4 +34,9 @@ export default class GeneratedOrganizationModel extends BaseModel {
|
||||
})
|
||||
updated_time;
|
||||
|
||||
@attr('boolean', {
|
||||
description: 'Whether the resource is disabled',
|
||||
})
|
||||
disabled;
|
||||
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { attr } from '@ember-data/model';
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export default class GeneratedOrganizationModel extends BaseModel {
|
||||
export default class GeneratedOrgModel extends BaseModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import GeneratedOrgModel from '../generated/models/org';
|
||||
|
||||
export default class OrgModel extends GeneratedOrgModel {}
|
||||
@@ -1,3 +0,0 @@
|
||||
import GeneratedOrganizationModel from '../generated/models/organization';
|
||||
|
||||
export default class OrganizationModel extends GeneratedOrganizationModel {}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/models/org';
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from 'api/models/organization';
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Model | organization', function(hooks) {
|
||||
module('Unit | Model | org', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('organization', {});
|
||||
let model = store.createRecord('org', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,15 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsRoute extends Route {}
|
||||
export default class OrgsRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns all orgs from the store.
|
||||
* @return {Promise[OrgModel]}
|
||||
*/
|
||||
model() {
|
||||
return this.store.findAll('org');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,13 +9,12 @@ export default class OrgsOrgRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns a mock organization object containing the specified ID.
|
||||
* TODO: load a real org instance from the API.
|
||||
* Returns an org by id.
|
||||
* @param {object} params
|
||||
* @return {object}
|
||||
* @return {Promise{OrgModel}}
|
||||
*/
|
||||
model({ org_id: id }) {
|
||||
return { id };
|
||||
return this.store.findRecord('org', id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,14 +15,34 @@ export default function() {
|
||||
if (config.api.host) this.passthrough(`${config.api.host}/**`);
|
||||
this.passthrough();
|
||||
|
||||
// Scope resources
|
||||
// org
|
||||
|
||||
this.get('/orgs');
|
||||
this.post('/orgs');
|
||||
this.get('/orgs/:id');
|
||||
this.patch('/orgs/:id');
|
||||
this.del('/orgs/:id');
|
||||
|
||||
// project
|
||||
|
||||
this.get('/orgs/:org_id/projects');
|
||||
this.post('/orgs/:org_id/projects');
|
||||
this.get('/orgs/:org_id/projects/:id');
|
||||
this.patch('/orgs/:org_id/projects/:id');
|
||||
this.del('/orgs/:org_id/projects/:id');
|
||||
|
||||
// Auth & IAM resources
|
||||
|
||||
this.get('/orgs/:org_id/auth-methods');
|
||||
this.post('/orgs/:org_id/auth-methods');
|
||||
this.get('/orgs/:org_id/auth-methods/:id');
|
||||
this.patch('/orgs/:org_id/auth-methods/:id');
|
||||
this.del('/orgs/:org_id/auth-methods/:id');
|
||||
|
||||
// Other resources
|
||||
// host-catalog
|
||||
|
||||
this.get('/orgs/:org_id/projects/:project_id/host-catalogs');
|
||||
this.post('/orgs/:org_id/projects/:project_id/host-catalogs');
|
||||
this.get('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import factory from '../generated/factories/auth-method';
|
||||
|
||||
export default factory.extend();
|
||||
@@ -0,0 +1,3 @@
|
||||
import factory from '../generated/factories/org';
|
||||
|
||||
export default factory.extend();
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedAuthMethodModelFactory
|
||||
*/
|
||||
export default Factory.extend({
|
||||
|
||||
type: 'password',
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
disabled: () => random.boolean(),
|
||||
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedOrgModelFactory
|
||||
*
|
||||
*/
|
||||
export default Factory.extend({
|
||||
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
|
||||
});
|
||||
@@ -1,14 +1,19 @@
|
||||
export default function(server) {
|
||||
|
||||
// Scope resources (org and project) have their relationship modelled.
|
||||
// Scope resources
|
||||
|
||||
server.createList('project', 3);
|
||||
server.createList('org', 3);
|
||||
server.createList('project', 6);
|
||||
|
||||
// For simplicity, other resources have their relationships modelled _except_
|
||||
// their relationships to scope. These leads to the situation where the UI
|
||||
// displays _all subresources_ as if they belong to _every scope_. This is
|
||||
// a tradeoff due to the complexity of relationship modelling.
|
||||
// Auth
|
||||
|
||||
server.createList('host-catalog', 3);
|
||||
// Auth methods exist both at the global scope and the org scope.
|
||||
// For simplicity we don't scope our mock auth methods and just return the
|
||||
// same items for request at all scopes.
|
||||
server.createList('auth-method', 3);
|
||||
|
||||
// Other resources
|
||||
|
||||
server.createList('host-catalog', 6);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
modelName: 'auth-method'
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
modelName: 'org'
|
||||
});
|
||||
@@ -7,6 +7,7 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let org;
|
||||
let project;
|
||||
let hostCatalog;
|
||||
let projectsURL;
|
||||
@@ -19,9 +20,10 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
let crumbPath;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
org = this.server.create('org');
|
||||
project = this.server.create('project');
|
||||
hostCatalog = this.server.create('host-catalog');
|
||||
projectsURL = `/orgs/1/projects`;
|
||||
projectsURL = `/orgs/${org.id}/projects`;
|
||||
newProjectURL = `${projectsURL}/new`;
|
||||
projectURL = `${projectsURL}/${project.id}`;
|
||||
hostCatalogsURL = `${projectURL}/host-catalogs`;
|
||||
@@ -36,7 +38,7 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname;
|
||||
assert.equal(crumbPath, projectURL, 'Last crumb has expected URL.');
|
||||
await click(find('.rose-nav-breadcrumbs-link:first-child'));
|
||||
assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.');
|
||||
assert.equal(currentURL(), projectsURL, 'After navigating via breadcrumbs, we are one level up.');
|
||||
});
|
||||
|
||||
test('can navigate via breadcrumbs to projects from new project', async function (assert) {
|
||||
@@ -46,7 +48,7 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname;
|
||||
assert.equal(crumbPath, newProjectURL, 'Last crumb has expected URL.');
|
||||
await click(find('.rose-nav-breadcrumbs-link:first-child'));
|
||||
assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.');
|
||||
assert.equal(currentURL(), projectsURL, 'After navigating via breadcrumbs, we are one level up.');
|
||||
});
|
||||
|
||||
test('can navigate via breadcrumbs to project from host catalogs', async function (assert) {
|
||||
|
||||
@@ -9,6 +9,10 @@ module('Acceptance | host catalogs', function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.server.create('org');
|
||||
});
|
||||
|
||||
test('visiting host catalogs', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.createList('project', 1);
|
||||
|
||||
@@ -9,6 +9,10 @@ module('Acceptance | projects', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.server.create('org');
|
||||
});
|
||||
|
||||
test('visiting projects', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.createList('project', 1);
|
||||
|
||||
Reference in new issue
Block a user