diff --git a/ui/tests/acceptance/job-clients-test.js b/ui/tests/acceptance/job-clients-test.js index 4f1ac8bde51..528a1565377 100644 --- a/ui/tests/acceptance/job-clients-test.js +++ b/ui/tests/acceptance/job-clients-test.js @@ -5,6 +5,7 @@ import { setupApplicationTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit'; import Clients from 'nomad-ui/tests/pages/jobs/job/clients'; +import setPolicy from 'nomad-ui/tests/utils/set-policy'; let job; let clients; @@ -227,13 +228,3 @@ module('Acceptance | job clients', function (hooks) { // TODO: add facet tests for actual list filtering } }); - -function setPolicy(policy) { - const { id: policyId } = server.create('policy', policy); - const clientToken = server.create('token', { type: 'client' }); - clientToken.policyIds = [policyId]; - clientToken.save(); - - window.localStorage.clear(); - window.localStorage.nomadTokenSecret = clientToken.secretId; -} diff --git a/ui/tests/helpers/module-for-job.js b/ui/tests/helpers/module-for-job.js index 58d078121b3..53d373ae812 100644 --- a/ui/tests/helpers/module-for-job.js +++ b/ui/tests/helpers/module-for-job.js @@ -10,6 +10,7 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; import JobDetail from 'nomad-ui/tests/pages/jobs/detail'; +import setPolicy from 'nomad-ui/tests/utils/set-policy'; // moduleFor is an old Ember-QUnit API that is deprected https://guides.emberjs.com/v1.10.0/testing/unit-test-helpers/ // this is a misnomer in our context, because we're not using this API, however, the linter does not understand this @@ -363,16 +364,6 @@ function urlWithNamespace(url, namespace) { return `${parts[0]}?${params.toString()}`; } -function setPolicy(policy) { - const { id: policyId } = server.create('policy', policy); - const clientToken = server.create('token', { type: 'client' }); - clientToken.policyIds = [policyId]; - clientToken.save(); - - window.localStorage.clear(); - window.localStorage.nomadTokenSecret = clientToken.secretId; -} - async function visitJobDetailPage({ id, namespace }) { if (!namespace || namespace === 'default') { await JobDetail.visit({ id }); diff --git a/ui/tests/utils/set-policy.js b/ui/tests/utils/set-policy.js new file mode 100644 index 00000000000..49915b6f5fe --- /dev/null +++ b/ui/tests/utils/set-policy.js @@ -0,0 +1,9 @@ +export default function setPolicy(policy) { + const { id: policyId } = server.create('policy', policy); + const clientToken = server.create('token', { type: 'client' }); + clientToken.policyIds = [policyId]; + clientToken.save(); + + window.localStorage.clear(); + window.localStorage.nomadTokenSecret = clientToken.secretId; +}