Commit 8703fdaa authored by Enrique Alcantara's avatar Enrique Alcantara

Fix base domain help text update

parent 5065f187
...@@ -279,14 +279,10 @@ export default class Clusters { ...@@ -279,14 +279,10 @@ export default class Clusters {
this.store.acknowledgeSuccessfulUpdate(appId); this.store.acknowledgeSuccessfulUpdate(appId);
} }
toggleIngressDomainHelpText(ingressPreviousState, ingressNewState) { toggleIngressDomainHelpText({ externalIp }, { externalIp: newExternalIp }) {
const { externalIp, status } = ingressNewState; if (externalIp !== newExternalIp) {
const helpTextHidden = status !== APPLICATION_STATUS.INSTALLED || !externalIp; this.ingressDomainHelpText.classList.toggle('hide', !newExternalIp);
const domainSnippetText = `${externalIp}${INGRESS_DOMAIN_SUFFIX}`; this.ingressDomainSnippet.textContent = `${newExternalIp}${INGRESS_DOMAIN_SUFFIX}`;
if (ingressPreviousState.status !== status) {
this.ingressDomainHelpText.classList.toggle('hide', helpTextHidden);
this.ingressDomainSnippet.textContent = domainSnippetText;
} }
} }
......
...@@ -6,7 +6,7 @@ import { loadHTMLFixture } from 'helpers/fixtures'; ...@@ -6,7 +6,7 @@ import { loadHTMLFixture } from 'helpers/fixtures';
import { setTestTimeout } from 'helpers/timeout'; import { setTestTimeout } from 'helpers/timeout';
import $ from 'jquery'; import $ from 'jquery';
const { INSTALLING, INSTALLABLE, INSTALLED, NOT_INSTALLABLE } = APPLICATION_STATUS; const { INSTALLING, INSTALLABLE, INSTALLED } = APPLICATION_STATUS;
describe('Clusters', () => { describe('Clusters', () => {
setTestTimeout(1000); setTestTimeout(1000);
...@@ -317,13 +317,12 @@ describe('Clusters', () => { ...@@ -317,13 +317,12 @@ describe('Clusters', () => {
let ingressNewState; let ingressNewState;
beforeEach(() => { beforeEach(() => {
ingressPreviousState = { status: INSTALLABLE }; ingressPreviousState = { externalIp: null };
ingressNewState = { status: INSTALLED, externalIp: '127.0.0.1' }; ingressNewState = { externalIp: '127.0.0.1' };
}); });
describe(`when ingress application new status is ${INSTALLED}`, () => { describe(`when ingress have an external ip assigned`, () => {
beforeEach(() => { beforeEach(() => {
ingressNewState.status = INSTALLED;
cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState); cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);
}); });
...@@ -338,31 +337,11 @@ describe('Clusters', () => { ...@@ -338,31 +337,11 @@ describe('Clusters', () => {
}); });
}); });
describe(`when ingress application new status is different from ${INSTALLED}`, () => { describe(`when ingress does not have an external ip assigned`, () => {
it('hides custom domain help text', () => { it('hides custom domain help text', () => {
ingressNewState.status = NOT_INSTALLABLE; ingressPreviousState.externalIp = '127.0.0.1';
cluster.ingressDomainHelpText.classList.remove('hide');
cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);
expect(cluster.ingressDomainHelpText.classList.contains('hide')).toEqual(true);
});
});
describe('when ingress application new status and old status are the same', () => {
it('does not display custom domain help text', () => {
ingressPreviousState.status = INSTALLED;
ingressNewState.status = ingressPreviousState.status;
cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);
expect(cluster.ingressDomainHelpText.classList.contains('hide')).toEqual(true);
});
});
describe(`when ingress new status is ${INSTALLED} and there isn’t an ip assigned`, () => {
it('does not display custom domain help text', () => {
ingressNewState.externalIp = null; ingressNewState.externalIp = null;
cluster.ingressDomainHelpText.classList.remove('hide');
cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState); cluster.toggleIngressDomainHelpText(ingressPreviousState, ingressNewState);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment