step1_test.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var wizardStep1Controller;
  20. var stacks = [
  21. App.Stack.createRecord({
  22. "id": "HDP-2.4",
  23. "stackName": "HDP",
  24. "stackVersion": "2.4"
  25. }),
  26. App.Stack.createRecord({
  27. "id": "HDP-2.5-2.5.0.0",
  28. "stackName": "HDP",
  29. "stackVersion": "2.5"
  30. }),
  31. App.Stack.createRecord({
  32. "id": "HDP-2.5",
  33. "stackName": "HDP",
  34. "stackVersion": "2.5"
  35. }),
  36. App.Stack.createRecord({
  37. "id": "HDP-2.3.ECS",
  38. "stackName": "HDP",
  39. "stackVersion": "2.3.ECS"
  40. }),
  41. App.Stack.createRecord({
  42. "id": "HDP-2.3",
  43. "stackName": "HDP",
  44. "stackVersion": "2.3"
  45. }),
  46. App.Stack.createRecord({
  47. "id": "HDP-2.2",
  48. "stackName": "HDP",
  49. "stackVersion": "2.2"
  50. }),
  51. App.Stack.createRecord({
  52. "id": "HDP-2.4-2.4.1.1-12345",
  53. "stackName": "HDP",
  54. "stackVersion": "2.4"
  55. })
  56. ];
  57. function getController() {
  58. return App.WizardStep1Controller.create({content: Em.Object.create({stacks: stacks})});
  59. }
  60. describe('App.WizardStep1Controller', function () {
  61. beforeEach(function() {
  62. wizardStep1Controller = getController();
  63. });
  64. App.TestAliases.testAsComputedFindBy(getController(), 'selectedStack', 'content.stacks', 'isSelected', true);
  65. App.TestAliases.testAsComputedFindBy(getController(), 'selectedStackType', 'availableStackTypes', 'isSelected', true);
  66. App.TestAliases.testAsComputedFilterBy(getController(), 'servicesForSelectedStack', 'selectedStack.stackServices', 'isHidden', false);
  67. App.TestAliases.testAsComputedEveryBy(getController(), 'networkIssuesExist', 'content.stacks', 'stackDefault', true);
  68. describe('#usePublicRepo', function () {
  69. beforeEach(function () {
  70. wizardStep1Controller.get('content.stacks').findProperty('id', 'HDP-2.5-2.5.0.0').setProperties({
  71. isSelected: true,
  72. useRedhatSatellite: true,
  73. usePublicRepo: false,
  74. useLocalRepo: true,
  75. });
  76. wizardStep1Controller.usePublicRepo();
  77. });
  78. it('correct stack is selected', function () {
  79. expect(wizardStep1Controller.get('selectedStack.id')).to.be.equal('HDP-2.5-2.5.0.0');
  80. });
  81. it('`useRedhatSatellite` is set `false`', function () {
  82. expect(wizardStep1Controller.get('selectedStack.useRedhatSatellite')).to.be.false;
  83. });
  84. it('`usePublicRepo` is set `true`', function () {
  85. expect(wizardStep1Controller.get('selectedStack.usePublicRepo')).to.be.true;
  86. });
  87. it('`useLocalRepo` is set `false`', function () {
  88. expect(wizardStep1Controller.get('selectedStack.useLocalRepo')).to.be.false;
  89. });
  90. });
  91. describe('#useLocalRepo', function () {
  92. beforeEach(function () {
  93. wizardStep1Controller.get('content.stacks').findProperty('id', 'HDP-2.5-2.5.0.0').setProperties({
  94. isSelected: true,
  95. usePublicRepo: true,
  96. useLocalRepo: false,
  97. });
  98. wizardStep1Controller.useLocalRepo();
  99. });
  100. it('correct stack is selected', function () {
  101. expect(wizardStep1Controller.get('selectedStack.id')).to.be.equal('HDP-2.5-2.5.0.0');
  102. });
  103. it('`usePublicRepo` is set `false`', function () {
  104. expect(wizardStep1Controller.get('selectedStack.usePublicRepo')).to.be.false;
  105. });
  106. it('`useLocalRepo` is set `true`', function () {
  107. expect(wizardStep1Controller.get('selectedStack.useLocalRepo')).to.be.true;
  108. });
  109. });
  110. describe('#selectStackBy', function () {
  111. it('select by `id`', function () {
  112. wizardStep1Controller.selectStackBy('id', 'HDP-2.5-2.5.0.0');
  113. expect(wizardStep1Controller.get('selectedStack.id')).to.be.equal('HDP-2.5-2.5.0.0');
  114. expect(wizardStep1Controller.get('content.stacks').filterProperty('isSelected')).to.have.property('length').equal(1);
  115. });
  116. it('select by `stackNameVersion`', function () {
  117. wizardStep1Controller.selectStackBy('stackNameVersion', 'HDP-2.5');
  118. expect(wizardStep1Controller.get('selectedStack.id')).to.be.equal('HDP-2.5-2.5.0.0'); // `HDP-2.5-2.5.0.0`-id is before `HDP-2.5`-id
  119. expect(wizardStep1Controller.get('content.stacks').filterProperty('isSelected')).to.have.property('length').equal(1);
  120. });
  121. });
  122. describe('#availableStackTypes', function () {
  123. it('stack types are sorted desc', function () {
  124. expect(wizardStep1Controller.get('availableStackTypes').mapProperty('stackName')).to.be.eql(['HDP-2.5', 'HDP-2.4', 'HDP-2.3.ECS', 'HDP-2.3', 'HDP-2.2']);
  125. });
  126. });
  127. describe('#readInfoIsNotProvided', function () {
  128. Em.A([
  129. {
  130. options: {
  131. uploadFile: {isSelected: false},
  132. enterUrl: {isSelected: false}
  133. },
  134. m: 'url and file are not selected',
  135. e: false
  136. },
  137. {
  138. options: {
  139. uploadFile: {isSelected: false},
  140. enterUrl: {isSelected: true, url: ''}
  141. },
  142. m: 'url is selected but not provided',
  143. e: true
  144. },
  145. {
  146. options: {
  147. uploadFile: {isSelected: false},
  148. enterUrl: {isSelected: true, url: ' url'}
  149. },
  150. m: 'url is selected and provided',
  151. e: false
  152. },
  153. {
  154. options: {
  155. uploadFile: {isSelected: true, file: ''},
  156. enterUrl: {isSelected: false}
  157. },
  158. m: 'file is selected but not provided',
  159. e: true
  160. },
  161. {
  162. options: {
  163. uploadFile: {isSelected: true, file: 'path'},
  164. enterUrl: {isSelected: false}
  165. },
  166. m: 'file is selected and provided',
  167. e: false
  168. }
  169. ]).forEach(function (test) {
  170. it(test.m, function () {
  171. wizardStep1Controller.set('optionsToSelect.useLocalRepo', test.options);
  172. expect(wizardStep1Controller.get('readInfoIsNotProvided')).to.be.equal(test.e);
  173. });
  174. });
  175. });
  176. });