123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- /**
- * 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');
- require('views/common/modal_popups/cluster_check_popup');
- describe('App.showClusterCheckPopup', function () {
- var isCallbackExecuted,
- callback = function () {
- isCallbackExecuted = true;
- },
- cases = [
- {
- inputData: {
- data: {
- items: [
- {
- UpgradeChecks: {
- id: 'p0',
- status: 'PASS'
- }
- },
- {
- UpgradeChecks: {
- id: 'p1',
- status: 'PASS'
- }
- }
- ]
- }
- },
- result: {
- primary: Em.I18n.t('common.proceedAnyway'),
- secondary: Em.I18n.t('common.cancel'),
- header: ' '
- },
- bodyResult: {
- failTitle: undefined,
- failAlert: undefined,
- warningTitle: undefined,
- warningAlert: undefined,
- fails: [],
- warnings: [],
- hasConfigsMergeConflicts: false,
- isAllPassed: true
- },
- isCallbackExecuted: false,
- title: 'no fails, no warnings, no popup customization'
- },
- {
- inputData: {
- data: {
- items: [
- {
- UpgradeChecks: {
- id: 'w0',
- status: 'WARNING'
- }
- },
- {
- UpgradeChecks: {
- id: 'w1',
- status: 'WARNING'
- }
- }
- ]
- },
- popup: {
- header: 'checks',
- failTitle: 'fail',
- failAlert: 'something has failed',
- warningTitle: 'warning',
- warningAlert: 'something is not good',
- callback: callback
- }
- },
- result: {
- primary: Em.I18n.t('common.proceedAnyway'),
- secondary: Em.I18n.t('common.cancel'),
- header: 'checks'
- },
- bodyResult: {
- failTitle: 'fail',
- failAlert: 'something has failed',
- warningTitle: 'warning',
- warningAlert: 'something is not good',
- fails: [],
- warnings: [
- {
- UpgradeChecks: {
- id: 'w0',
- status: 'WARNING'
- }
- },
- {
- UpgradeChecks: {
- id: 'w1',
- status: 'WARNING'
- }
- }
- ],
- hasConfigsMergeConflicts: false,
- isAllPassed: false
- },
- isCallbackExecuted: true,
- title: 'no fails, default buttons, callback executed'
- },
- {
- inputData: {
- data: {
- items: [
- {
- UpgradeChecks: {
- id: 'f0',
- status: 'FAIL'
- }
- },
- {
- UpgradeChecks: {
- id: 'f1',
- status: 'FAIL'
- }
- }
- ]
- },
- popup: {
- callback: callback,
- noCallbackCondition: true
- }
- },
- result: {
- primary: Em.I18n.t('common.dismiss'),
- secondary: false,
- header: ' '
- },
- bodyResult: {
- failTitle: undefined,
- failAlert: undefined,
- warningTitle: undefined,
- warningAlert: undefined,
- fails: [
- {
- UpgradeChecks: {
- id: 'f0',
- status: 'FAIL'
- }
- },
- {
- UpgradeChecks: {
- id: 'f1',
- status: 'FAIL'
- }
- }
- ],
- warnings: [],
- hasConfigsMergeConflicts: false,
- isAllPassed: false
- },
- isCallbackExecuted: false,
- title: 'fails detected, default buttons, callback not executed'
- },
- {
- inputData: {
- data: {
- items: [
- {
- UpgradeChecks: {
- id: 'p0',
- status: 'PASS'
- }
- },
- {
- UpgradeChecks: {
- id: 'p1',
- status: 'PASS'
- }
- }
- ]
- },
- popup: {
- primary: 'ok',
- secondary: 'cancel'
- },
- configs: [
- {
- name: 'c0'
- },
- {
- name: 'c1'
- }
- ],
- upgradeVersion: 'HDP-2.3.0.0'
- },
- result: {
- primary: 'ok',
- secondary: 'cancel',
- header: ' '
- },
- bodyResult: {
- failTitle: undefined,
- failAlert: undefined,
- warningTitle: undefined,
- warningAlert: undefined,
- fails: [],
- warnings: [],
- hasConfigsMergeConflicts: true,
- isAllPassed: false
- },
- configsResult: [
- {
- name: 'c0'
- },
- {
- name: 'c1'
- }
- ],
- isCallbackExecuted: false,
- title: 'configs merge conflicts detected, custom buttons'
- }
- ];
- beforeEach(function () {
- isCallbackExecuted = false;
- sinon.stub(App, 'tooltip', Em.K);
- });
- afterEach(function () {
- App.tooltip.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- var popup = App.showClusterCheckPopup(item.inputData.data, item.inputData.popup, item.inputData.configs, item.inputData.upgradeVersion),
- popupBody = popup.bodyClass.create();
- popup.onPrimary();
- Em.keys(item.result).forEach(function (key) {
- expect(popup[key]).to.equal(item.result[key]);
- });
- Em.keys(item.bodyResult).forEach(function (key) {
- expect(popupBody[key]).to.eql(item.bodyResult[key]);
- });
- expect(isCallbackExecuted).to.equal(item.isCallbackExecuted);
- if (item.bodyResult.hasConfigsMergeConflicts) {
- var configsMergeTable = popupBody.configsMergeTable.create();
- configsMergeTable.didInsertElement();
- expect(configsMergeTable.configs).to.eql(item.configsResult);
- expect(App.tooltip.calledOnce).to.be.true;
- expect(App.tooltip.firstCall.args[1].title).to.equal(item.inputData.upgradeVersion);
- } else {
- expect(App.tooltip.calledOnce).to.be.false;
- }
- });
- });
- });
|