refactor: 💡 remove route-action usage for users (#2299)

* refactor: 💡 remove route-action usage for users

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12612
This commit is contained in:
Lisbet Alvarez authored and GitHub committed 2024-06-10 17:00:57 -07:00
1 parent 2f6e36c035
commit ea460c1391
18 files changed
+323 -116

No files matched your search

@@ -0,0 +1,16 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module(
'Unit | Controller | scopes/scope/users/user/accounts',
function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let controller = this.owner.lookup(
'controller:scopes/scope/users/user/accounts',
);
assert.ok(controller);
});
},
);
@@ -0,0 +1,63 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { visit } from '@ember/test-helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { authenticateSession } from 'ember-simple-auth/test-support';
module(
'Unit | Controller | scopes/scope/users/user/add-accounts',
function (hooks) {
setupTest(hooks);
setupMirage(hooks);
let store;
let controller;
const instances = {
scopes: {
global: null,
},
user: null,
account: null,
};
const urls = {
globalScope: null,
addAccounts: null,
};
hooks.beforeEach(function () {
authenticateSession({});
store = this.owner.lookup('service:store');
controller = this.owner.lookup(
'controller:scopes/scope/users/user/add-accounts',
);
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.user = this.server.create('user', {
scope: instances.scopes.global,
});
instances.account = this.server.create('account', {
scope: instances.scopes.global,
});
urls.globalScope = `/scopes/global`;
urls.addAccounts = `${urls.globalScope}/users/add-accounts`;
});
test('it exists', function (assert) {
assert.ok(controller);
});
test('addAccount action adds specified account to model', async function (assert) {
await visit(urls.addAccounts);
const user = await store.findRecord('user', instances.user.id);
assert.deepEqual(user.account_ids, []);
await controller.addAccounts(user, [instances.account.id]);
assert.deepEqual(user.account_ids, [instances.account.id]);
});
},
);
@@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/users/user/index', function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let controller = this.owner.lookup(
'controller:scopes/scope/users/user/index',
);
assert.ok(controller);
});
});