test: 💍 test global scope auto-create

This commit is contained in:
Randall Morey committed 2020-10-27 15:26:12 -04:00
1 parent 2fba8025b0
commit 14408bc63e
2 files changed
+27 -2

No files matched your search

+2 -2
View File
@@ -27,6 +27,7 @@ export default class ScopesScopeRoute extends Route {
return this.store.findRecord('scope', id).catch(() => {
const maybeExistingScope = this.store.peekRecord('scope', id);
const scopeOptions = { id, type };
/* istanbul ignore else */
if (type === 'global') {
scopeOptions.name = this.intl.t('titles.global');
}
@@ -47,8 +48,7 @@ export default class ScopesScopeRoute extends Route {
orgs = await this.store.query('scope', { scope_id: 'global' })
.catch(() => A([]));
if (model.isProject) {
projects = await this.store.query('scope', { scope_id: model.scopeID })
.catch(() => A([]));
projects = await this.store.query('scope', { scope_id: model.scopeID });
}
// Then pull out the "selected" scopes, if relevant
let selectedOrg, selectedProject;
+25
View File
@@ -3,6 +3,7 @@ import { visit, currentURL, click } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import { Response } from 'miragejs';
import {
authenticateSession,
// These are left here intentionally for future reference.
@@ -58,6 +59,30 @@ module('Acceptance | scopes', function (hooks) {
authenticateSession({});
});
test('visiting global scope', async function (assert) {
assert.expect(1);
await visit(urls.globalScope);
await a11yAudit();
assert.equal(currentURL(), urls.globalScope);
});
// TODO: this probably shouldn't be the case, but was setup to enable
// authentication when the global scope couldn't be loaded.
// In order to resolve this, we might hoist authentication routes up from
// under scopes.
test('visiting global scope is successful even when the global scope cannot be fetched', async function (assert) {
assert.expect(1);
this.server.get('/scopes/:id', ({ scopes }, { params: { id } }) => {
const scope = scopes.find(id);
const response = (id === 'global')
? new Response(404)
: scope;
return response;
});
await visit(urls.globalScope);
assert.equal(currentURL(), urls.globalScope);
});
test('visiting org scope', async function (assert) {
assert.expect(1);
await visit(urls.orgScope);