Best JavaScript code snippet using appium-base-driver
appDownload.js
Source:appDownload.js
1/*2 * Copyright (c) 2017 NiXPS, All rights reserved.3 *4 * This Source Code Form is subject to the terms of the Mozilla Public5 * License, v. 2.0. If a copy of the MPL was not distributed with this6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.7 *8 */9'use strict';10const { assert } = require('chai');11const nock = require('nock');12const fs = require('fs');13const mkdirp = require('mkdirp');14const remove = require('remove');15const streamify = require('stream-array');16const os = require('os');17const _ = require('lodash');18const APIMockDelegate = require('../util/APIMockDelegate');19const cfapp = require('../../lib/cfapp');20const apiMock = require('cloudflow-api');21const JSONOutputStream = require('../../lib/util/JSONOutputStream');22function getFileDownloadMock(downloadedFiles, expected) {23 const downloadFileURLRegex = /portal.cgi\?dl=(.*)&session=session_admin_admin/;24 nock('http://localhost:9090')25 .get(downloadFileURLRegex, function() {26 return true;27 })28 .times(expected)29 .reply(200, function(uri) {30 const matches = uri.match(downloadFileURLRegex);31 if (Array.isArray(matches) && matches.length > 1) {32 // The Cloudflow URIs are URI encoded in the upload URL33 downloadedFiles.push(decodeURIComponent(matches[1]));34 }35 return streamify(['1', '2', '3', os.EOF]);36 }, {37 'Content-Type': 'application/pdf',38 'Content-Disposition': 'attachment; filename="file.pdf"'39 });40}41function downloadTests() {42 class ExistingSingleAppDelegate extends APIMockDelegate {43 doesExist(url) {44 if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/test/' ||45 url === 'cloudflow://PP_FILE_STORE/DownloadApp/test') {46 return {47 exists: true,48 is_folder: true,49 url: url50 };51 }52 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/' ||53 url === 'cloudflow://PP_FILE_STORE/DownloadApp/docs') {54 return {55 exists: true,56 is_folder: true,57 url: url58 };59 }60 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {61 return {62 exists: true,63 is_folder: true,64 url: url65 };66 }67 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/index.html') {68 return {69 exists: true,70 is_folder: false,71 url: url72 };73 }74 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png') {75 return {76 exists: true,77 is_folder: false,78 url: url79 };80 }81 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf') {82 return {83 exists: true,84 is_folder: false,85 url: url86 };87 }88 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md') {89 return {90 exists: true,91 is_folder: false,92 url: url93 };94 }95 return super.doesExist(url);96 }97 existingAssets(query) {98 if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf') {99 return [{100 _id: 'I exist doc.pdf',101 cloudflow: {102 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf'103 }104 }];105 }106 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md') {107 return [{108 _id: 'I exist readme.md',109 cloudflow: {110 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md'111 }112 }];113 }114 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/'115 || query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs') {116 return [{117 _id: 'I exist readme.md',118 cloudflow: {119 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md'120 }121 }, {122 _id: 'I exist doc.pdf',123 cloudflow: {124 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf'125 }126 }];127 }128 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png') {129 return [{130 _id: 'I exist icon.png',131 cloudflow: {132 file: 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png'133 }134 }];135 }136 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png') {137 return [{138 _id: 'I exist',139 cloudflow: {140 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png'141 }142 }];143 }144 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png') {145 return [{146 _id: 'I exist too',147 cloudflow: {148 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png'149 }150 }];151 } else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {152 // Get the assets in the image folder153 return [{154 _id: 'I exist',155 cloudflow: {156 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png'157 }158 }, {159 _id: 'I exist too',160 cloudflow: {161 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png'162 }163 }];164 }165 return [];166 }167 existingWhitepapers() {168 return [ {169 _id: 'Workflow1',170 name: 'Workflow1'171 }, {172 _id: 'Workflow2',173 name: 'Workflow2'174 }];175 }176 existingFolders(query) {177 if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/test/' ||178 query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/test') {179 return [ 'test' ];180 } else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/' ||181 query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs') {182 return [ 'docs' ];183 }184 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {185 return [ 'images' ];186 }187 return [];188 }189 }190 class AssetDoesExistThrowsErrorAppDelegate extends APIMockDelegate {191 doesExist() {192 throw new Error('Parameter Error');193 }194 existingAssets() {195 return [ ];196 }197 existingWhitepapers() {198 return [ ];199 }200 existingFolders() {201 return [ ];202 }203 }204 const projectCFApp = {205 name: 'DownloadApp',206 host: 'http://localhost:9090',207 login: 'admin',208 password: 'admin',209 description: 'A test for downloading an application',210 files: [211 'cloudflow://PP_FILE_STORE/DownloadApp/images/',212 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',213 ],214 workflows: [215 'Workflow1',216 'Workflow2'217 ]218 };219 after(function() {220 if (fs.existsSync(__dirname + '/downloadTest')) {221 remove.removeSync(__dirname + '/downloadTest');222 }223 });224 it('download a single application', function() {225 const outputStream = new JSONOutputStream();226 apiMock.mockDelegate = new ExistingSingleAppDelegate();227 const downloadedFiles = [];228 getFileDownloadMock(downloadedFiles, 3);229 if (fs.existsSync(__dirname + '/downloadTest') === true) {230 remove.removeSync(__dirname + '/downloadTest');231 }232 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');233 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));234 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {235 const mockDelegate = apiMock.mockDelegate;236 assert.equal(mockDelegate.downloadedGetWhitepapers.length, 2, 'not all whitepapers were downloaded');237 assert.includeMembers(_.map(mockDelegate.downloadedGetWhitepapers, function (w) {238 return w.name;239 }), [240 'Workflow1',241 'Workflow2'242 ], 'not all whitepapers were downloaded');243 assert.equal(downloadedFiles.length, 3, 'not all files were downloaded');244 assert.includeMembers(downloadedFiles, [245 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png',246 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png',247 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'248 ], 'not all files were downloaded');249 assert(nock.isDone(), 'expected requests not performed');250 // TODO: assert file structure too251 });252 });253 it('should not overwrite', function() {254 const outputStream = new JSONOutputStream();255 apiMock.mockDelegate = new ExistingSingleAppDelegate();256 const downloadedFiles = [];257 getFileDownloadMock(downloadedFiles, 3);258 const projectCFApp = {259 name: 'DownloadApp',260 host: 'http://localhost:9090',261 login: 'admin',262 password: 'admin',263 description: 'A test for downloading an application',264 files: [265 'cloudflow://PP_FILE_STORE/DownloadApp/images/',266 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',267 ],268 workflows: [269 'Workflow1',270 'Workflow2'271 ]272 };273 if (fs.existsSync(__dirname + '/downloadTest') === true) {274 remove.removeSync(__dirname + '/downloadTest');275 }276 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');277 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));278 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {279 // Reset the mock delegate280 nock.cleanAll();281 apiMock.mockDelegate = new ExistingSingleAppDelegate();282 const downloadedFiles = [];283 getFileDownloadMock(downloadedFiles, 1);284 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {285 const mockDelegate = apiMock.mockDelegate;286 assert.equal(mockDelegate.downloadedWhitepapers.length, 0, 'no whitepapers should be downloaded');287 assert.equal(downloadedFiles.length, 0, 'no files should be downloaded');288 assert(nock.isDone() === false, 'requests were performed while none expected');289 // TODO: assert file structure too290 });291 });292 });293 it('should overwrite when the flag is set', function() {294 const outputStream = new JSONOutputStream();295 apiMock.mockDelegate = new ExistingSingleAppDelegate();296 const downloadedFiles = [];297 getFileDownloadMock(downloadedFiles, 3);298 if (fs.existsSync(__dirname + '/downloadTest') === true) {299 remove.removeSync(__dirname + '/downloadTest');300 }301 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');302 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));303 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {304 // Reset the mock delegate305 nock.cleanAll();306 apiMock.mockDelegate = new ExistingSingleAppDelegate();307 const downloadedFiles = [];308 getFileDownloadMock(downloadedFiles, 3);309 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {310 overwrite: true311 }, outputStream).then(function() {312 const mockDelegate = apiMock.mockDelegate;313 assert.equal(mockDelegate.downloadedGetWhitepapers.length, 2, 'not all whitepapers were downloaded');314 assert.includeMembers(_.map(mockDelegate.downloadedGetWhitepapers, function (w) {315 return w.name;316 }), [317 'Workflow1',318 'Workflow2'319 ], 'not all whitepapers were downloaded');320 assert.equal(downloadedFiles.length, 3, 'not all files were downloaded');321 assert.includeMembers(downloadedFiles, [322 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png',323 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png',324 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'325 ], 'not all files were downloaded');326 assert(nock.isDone(), 'expected requests not performed');327 });328 });329 });330 it('should throw an error when a workflow that needs to be downloaded does not exist', function() {331 class RemoteWorkflowsMissingAppDelegate extends ExistingSingleAppDelegate {332 existingWhitepapers() {333 return [ {334 _id: 'Workflow1',335 name: 'Workflow1'336 }];337 }338 }339 const outputStream = new JSONOutputStream();340 apiMock.mockDelegate = new RemoteWorkflowsMissingAppDelegate();341 const downloadedFiles = [];342 getFileDownloadMock(downloadedFiles, 3);343 if (fs.existsSync(__dirname + '/downloadTest') === true) {344 remove.removeSync(__dirname + '/downloadTest');345 }346 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');347 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));348 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {349 assert.notOk('the promise should not resolve if a folder is missing on the remote Cloudflow');350 }).catch(function(error) {351 assert.equal(error.errorCode, 'CFAPPERR018');352 assert.equal(error.message, 'Specified workflow "Workflow2" does not exist on the remote Cloudflow');353 });354 });355 it('should throw an error when a file that needs to be downloaded does not exist', function() {356 class RemoteFilesDoNotExistAppDelegate extends APIMockDelegate {357 existingAssets() {358 return [];359 }360 existingWhitepapers() {361 return [ {362 _id: 'Workflow1',363 name: 'Workflow1'364 }, {365 _id: 'Workflow2',366 name: 'Workflow2'367 }];368 }369 existingFolders() {370 return [];371 }372 }373 const outputStream = new JSONOutputStream();374 apiMock.mockDelegate = new RemoteFilesDoNotExistAppDelegate();375 const downloadedFiles = [];376 getFileDownloadMock(downloadedFiles, 0);377 if (fs.existsSync(__dirname + '/downloadTest') === true) {378 remove.removeSync(__dirname + '/downloadTest');379 }380 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');381 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));382 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {383 assert.notOk('the promise should not resolve if a folder is missing on the remote Cloudflow');384 }).catch(function(error) {385 assert.equal(error.errorCode, 'CFAPPERR014');386 assert.equal(error.message, 'Specified file does not exist "cloudflow://PP_FILE_STORE/DownloadApp/images/" on the remote Cloudflow');387 });388 });389 390 it('should show an appropriate error code when no project.cfapp file is found', function() {391 const outputStream = new JSONOutputStream();392 apiMock.mockDelegate = new ExistingSingleAppDelegate();393 const downloadedFiles = [];394 getFileDownloadMock(downloadedFiles, 0);395 if (fs.existsSync(__dirname + '/downloadTest') === true) {396 remove.removeSync(__dirname + '/downloadTest');397 }398 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');399 assert.throws(function() {400 cfapp.apps.download(__dirname + '/downloadTest/DownloadApp/', {}, outputStream).then(function() {401 assert.isNotOk(true, 'this function should have failed earlier (then)');402 }).catch(function() {403 assert.isNotOk(true, 'this function should have failed earlier (catch)');404 });405 }, /^Missing 'project\.cfapp' file/, 'an error should be returned');406 assert.equal(downloadedFiles.length, 0, 'no files should be uploaded');407 });408 it('should show an appropriate error code when does_exist fails with a "Parameter Error"', function() {409 const projectCFApp = {410 name: 'DownloadApp',411 host: 'http://localhost:9090',412 login: 'admin',413 password: 'admin',414 description: 'A test for downloading an application',415 files: [416 'cloudflow://PP_FILE_STORE'417 ],418 workflows: [ ]419 };420 const outputStream = new JSONOutputStream();421 apiMock.mockDelegate = new AssetDoesExistThrowsErrorAppDelegate();422 if (fs.existsSync(__dirname + '/downloadTest') === true) {423 remove.removeSync(__dirname + '/downloadTest');424 }425 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');426 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));427 const downloadedFiles = [];428 getFileDownloadMock(downloadedFiles, 0);429 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp/', {}, outputStream).then(function() {430 assert.isNotOk(true, 'this function should have failed after then');431 }).catch(function(error) {432 assert.equal(error.errorCode, 'CFAPPERR016', 'wrong error code is returned');433 assert.match(error, /^Error: api\.file\.does_exist failed for path/, 'wrong error message returned');434 });435 });436 it('download a single application with icon and documentation', function() {437 const projectWithIconAndDocumentationCFApp = {438 name: 'DownloadApp',439 host: 'http://localhost:9090',440 login: 'admin',441 password: 'admin',442 description: 'A test for downloading an application',443 icon: 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png',444 documentation: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/',445 files: [446 'cloudflow://PP_FILE_STORE/DownloadApp/images/',447 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',448 ],449 workflows: [450 'Workflow1',451 'Workflow2'452 ]453 };454 const outputStream = new JSONOutputStream();455 apiMock.mockDelegate = new ExistingSingleAppDelegate();456 const downloadedFiles = [];457 getFileDownloadMock(downloadedFiles, 6);458 if (fs.existsSync(__dirname + '/downloadTest') === true) {459 remove.removeSync(__dirname + '/downloadTest');460 }461 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');462 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectWithIconAndDocumentationCFApp));463 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {464 const mockDelegate = apiMock.mockDelegate;465 assert.equal(mockDelegate.downloadedGetWhitepapers.length, 2, 'not all whitepapers were downloaded');466 assert.includeMembers(_.map(mockDelegate.downloadedGetWhitepapers, function (w) {467 return w.name;468 }), [469 'Workflow1',470 'Workflow2'471 ], 'not all whitepapers were downloaded');472 assert.includeMembers(downloadedFiles, [473 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf',474 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md',475 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png',476 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png',477 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png',478 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'479 ], 'not all files were downloaded');480 assert.equal(downloadedFiles.length, 6, 'not all files were downloaded');481 assert(nock.isDone(), 'expected requests not performed');482 // TODO: assert file structure too483 const projectCFApp = fs.readFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp');484 const projectCFAppJSON = JSON.parse(projectCFApp);485 assert.equal(projectCFAppJSON.documentation, 'cloudflow://PP_FILE_STORE/DownloadApp/docs/', 'The documentation field should not be changed');486 });487 });488 it('empty folders and documentation folder should end with a directory separator in project.cfapp', function() {489 const projectWithIconAndDocumentationCFApp = {490 name: 'DownloadApp',491 host: 'http://localhost:9090',492 login: 'admin',493 password: 'admin',494 description: 'A test for downloading an application',495 documentation: 'cloudflow://PP_FILE_STORE/DownloadApp/docs',496 files: [497 'cloudflow://PP_FILE_STORE/DownloadApp/test',498 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',499 ],500 workflows: []501 };502 const outputStream = new JSONOutputStream();503 apiMock.mockDelegate = new ExistingSingleAppDelegate();504 const downloadedFiles = [];505 getFileDownloadMock(downloadedFiles, 3);506 if (fs.existsSync(__dirname + '/downloadTest') === true) {507 remove.removeSync(__dirname + '/downloadTest');508 }509 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');510 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectWithIconAndDocumentationCFApp));511 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {512 const mockDelegate = apiMock.mockDelegate;513 assert.equal(mockDelegate.downloadedWhitepapers.length, 0, 'not all whitepapers were downloaded');514 assert.includeMembers(mockDelegate.downloadedWhitepapers, [], 'not all whitepapers were downloaded');515 assert.includeMembers(downloadedFiles, [516 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf',517 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md',518 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'519 ], 'not all files were downloaded');520 assert.equal(downloadedFiles.length, 3, 'not all files were downloaded');521 assert(nock.isDone(), 'expected requests not performed');522 const fileContents = fs.readFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', 'utf8');523 let projectCFApp = null;524 assert.doesNotThrow(function () {525 projectCFApp = JSON.parse(fileContents);526 }, SyntaxError, /.*/, `file output is not parsable: ${fileContents}`);527 assert.equal(projectCFApp.documentation, 'cloudflow://PP_FILE_STORE/DownloadApp/docs/', 'error in project.cfapp: ');528 assert.equal(projectCFApp.files[0], 'cloudflow://PP_FILE_STORE/DownloadApp/test/');529 assert.equal(projectCFApp.files[1], 'cloudflow://PP_FILE_STORE/DownloadApp/index.html');530 });531 });532 it('should not download template workflows', function () {533 class TemplateWhitepapers extends APIMockDelegate {534 existingWhitepapers() {535 return [ {536 _id: 'Workflow1',537 name: 'Workflow1',538 template: {}539 }, {540 _id: 'Workflow2',541 name: 'Workflow2'542 }];543 }544 }545 546 const projectCFApp = {547 name: 'DownloadApp',548 host: 'http://localhost:9090',549 login: 'admin',550 password: 'admin',551 description: 'A test for downloading an application',552 files: [],553 workflows: [554 'Workflow1',555 'Workflow2' 556 ]557 };558 const outputStream = new JSONOutputStream();559 apiMock.mockDelegate = new TemplateWhitepapers();560 const downloadedFiles = [];561 getFileDownloadMock(downloadedFiles, 0);562 if (fs.existsSync(__dirname + '/downloadTest') === true) {563 remove.removeSync(__dirname + '/downloadTest');564 }565 mkdirp.sync(__dirname + '/downloadTest/DownloadApp');566 fs.writeFileSync(__dirname + '/downloadTest/DownloadApp/project.cfapp', JSON.stringify(projectCFApp));567 return cfapp.apps.download(__dirname + '/downloadTest/DownloadApp', {}, outputStream).then(function() {568 assert.isNotOk(true, 'this function should have failed');569 }).catch(function (error) {570 assert.equal(error.errorCode, 'CFAPPERR018');571 assert.equal(error.message, 'Specified workflow "Workflow1" does not exist on the remote Cloudflow');572 });573 })574}...
appRemove.js
Source:appRemove.js
1/*2 * Copyright (c) 2017 NiXPS, All rights reserved.3 *4 * This Source Code Form is subject to the terms of the Mozilla Public5 * License, v. 2.0. If a copy of the MPL was not distributed with this6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.7 *8 */9'use strict';10const { assert } = require('chai');11const APIMockDelegate = require('../util/APIMockDelegate');12const apiMock = require('cloudflow-api');13const cfapp = require('../../lib/cfapp');14const JSONOutputStream = require('../../lib/util/JSONOutputStream');15class NestedAppDelegate extends APIMockDelegate {16 get supportsApplications() {17 return true;18 }19 doesExist(url) {20 if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/') {21 return {22 exists: true,23 is_folder: true,24 url: url,25 valid: true26 };27 } else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/index.html') {28 return {29 exists: true,30 is_folder: false,31 url: url,32 valid: true33 };34 } else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {35 return {36 exists: true,37 is_folder: true,38 url: url,39 valid: true40 };41 }42 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/') {43 return {44 exists: true,45 is_folder: true,46 url: url,47 valid: true48 };49 }50 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png') {51 return {52 exists: true,53 is_folder: false,54 url: url,55 valid: true56 };57 }58 return super.doesExist(url);59 }60 existingAssets(query) {61 if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png') {62 return [{63 _id: 'I exist',64 cloudflow: {65 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png'66 }67 }];68 }69 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/index.html') {70 return [{71 _id: 'I exist as well',72 cloudflow: {73 file: 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'74 }75 }];76 }77 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png') {78 return [{79 _id: 'I exist too',80 cloudflow: {81 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png'82 }83 }];84 }85 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf') {86 return [{87 _id: 'I exist too',88 cloudflow: {89 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf'90 }91 }];92 }93 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md') {94 return [{95 _id: 'I exist too',96 cloudflow: {97 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md'98 }99 }];100 }101 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png') {102 return [{103 _id: 'I exist too',104 cloudflow: {105 file: 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png'106 }107 }];108 }109 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {110 // Get the assets in the image folder111 return [{112 _id: 'I exist',113 cloudflow: {114 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png'115 }116 }, {117 _id: 'I exist too',118 cloudflow: {119 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png'120 }121 }];122 }123 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/') {124 // Get the assets in the docs folder125 return [{126 _id: 'I exist',127 cloudflow: {128 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md'129 }130 }, {131 _id: 'I exist too',132 cloudflow: {133 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf'134 }135 }];136 }137 return [];138 }139 existingWhitepapers(query) {140 if (Array.isArray(query) && query.length > 0) {141 if (query[2] === 'Workflow1') {142 return [{143 _id: 'Workflow1',144 name: 'Workflow1'145 }];146 }147 else if (query[2] === 'Workflow2') {148 return [{149 _id: 'Workflow2',150 name: 'Workflow2'151 }];152 }153 }154 return [{155 _id: 'Workflow1',156 name: 'Workflow1'157 }, {158 _id: 'Workflow2',159 name: 'Workflow2'160 }];161 }162 existingFolders(query) {163 if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/') {164 return [ 'DownloadApp' ];165 }166 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {167 return [ 'images' ];168 }169 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/') {170 return [ 'docs' ];171 }172 return [];173 }174 applicationList(query) {175 if (query[2] !== 'DownloadAppWithIconAndDocs') {176 return [];177 }178 return [{179 _id: 'DownloadAppWithIconAndDocsID',180 name: 'DownloadAppWithIconAndDocs',181 host: 'http://localhost:9090',182 version: '0.0.1',183 login: 'admin',184 password: 'admin',185 description: 'A test for downloading an application',186 icon: 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png',187 documentation: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/',188 files: [189 'cloudflow://PP_FILE_STORE/DownloadApp/',190 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',191 ],192 workflows: [193 'Workflow1',194 'Workflow2'195 ]196 }];197 }198}199class ExistingSingleAppDelegate extends APIMockDelegate {200 get supportsApplications() {201 return true;202 }203 doesExist(url) {204 if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/index.html') {205 return {206 exists: true,207 is_folder: false,208 url: url,209 valid: true210 };211 } else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {212 return {213 exists: true,214 is_folder: true,215 url: url,216 valid: true217 };218 }219 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/') {220 return {221 exists: true,222 is_folder: true,223 url: url,224 valid: true225 };226 }227 else if (url === 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png') {228 return {229 exists: true,230 is_folder: false,231 url: url,232 valid: true233 };234 }235 return super.doesExist(url);236 }237 existingAssets(query) {238 if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png') {239 return [{240 _id: 'I exist',241 cloudflow: {242 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png'243 }244 }];245 }246 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/index.html') {247 return [{248 _id: 'I exist as well',249 cloudflow: {250 file: 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'251 }252 }];253 }254 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png') {255 return [{256 _id: 'I exist too',257 cloudflow: {258 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png'259 }260 }];261 }262 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf') {263 return [{264 _id: 'I exist too',265 cloudflow: {266 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf'267 }268 }];269 }270 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md') {271 return [{272 _id: 'I exist too',273 cloudflow: {274 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md'275 }276 }];277 }278 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png') {279 return [{280 _id: 'I exist too',281 cloudflow: {282 file: 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png'283 }284 }];285 }286 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {287 // Get the assets in the image folder288 return [{289 _id: 'I exist',290 cloudflow: {291 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/win.png'292 }293 }, {294 _id: 'I exist too',295 cloudflow: {296 file: 'cloudflow://PP_FILE_STORE/DownloadApp/images/mac.png'297 }298 }];299 }300 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/') {301 // Get the assets in the docs folder302 return [{303 _id: 'I exist',304 cloudflow: {305 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/readme.md'306 }307 }, {308 _id: 'I exist too',309 cloudflow: {310 file: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/doc.pdf'311 }312 }];313 }314 return [];315 }316 existingWhitepapers(query) {317 if (Array.isArray(query) && query.length > 0) {318 if (query[2] === 'Workflow1') {319 return [{320 _id: 'Workflow1',321 name: 'Workflow1'322 }];323 }324 else if (query[2] === 'Workflow2') {325 return [{326 _id: 'Workflow2',327 name: 'Workflow2'328 }];329 }330 }331 return [{332 _id: 'Workflow1',333 name: 'Workflow1'334 }, {335 _id: 'Workflow2',336 name: 'Workflow2'337 }];338 }339 existingFolders(query) {340 if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/images/') {341 return [ 'images' ];342 }343 else if (query[2] === 'cloudflow://PP_FILE_STORE/DownloadApp/docs/') {344 return [ 'docs' ];345 }346 return [];347 }348 applicationList(query) {349 if (query[2] !== 'DownloadApp' &&350 query[2] !== 'DownloadAppWithIconAndDocs') {351 return [];352 }353 if (query[2] === 'DownloadApp') {354 return [{355 _id: 'DownloadAppID',356 name: 'DownloadApp',357 host: 'http://localhost:9090',358 version: '0.0.1',359 login: 'admin',360 password: 'admin',361 description: 'A test for downloading an application',362 files: [363 'cloudflow://PP_FILE_STORE/DownloadApp/images/',364 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',365 ],366 workflows: [367 'Workflow1',368 'Workflow2'369 ]370 }];371 }372 return [{373 _id: 'DownloadAppWithIconAndDocsID',374 name: 'DownloadAppWithIconAndDocs',375 host: 'http://localhost:9090',376 version: '0.0.1',377 login: 'admin',378 password: 'admin',379 description: 'A test for downloading an application',380 icon: 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png',381 documentation: 'cloudflow://PP_FILE_STORE/DownloadApp/docs/',382 files: [383 'cloudflow://PP_FILE_STORE/DownloadApp/images/',384 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',385 ],386 workflows: [387 'Workflow1',388 'Workflow2'389 ]390 }];391 }392}393class NoInstalledAppsDelegate extends APIMockDelegate {394 get supportsApplications() {395 return true;396 }397}398class ExistingSingleAppWithWorkablesDelegate extends ExistingSingleAppDelegate {399 listWorkables (query, fields) {400 return [{401 id: 'hi',402 whitepaper_name: 'Workflow1'403 }, {404 id: 'hello',405 whitepaper_name: 'Workflow1'406 }]407 }408}409class ExistingAppCannotDeleteFiles extends ExistingSingleAppDelegate {410 fileDeletedError (file) {411 return {412 'error_code': 'Delete folder failed',413 'error': `Delete of folder ${file} failed. Macintosh Error: -47`,414 'messages': [{415 'severity':'error',416 'type': 'Delete folder failed',417 'description': `Delete of folder ${file} failed. Macintosh Error: -47`418 }]419 };420 }421}422function removeTests() {423 describe('default parameters', function() {424 it('should remove an existing app', function() {425 const outputStream = new JSONOutputStream();426 const apiMockDelegate = new ExistingSingleAppDelegate();427 apiMock.mockDelegate = apiMockDelegate;428 return cfapp.apps.remove('DownloadApp', {429 host: 'http://localhost:9090',430 login: 'admin',431 password: 'admin'432 }, outputStream).then(function() {433 assert.includeMembers(apiMockDelegate.deletedFiles, [434 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'435 ], 'not all the installed files were removed');436 assert.includeMembers(apiMockDelegate.deletedFolders, [437 'cloudflow://PP_FILE_STORE/DownloadApp/images/'438 ], 'not all the installed folders were removed');439 assert.includeMembers(apiMockDelegate.deletedWhitepapers, [440 'Workflow1',441 'Workflow2'442 ], 'not all the installed workflows were removed');443 assert.includeMembers(apiMockDelegate.deletedApplications, [444 'DownloadAppID'445 ], 'the app was not removed from the application registry');446 });447 });448 it('should not remove paths that are nested', function() {449 const outputStream = new JSONOutputStream();450 const apiMockDelegate = new NestedAppDelegate();451 apiMock.mockDelegate = apiMockDelegate;452 return cfapp.apps.remove('DownloadAppWithIconAndDocs', {453 host: 'http://localhost:9090',454 login: 'admin',455 password: 'admin'456 }, outputStream).then(function() {457 assert.lengthOf(apiMockDelegate.deletedFiles, 0,458 'no files should be deleted');459 assert.lengthOf(apiMockDelegate.deletedFolders, 1,460 'only one folder should be deleted');461 assert.includeMembers(apiMockDelegate.deletedFolders, [462 'cloudflow://PP_FILE_STORE/DownloadApp/'463 ], 'not all the installed folders were removed');464 assert.includeMembers(apiMockDelegate.deletedWhitepapers, [465 'Workflow1',466 'Workflow2'467 ], 'not all the installed workflows were removed');468 assert.includeMembers(apiMockDelegate.deletedApplications, [469 'DownloadAppWithIconAndDocsID'470 ], 'the app was not removed from the application registry');471 });472 });473 it('should remove an existing app with icons and documentation', function() {474 const outputStream = new JSONOutputStream();475 const apiMockDelegate = new ExistingSingleAppDelegate();476 apiMock.mockDelegate = apiMockDelegate;477 return cfapp.apps.remove('DownloadAppWithIconAndDocs', {478 host: 'http://localhost:9090',479 login: 'admin',480 password: 'admin'481 }, outputStream).then(function() {482 assert.includeMembers(apiMockDelegate.deletedFiles, [483 'cloudflow://PP_FILE_STORE/DownloadApp/index.html',484 'cloudflow://PP_FILE_STORE/DownloadApp/icon.png',485 ], 'not all the installed files were removed');486 assert.includeMembers(apiMockDelegate.deletedFolders, [487 'cloudflow://PP_FILE_STORE/DownloadApp/images/',488 'cloudflow://PP_FILE_STORE/DownloadApp/docs/'489 ], 'not all the installed folders were removed');490 assert.includeMembers(apiMockDelegate.deletedWhitepapers, [491 'Workflow1',492 'Workflow2'493 ], 'not all the installed workflows were removed');494 assert.includeMembers(apiMockDelegate.deletedApplications, [495 'DownloadAppWithIconAndDocsID'496 ], 'the app was not removed from the application registry');497 });498 });499 it('should give an error when the app does not exist', function() {500 const outputStream = new JSONOutputStream();501 const apiMockDelegate = new NoInstalledAppsDelegate();502 apiMock.mockDelegate = apiMockDelegate;503 assert.throws(function() {504 cfapp.apps.remove('DownloadApp', {505 host: 'http://localhost:9090',506 login: 'admin',507 password: 'admin'508 }, outputStream);509 }, 'application DownloadApp is not installed', 'should show an appropriate error message');510 });511 it('not remove the workflows with running workables', function() {512 const outputStream = new JSONOutputStream();513 const apiMockDelegate = new ExistingSingleAppWithWorkablesDelegate();514 apiMock.mockDelegate = apiMockDelegate;515 return cfapp.apps.remove('DownloadApp', {516 host: 'http://localhost:9090',517 login: 'admin',518 password: 'admin'519 }, outputStream).then(function() {520 assert.includeMembers(apiMockDelegate.deletedFiles, [521 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'522 ], 'not all the installed files were removed');523 assert.includeMembers(apiMockDelegate.deletedFolders, [524 'cloudflow://PP_FILE_STORE/DownloadApp/images/'525 ], 'not all the installed folders were removed');526 assert.equal(apiMockDelegate.deletedWhitepapers.length, 1, 'only Workflow2 should be removed')527 assert.includeMembers(apiMockDelegate.deletedWhitepapers, [528 'Workflow2'529 ], 'not all the installed workflows were removed');530 assert.includeMembers(apiMockDelegate.deletedApplications, [531 'DownloadAppID'532 ], 'the app was not removed from the application registry');533 });534 });535 it('remove the workflows with running workables when force-remove-workflows is passed', function() {536 const outputStream = new JSONOutputStream();537 const apiMockDelegate = new ExistingSingleAppWithWorkablesDelegate();538 apiMock.mockDelegate = apiMockDelegate;539 return cfapp.apps.remove('DownloadApp', {540 host: 'http://localhost:9090',541 login: 'admin',542 password: 'admin',543 forceRemoveWorkflows: true544 }, outputStream).then(function() {545 assert.includeMembers(apiMockDelegate.deletedFiles, [546 'cloudflow://PP_FILE_STORE/DownloadApp/index.html'547 ], 'not all the installed files were removed');548 assert.includeMembers(apiMockDelegate.deletedFolders, [549 'cloudflow://PP_FILE_STORE/DownloadApp/images/'550 ], 'not all the installed folders were removed');551 assert.equal(apiMockDelegate.deletedWhitepapers.length, 2, 'both workflows should be removed')552 assert.includeMembers(apiMockDelegate.deletedWhitepapers, [553 'Workflow1',554 'Workflow2'555 ], 'not all the installed workflows were removed');556 assert.includeMembers(apiMockDelegate.deletedApplications, [557 'DownloadAppID'558 ], 'the app was not removed from the application registry');559 });560 });561 it('should show an error when some files cannot be removed', function() {562 const outputStream = new JSONOutputStream();563 const apiMockDelegate = new ExistingAppCannotDeleteFiles();564 apiMock.mockDelegate = apiMockDelegate;565 cfapp.apps.remove('DownloadApp', {566 host: 'http://localhost:9090',567 login: 'admin',568 password: 'admin'569 }, outputStream).then(function () {570 assert.isNotOk(true, 'this action should not succeed');571 }).catch(function (error) {572 assert.equal(error.errorCode, 'CFAPPERR026', 'the error code is not correct');573 });574 });575 });576}...
DownloadApp.js
Source:DownloadApp.js
1/*2 * Copyright 2007-2017 Charles du Jeu - Abstrium SAS <team (at) pyd.io>3 * This file is part of Pydio.4 *5 * Pydio is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * Pydio is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU Affero General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Pydio. If not, see <http://www.gnu.org/licenses/>.17 *18 * The latest code can be found at <https://pydio.com>.19 */20"use strict";21Object.defineProperty(exports, "__esModule", {22 value: true23});24var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };25var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();26var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };27function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }28function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }29var DownloadApp = (function (_React$Component) {30 _inherits(DownloadApp, _React$Component);31 function DownloadApp() {32 _classCallCheck(this, DownloadApp);33 _get(Object.getPrototypeOf(DownloadApp.prototype), "constructor", this).apply(this, arguments);34 }35 _createClass(DownloadApp, [{36 key: "render",37 value: function render() {38 var styles = {39 smallIcon: {40 fontSize: 40,41 width: 40,42 height: 4043 },44 small: {45 width: 80,46 height: 80,47 padding: 2048 }49 };50 var _props = this.props;51 var pydio = _props.pydio;52 var iconClassName = _props.iconClassName;53 var tooltipId = _props.tooltipId;54 var configs = _props.configs;55 var configHref = _props.configHref;56 return React.createElement(MaterialUI.IconButton, {57 iconClassName: iconClassName,58 tooltip: pydio.MessageHash[tooltipId],59 tooltipStyles: { marginTop: 40 },60 style: styles.small,61 iconStyle: _extends({}, styles.smallIcon, { color: this.props.iconColor }),62 onTouchTap: function () {63 window.open(configs.get(configHref));64 }65 });66 }67 }]);68 return DownloadApp;69})(React.Component);70DownloadApp.propTypes = {71 pydio: React.PropTypes.instanceOf(Pydio),72 id: React.PropTypes.string,73 configs: React.PropTypes.object,74 configHref: React.PropTypes.string,75 iconClassName: React.PropTypes.string,76 iconColor: React.PropTypes.string,77 messageId: React.PropTypes.string,78 tooltipId: React.PropTypes.string79};80exports["default"] = DownloadApp;...
DownloadApp.jsx
Source:DownloadApp.jsx
1import style from '../../style/LandingPage/DownloadApp.module.css'2import GooglePlay from '../../static/google_play_badge.png'3import AppStore from '../../static/app_store_badge.png'4import PhoneFront from '../../static/LandingPage/downloadApp/phone_front.png'5import PhoneBack from '../../static/LandingPage/downloadApp/phone_back.png'6import {Desktop, Mobile} from "../MediaContainer";7const DownloadApp = () => {8 return (9 <div className={style.mainContainer}>10 <div className={style.container}>11 <Desktop>12 <h2 className={style.header}>13 ÐÑ Ð½Ð° ÑÑадии ÑазÑабоÑки <br/>14 мобилÑного пÑÐ¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ âZHOLDAâ15 </h2>16 <h3 className={style.subHeader}>17 СÑаÑÑ Ð¿Ð°ÑÑнеÑом ZHOLDA.KZ легко, доÑÑаÑоÑно ÑолÑко <br/>18 ÑкаÑаÑÑ Ð½Ð°Ñе пÑиложение и пÑойÑи ÑегиÑÑÑаÑиÑ.19 </h3>20 </Desktop>21 <Mobile>22 <h2 className={style.header}>23 ÐÑ Ð½Ð° ÑÑадии ÑазÑабоÑки <br/>24 мобилÑного пÑиложениÑ25 </h2>26 <h3 className={style.subHeader}>27 СÑаÑÑ Ð¿Ð°ÑÑнеÑом ZHOLDA.KZ <br/>28 легко, доÑÑаÑоÑно ÑолÑко <br/>29 ÑкаÑаÑÑ Ð½Ð°Ñе пÑиложение <br/>30 и пÑойÑи ÑегиÑÑÑаÑиÑ.31 </h3>32 </Mobile>33 <div className={style.badges}>34 <a href='/'>35 <img src={AppStore} alt={'app store badge'}/>36 </a>37 <a href='/'>38 <img src={GooglePlay} alt={'google play badge'}/>39 </a>40 </div>41 <img className={style.phoneFront} src={PhoneFront} alt={'phone front side'}/>42 <img className={style.phoneBack} src={PhoneBack} alt={'phone back side'}/>43 </div>44 </div>45 )46}...
common.js
Source:common.js
1//headerçä¸è½½äºç»´ç 2let $downloadapp = $(".header_l").find("li").eq(20);3$downloadapp.mouseenter(() => {4 $downloadapp.find("div").finish();5 $downloadapp.find("div").slideDown(100);6})7$downloadapp.mouseleave(() => {8 $downloadapp.find("div").finish();9 $downloadapp.find("div").slideUp(100);10})11// è´ç©è½¦çæ示12let $shoppingbox = $(".header_r").find("li").eq(5);13$shoppingbox.mouseenter(() => {14 $shoppingbox.find("div").finish();15 $shoppingbox.find("div").slideDown(200);16})17$shoppingbox.mouseleave(() => {18 $shoppingbox.find("div").finish();19 $shoppingbox.find("div").slideUp(200);20})21$shoppingbox.find("div").mouseenter(() => {22 $shoppingbox.find("div").css("display", "block")23})24// äºçº§å¯¼èª25let $nava = $(".nav_c>li:gt(0) a");26$nava.mouseover((event) => {27 $(event.target).next().finish();28 $(event.target).next().slideDown(200);29})30$nava.children().mouseover((event) => {31 event.stopPropagation();32})33$nava.next().mouseenter(function() {34 $(this).css("display", "block");35})36$nava.mouseout((event) => {37 $(event.target).next().finish();38 $(event.target).next().slideUp(200);39})40$nava.children().mouseout((event) => {41 event.stopPropagation();42})43// æç´¢æ¡44$(".headSearch>input").focus((event) => {45 $(event.target).nextAll().css("display", "none")46 $(event.target).parent().css("border-color", "orange")47 $(event.target).parent().parent().css("border-color", "orange")48})49$(".headSearch>input").focusout((event) => {50 $(event.target).nextAll().css("display", "block")51 $(event.target).parent().css("border-color", "#9c9d9c")52 $(event.target).parent().parent().css("border-color", "#9c9d9c")53})54// 微信äºç»´ç 55$(".link-wrap>ul:last-child>li:nth-child(4)>a>i:nth-of-type(2)").mouseover(function() {56 $(".link-wrap>ul:last-child>li:nth-child(4)>a>div").css("display", "block")57})58$(".link-wrap>ul:last-child>li:nth-child(4)>a>i:nth-of-type(2)").mouseout(function() {59 $(".link-wrap>ul:last-child>li:nth-child(4)>a>div").css("display", "none")...
App.js
Source:App.js
1import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';2import './App.css';3import About from './components/About/About';4import MyCarousel from './components/Carousel/MyCarousel';5import Contact from './components/Contact/Contact';6import Course from './components/Course/Course';7import DownloadApp from './components/DownloadApp/DownloadApp';8import Footer from './components/Footer/Footer';9import Header from './components/Header/Header';10import NotFound from './components/NotFound/NotFound';11import SingleCourse from './components/SingleCourse/SingleCourse';12function App() {13 return (14 <div className="App">15 <div className="container">16 <Router>17 <Header></Header>18 <Switch>19 <Route exact path="/">20 <MyCarousel></MyCarousel>21 <br/>22 <hr />23 <Course route='home'></Course>24 <br />25 <hr />26 <DownloadApp></DownloadApp>27 <br />28 <br />29 </Route>30 <Route path="/home">31 <MyCarousel></MyCarousel>32 <br/>33 <hr />34 <Course route='home'></Course>35 <br />36 <hr />37 <DownloadApp></DownloadApp>38 <br />39 <br />40 </Route>41 <Route exact path="/about">42 <About></About>43 </Route>44 <Route exact path="/courses">45 <Course ></Course>46 </Route>47 <Route path="/course/:courseID">48 <SingleCourse></SingleCourse>49 </Route>50 <Route exact path="/contact">51 <Contact></Contact>52 </Route>53 <Route path="*">54 <NotFound></NotFound>55 </Route>56 </Switch>57 <Footer></Footer>58 </Router>59 </div>60 </div>61 );62}...
AdList.js
Source:AdList.js
1{2 "code": 0,3 "data": [4 { "url":"/images/index-swipe-lazy.jpg","src":"/DownloadApp"},5 { "url":"/images/ririsongfuli.png","src":"/DownloadApp"},6 { "url":"https://t1.picb.cc/uploads/2020/02/21/k7LYLi.jpg","src":"https://u.jd.com/LzPuf2"},7 { "url":"https://t1.picb.cc/uploads/2020/02/21/k7UeFN.jpg","src":"https://u.jd.com/1QfxyH"},8 { "url":"/images/haosheng-01.jpg","src":"/DownloadApp"},9 { "url":"https://t1.picb.cc/uploads/2020/02/20/k7aweg.jpg","src":"/DownloadApp"},10 { "url":"https://t1.picb.cc/uploads/2020/02/20/k7ay8i.jpg","src":"/DownloadApp"},11 { "url":"https://t1.picb.cc/uploads/2020/02/20/k7atE8.jpg","src":"/DownloadApp"},12 { "url":"https://t1.picb.cc/uploads/2020/02/20/k7a2XL.jpg","src":"/mall/index"},13 { "url":"https://t1.picb.cc/uploads/2020/02/20/k7af7X.jpg","src":"/DownloadApp"},14 { "url":"https://t1.picb.cc/uploads/2020/02/20/k7QYTD.jpg","src":"/mall/index"}15 ]...
index.js
Source:index.js
1import React from 'react'2import DownloadApp from '../components/DownloadApp/DownloadApp'3import FoodNearMe from '../components/FoodNearMe/FoodNearme'4import BookForLunch from '../components/BookForLunch/BookForLunch'5import Header from '../components/header/Header'6import Hero from '../components/hero/Hero'7import LatestNews from '../components/LatestNews/LatestNews'8import Serving from '../components/serving/Serving'9export default function Landing() {10 return (11 <div className="hero_main">12 <Header/>13 <Hero/>14 <FoodNearMe title="Food Near Me" link="/category"/>15 <BookForLunch title="Book for lunch today" link="/category"/>16 <DownloadApp/>17 <Serving/>18 <LatestNews/>19 </div>20 )...
Using AI Code Generation
1var request = require('request');2var fs = require('fs');3var path = require('path');4var _ = require('lodash');5var unzip = require('unzip');6var AdmZip = require('adm-zip');7var Appium = require('appium');8var wd = require('wd');9var chai = require('chai');10var chaiAsPromised = require('chai-as-promised');11chai.use(chaiAsPromised);12chai.should();13chaiAsPromised.transferPromiseness = wd.transferPromiseness;14var appPath = path.resolve(__dirname, 'app/Android/ApiDemos-debug.apk');15var desiredCaps = {16};17var desiredCaps = {18};19var driver = wd.promiseChainRemote(server);20driver = driver.setImplicitWaitTimeout(30000);21driver.init(desiredCaps).then(function() {22 return driver.elementById('android:id/text1');23}).then(function(el) {24 return el.click();25}).then(function() {26 return driver.elementById('android:id/text1');27}).then(function(el) {28 return el.click();29}).then(function() {30 return driver.elementById('android:id/text1');31}).then(function(el) {32 return el.click();33}).then(function() {34 return driver.elementById('android:id/text1');35}).then(function(el) {36 return el.click();37}).then(function() {38 return driver.elementById('android:id/text1');39}).then(function(el) {40 return el.click();41}).then
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!