123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- var validationUtils = require('utils/validator');
- require('utils/helper');
- require('controllers/wizard/step6_controller');
- var controller,
- services = [
- Em.Object.create({
- serviceName: 'YARN',
- isSelected: true
- }),
- Em.Object.create({
- serviceName: 'HBASE',
- isSelected: true
- }),
- Em.Object.create({
- serviceName: 'HDFS',
- isSelected: true
- }),
- Em.Object.create({
- serviceName: 'STORM',
- isSelected: true
- }),
- Em.Object.create({
- serviceName: 'FLUME',
- isSelected: true
- })
- ];
- function getController() {
- var c = App.WizardStep6Controller.create({
- content: Em.Object.create({
- hosts: {},
- masterComponentHosts: {},
- services: services,
- controllerName: ''
- })
- });
- var h = {}, m = [];
- Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) {
- var obj = Em.Object.create({
- name: hostName,
- hostName: hostName,
- bootStatus: 'REGISTERED'
- });
- h[hostName] = obj;
- m.push(obj);
- });
- c.set('content.hosts', h);
- c.set('content.masterComponentHosts', m);
- c.set('isMasters', false);
- return c;
- }
- describe('App.WizardStep6Controller', function () {
- beforeEach(function () {
- controller = getController();
- });
- App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController');
- describe('#installedServiceNames', function () {
- it(' should filter content.services by isInstalled property', function () {
- var _services = Em.A([]);
- _services.pushObjects(Em.A([{isInstalled: true, serviceName: "service1"},
- {isInstalled: false, serviceName: "service2"},
- {isInstalled: true, serviceName: "service3"},
- {isInstalled: false, serviceName: "service4"},
- {isInstalled: true, serviceName: "service5"}]));
- controller.set('content.services', _services);
- expect(controller.get('installedServiceNames')).to.eql(["service1", "service3", "service5"]);
- });
- });
- describe('#showValidationIssuesAcceptBox', function () {
- it('should return true if success callback', function () {
- var deffer = jQuery.Deferred();
- function callback() {
- deffer.resolve(true);
- }
- controller.showValidationIssuesAcceptBox(callback);
- jQuery.when(deffer.promise()).then(function(data) {
- expect(data).to.equal(true);
- });
- });
- });
- describe('#selectAllNodes', function () {
- var hostsObj = Em.A([Em.Object.create({
- hasMaster: false,
- isInstalled: false,
- checkboxes: Em.A([
- Em.Object.create({
- title: 'l1',
- component: 'name',
- isInstalled: false,
- checked: false
- })
- ])
- })]);
- var obj = Em.Object.create({
- context: {
- name: "name"
- }
- });
- var clientComponents = Em.A([{component_name: "name1"}]);
- it('should make checkbox checked', function () {
- controller.set('hosts', hostsObj);
- controller.set('content.clients', clientComponents);
- controller.selectAllNodes(obj);
- expect(controller.get('hosts')).to.eql(Em.A([Em.Object.create({
- hasMaster: false,
- isInstalled: false,
- checkboxes: Em.A([
- Em.Object.create({
- title: 'l1',
- component: 'name',
- isInstalled: false,
- checked: true
- })
- ])
- })]));
- });
- });
- describe('#deselectAllNodes', function () {
- var hostsObj = Em.A([Em.Object.create({
- hasMaster: false,
- isInstalled: false,
- checkboxes: Em.A([
- Em.Object.create({
- title: 'l1',
- component: 'name',
- isInstalled: false,
- checked: true
- })
- ])
- })]);
- var obj = Em.Object.create({
- context: {
- name: "name"
- }
- });
- var clientComponents = Em.A([{component_name: "name1"}]);
- it('should uncheck checkbox', function () {
- controller.set('hosts', hostsObj);
- controller.set('content.clients', clientComponents);
- controller.deselectAllNodes(obj);
- expect(controller.get('hosts')).to.eql(Em.A([Em.Object.create({
- hasMaster: false,
- isInstalled: false,
- checkboxes: Em.A([
- Em.Object.create({
- title: 'l1',
- component: 'name',
- isInstalled: false,
- checked: false
- })
- ])
- })]));
- });
- });
- describe('#renderSlaves()', function () {
- var hostsObj = [{}];
- beforeEach(function() {
- sinon.stub(controller, 'selectRecommendedComponents');
- sinon.stub(controller, 'setInstalledComponents');
- sinon.stub(controller, 'restoreComponentsSelection');
- sinon.stub(controller, 'selectClientHost');
- });
- afterEach(function() {
- controller.selectRecommendedComponents.restore();
- controller.setInstalledComponents.restore();
- controller.restoreComponentsSelection.restore();
- controller.selectClientHost.restore();
- });
- describe("slaveComponents is null", function() {
- beforeEach(function() {
- controller.set('content.slaveComponentHosts', null);
- });
- it("selectRecommendedComponents should be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.selectRecommendedComponents.calledWith(hostsObj)).to.be.true;
- });
- it("setInstalledComponents should be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.setInstalledComponents.calledWith(hostsObj)).to.be.true;
- });
- it("restoreComponentsSelection should not be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.restoreComponentsSelection.called).to.be.false;
- });
- it("selectClientHost should be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.selectClientHost.calledWith(hostsObj)).to.be.true;
- });
- });
- describe("slaveComponents is defined", function() {
- var slaveComponentHosts = [{}];
- beforeEach(function() {
- controller.set('content.slaveComponentHosts', slaveComponentHosts);
- });
- it("selectRecommendedComponents should not be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.selectRecommendedComponents.called).to.be.false;
- });
- it("setInstalledComponents should not be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.setInstalledComponents.called).to.be.false;
- });
- it("restoreComponentsSelection should be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.restoreComponentsSelection.calledWith(hostsObj, slaveComponentHosts)).to.be.true;
- });
- it("selectClientHost should be called", function() {
- expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
- expect(controller.selectClientHost.calledWith(hostsObj)).to.be.true;
- });
- });
- });
- describe("#setInstalledComponents()", function() {
- var hostsObj = [{
- hostName: 'host1',
- checkboxes: [
- {
- component: 'C1',
- isInstalled: false,
- checked: false
- },
- {
- component: 'C2',
- isInstalled: false,
- checked: false
- }
- ]
- }];
- it("installedHosts is null", function() {
- controller.set('content.installedHosts', null);
- expect(controller.setInstalledComponents(hostsObj)).to.be.false;
- });
- it("installedHosts is defined", function() {
- controller.set('content.installedHosts', {
- 'host1': {
- hostComponents: [
- {
- HostRoles: {
- component_name: 'C1'
- }
- }
- ]
- }
- });
- controller.setInstalledComponents(hostsObj);
- expect(hostsObj[0].checkboxes[0].isInstalled).to.be.true;
- expect(hostsObj[0].checkboxes[1].isInstalled).to.be.false;
- expect(hostsObj[0].checkboxes[0].checked).to.be.true;
- expect(hostsObj[0].checkboxes[1].checked).to.be.false;
- });
- });
- describe("#restoreComponentsSelection()", function() {
- var getHostsObj = function() {
- return [{
- hostName: 'host1',
- checkboxes: [
- {
- component: 'C1',
- title: 'c1',
- isInstalled: false,
- checked: false
- },
- {
- component: 'C2',
- title: 'c1',
- isInstalled: true,
- checked: false
- },
- {
- component: 'C3',
- title: 'c3',
- isInstalled: false,
- checked: false
- }
- ]
- }];
- };
- var slaveComponents = [
- {
- componentName: 'C1',
- hosts: [{hostName: 'host1', isInstalled: true}]
- }
- ];
- beforeEach(function() {
- controller.set('headers', [
- Em.Object.create({
- name: 'C1',
- label: 'c1'
- }),
- Em.Object.create({
- name: 'C2',
- label: 'c2'
- }),
- Em.Object.create({
- name: 'C3',
- label: 'c3'
- })
- ]);
- });
- it("C1 components should be checked and installed", function() {
- var hostsObj = getHostsObj();
- controller.restoreComponentsSelection(hostsObj, slaveComponents);
- expect(hostsObj[0].checkboxes[0].isInstalled).to.be.true;
- expect(hostsObj[0].checkboxes[0].checked).to.be.true;
- });
- it("C2 components should not be checked and should be installed", function() {
- var hostsObj = getHostsObj();
- controller.restoreComponentsSelection(hostsObj, slaveComponents);
- expect(hostsObj[0].checkboxes[1].isInstalled).to.be.true;
- expect(hostsObj[0].checkboxes[1].checked).to.be.false;
- });
- it("C3 components should not be checked and should not be installed", function() {
- var hostsObj = getHostsObj();
- controller.restoreComponentsSelection(hostsObj, slaveComponents);
- expect(hostsObj[0].checkboxes[2].isInstalled).to.be.false;
- expect(hostsObj[0].checkboxes[2].checked).to.be.false;
- });
- });
- describe("#selectRecommendedComponents()", function() {
- var hostsObj = [{
- hostName: 'host1',
- checkboxes: [
- {
- component: 'C1',
- checked: false,
- isDisabled: false
- },
- {
- component: 'C2',
- checked: false,
- isDisabled: true
- },
- {
- component: 'C3',
- checked: false,
- isDisabled: false
- },
- {
- component: 'CLIENT',
- checked: false,
- isDisabled: false
- }
- ]
- }];
- var recommendations = {
- blueprint: {
- host_groups: [
- {
- name: 'g1',
- components: [
- {name: 'C1'},
- {name: 'C2'},
- {name: 'C_CLIENT'}
- ]
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- name: 'g1',
- hosts: [{fqdn: 'host1'}]
- }
- ]
- }
- };
- beforeEach(function() {
- sinon.stub(App, 'get').returns(['C_CLIENT']);
- });
- afterEach(function() {
- App.get.restore();
- });
- it("C1 should be checked", function() {
- controller.set('content.recommendations', recommendations);
- controller.selectRecommendedComponents(hostsObj);
- expect(hostsObj[0].checkboxes[0].checked).to.be.true;
- });
- it("C2 should not be checked, as it is disabled", function() {
- controller.set('content.recommendations', recommendations);
- controller.selectRecommendedComponents(hostsObj);
- expect(hostsObj[0].checkboxes[1].checked).to.be.false;
- });
- it("C3 should not be checked", function() {
- controller.set('content.recommendations', recommendations);
- controller.selectRecommendedComponents(hostsObj);
- expect(hostsObj[0].checkboxes[2].checked).to.be.false;
- });
- it("CLIENT should be checked", function() {
- controller.set('content.recommendations', recommendations);
- controller.selectRecommendedComponents(hostsObj);
- expect(hostsObj[0].checkboxes[3].checked).to.be.true;
- });
- });
- App.TestAliases.testAsComputedOr(getController(), 'anyGeneralErrors', ['errorMessage', 'generalErrorMessages.length']);
- describe('#render', function () {
- it('true if loaded', function () {
- var hosts = {
- h1: {bootStatus: 'REGISTERED', name: 'h1'},
- h2: {bootStatus: 'REGISTERED', name: 'h2'},
- h3: {bootStatus: 'REGISTERED', name: 'h3'}
- };
- var headers = Em.A([
- Em.Object.create({name: "c1", label: 'l1', isDisabled: true}),
- Em.Object.create({name: "c2", label: 'l2', isDisabled: false})
- ]);
- var masterComponentHosts = Em.A([
- {hostName: 'h1', component: 'c1'}
- ]);
- var recommendations = {
- blueprint: {
- host_groups: [
- {
- components: [
- {
- name: 'c6'
- }
- ],
- name: 'host-group-1'
- },
- {
- components: [
- {
- name: 'c8'
- }
- ],
- name: 'host-group-2'
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- hosts: [
- {
- fqdn: 'h0'
- }
- ],
- name: 'host-group-1'
- },
- {
- hosts: [
- {
- fqdn: 'h1'
- }
- ],
- name: 'host-group-2'
- }]
- }
- };
- controller.set('content.hosts', hosts);
- controller.set('content.masterComponentHosts', masterComponentHosts);
- controller.set('content.recommendations', recommendations);
- controller.set('headers', headers);
- controller.render();
- expect(controller.get('isLoaded')).to.equal(true);
- });
- });
- describe('#anyGeneralWarnings', function () {
- it('true if generalWarningMessages is non empty array and warningMessage is undefined', function () {
- controller.set('generalWarningMessages', ["warning1", "warning2"]);
- expect(controller.get('anyGeneralWarnings')).to.equal(true);
- });
- it('false if generalWarningMessages is empty array', function () {
- controller.set('generalWarningMessages', []);
- expect(controller.get('anyGeneralWarnings')).to.equal(false);
- });
- it('undefined if generalWarningMessages is undefined', function () {
- controller.set('generalWarningMessages', false);
- expect(controller.get('anyGeneralWarnings')).to.equal(false);
- });
- });
- App.TestAliases.testAsComputedOr(getController(), 'anyGeneralIssues', ['anyGeneralErrors', 'anyGeneralWarnings']);
- App.TestAliases.testAsComputedOr(getController(), 'anyErrors', ['anyGeneralErrors', 'anyHostErrors']);
- App.TestAliases.testAsComputedOr(getController(), 'anyWarnings', ['anyGeneralWarnings', 'anyHostWarnings']);
- describe('#anyWarnings', function () {
- it('true if generalWarningMessages is non empty', function () {
- controller.set('generalWarningMessages', ["error 404", "error"]);
- expect(controller.get('anyWarnings')).to.equal(true);
- });
- it('false if generalWarningMessages is empty', function () {
- controller.set('generalWarningMessages', []);
- expect(controller.get('anyWarnings')).to.equal(false);
- });
- });
- App.TestAliases.testAsComputedEqual(getController(), 'isInstallerWizard', 'content.controllerName', 'installerController');
- App.TestAliases.testAsComputedEqual(getController(), 'isAddServiceWizard', 'content.controllerName', 'addServiceController');
- describe('#selectClientHost', function () {
- it('true if isClientsSet false', function () {
- var hostsObj = Em.A([Em.Object.create({
- hasMaster: false,
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: true
- })
- ])
- })]);
- controller.set('isClientsSet', false);
- controller.selectClientHost(hostsObj);
- expect(controller.get('isClientsSet')).to.equal(true);
- });
- });
- describe('#updateValidationsSuccessCallback', function () {
- var hosts = Em.A([Em.Object.create({
- warnMessages: "warn",
- errorMessages: "error",
- anyMessage: true,
- checkboxes: Em.A([Em.Object.create({
- hasWarnMessage: true,
- hasErrorMessage: true
- })])
- })]);
- var validationData = Em.Object.create({
- resources: Em.A([
- Em.Object.create({
- items: Em.A([
- Em.Object.create({
- "component-name": 'HDFS_CLIENT',
- host: "1",
- isMaster: true
- })
- ])
- })
- ])
- });
- beforeEach(function () {
- sinon.stub(validationUtils, 'filterNotInstalledComponents', function () {
- return Em.A([Em.Object.create({
- componentName: 'c0',
- isSlave: true,
- type: 'host-component',
- level: 'ERROR'
- }),
- Em.Object.create({
- componentName: 'c1',
- isSlave: true,
- type: 'host-component',
- level: 'WARN',
- isShownOnInstallerSlaveClientPage: true
- })]);
- });
- sinon.stub(App.StackServiceComponent, 'find', function () {
- return [
- Em.Object.create({
- componentName: 'c0',
- isSlave: true
- }),
- Em.Object.create({
- componentName: 'c1',
- isSlave: true,
- isShownOnInstallerSlaveClientPage: true
- }),
- Em.Object.create({
- componentName: 'c2',
- isSlave: true,
- isShownOnInstallerSlaveClientPage: false
- }),
- Em.Object.create({
- componentName: 'c3',
- isClient: true
- }),
- Em.Object.create({
- componentName: 'c4',
- isClient: true,
- isRequiredOnAllHosts: false
- }),
- Em.Object.create({
- componentName: 'c5',
- isClient: true,
- isRequiredOnAllHosts: true
- }),
- Em.Object.create({
- componentName: 'c6',
- isMaster: true,
- isShownOnInstallerAssignMasterPage: true
- }),
- Em.Object.create({
- componentName: 'c7',
- isMaster: true,
- isShownOnInstallerAssignMasterPage: false
- }),
- Em.Object.create({
- componentName: 'HDFS_CLIENT',
- isMaster: true,
- isShownOnAddServiceAssignMasterPage: true
- }),
- Em.Object.create({
- componentName: 'c9',
- isMaster: true,
- isShownOnAddServiceAssignMasterPage: false
- })
- ];
- });
- controller.set('hosts', hosts);
- controller.updateValidationsSuccessCallback(validationData);
- });
- afterEach(function () {
- App.StackServiceComponent.find.restore();
- validationUtils.filterNotInstalledComponents.restore();
- });
- it('no generalErrorMessages', function () {
- expect(controller.get('generalErrorMessages').length).to.equal(0);
- });
- it('no generalWarningMessages', function () {
- expect(controller.get('generalWarningMessages').length).to.equal(0);
- });
- it('hosts info is valid', function () {
- var cHosts = JSON.parse(JSON.stringify(controller.get('hosts')));
- var expected = [{
- warnMessages: [null],
- errorMessages: [null],
- anyMessage: true,
- checkboxes: [{
- hasWarnMessage: true,
- hasErrorMessage: true
- }]
- }];
- expect(cHosts).to.eql(expected);
- });
- });
- describe('#clearError', function () {
- var headers = Em.A([
- Em.Object.create({name: "c1", label: 't1'}),
- Em.Object.create({name: "c2", label: 't2'})]);
- beforeEach(function () {
- controller.set('errorMessage', 'error');
- controller.set('headers', headers);
- });
- it('both checkboxes are checked', function () {
- var hosts = Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: true
- }),
- Em.Object.create({
- component: 'c2',
- isInstalled: false,
- checked: true
- })])
- })
- ]);
- controller.set('hosts', hosts);
- controller.clearError();
- expect(controller.get('errorMessage')).to.equal('');
- });
- it('true if is one of checkboxes checked false', function () {
- var hosts = Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- title: "t1",
- component: 'c1',
- isInstalled: false,
- checked: false
- }),
- Em.Object.create({
- title: "t2",
- component: 'c2',
- isInstalled: false,
- checked: true
- })])
- })
- ]);
- controller.set('hosts', hosts);
- controller.set('isAddHostWizard', true);
- controller.clearError();
- expect(controller.get('errorMessage')).to.equal('error');
- });
- });
- describe('#clearStep', function () {
- beforeEach(function () {
- sinon.stub(controller, 'clearError', Em.K);
- });
- afterEach(function () {
- controller.clearError.restore();
- });
- it('should call clearError', function () {
- controller.clearStep();
- expect(controller.clearError.calledOnce).to.equal(true);
- });
- it('should clear hosts', function () {
- controller.set('hosts', [
- {},
- {}
- ]);
- controller.clearStep();
- expect(controller.get('hosts')).to.eql([]);
- });
- it('should clear headers', function () {
- controller.set('headers', [
- {},
- {}
- ]);
- controller.clearStep();
- expect(controller.get('headers')).to.eql([]);
- });
- it('should set isLoaded to false', function () {
- controller.set('isLoaded', true);
- controller.clearStep();
- expect(controller.get('isLoaded')).to.equal(false);
- });
- });
- describe('#checkCallback', function () {
- beforeEach(function () {
- sinon.stub(controller, 'clearError', Em.K);
- });
- afterEach(function () {
- controller.clearError.restore();
- });
- it('should call clearError', function () {
- controller.checkCallback('');
- expect(controller.clearError.calledOnce).to.equal(true);
- });
- Em.A([
- {
- m: 'all checked, isInstalled false',
- headers: Em.A([
- Em.Object.create({name: 'c1'})
- ]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: true
- })
- ])
- })
- ]),
- component: 'c1',
- e: {
- allChecked: true,
- noChecked: false
- }
- },
- {
- m: 'all checked, isInstalled true',
- headers: Em.A([
- Em.Object.create({name: 'c1'})
- ]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: true,
- checked: true
- })
- ])
- })
- ]),
- component: 'c1',
- e: {
- allChecked: true,
- noChecked: true
- }
- },
- {
- m: 'no one checked',
- headers: Em.A([
- Em.Object.create({name: 'c1'})
- ]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: false
- })
- ])
- })
- ]),
- component: 'c1',
- e: {
- allChecked: false,
- noChecked: true
- }
- },
- {
- m: 'some checked',
- headers: Em.A([
- Em.Object.create({name: 'c1'})
- ]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: true
- }),
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: false
- })
- ])
- })
- ]),
- component: 'c1',
- e: {
- allChecked: false,
- noChecked: false
- }
- },
- {
- m: 'some checked, some isInstalled true',
- headers: Em.A([
- Em.Object.create({name: 'c1'})
- ]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: true,
- checked: true
- }),
- Em.Object.create({
- component: 'c1',
- isInstalled: true,
- checked: true
- })
- ])
- })
- ]),
- component: 'c1',
- e: {
- allChecked: true,
- noChecked: true
- }
- },
- {
- m: 'some checked, some isInstalled true (2)',
- headers: Em.A([
- Em.Object.create({name: 'c1'})
- ]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- isInstalled: false,
- checked: false
- }),
- Em.Object.create({
- component: 'c1',
- isInstalled: true,
- checked: true
- })
- ])
- })
- ]),
- component: 'c1',
- e: {
- allChecked: false,
- noChecked: true
- }
- }
- ]).forEach(function (test) {
- describe(test.m, function () {
- beforeEach(function () {
- controller.clearStep();
- controller.set('headers', test.headers);
- controller.set('hosts', test.hosts);
- controller.checkCallback(test.component);
- this.header = controller.get('headers').findProperty('name', test.component);
- });
- it('allChecked is ' + test.e.allChecked, function () {
- expect(this.header.get('allChecked')).to.equal(test.e.allChecked);
- });
- it('noChecked is ' + test.e.noChecked, function () {
- expect(this.header.get('noChecked')).to.equal(test.e.noChecked);
- });
- });
- });
- });
- describe('#getHostNames', function () {
- var tests = Em.A([
- {
- hosts: {
- h1: {bootStatus: 'REGISTERED', name: 'h1'},
- h2: {bootStatus: 'REGISTERED', name: 'h2'},
- h3: {bootStatus: 'REGISTERED', name: 'h3'}
- },
- m: 'All REGISTERED',
- e: ['h1', 'h2', 'h3']
- },
- {
- hosts: {
- h1: {bootStatus: 'REGISTERED', name: 'h1'},
- h2: {bootStatus: 'FAILED', name: 'h2'},
- h3: {bootStatus: 'REGISTERED', name: 'h3'}
- },
- m: 'Some REGISTERED',
- e: ['h1', 'h3']
- },
- {
- hosts: {
- h1: {bootStatus: 'FAILED', name: 'h1'},
- h2: {bootStatus: 'FAILED', name: 'h2'},
- h3: {bootStatus: 'FAILED', name: 'h3'}
- },
- m: 'No one REGISTERED',
- e: []
- },
- {
- hosts: {},
- m: 'Empty hosts',
- e: []
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- controller.set('content.hosts', test.hosts);
- var r = controller.getHostNames();
- expect(r).to.eql(test.e);
- });
- });
- });
- describe('#getMasterComponentsForHost', function () {
- var tests = Em.A([
- {
- masterComponentHosts: Em.A([
- {hostName: 'h1', component: 'c1'}
- ]),
- hostName: 'h1',
- m: 'host exists',
- e: ['c1']
- },
- {
- masterComponentHosts: Em.A([
- {hostName: 'h1', component: 'c1'}
- ]),
- hostName: 'h2',
- m: 'host donesn\'t exists',
- e: []
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- controller.set('content.masterComponentHosts', test.masterComponentHosts);
- var r = controller.getMasterComponentsForHost(test.hostName);
- expect(r).to.eql(test.e);
- });
- });
- });
- describe('#selectMasterComponents', function () {
- var tests = Em.A([
- {
- masterComponentHosts: Em.A([
- {
- hostName: 'h1',
- component: 'c1'
- }
- ]),
- hostsObj: [
- Em.Object.create({
- hostName: 'h1',
- checkboxes: [
- Em.Object.create({
- component: 'c1',
- checked: false
- })
- ]
- })
- ],
- e: true,
- m: 'host and component exist'
- },
- {
- masterComponentHosts: Em.A([
- {
- hostName: 'h1',
- component: 'c2'
- }
- ]),
- hostsObj: [
- Em.Object.create({
- hostName: 'h1',
- checkboxes: [
- Em.Object.create({
- component: 'c1',
- checked: false
- })
- ]
- })
- ],
- e: false,
- m: 'host exists'
- },
- {
- masterComponentHosts: Em.A([
- {
- hostName: 'h2',
- component: 'c2'
- }
- ]),
- hostsObj: [
- Em.Object.create({
- hostName: 'h1',
- checkboxes: [
- Em.Object.create({
- component: 'c1',
- checked: false
- })
- ]
- })
- ],
- e: false,
- m: 'host and component don\'t exist'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- controller.set('content.masterComponentHosts', test.masterComponentHosts);
- var r = controller.selectMasterComponents(test.hostsObj);
- expect(r.findProperty('hostName', 'h1').get('checkboxes').findProperty('component', 'c1').get('checked')).to.equal(test.e);
- });
- });
- });
- describe('#getCurrentMastersBlueprint', function () {
- var tests = Em.A([
- {
- masterComponentHosts: Em.A([
- {hostName: 'h1', component: 'c1'}
- ]),
- hosts: {'h1': {}},
- m: 'one host and one component',
- e:{
- blueprint: {
- host_groups: [
- {
- name: 'host-group-1',
- components: [
- { name: 'c1' }
- ]
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- name: 'host-group-1',
- hosts: [
- { fqdn: 'h1' }
- ]
- }
- ]
- }
- }
- },
- {
- masterComponentHosts: Em.A([
- {hostName: 'h1', component: 'c1'},
- {hostName: 'h2', component: 'c2'},
- {hostName: 'h2', component: 'c3'}
- ]),
- hosts: {'h1': {}, 'h2': {}, 'h3': {}},
- m: 'multiple hosts and multiple components',
- e: {
- blueprint: {
- host_groups: [
- {
- name: 'host-group-1',
- components: [
- { name: 'c1' }
- ]
- },
- {
- name: 'host-group-2',
- components: [
- { name: 'c2' },
- { name: 'c3' }
- ]
- },
- {
- name: 'host-group-3',
- components: []
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- name: 'host-group-1',
- hosts: [
- { fqdn: 'h1' }
- ]
- },
- {
- name: 'host-group-2',
- hosts: [
- { fqdn: 'h2' }
- ]
- },
- {
- name: 'host-group-3',
- hosts: [
- { fqdn: 'h3' }
- ]
- }
- ]
- }
- }
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- controller.set('content.masterComponentHosts', test.masterComponentHosts);
- controller.set('content.hosts', test.hosts);
- var r = controller.getCurrentMastersBlueprint();
- expect(r).to.eql(test.e);
- });
- });
- });
- describe('#getCurrentBlueprint', function () {
- var tests = Em.A([
- {
- clientComponents: Em.A([{component_name: "name1"}]),
- hosts: Em.A([
- Em.Object.create({
- checkboxes: Em.A([
- Em.Object.create({
- component: 'c1',
- checked: true
- }),
- Em.Object.create({
- component: 'CLIENT',
- checked: true
- })
- ])
- })
- ]),
- m: 'one host and one component',
- e:{
- blueprint: {
- host_groups: [
- {
- name: 'host-group-1',
- components: [
- { name: 'c1' },
- { name: 'name1' }
- ]
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- name: 'host-group-1',
- hosts: [
- {}
- ]
- }
- ]
- }
- }
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- controller.set('content.clients', test.clientComponents);
- controller.set('hosts', test.hosts);
- var r = controller.getCurrentBlueprint();
- expect(JSON.parse(JSON.stringify(r))).to.eql(JSON.parse(JSON.stringify(test.e)));
- });
- });
- });
- describe('#callServerSideValidation', function () {
- var cases = [
- {
- controllerName: 'installerController',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- }
- ],
- expected: [
- ['c0', 'c6'],
- ['c1', 'c3', 'c8']
- ]
- },
- {
- controllerName: 'addServiceController',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- }
- ],
- expected: [
- ['c0', 'c6'],
- ['c1', 'c3', 'c8']
- ]
- },
- {
- controllerName: 'addHostController',
- hosts: [
- {
- hostName: 'h0'
- }
- ],
- expected: [
- ['c0', 'c2', 'c5', 'c6'],
- ['c1', 'c2', 'c3', 'c5', 'c8']
- ]
- }
- ],
- expectedHostGroups = [
- {
- name: 'host-group-1',
- fqdn: 'h0'
- },
- {
- name: 'host-group-2',
- fqdn: 'h1'
- }
- ];
- beforeEach(function () {
- controller.get('content').setProperties({
- recommendations: {
- blueprint: {
- host_groups: [
- {
- components: [
- {
- name: 'c6'
- }
- ],
- name: 'host-group-1'
- },
- {
- components: [
- {
- name: 'c8'
- }
- ],
- name: 'host-group-2'
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- hosts: [
- {
- fqdn: 'h0'
- }
- ],
- name: 'host-group-1'
- },
- {
- hosts: [
- {
- fqdn: 'h1'
- }
- ],
- name: 'host-group-2'
- }]
- }
- },
- clients: [
- {
- component_name: 'c3'
- }
- ]
- });
- sinon.stub(App.StackService, 'find', function () {
- return [
- Em.Object.create({
- serviceName: 's0',
- isSelected: true
- }),
- Em.Object.create({
- serviceName: 's1',
- isInstalled: true,
- isSelected: true
- })
- ];
- });
- sinon.stub(App.StackServiceComponent, 'find', function () {
- return [
- Em.Object.create({
- componentName: 'c0',
- isSlave: true
- }),
- Em.Object.create({
- componentName: 'c1',
- isSlave: true,
- isShownOnInstallerSlaveClientPage: true
- }),
- Em.Object.create({
- componentName: 'c2',
- isSlave: true,
- isShownOnInstallerSlaveClientPage: false
- }),
- Em.Object.create({
- componentName: 'c3',
- isClient: true
- }),
- Em.Object.create({
- componentName: 'c4',
- isClient: true,
- isRequiredOnAllHosts: false
- }),
- Em.Object.create({
- componentName: 'c5',
- isClient: true,
- isRequiredOnAllHosts: true
- }),
- Em.Object.create({
- componentName: 'c6',
- isMaster: true,
- isShownOnInstallerAssignMasterPage: true
- }),
- Em.Object.create({
- componentName: 'c7',
- isMaster: true,
- isShownOnInstallerAssignMasterPage: false
- }),
- Em.Object.create({
- componentName: 'c8',
- isMaster: true,
- isShownOnAddServiceAssignMasterPage: true
- }),
- Em.Object.create({
- componentName: 'c9',
- isMaster: true,
- isShownOnAddServiceAssignMasterPage: false
- })
- ];
- });
- sinon.stub(controller, 'getCurrentBlueprint', function () {
- return {
- blueprint: {
- host_groups: [
- {
- components: [
- {
- name: 'c0'
- }
- ],
- name: 'host-group-1'
- },
- {
- components: [
- {
- name: 'c1'
- },
- {
- name: 'c3'
- }
- ],
- name: 'host-group-2'
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- hosts: [
- {
- fqdn: 'h0'
- }
- ],
- name: 'host-group-1'
- },
- {
- hosts: [
- {
- fqdn: 'h1'
- }
- ],
- name: 'host-group-2'
- }]
- }
- };
- });
- sinon.stub(controller, 'getCurrentMastersBlueprint', function () {
- return {
- blueprint: {
- host_groups: [
- {
- components: [
- {
- name: 'c6'
- }
- ],
- name: 'host-group-1'
- },
- {
- components: [
- {
- name: 'c8'
- }
- ],
- name: 'host-group-2'
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- hosts: [
- {
- fqdn: 'h0'
- }
- ],
- name: 'host-group-1'
- },
- {
- hosts: [
- {
- fqdn: 'h1'
- }
- ],
- name: 'host-group-2'
- }]
- }
- };
- });
- sinon.stub(App, 'get').withArgs('components.clients').returns(['c3', 'c4']);
- sinon.stub(controller, 'getCurrentMasterSlaveBlueprint', function () {
- return {
- blueprint: {
- host_groups: [
- {
- components: [
- {
- name: 'c6'
- }
- ],
- name: 'host-group-1'
- },
- {
- components: [
- {
- name: 'c8'
- }
- ],
- name: 'host-group-2'
- }
- ]
- },
- blueprint_cluster_binding: {
- host_groups: [
- {
- hosts: [
- {
- fqdn: 'h0'
- }
- ],
- name: 'host-group-1'
- },
- {
- hosts: [
- {
- fqdn: 'h1'
- }
- ],
- name: 'host-group-2'
- }]
- }
- };
- });
- sinon.stub(App.Host, 'find', function () {
- return [
- {
- hostName: 'h1'
- }
- ];
- });
- });
- afterEach(function () {
- App.StackService.find.restore();
- App.StackServiceComponent.find.restore();
- controller.getCurrentBlueprint.restore();
- controller.getCurrentMastersBlueprint.restore();
- App.get.restore();
- controller.getCurrentMasterSlaveBlueprint.restore();
- App.Host.find.restore();
- });
- cases.forEach(function (item) {
- describe(item.controllerName, function () {
- beforeEach(function () {
- controller.set('hosts', item.hosts);
- controller.set('content.controllerName', item.controllerName);
- controller.callServerSideValidation();
- });
- it('blueprint.host_groups count is correct', function () {
- expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups.length')).to.equal(expectedHostGroups.length);
- });
- it('blueprint_cluster_binding.host_groups count is correct', function () {
- expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
- });
- item.expected.forEach(function (e, index) {
- it('components are valid for group# ' + (index + 1), function () {
- expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups')[index].components.mapProperty('name').sort()).to.be.eql(e);
- });
- });
- expectedHostGroups.forEach(function (group) {
- it(group.name, function () {
- var bpGroup = controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups').findProperty('name', group.name);
- expect(bpGroup.hosts).to.have.length(1);
- expect(bpGroup.hosts[0].fqdn).to.equal(group.fqdn);
- });
- });
- });
- });
- });
- describe('#isAllCheckboxesEmpty', function () {
- Em.A([
- {
- m: 'all checkboxes are not empty',
- hosts: [
- {checkboxes: [{checked: true}, {checked: true}]},
- {checkboxes: [{checked: true}, {checked: true}]}
- ],
- e: false
- },
- {
- m: 'some checkboxes are empty',
- hosts: [
- {checkboxes: [{checked: true}, {checked: false}]},
- {checkboxes: [{checked: true}, {checked: false}]}
- ],
- e: false
- },
- {
- m: 'all checkboxes are empty',
- hosts: [
- {checkboxes: [{checked: false}, {checked: false}]},
- {checkboxes: [{checked: false}, {checked: false}]}
- ],
- e: true
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- controller.set('hosts', test.hosts);
- expect(controller.isAllCheckboxesEmpty()).to.be.equal(test.e);
- });
- });
- });
- describe('#loadStep', function () {
- beforeEach(function () {
- sinon.stub(controller, 'render', Em.K);
- sinon.stub(controller, 'callValidation', Em.K);
- sinon.stub(App.StackService, 'find').returns([
- Em.Object.create({
- isSelected: true,
- serviceName: 's1',
- serviceComponents: [
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's1c1', isRequired: true}),
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's1c2', isRequired: true})
- ]
- }),
- Em.Object.create({
- isSelected: true,
- serviceName: 's2',
- serviceComponents: [
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's2c3', isRequired: false}),
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's2c4', isRequired: false})
- ]
- }),
- Em.Object.create({
- isInstalled: true,
- serviceName: 's3',
- serviceComponents: [
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's3c1', isRequired: true}),
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's3c2', isRequired: true})
- ]
- }),
- Em.Object.create({
- isInstalled: true,
- serviceName: 's4',
- serviceComponents: [
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's4c3', isRequired: false}),
- Em.Object.create({isShownOnInstallerSlaveClientPage: true, componentName: 's4c4', isRequired: false})
- ]
- })
- ]);
- });
- afterEach(function () {
- controller.render.restore();
- controller.callValidation.restore();
- App.StackService.find.restore();
- });
- describe('isInstallerWizard', function () {
- beforeEach(function () {
- controller.set('content', {
- clients: [{}],
- controllerName: 'installerController'
- });
- controller.loadStep();
- });
- it('component names are valid', function () {
- expect(controller.get('headers').mapProperty('name')).to.be.eql(['s1c1', 's1c2', 's2c3', 's2c4', 'CLIENT']);
- });
- it('component labels are valid', function () {
- expect(controller.get('headers').mapProperty('label')).to.be.eql(['S1c1', 'S1c2', 'S2c3', 'S2c4', 'Client']);
- });
- it('everyone allChecked is false', function () {
- expect(controller.get('headers').everyProperty('allChecked', false)).to.be.true;
- });
- it('component required-flags are valid', function () {
- expect(controller.get('headers').mapProperty('isRequired')).to.be.eql([true, true, false, false, undefined]);
- });
- it('everyone noChecked is false', function () {
- expect(controller.get('headers').everyProperty('noChecked', true)).to.be.true;
- });
- it('everyone isDisabled is false', function () {
- expect(controller.get('headers').everyProperty('isDisabled', false)).to.be.true;
- });
- it('component allId-fields are valid', function () {
- expect(controller.get('headers').mapProperty('allId')).to.be.eql(['all-s1c1', 'all-s1c2', 'all-s2c3', 'all-s2c4', 'all-CLIENT']);
- });
- it('component noneId-fields are valid', function () {
- expect(controller.get('headers').mapProperty('noneId')).to.be.eql(['none-s1c1', 'none-s1c2', 'none-s2c3', 'none-s2c4', 'none-CLIENT']);
- });
- });
- describe('isAddHostWizard', function () {
- beforeEach(function () {
- controller.set('content', {
- clients: [{}],
- controllerName: 'addHostController'
- });
- controller.loadStep();
- });
- it('component names are valid', function () {
- expect(controller.get('headers').mapProperty('name')).to.be.eql(['s3c1', 's3c2', 's4c3', 's4c4', 'CLIENT']);
- });
- it('component labels are valid', function () {
- expect(controller.get('headers').mapProperty('label')).to.be.eql(['S3c1', 'S3c2', 'S4c3', 'S4c4', 'Client']);
- });
- it('everyone allChecked is false', function () {
- expect(controller.get('headers').everyProperty('allChecked', false)).to.be.true;
- });
- it('component required-flags are valid', function () {
- expect(controller.get('headers').mapProperty('isRequired')).to.be.eql([true, true, false, false, undefined]);
- });
- it('everyone noChecked is false', function () {
- expect(controller.get('headers').everyProperty('noChecked', true)).to.be.true;
- });
- it('everyone isDisabled is false', function () {
- expect(controller.get('headers').everyProperty('isDisabled', false)).to.be.true;
- });
- it('component allId-fields are valid', function () {
- expect(controller.get('headers').mapProperty('allId')).to.be.eql(['all-s3c1', 'all-s3c2', 'all-s4c3', 'all-s4c4', 'all-CLIENT']);
- });
- it('component noneId-fields are valid', function () {
- expect(controller.get('headers').mapProperty('noneId')).to.be.eql(['none-s3c1', 'none-s3c2', 'none-s4c3', 'none-s4c4', 'none-CLIENT']);
- });
- });
- describe('isAddServiceWizard', function () {
- beforeEach(function () {
- controller.set('content', {
- clients: [{}],
- controllerName: 'addServiceController'
- });
- controller.loadStep();
- });
- it('component names are valid', function () {
- expect(controller.get('headers').mapProperty('name')).to.be.eql(['s3c1', 's3c2', 's4c3', 's4c4', 's1c1', 's1c2', 's2c3', 's2c4', 'CLIENT']);
- });
- it('component labels are valid', function () {
- expect(controller.get('headers').mapProperty('label')).to.be.eql(['S3c1', 'S3c2', 'S4c3', 'S4c4', 'S1c1', 'S1c2', 'S2c3', 'S2c4', 'Client']);
- });
- it('everyone allChecked is false', function () {
- expect(controller.get('headers').everyProperty('allChecked', false)).to.be.true;
- });
- it('component required-flags are valid', function () {
- expect(controller.get('headers').mapProperty('isRequired')).to.be.eql([true, true, false, false, true, true, false, false, undefined]);
- });
- it('everyone noChecked is false', function () {
- expect(controller.get('headers').everyProperty('noChecked', true)).to.be.true;
- });
- it('installed services are disabled', function () {
- expect(controller.get('headers').mapProperty('isDisabled', false)).to.be.eql([true, true, true, true, false, false, false, false, false]);
- });
- it('component allId-fields are valid', function () {
- expect(controller.get('headers').mapProperty('allId')).to.be.eql(['all-s3c1', 'all-s3c2', 'all-s4c3', 'all-s4c4', 'all-s1c1', 'all-s1c2', 'all-s2c3', 'all-s2c4', 'all-CLIENT']);
- });
- it('component noneId-fields are valid', function () {
- expect(controller.get('headers').mapProperty('noneId')).to.be.eql(['none-s3c1', 'none-s3c2', 'none-s4c3', 'none-s4c4', 'none-s1c1', 'none-s1c2', 'none-s2c3', 'none-s2c4', 'none-CLIENT']);
- });
- });
- });
-
- describe('#anyHostErrors', function () {
- var tests = [
- {
- it: "anyHostErrors returns true if errorMessages are defined",
- host: Em.A([Em.Object.create({
- errorMessages: "Error Message"
- })]),
- result: true
- },
- {
- it: "anyHostErrors returns false if errorMessages are not defined",
- host: Em.A([Em.Object.create({
- })]),
- result: false
- }
- ];
- tests.forEach(function(test) {
- it(test.it, function() {
- controller.set('hosts', test.host);
- expect(controller.get('anyHostErrors')).to.equal(test.result);
- })
- });
- });
-
- describe('#anyHostWarnings', function () {
- var tests = [
- {
- it: "anyHostWarnings returns true if warnMessages are defined",
- host: Em.A([Em.Object.create({
- warnMessages: "Warning Message"
- })]),
- result: true
- },
- {
- it: "anyHostWarnings returns false if warnMessages are not defined",
- host: Em.A([Em.Object.create({
- })]),
- result: false
- }
- ];
- tests.forEach(function(test) {
- it(test.it, function() {
- controller.set('hosts', test.host);
- expect(controller.get('anyHostWarnings')).to.equal(test.result);
- })
- });
- });
- });
|