Files
threshold-ui/ui/admin/tests/acceptance/managed-groups/members-test.js
T
hashicorp-copywrite[bot]andCameron Perera 3d610427d0 [COMPLIANCE] Add Copyright and License Headers (#1617)
* [COMPLIANCE] Add Copyright and License Headers

* chore: 🤖 update Copyright headers to satisfy our lint rules

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-03-01 09:39:41 -06:00

75 lines
2.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { visit, currentURL, findAll } 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 {
authenticateSession,
// These are left here intentionally for future reference.
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | managed-groups | members', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
const instances = {
scopes: {
global: null,
org: null,
},
authMethod: null,
managedGroup: null,
accounts: null,
};
const urls = {
orgScope: null,
authMethods: null,
managedGroups: null,
managedGroup: null,
managedGroupMembers: null,
};
hooks.beforeEach(function () {
authenticateSession({});
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
});
instances.authMethod = this.server.create(
'auth-method',
{
scope: instances.scopes.org,
type: 'oidc',
},
'withAccountsAndUsersAndManagedGroups'
);
instances.managedGroup = this.server.db.managedGroups[0];
// Generate route URLs for resources
urls.orgScope = `/scopes/${instances.scopes.org.id}`;
urls.authMethods = `${urls.orgScope}/auth-methods`;
urls.authMethod = `${urls.authMethods}/${instances.authMethod.id}`;
urls.managedGroups = `${urls.authMethod}/managed-groups`;
urls.managedGroup = `${urls.managedGroups}/${instances.managedGroup.id}`;
urls.managedGroupMembers = `${urls.managedGroup}/members`;
});
test('User can navigate to index', async function (assert) {
assert.expect(3);
const membersCount = instances.managedGroup.memberIds.length;
await visit(urls.managedGroupMembers);
await a11yAudit();
assert.strictEqual(currentURL(), urls.managedGroupMembers);
assert.ok(membersCount);
assert.strictEqual(findAll('tbody tr').length, membersCount);
});
});