diff --git a/x-pack/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap b/x-pack/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap index da3ec270458f6..641ff4fcab258 100644 --- a/x-pack/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap +++ b/x-pack/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`RequestTrialExtension component should display when trial license is about to expire 1`] = `"
Extend your trial

If you’d like to continuing using Security, Machine Learning, and our other awesome platinum features, request an extension now.

Extend trial
"`; +exports[`RequestTrialExtension component should display when license is active and trial has been used 1`] = `"
Extend your trial

If you’d like to continuing using Security, Machine Learning, and our other awesome platinum features, request an extension now.

Extend trial
"`; -exports[`RequestTrialExtension component should display when trial license is expired 1`] = `"
Extend your trial

If you’d like to continuing using Security, Machine Learning, and our other awesome platinum features, request an extension now.

Extend trial
"`; +exports[`RequestTrialExtension component should display when license is not active and trial has been used 1`] = `"
Extend your trial

If you’d like to continuing using Security, Machine Learning, and our other awesome platinum features, request an extension now.

Extend trial
"`; + +exports[`RequestTrialExtension component should display when platinum license is not active and trial has been used 1`] = `"
Extend your trial

If you’d like to continuing using Security, Machine Learning, and our other awesome platinum features, request an extension now.

Extend trial
"`; diff --git a/x-pack/plugins/license_management/__jest__/request_trial_extension.test.js b/x-pack/plugins/license_management/__jest__/request_trial_extension.test.js index ca2f4dde0bbcb..d8bb63b91b402 100644 --- a/x-pack/plugins/license_management/__jest__/request_trial_extension.test.js +++ b/x-pack/plugins/license_management/__jest__/request_trial_extension.test.js @@ -6,25 +6,28 @@ import { RequestTrialExtension } from '../public/sections/license_dashboard/request_trial_extension'; import { createMockLicense, getComponent } from './util'; -const nonImminentExpirationTime = new Date().getTime() + (30 * 24 * 60 * 60 * 1000); -// ten days from now -const imminentExpirationTime = new Date().getTime() + (10 * 24 * 60 * 60 * 1000); describe('RequestTrialExtension component', () => { - test('should not display when trial expires in > 24 days', () => { + test('should not display when license is active and trial has not been used', () => { const rendered = getComponent( { - license: createMockLicense('trial', nonImminentExpirationTime) + trialStatus: { + canStartTrial: true + }, + license: createMockLicense('trial') }, RequestTrialExtension ); const html = rendered.html(); expect(html).toBeNull(); }); - test('should display when trial license is expired', () => { + test('should display when license is active and trial has been used', () => { const rendered = getComponent( { - license: createMockLicense('trial', 0) + trialStatus: { + canStartTrial: false + }, + license: createMockLicense('trial') }, RequestTrialExtension ); @@ -32,96 +35,58 @@ describe('RequestTrialExtension component', () => { expect(html).not.toBeNull(); expect(html).toMatchSnapshot(); }); - test('should display when trial license is about to expire', () => { + test('should not display when license is not active and trial has not been used', () => { const rendered = getComponent( { - license: createMockLicense('trial', imminentExpirationTime) + trialStatus: { + canStartTrial: true + }, + license: createMockLicense('trial', 0) }, RequestTrialExtension ); const html = rendered.html(); - expect(html).not.toBeNull(); - expect(html).toMatchSnapshot(); - }); - test('should not display for about to expire basic license', () => { - const rendered = getComponent( - { - license: createMockLicense('basic', imminentExpirationTime) - }, - RequestTrialExtension - ); - expect(rendered.html()).toBeNull(); - }); - test('should not display for expired basic license', () => { - const rendered = getComponent( - { - license: createMockLicense('basic', 0) - }, - RequestTrialExtension - ); - expect(rendered.html()).toBeNull(); - }); - test('should not display for active basic license', () => { - const rendered = getComponent( - { - license: createMockLicense('basic') - }, - RequestTrialExtension - ); - expect(rendered.html()).toBeNull(); - }); - test('should not display for about to expire gold license', () => { - const rendered = getComponent( - { - license: createMockLicense('gold', imminentExpirationTime) - }, - RequestTrialExtension - ); - expect(rendered.html()).toBeNull(); - }); - test('should not display for expired gold license', () => { - const rendered = getComponent( - { - license: createMockLicense('gold', 0) - }, - RequestTrialExtension - ); - expect(rendered.html()).toBeNull(); - }); - test('should not display for active gold license', () => { - const rendered = getComponent( - { - license: createMockLicense('gold') - }, - RequestTrialExtension - ); - expect(rendered.html()).toBeNull(); + expect(html).toBeNull(); }); - test('should not display for about to expire platinum license', () => { + test('should display when license is not active and trial has been used', () => { const rendered = getComponent( { - license: createMockLicense('platinum', imminentExpirationTime) + trialStatus: { + canStartTrial: false + }, + license: createMockLicense('trial', 0) }, RequestTrialExtension ); - expect(rendered.html()).toBeNull(); + const html = rendered.html(); + expect(html).not.toBeNull(); + expect(html).toMatchSnapshot(); }); - test('should not display for expired platinum license', () => { + test('should display when platinum license is not active and trial has been used', () => { const rendered = getComponent( { + trialStatus: { + canStartTrial: false + }, license: createMockLicense('platinum', 0) }, RequestTrialExtension ); - expect(rendered.html()).toBeNull(); + const html = rendered.html(); + expect(html).not.toBeNull(); + expect(html).toMatchSnapshot(); }); - test('should not display for active platinum license', () => { + test('should not display when platinum license is active and trial has been used', () => { const rendered = getComponent( { + trialStatus: { + canStartTrial: false + }, license: createMockLicense('platinum') }, RequestTrialExtension ); - expect(rendered.html()).toBeNull(); + const html = rendered.html(); + expect(html).toBeNull(); }); }); diff --git a/x-pack/plugins/license_management/public/store/reducers/licenseManagement.js b/x-pack/plugins/license_management/public/store/reducers/licenseManagement.js index 35c1a02f26a07..4b79b330da2c1 100644 --- a/x-pack/plugins/license_management/public/store/reducers/licenseManagement.js +++ b/x-pack/plugins/license_management/public/store/reducers/licenseManagement.js @@ -71,11 +71,6 @@ export const shouldShowRevertToBasicLicense = state => { return type === 'trial' || isImminentExpiration(state) || isExpired(state); }; -export const shouldShowRequestTrialExtension = state => { - const { type } = getLicense(state); - return type === 'trial' && (isImminentExpiration(state) || isExpired(state)); -}; - export const uploadNeedsAcknowledgement = state => { return !!state.uploadStatus.acknowledge; }; @@ -105,6 +100,15 @@ export const shouldShowStartTrial = state => { (licenseType !== 'platinum' || isExpired(state)) ); }; + +export const shouldShowRequestTrialExtension = state => { + if (state.trialStatus.canStartTrial) { + return false; + } + const { type } = getLicense(state); + return type !== 'platinum' || isExpired(state); +}; + export const startTrialError = state => { return state.trialStatus.startTrialError; };