refactor: 💡 use constants for target types (#1538)

* refactor: 💡 use constants for target types

* chore: 🤖 import types rather than *

* chore: 🤖 use capitalized TYPES_TARGET constant name
This commit is contained in:
Randall Morey authored and GitHub committed 2022-12-20 12:07:52 -05:00
1 parent 473ebcc397
commit 69dfc7c784
13 files changed
+44 -32

No files matched your search

@@ -16,6 +16,7 @@ import {
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
module('Acceptance | targets | create', function (hooks) {
setupApplicationTest(hooks);
@@ -71,16 +72,16 @@ module('Acceptance | targets | create', function (hooks) {
// Generate resource counter
getTargetCount = () => this.server.schema.targets.all().models.length;
getSSHTargetCount = () =>
this.server.schema.targets.where({ type: 'ssh' }).models.length;
this.server.schema.targets.where({ type: TYPE_TARGET_SSH }).models.length;
getTCPTargetCount = () =>
this.server.schema.targets.where({ type: 'tcp' }).models.length;
this.server.schema.targets.where({ type: TYPE_TARGET_TCP }).models.length;
authenticateSession({});
});
test('defaults to type `ssh` when no query param provided', async function (assert) {
assert.expect(1);
await visit(urls.newTarget);
assert.strictEqual(find('[name="type"]:checked').value, 'ssh');
assert.strictEqual(find('[name="type"]:checked').value, TYPE_TARGET_SSH);
});
test('can create type `ssh`', async function (assert) {
@@ -5,6 +5,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { Response } from 'miragejs';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import { authenticateSession } from 'ember-simple-auth/test-support';
import { TYPE_TARGET_SSH } from 'api/models/target';
module(
'Acceptance | targets | injected application credential sources',
@@ -78,7 +79,7 @@ module(
instances.credential = instances.credentials[0];
instances.target = this.server.create('target', {
scope: instances.scopes.project,
type: 'ssh',
type: TYPE_TARGET_SSH,
});
randomlySelectedCredentials = this.server.schema.credentials
.all()
@@ -9,6 +9,7 @@ import {
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
module('Acceptance | targets | read', function (hooks) {
setupApplicationTest(hooks);
@@ -44,11 +45,11 @@ module('Acceptance | targets | read', function (hooks) {
scope: { id: instances.scopes.org.id, type: 'org' },
});
instances.sshTarget = this.server.create('target', {
type: 'ssh',
type: TYPE_TARGET_SSH,
scope: instances.scopes.project,
});
instances.tcpTarget = this.server.create('target', {
type: 'tcp',
type: TYPE_TARGET_TCP,
scope: instances.scopes.project,
});
// Generate route URLs for resources