Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andaley committed Jan 25, 2019
1 parent 9cf108b commit 991e291
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ui/tests/integration/components/features-selection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,36 @@ import { render } from '@ember/test-helpers';
import { create } from 'ember-cli-page-object';
import featuresSelection from 'vault/tests/pages/components/wizard/features-selection';
import hbs from 'htmlbars-inline-precompile';
import Service from '@ember/service';

const component = create(featuresSelection);

const permissionsService = Service.extend({
hasPermission(path) {
// This enables the Secrets and Authentication wizard items and disables the others.
const allowedPaths = ['sys/mounts/example', 'sys/auth', 'sys/auth/foo', 'sys/wrapping/wrap'];
if (allowedPaths.includes(path)) {
return true;
}
return false;
},
});

module('Integration | Component | features-selection', function(hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function() {
component.setContext(this);
this.owner.register('service:permissions', permissionsService);
});

hooks.afterEach(function() {
component.removeContext();
});

test('it disables and enables wizard items according to user permissions', async function(assert) {
const enabled = { Secrets: true, Authentication: false, Policies: true, Tools: false };
await render(hbs`{{wizard/features-selection allFeatures=}}`);
const enabled = { Secrets: true, Authentication: true, Policies: false, Tools: false };
await render(hbs`{{wizard/features-selection}}`);

component.wizardItems.forEach(i => {
assert.equal(
Expand All @@ -37,7 +50,7 @@ module('Integration | Component | features-selection', function(hooks) {
});

test('it enables the start button when user has permission and wizard items are checked', async function(assert) {
await render(hbs`{{wizard/features-selection hasSecretsPermission=true}}`);
await render(hbs`{{wizard/features-selection}}`);
await component.selectSecrets();

assert.equal(component.hasDisabledStartButton, false);
Expand Down

0 comments on commit 991e291

Please sign in to comment.