2022-05-17 18:52:14 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { currentURL } from '@ember/test-helpers';
|
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
|
|
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
|
|
|
|
import defaultScenario from '../../mirage/scenarios/default';
|
|
|
|
|
|
|
|
import Variables from 'nomad-ui/tests/pages/variables';
|
|
|
|
import Layout from 'nomad-ui/tests/pages/layout';
|
|
|
|
|
|
|
|
const SECURE_TOKEN_ID = '53cur3-v4r14bl35';
|
|
|
|
|
|
|
|
module('Acceptance | secure variables', function (hooks) {
|
|
|
|
setupApplicationTest(hooks);
|
|
|
|
setupMirage(hooks);
|
2022-05-30 17:10:44 +00:00
|
|
|
hooks.beforeEach(async function () {
|
|
|
|
server.createList('variable', 3);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it redirects to jobs and hides the gutter link when the token lacks permissions', async function (assert) {
|
|
|
|
await Variables.visit();
|
|
|
|
assert.equal(currentURL(), '/jobs');
|
|
|
|
assert.ok(Layout.gutter.variables.isHidden);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it allows access for management level tokens', async function (assert) {
|
|
|
|
defaultScenario(server);
|
|
|
|
window.localStorage.nomadTokenSecret = server.db.tokens[0].secretId;
|
|
|
|
await Variables.visit();
|
|
|
|
assert.equal(currentURL(), '/variables');
|
|
|
|
assert.ok(Layout.gutter.variables.isVisible, 'Menu section is visible');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it allows access for list-variables allowed ACL rules', async function (assert) {
|
|
|
|
assert.expect(2);
|
|
|
|
defaultScenario(server);
|
|
|
|
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
|
|
|
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
|
|
|
|
|
|
|
await Variables.visit();
|
|
|
|
assert.equal(currentURL(), '/variables');
|
|
|
|
assert.ok(Layout.gutter.variables.isVisible);
|
|
|
|
});
|
2022-05-17 18:52:14 +00:00
|
|
|
|
2022-05-30 17:10:44 +00:00
|
|
|
test('it passes an accessibility audit', async function (assert) {
|
|
|
|
assert.expect(1);
|
|
|
|
defaultScenario(server);
|
|
|
|
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
|
|
|
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
|
|
|
await Variables.visit();
|
|
|
|
await a11yAudit(assert);
|
2022-05-17 18:52:14 +00:00
|
|
|
});
|
|
|
|
});
|