test: Add test for non-global scope index redirection

This commit is contained in:
Susmitha Girumala committed 2020-09-24 14:38:15 -04:00
1 parent c5ff915414
commit 44c296cacb
2 files changed
+13 -9

No files matched your search

+4 -1
View File
@@ -12,10 +12,13 @@ export default class ScopesScopeOrgsRoute extends Route {
// =methods
/**
* If arriving here unauthenticated, redirect to index for further processing.
* If arriving here unauthenticated or from a non-global scope,
* redirect to index for further processing.
*/
beforeModel() {
if (!this.session.isAuthenticated) this.transitionTo('index');
const scope = this.modelFor('scopes.scope');
if(!scope.isGlobal) this.transitionTo('index');
}
/**
+9 -8
View File
@@ -56,25 +56,26 @@ module('Acceptance | org', function (hooks) {
assert.equal(findAll('article').length, orgsCount);
});
test('visiting scopes redirects to orgs', async function (assert) {
test('visiting scopes redirects to index', async function (assert) {
assert.expect(1);
await visit(urls.scopes);
await a11yAudit();
assert.equal(currentURL(), urls.orgs);
});
test('visiting root redirects to orgs', async function (assert) {
test('visiting root redirects to index', async function (assert) {
assert.expect(1);
await visit(urls.root);
await a11yAudit();
assert.equal(currentURL(), urls.orgs);
});
test('visiting orgs within a org scope redirects to the parent org scope', async function (assert) {
assert.expect(0);
test('visiting orgs within a non global scope redirects to index', async function (assert) {
const nonGlobalScopeURL = `${urls.scopes}/123/orgs`;
assert.expect(1);
await visit(nonGlobalScopeURL);
assert.equal(currentURL(), urls.orgs);
});
test('can create new orgs', async function (assert) {
test('can create a new org', async function (assert) {
assert.expect(1);
await visit(urls.newOrg);
await fillIn('[name="name"]', 'Org name');
@@ -83,7 +84,7 @@ module('Acceptance | org', function (hooks) {
assert.equal(this.server.db.scopes.where(scope => scope.type === 'org').length, orgsCount + 1);
});
test('can cancel create new orgs', async function (assert) {
test('can cancel new org creation', async function (assert) {
assert.expect(2);
await visit(urls.newOrg);
await fillIn('[name="name"]', 'Org name');