Skip to content

Commit

Permalink
UI - fix perf standby feature display (#5971)
Browse files Browse the repository at this point in the history
* add performanceStandbyCount to license model

* use count to determine if perf standby is an active feature

* rename test file and add tests for new perf standby behavior

* Update ui/app/templates/components/license-info.hbs

* update display language
  • Loading branch information
meirish authored Dec 18, 2018
1 parent 0a703fd commit fb35119
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
19 changes: 13 additions & 6 deletions ui/app/components/license-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ export default Component.extend({
startTime: '',
licenseId: '',
features: null,
model: null,
text: '',
showForm: false,
isTemporary: computed('licenseId', function() {
return this.licenseId === 'temporary';
}),
featuresInfo: computed('features', function() {
let info = [];
allFeatures().forEach(feature => {
let active = this.features.includes(feature) ? true : false;
info.push({ name: feature, active: active });
featuresInfo: computed('model', 'features', function() {
return allFeatures().map(feature => {
let active = this.features.includes(feature);
if (active && feature === 'Performance Standby') {
let count = this.model.performanceStandbyCount;
return {
name: feature,
active: count ? active : false,
count,
};
}
return { name: feature, active };
});
return info;
}),
saveModel() {},
actions: {
Expand Down
1 change: 1 addition & 0 deletions ui/app/models/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export default DS.Model.extend({
licenseId: attr('string'),
startTime: attr('string'),
text: attr('string'),
performanceStandbyCount: attr('number'),
});
3 changes: 2 additions & 1 deletion ui/app/templates/components/license-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
{{#each featuresInfo as |info|}}
{{#info-table-row label=info.name value=(if info.active "Active" "Not Active") data-test-feature-row="data-test-feature-row"}}
{{#if info.active}}
<ICon @size=28 @glyph="true" /> <span data-test-feature-status>Active</span>
<ICon @size=28 @glyph="true" /> <span data-test-feature-status>Active {{#if info.count}}&mdash;
{{info.count}} standby nodes allotted{{/if}}</span>
{{else}}
<ICon @size=28 @glyph="false" /> <span data-test-feature-status>Not Active</span>
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ const component = create(license);
module('Integration | Component | license info', function(hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function() {
component.setContext(this);
});

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

const LICENSE_WARNING_TEXT = `Warning Your temporary license expires in 30 minutes and your vault will seal. Please enter a valid license below.`;

test('it renders properly for temporary license', async function(assert) {
Expand Down Expand Up @@ -114,4 +106,36 @@ module('Integration | Component | license info', function(hooks) {
await component.saveButton();
assert.ok(this.get('saveModel').calledOnce);
});

test('it renders Performance Standby as inactive if count is 0', async function(assert) {
const now = Date.now();
this.set('licenseId', 'temporary');
this.set('expirationTime', addMinutes(now, 30));
this.set('startTime', now);
this.set('model', { performanceStandbyCount: 0 });
this.set('features', ['Performance Standby', 'Namespaces']);

await render(
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}} @model={{this.model}}/>`
);

let row = component.featureRows.filterBy('featureName', 'Performance Standby')[0];
assert.equal(row.featureStatus, 'Not Active', 'renders feature as inactive because when count is 0');
});

test('it renders Performance Standby as active and shows count', async function(assert) {
const now = Date.now();
this.set('licenseId', 'temporary');
this.set('expirationTime', addMinutes(now, 30));
this.set('startTime', now);
this.set('model', { performanceStandbyCount: 4 });
this.set('features', ['Performance Standby', 'Namespaces']);

await render(
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}} @model={{this.model}}/>`
);

let row = component.featureRows.filterBy('featureName', 'Performance Standby')[0];
assert.equal(row.featureStatus, 'Active — 4 standby nodes allotted', 'renders active and displays count');
});
});

0 comments on commit fb35119

Please sign in to comment.