Best JavaScript code snippet using cypress
item_test.js
Source:item_test.js
1/**2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */18var App = require('app');19require('views/main/service/item');20var view;21function getView() {22 return App.MainServiceItemView.create({23 controller: Em.Object.create({24 content: Em.Object.create({25 hostComponents: []26 })27 })28 });29}30describe('App.MainServiceItemView', function () {31 App.TestAliases.testAsComputedAlias(getView(), 'serviceName', 'controller.content.serviceName', 'string');32 App.TestAliases.testAsComputedAlias(getView(), 'displayName', 'controller.content.displayName', 'string');33 describe('#mastersExcludedCommands', function () {34 view = App.MainServiceItemView.create({35 controller: Em.Object.create({36 content: Em.Object.create({37 hostComponents: []38 })39 })40 });41 var nonCustomAction = ['RESTART_ALL', 'RUN_SMOKE_TEST', 'REFRESH_CONFIGS', 'ROLLING_RESTART', 'TOGGLE_PASSIVE', 'TOGGLE_NN_HA', 'TOGGLE_RM_HA', 'MOVE_COMPONENT', 'DOWNLOAD_CLIENT_CONFIGS', 'MASTER_CUSTOM_COMMAND'];42 var keys = Object.keys(view.mastersExcludedCommands);43 var mastersExcludedCommands = [];44 for (var i = 0; i < keys.length; i++) {45 mastersExcludedCommands[i] = view.mastersExcludedCommands[keys[i]];46 }47 var allMastersExcludedCommands = mastersExcludedCommands.reduce(function (previous, current) {48 return previous.concat(current);49 });50 var actionMap = App.HostComponentActionMap.getMap(view);51 var customActionsArray = [];52 Object.keys(actionMap).forEach(function (iter) {53 customActionsArray.push(actionMap[iter]);54 });55 var customActions = customActionsArray.mapProperty('customCommand').filter(function (action) {56 return !nonCustomAction.contains(action);57 }).uniq();58 // remove null and undefined from the list59 customActions = customActions.filter(function (value) {60 return !Em.isNone(value);61 });62 customActions.forEach(function (action) {63 it(action + ' should be present in App.MainServiceItemView mastersExcludedCommands object', function () {64 expect(allMastersExcludedCommands).to.contain(action);65 });66 });67 });68 describe('#observeMaintenance', function () {69 var cases = [70 {71 isMaintenanceSet: true,72 isServicesInfoLoaded: true,73 isServiceConfigsLoaded: true,74 observeMaintenanceOnceCallCount: 0,75 title: 'actions array set, services info loaded'76 },77 {78 isMaintenanceSet: true,79 isServicesInfoLoaded: false,80 isServiceConfigsLoaded: true,81 observeMaintenanceOnceCallCount: 0,82 title: 'actions array set, services info not loaded'83 },84 {85 isMaintenanceSet: false,86 isServicesInfoLoaded: true,87 isServiceConfigsLoaded: true,88 observeMaintenanceOnceCallCount: 1,89 title: 'actions array not set, services info loaded'90 },91 {92 isMaintenanceSet: false,93 isServicesInfoLoaded: false,94 isServiceConfigsLoaded: true,95 observeMaintenanceOnceCallCount: 0,96 title: 'actions array not set, services info not loaded'97 }98 ];99 beforeEach(function () {100 sinon.stub(view, 'observeMaintenanceOnce', Em.K);101 });102 afterEach(function () {103 view.observeMaintenanceOnce.restore();104 });105 cases.forEach(function (item) {106 it(item.title, function () {107 view.setProperties({108 'isMaintenanceSet': item.isMaintenanceSet,109 'controller.isServicesInfoLoaded': item.isServicesInfoLoaded,110 'controller.isServiceConfigsLoaded': item.isServiceConfigsLoaded111 });112 view.observeMaintenance();113 expect(view.observeMaintenanceOnce.callCount).to.equal(item.observeMaintenanceOnceCallCount);114 });115 });116 });117 describe('#observeMaintenanceOnce', function () {118 var mastersExcludedCommands = {119 NAMENODE: ["DECOMMISSION", "REBALANCEHDFS"],120 RESOURCEMANAGER: ["DECOMMISSION", "REFRESHQUEUES"],121 HBASE_MASTER: ["DECOMMISSION"],122 KNOX_GATEWAY: ["STARTDEMOLDAP", "STOPDEMOLDAP"]123 },124 hasConfigTab = true,125 testCases = [126 {127 serviceName: "HDFS",128 displayName: "HDFS",129 isSingleNode: true,130 serviceTypes: ["HA_MODE"],131 slaveComponents: [132 Em.Object.create({133 componentName: 'DATANODE',134 totalCount: 1135 })136 ],137 clientComponents: [138 Em.Object.create({139 componentName: 'HDFS_CLIENT',140 totalCount: 1141 })142 ],143 hostComponents: [144 Em.Object.create({145 componentName: 'NAMENODE',146 isNotInstalled: true,147 isMaster: true,148 isSlave: false149 }),150 Em.Object.create({151 componentName: 'SECONDARY_NAMENODE',152 isMaster: true,153 isSlave: false154 })155 ],156 result: [157 {"action": "restartAllHostComponents", "context": "HDFS", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},158 {"action": "rollingRestart", "label": "Restart DataNodes", "cssClass": "icon-time", "disabled": false, "context": "DATANODE"},159 {"action": "reassignMaster", "context": "NAMENODE", "label": "Move NameNode", "cssClass": "icon-share-alt", "disabled": false},160 {"action": "reassignMaster", "context": "SECONDARY_NAMENODE", "label": "Move SNameNode", "cssClass": "icon-share-alt", "disabled": false},161 {"action": "enableHighAvailability", "label": "Enable NameNode HA", "cssClass": "icon-arrow-up", "isHidden": false, "disabled": true},162 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},163 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for HDFS", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},164 {"action": "rebalanceHdfsNodes", "customCommand": "REBALANCEHDFS", "context": "Rebalance HDFS", "label": "Rebalance HDFS", "cssClass": "icon-refresh", "disabled": false},165 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": false, "disabled": false, hasSubmenu: false, submenuOptions: []}166 ]167 },168 {169 serviceName: "ZOOKEEPER",170 displayName: "ZooKeeper",171 serviceTypes: [],172 slaveComponents: [],173 clientComponents: [174 Em.Object.create({175 componentName: 'ZOOKEEPER_CLIENT',176 totalCount: 1177 })178 ],179 hostComponents: [180 Em.Object.create({181 componentName: 'ZOOKEEPER_SERVER',182 isMaster: true,183 isSlave: false184 })185 ],186 controller: [187 {'addDisabledTooltipZOOKEEPER_SERVER': ''},188 {'isAddDisabled-ZOOKEEPER_SERVER': 'disabled'}189 ],190 result: [191 {"action": "restartAllHostComponents", "context": "ZOOKEEPER", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},192 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},193 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for ZooKeeper", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},194 {"cssClass": "icon-plus", "label": "Add ZooKeeper Server", "service": "ZOOKEEPER", "component": "ZOOKEEPER_SERVER", "action": "addComponent", "disabled": "", tooltip: ''},195 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": false, "disabled": false, "hasSubmenu": false, "submenuOptions": []}196 ]197 },198 {199 serviceName: "YARN",200 displayName: "YARN",201 serviceTypes: ['HA_MODE'],202 slaveComponents: [203 Em.Object.create({204 componentName: 'NODEMANAGER',205 totalCount: 1206 })207 ],208 clientComponents: [209 Em.Object.create({210 componentName: 'YARN_CLIENT',211 totalCount: 1212 })213 ],214 hostComponents: [215 Em.Object.create({216 componentName: 'APP_TIMELINE_SERVER',217 isMaster: true,218 isSlave: false219 }),220 Em.Object.create({221 componentName: 'RESOURCEMANAGER',222 isMaster: true,223 isSlave: false,224 isNotInstalled: false225 })226 ],227 result: [228 {"action": "refreshYarnQueues", "customCommand": "REFRESHQUEUES", "context": "Refresh YARN Capacity Scheduler", "label": "Refresh YARN Capacity Scheduler", "cssClass": "icon-refresh", "disabled": false},229 {"action": "restartAllHostComponents", "context": "YARN", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},230 {"action": "rollingRestart", "label": "Restart NodeManagers", "cssClass": "icon-time", "disabled": false, "context": "NODEMANAGER"},231 {"action": "reassignMaster", "context": "APP_TIMELINE_SERVER", "label": "Move App Timeline Server", "cssClass": "icon-share-alt", "disabled": false},232 {"action": "reassignMaster", "context": "RESOURCEMANAGER", "label": "Move ResourceManager", "cssClass": "icon-share-alt", "disabled": false},233 {"action": "enableRMHighAvailability", "label": "Enable ResourceManager HA", "cssClass": "icon-arrow-up", "isHidden": false, disabled: false},234 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},235 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for YARN", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},236 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": false, "disabled": false, "hasSubmenu": false, "submenuOptions": []}237 ]238 },239 {240 serviceName: "MAPREDUCE2",241 displayName: "MapReduce2",242 serviceTypes: [],243 slaveComponents: [],244 clientComponents: [245 Em.Object.create({246 componentName: 'MAPREDUCE2_CLIENT',247 totalCount: 1248 })249 ],250 hostComponents: [251 Em.Object.create({252 componentName: 'HISTORYSERVER',253 isMaster: true,254 isSlave: false255 })256 ],257 result: [258 {"action": "restartAllHostComponents", "context": "MAPREDUCE2", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},259 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},260 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for MapReduce2", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},261 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": false, "disabled": false, "hasSubmenu": false, "submenuOptions": []}262 ]263 },264 {265 serviceName: "KAFKA",266 displayName: "Kafka",267 serviceTypes: [],268 slaveComponents: [],269 clientComponents: [],270 hostComponents: [271 Em.Object.create({272 componentName: 'KAFKA_BROKER',273 isMaster: true,274 isSlave: false275 })276 ],277 result: [278 {"action": "restartAllHostComponents", "context": "KAFKA", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},279 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},280 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for Kafka", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},281 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": true, "disabled": false, "hasSubmenu": false, "submenuOptions": []}282 ]283 },284 {285 serviceName: "FLUME",286 displayName: "Flume",287 serviceTypes: [],288 clientComponents: [],289 slaveComponents: [290 Em.Object.create({291 componentName: 'FLUME_HANDLER',292 totalCount: 1293 })294 ],295 hostComponents: [296 ],297 controller: [298 {'addDisabledTooltipFLUME_HANDLER': ''},299 {'isAddDisabled-FLUME_HANDLER': ''}300 ],301 result: [302 {"action": "refreshConfigs", "label": "Refresh configs", "cssClass": "icon-refresh", "disabled": false},303 {"action": "restartAllHostComponents", "context": "FLUME", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},304 {"action": "rollingRestart", "label": "Restart Flumes", "cssClass": "icon-time", "disabled": false, "context": "FLUME_HANDLER"},305 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},306 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for Flume", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},307 {"cssClass": "icon-plus", "label": "Add Flume Component", "service": "FLUME", "component": "FLUME_HANDLER", "action": "addComponent", "disabled": '', tooltip: ''},308 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": true, "disabled": false, "hasSubmenu": false, "submenuOptions": []}309 ]310 },311 {312 serviceName: "HBASE",313 displayName: "HBase",314 serviceTypes: [],315 slaveComponents: [316 Em.Object.create({317 componentName: 'HBASE_REGIONSERVER',318 totalCount: 1319 })320 ],321 clientComponents: [322 Em.Object.create({323 componentName: 'HBASE_CLIENT',324 totalCount: 1325 })326 ],327 hostComponents: [328 Em.Object.create({329 componentName: 'HBASE_MASTER',330 isMaster: true,331 isSlave: false332 })333 ],334 controller: [335 {'addDisabledTooltipHBASE_MASTER': ''},336 {'isAddDisabled-HBASE_MASTER': ''}337 ],338 result: [339 {"action": "restartAllHostComponents", "context": "HBASE", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},340 {"action": "rollingRestart", "label": "Restart RegionServers", "cssClass": "icon-time", "disabled": false, "context": "HBASE_REGIONSERVER"},341 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},342 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for HBase", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},343 {"cssClass": "icon-plus", "label": "Add HBase Master", "service": "HBASE", "component": "HBASE_MASTER", "action": "addComponent", "disabled": '', tooltip: ''},344 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": false, "disabled": false, "hasSubmenu": false, "submenuOptions": []}345 ]346 },347 {348 serviceName: "OOZIE",349 displayName: "Oozie",350 serviceTypes: [],351 slaveComponents: [],352 clientComponents: [353 Em.Object.create({354 componentName: 'OOZIE_CLIENT',355 totalCount: 1356 })357 ],358 hostComponents: [359 Em.Object.create({360 componentName: 'OOZIE_SERVER',361 isMaster: true,362 isSlave: false363 })364 ],365 result: [366 {"action": "restartAllHostComponents", "context": "OOZIE", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},367 {"action": "reassignMaster", "context": "OOZIE_SERVER", "label": "Move Oozie Server", "cssClass": "icon-share-alt", "disabled": false},368 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},369 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for Oozie", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},370 {"cssClass": "icon-plus", "label": "Add Oozie Server", "service": "OOZIE", "component": "OOZIE_SERVER", "action": "addComponent", "disabled": "disabled", tooltip: Em.I18n.t('services.summary.allHostsAlreadyRunComponent').format('OOZIE_SERVER')},371 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": false, "disabled": false, "hasSubmenu": false, "submenuOptions": []}372 ]373 },374 {375 serviceName: "KNOX",376 displayName: "Knox",377 serviceTypes: [],378 slaveComponents: [],379 clientComponents: [],380 hostComponents: [381 Em.Object.create({382 componentName: 'KNOX_GATEWAY',383 isMaster: true,384 isSlave: false385 })386 ],387 result: [388 {"action": "restartAllHostComponents", "context": "KNOX", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},389 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},390 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for Knox", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},391 {"action": "startLdapKnox", "customCommand": "STARTDEMOLDAP", "context": "Start Demo LDAP", "label": "Start Demo LDAP", "cssClass": "icon-play-sign", "disabled": false},392 {"action": "stopLdapKnox", "customCommand": "STOPDEMOLDAP", "context": "Stop Demo LDAP", "label": "Stop Demo LDAP", "cssClass": "icon-stop", "disabled": false},393 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": true, "disabled": false, "hasSubmenu": false, "submenuOptions": []}394 ]395 },396 {397 serviceName: "STORM",398 displayName: "Storm",399 serviceTypes: [],400 slaveComponents: [],401 clientComponents: [],402 hostComponents: [403 Em.Object.create({404 componentName: 'NIMBUS',405 isMaster: true,406 isSlave: false407 })408 ],409 result: [410 {"action": "restartAllHostComponents", "context": "STORM", "label": "Restart All", "cssClass": "icon-repeat", "disabled": false},411 {"action": "runSmokeTest", "label": "Run Service Check", "cssClass": "icon-thumbs-up-alt", "disabled": false},412 {"action": "turnOnOffPassive", "context": "Turn On Maintenance Mode for Storm", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", "disabled": false},413 {"action": "downloadClientConfigs", "label": "Download Client Configs", "cssClass": "icon-download-alt", "isHidden": true, "disabled": false, "hasSubmenu": false, "submenuOptions": []}414 ]415 }416 ];417 beforeEach(function () {418 view = App.MainServiceItemView.create({});419 sinon.stub(App, 'get', function (k) {420 switch (k) {421 case 'isSingleNode':422 return view.get('controller.content.serviceName') === 'HDFS';423 case 'supports.autoRollbackHA':424 case 'isRMHaEnabled':425 case 'isHaEnabled':426 return false;427 case 'components.rollinRestartAllowed':428 return ["DATANODE", "JOURNALNODE", "ZKFC", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"];429 case 'components.reassignable':430 return ["NAMENODE", "SECONDARY_NAMENODE", "APP_TIMELINE_SERVER", "RESOURCEMANAGER", "WEBHCAT_SERVER", "OOZIE_SERVER"];431 case 'services.supportsServiceCheck':432 return ["HDFS", "MAPREDUCE2", "YARN", "HIVE", "HBASE", "PIG", "SQOOP", "OOZIE", "ZOOKEEPER", "FALCON", "STORM", "FLUME", "SLIDER", "KNOX", "KAFKA"];433 case 'components.addableToHost':434 return ["DATANODE", "HDFS_CLIENT", "MAPREDUCE2_CLIENT", "NODEMANAGER", "YARN_CLIENT", "TEZ_CLIENT", "GANGLIA_MONITOR", "HCAT", "HIVE_CLIENT", "HIVE_METASTORE", "HIVE_SERVER", "WEBHCAT_SERVER", "HBASE_CLIENT", "HBASE_MASTER", "HBASE_REGIONSERVER", "PIG", "SQOOP", "OOZIE_CLIENT", "OOZIE_SERVER", "ZOOKEEPER_CLIENT", "ZOOKEEPER_SERVER", "FALCON_CLIENT", "SUPERVISOR", "FLUME_HANDLER", "METRICS_MONITOR", "KAFKA_BROKER", "KERBEROS_CLIENT", "KNOX_GATEWAY", "SLIDER", "SPARK_CLIENT"];435 case 'allHostNames.length':436 return 2;437 default:438 return Em.get(App, k);439 }440 });441 sinon.stub(App.HostComponent, 'find', function () {442 return [443 Em.Object.create({444 hostName: 'host1',445 componentName: 'NAMENODE'446 }),447 Em.Object.create({448 hostName: 'host1',449 componentName: 'SECONDARY_NAMENODE'450 }),451 Em.Object.create({452 hostName: 'host1',453 componentName: 'APP_TIMELINE_SERVER'454 }),455 Em.Object.create({456 hostName: 'host1',457 componentName: 'RESOURCEMANAGER'458 }),459 Em.Object.create({460 hostName: 'host1',461 componentName: 'OOZIE_SERVER'462 })463 ];464 });465 /*eslint-disable complexity */466 sinon.stub(App.StackServiceComponent, 'find', function (id) {467 switch (id) {468 case 'NAMENODE':469 return Em.Object.create({ customCommands: ["DECOMMISSION", "REBALANCEHDFS"] });470 case 'RESOURCEMANAGER':471 return Em.Object.create({ customCommands: ["DECOMMISSION", "REFRESHQUEUES"] });472 case 'HBASE_MASTER':473 return Em.Object.create({ customCommands: ["DECOMMISSION"] });474 case 'KNOX_GATEWAY':475 return Em.Object.create({ customCommands: ["STARTDEMOLDAP", "STOPDEMOLDAP"] });476 case 'HISTORYSERVER':477 case 'SECONDARY_NAMENODE':478 case 'ZOOKEEPER_SERVER':479 case 'APP_TIMELINE_SERVER':480 case 'KAFKA_BROKER':481 case 'OOZIE_SERVER':482 case 'NIMBUS':483 return Em.Object.create({ customCommands: [] });484 default:485 return [486 Em.Object.create({487 customCommands: ["DECOMMISSION", "REBALANCEHDFS"],488 componentName: 'NAMENODE'489 }),490 Em.Object.create({491 customCommands: ["STARTDEMOLDAP", "STOPDEMOLDAP"],492 componentName: 'KNOX_GATEWAY'493 })494 ];495 }496 });497 /*eslint-enable complexity */498 });499 afterEach(function () {500 App.get.restore();501 App.HostComponent.find.restore();502 App.StackServiceComponent.find.restore();503 });504 testCases.forEach(function (testCase) {505 describe('Maintenance for ' + testCase.serviceName + ' service', function () {506 beforeEach(function () {507 view.reopen({508 controller: Em.Object.create({509 content: Em.Object.create({510 hostComponents: testCase.hostComponents,511 slaveComponents: testCase.slaveComponents,512 clientComponents: testCase.clientComponents,513 serviceName: testCase.serviceName,514 displayName: testCase.displayName,515 serviceTypes: testCase.serviceTypes,516 passiveState: 'OFF'517 }),518 isSeveralClients: false,519 clientComponents: [],520 isStopDisabled: false521 }),522 mastersExcludedCommands: mastersExcludedCommands,523 hasConfigTab: hasConfigTab524 });525 if (testCase.controller) {526 testCase.controller.forEach(function (item) {527 Object.keys(item).forEach(function (key) {528 view.set('controller.' + key, item[key]);529 });530 });531 }532 view.observeMaintenanceOnce();533 });534 testCase.result.forEach(function (option, index) {535 Object.keys(option).forEach(function (key) {536 it(option.action + ', key - ' + key, function () {537 var r = view.get('maintenance')[index];538 expect(Em.get(option, key)).to.eql(Em.get(r, key));539 });540 });541 });542 it('maintenance is updated', function () {543 var oldMaintenance = JSON.parse(JSON.stringify(view.get('maintenance')));544 view.set('controller.content.passiveState', 'ON');545 view.observeMaintenanceOnce();546 expect(view.get('maintenance')).to.not.eql(oldMaintenance);547 expect(view.get('isMaintenanceSet')).to.be.true;548 });549 });550 });551 });552 describe('#clearIsMaintenanceSet', function () {553 it('isMaintenanceSet should be false', function () {554 view.set('isMaintenanceSet', true);555 view.clearIsMaintenanceSet();556 expect(view.get('isMaintenanceSet')).to.be.false;557 });558 });...
verify.js
Source:verify.js
...145 },146 task: (ctx, task) => {147 debug('clearing out the verified version');148 return state.clearBinaryStateAsync(binaryDir).then(() => {149 return Promise.all([runSmokeTest(binaryDir, options), Promise.resolve().delay(1500) // good user experience150 ]);151 }).then(() => {152 debug('write verified: true');153 return state.writeBinaryVerifiedAsync(true, binaryDir);154 }).then(() => {155 util.setTaskTitle(task, util.titleize(chalk.green('Verified Cypress!'), chalk.gray(binaryDir)), rendererOptions.renderer);156 });157 }158 }], {159 rendererOptions160 });161 return tasks.run();162}163const maybeVerify = (installedVersion, binaryDir, options) => {164 return state.getBinaryVerifiedAsync(binaryDir).then(isVerified => {165 debug('is Verified ?', isVerified);166 let shouldVerify = !isVerified; // force verify if options.force167 if (options.force) {168 debug('force verify');169 shouldVerify = true;170 }171 if (shouldVerify) {172 return testBinary(installedVersion, binaryDir, options).then(() => {173 if (options.welcomeMessage) {174 logger.log();175 logger.log('Opening Cypress...');176 }177 });178 }179 });180};181const start = (options = {}) => {182 debug('verifying Cypress app');183 const packageVersion = util.pkgVersion();184 let binaryDir = state.getBinaryDir(packageVersion);185 _.defaults(options, {186 dev: false,187 force: false,188 welcomeMessage: true,189 smokeTestTimeout: VERIFY_TEST_RUNNER_TIMEOUT_MS190 });191 if (options.dev) {192 return runSmokeTest('', options);193 }194 const parseBinaryEnvVar = () => {195 const envBinaryPath = util.getEnv('CYPRESS_RUN_BINARY');196 debug('CYPRESS_RUN_BINARY exists, =', envBinaryPath);197 logger.log(stripIndent`198 ${chalk.yellow('Note:')} You have set the environment variable:199 ${chalk.white('CYPRESS_RUN_BINARY=')}${chalk.cyan(envBinaryPath)}200 This overrides the default Cypress binary path used.201 `);202 logger.log();203 return util.isExecutableAsync(envBinaryPath).then(isExecutable => {204 debug('CYPRESS_RUN_BINARY is executable? :', isExecutable);205 if (!isExecutable) {206 return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(stripIndent`...
smoke.js
Source:smoke.js
...125const test = async function (buildAppExecutable) {126 await Fixtures.scaffoldCommonNodeModules()127 Fixtures.scaffoldProject('e2e')128 const e2e = Fixtures.projectPath('e2e')129 await runSmokeTest(buildAppExecutable)130 await runProjectTest(buildAppExecutable, e2e)131 await runFailingProjectTest(buildAppExecutable, e2e)132 Fixtures.remove()133}134module.exports = {135 test,136}137if (require.main === module) {138 const buildAppExecutable = path.join(__dirname, `../../build/${os.platform()}-unpacked/Cypress`)139 console.log('Script invoked directly, running smoke tests.')140 test(buildAppExecutable)...
item.js
Source:item.js
1/**2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */18var App = require('app');19App.MainServiceItemView = Em.View.extend({20 templateName: require('templates/main/service/item'),21 maintenance: function(){22 var options = [];23 var service = this.get('controller.content');24 switch(service.get('serviceName')) {25// case 'HDFS':26// options.push({action: 'runRebalancer', 'label': Em.I18n.t('services.service.actions.run.rebalancer')});27// break;28// case 'HBASE':29// options.push({action: 'runCompaction', 'label': Em.I18n.t('services.service.actions.run.compaction')});30// break;31 case 'GANGLIA':32 case 'NAGIOS':33 if (App.supports.reassignMaster) {34 this.get('controller.content.hostComponents').filterProperty('isMaster').forEach (function (hostComponent){35 options.push({action: 'reassignMaster', context: hostComponent, 'label': Em.I18n.t('services.service.actions.reassign.master').format(hostComponent.get('displayName'))});36 })37 }38 break;39 case 'HIVE':40 options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});41 if (App.supports.reassignMaster) {42 options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_METASTORE'), 'label': Em.I18n.t('services.service.actions.reassign.master').format(App.HostComponent.find().findProperty('componentName', 'HIVE_METASTORE').get('displayName'))});43 options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER'), 'label': Em.I18n.t('services.service.actions.reassign.master.hive')});44 }45 break;46 case 'WEBHCAT':47 options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});48 if (App.supports.reassignMaster) {49 options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER'), 'label': Em.I18n.t('services.service.actions.reassign.master.hive')});50 }51 break;52 case 'HUE':53 options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});54 break;55 case 'FLUME':56 break;57 case 'SPARK':58 break;59 case 'SHARK':60 break; //TODO(alex) runSmokeTest ?61 default:62 var components = this.get('controller.content.hostComponents');63 options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});64 if (App.supports.reassignMaster) {65 components.filterProperty('isMaster').mapProperty('displayName').uniq().forEach (function (hostComponent){66 options.push({action: 'reassignMaster', context: components.findProperty('displayName', hostComponent), 'label': Em.I18n.t('services.service.actions.reassign.master').format(hostComponent)});67 })68 }69 }70 return options;71 }.property('controller.content'),72 isMaintenanceActive: function() {73 return this.get('maintenance').length !== 0;74 }.property('maintenance'),75 hasConfigTab: function(){76 return this.get("controller.content.isConfigurable");77 }.property('controller.content.isConfigurable'),78 didInsertElement: function () {79 this.get('controller').setStartStopState();80 }...
smoketest.js
Source:smoketest.js
1const newman = require('newman');2const get = require('simple-get');3const fs = require('fs-extra');4// runSmokeTest("chipmunk");5runSmokeTest("lion");6function runSmokeTest(instance){7 let env= fs.readFileSync('tests/'+instance+'.postman_environment.json', { encoding: 'utf8' }, (err, data) => {8 if (err) throw err;9 console.log(data);10 });11 // call newman.run to pass `options` object and wait for callback12 newman.run({13 collection: require('../tests/monitor.postman_collection.json'),14 reporters: 'cli',15 insecure: true,16 environment: JSON.parse(env)17 }).on('start', function (err, args) { // on start of run, log to console18 console.log('running a collection...');19 }).on('done', function (err, summary) {20 if (err || summary.error) {...
custom_services_checks_view_test.js
Source:custom_services_checks_view_test.js
...35 it('should call runSmokeTest of mainServiceItemController with proper params', function () {36 var service = {};37 var controller = App.router.get('mainServiceItemController');38 sinon.stub(controller, 'runSmokeTest');39 view.runSmokeTest({context: service});40 expect(controller.runSmokeTest.calledWith(service)).to.be.equal(true);41 controller.runSmokeTest.restore();42 });43 });...
index.js
Source:index.js
...39if (SCHEDULE_CRON) {40 Logger.info('Scheduling smoke tests...');41 cron.schedule('0 */3 * * *', async () => {42 Logger.info(`Running smoke test at ${new Date(Date.now()).toTimeString()}`);43 await runSmokeTest();44 });45} else {46 Logger.info('Running smoke tests now...');47 runSmokeTest();...
Using AI Code Generation
1const cypressSmokeTest = require('cypress-smoke-test');2cypressSmokeTest.runSmokeTest();3const cypressSmokeTest = require('cypress-smoke-test');4const path = require('path');5cypressSmokeTest.runSmokeTest(path.join(__dirname, 'cypress'));6const cypressSmokeTest = require('cypress-smoke-test');7const path = require('path');8cypressSmokeTest.runSmokeTest(path.join(__dirname, 'cypress'), {9 config: {10 },11 env: {12 }13});14const cypressSmokeTest = require('cypress-smoke-test');15const path = require('path');16cypressSmokeTest.runSmokeTest(path.join(__dirname, 'cypress'), {17 config: {18 },19 env: {20 }21}, (err, results) => {22 if (err) {23 console.error(err);24 } else {25 console.log(results);26 }27});28const cypressSmokeTest = require('cypress-smoke-test');29const path = require('path');30cypressSmokeTest.runSmokeTest(path.join(__dirname, 'cypress'), {31 config: {32 },33 env: {34 }35}, (err, results) => {36 if (err) {37 console.error(err);38 } else {39 console.log(results);40 }41});42const cypressSmokeTest = require('cypress
Using AI Code Generation
1const {CypressSmokeTest} = require('cypress-smoke-test');2const cypressSmokeTest = new CypressSmokeTest();3cypressSmokeTest.runSmokeTest('test1', 'test2', 'test3');4{5}6{7 "dependencies": {8 }9}
Using AI Code Generation
1var cypressSmokeTest = require('./cypressSmokeTest.js');2cypressSmokeTest.runSmokeTest();3var cypress = require('cypress');4var cypressSmokeTest = {5 runSmokeTest: function() {6 cypress.run({7 })8 }9}10module.exports = cypressSmokeTest;11describe('Smoke Test', function() {12 it('Smoke Test', function() {13 cy.contains('type').click()14 cy.url().should('include', '/commands/actions')15 cy.get('.action-email')16 .type('
Using AI Code Generation
1const cypress = require('cypress')2cypress.runSmokeTest()3const cypress = require('cypress')4cypress.runSmokeTest()5const cypress = require('cypress')6cypress.runSmokeTest()7const cypress = require('cypress')8cypress.runSmokeTest()9const cypress = require('cypress')10cypress.runSmokeTest()11const cypress = require('cypress')12cypress.runSmokeTest()13const cypress = require('cypress')14cypress.runSmokeTest()15const cypress = require('cypress')16cypress.runSmokeTest()17const cypress = require('cypress')18cypress.runSmokeTest()
Using AI Code Generation
1var cypressTest = new CypressTest();2cypressTest.runSmokeTest();3class CypressTest {4 runSmokeTest() {5 }6}7We have also seen how to import and use classes in Cypress. We have seen how to use
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!