How to use Updater.check method in Cypress

Best JavaScript code snippet using cypress

updater-test.js

Source:updater-test.js Github

copy

Full Screen

1var chai = require("chai");2var chaiAsPromised = require("chai-as-promised");3var Promise = require('promise')4chai.use(chaiAsPromised);5chai.should();6const assert = chai.assert7const expect = chai.expect8const mocha = require("mocha")9chai.should()10chai.config.includeStack = false11chai.config.showDiff = true12const fs = require('fs') //File system interaction13const setup = require('./setup.js') //Contains low-level test setup stuff14var updater = null15var checkForUpdateAndTellHubHowItWorkedOut = null16const testUtil = require('./test-util')17const testFixture = require('./test-fixture')18const util = require('../src/util')19const rootDir = testUtil.updaterRootDir20//An in-memory integration test that checks if the updater works, end-to-end.21//Both the file system and http requests are mocked, so everything happens in-memory.22//So no real IO happens.23describe('Updater', function() {24 //=================================================================================25 beforeEach(function() {26 updater = setup.getUpdater()27 testUtil.initTestFiles()28 testFixture.initFixture()29 testFixture.shouldNextUpdateScriptSucceed = true //TODO not sure why I couldn't do this inside initFixture, but it didn't work for some reason30 })31 afterEach(function() {32 testUtil.removeTestFiles()33 })34 //================================================================================35 it('If updaterUrl is invalid, update should fail', function() {36 updater.hubUrl = 'http://totally.invalid.url'37 return updater.checkForUpdateAndTellHubHowItWorkedOut().should.be.rejected38 })39 //================================================================================40 it('If no update was needed, then nothing should happen', function() {41 testFixture.setDeviceId("deviceA")42 testFixture.setSnapshotId("1")43 //Call the updater44 return updater.checkForUpdateAndTellHubHowItWorkedOut().should.eventually.deep.equal(45 {46 deviceId: "deviceA",47 snapshotId: 1,48 updated: false49 }50 )51 })52 //================================================================================53 it('If update was needed, it should be downloaded and executed.', function() {54 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {55 //Ensure that it created a snapshot-id file56 assert.isOk(fs.existsSync(rootDir + "/snapshot-id"))57 const snapshotId = fs.readFileSync(rootDir + "/snapshot-id")58 assert.equal(snapshotId, '1')59 //Ensure that the file was downloaded to /downloads60 assert.isOk(fs.existsSync(rootDir + "/downloads/1/download.zip"))61 assert.isOk(fs.existsSync(rootDir + "/downloads/1/update.sh"))62 //Ensure that update.sh was executed63 assert.equal(updater.lastExecutedCommand, rootDir + "/downloads/1/update.sh")64 }).catch((err) => {65 console.log("failed", err)66 })67 })68 //================================================================================69 it('The update script output should be posted to the hub', function() {70 return updater.checkForUpdateAndTellHubHowItWorkedOut().then( function() {71 expect(testFixture.getLastLog("deviceA")).to.deep.equal({72 deviceId: "deviceA",73 output: "update successful!",74 snapshotId: 1,75 success: "true"76 })77 })78 })79 //================================================================================80 it('The update script output should be posted to the hub, even if the script fails.', function() {81 testFixture.shouldNextUpdateScriptSucceed = false82 return updater.checkForUpdateAndTellHubHowItWorkedOut().should.eventually.be.rejected.then( function() {83 expect(testFixture.getLastLog("deviceA")).to.deep.equal({84 deviceId: "deviceA",85 output: "Error: update failed!",86 snapshotId: 1,87 success: "false"88 })89 })90 })91 //================================================================================92 it('If the update script fails, my snapshot-id file should NOT be updated.', function() {93 testFixture.setSnapshotId("0")94 testFixture.shouldNextUpdateScriptSucceed = false95 return updater.checkForUpdateAndTellHubHowItWorkedOut().should.be.rejected.then( function() {96 //Ensure that snapshot-id is unchanged97 assert.equal(testFixture.getSnapshotId(), "0")98 })99 })100 //================================================================================101 it('should set environment variable "app_root" when running update scripts', function() {102 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {103 //Ensure that the environment variable was set104 assert.isOk(process.env)105 assert.equal(process.env.apps_root, rootDir + "/apps")106 })107 })108 //================================================================================109 it('should set the correct working directory when running update scripts', function() {110 console.log("==========================")111 return updater.checkForUpdateAndTellHubHowItWorkedOut().then( function() {112 //Ensure that the environment variable was set113 console.log("Y updater.lastExecutedCommandOptions", updater.lastExecutedCommandOptions)114 assert.isOk(updater.lastExecutedCommandOptions.cwd)115 assert.equal(updater.lastExecutedCommandOptions.cwd, rootDir + "/downloads/1")116 })117 })118 //================================================================================119 it('should fail update if the downloaded ZIP doesnt contain update.sh', function() {120 testFixture.setDeviceId("deviceC") //This one has a ZIP file with no update.sh inside!121 testFixture.setSnapshotId(1)122 return updater.checkForUpdateAndTellHubHowItWorkedOut().should.be.rejected.then(function() {123 //No new snapshot should have been generated.124 assert.equal(testFixture.getSnapshotId(), 1)125 //And the updater should have reported a failure to the hub.126 expect(testFixture.getLastLog("deviceC")).to.deep.equal({127 deviceId: "deviceC",128 output: "Error: The zip file didn't contain update.sh!",129 snapshotId: 2,130 success: "false"131 })132 })133 })134 //================================================================================135 it('If update.sh is under a subdirectory in the ZIP, it should still be found.', function() {136 testFixture.setDeviceId("deviceD")137 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {138 //Ensure that update.sh was executed139 assert.equal(updater.lastExecutedCommand, rootDir + "/downloads/5/stuff/update.sh")140 })141 })142 //================================================================================143 it('can download an .sh file directly.', function() {144 testFixture.setDeviceId("deviceE")145 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {146 //Ensure that update.sh was executed147 assert.equal(updater.lastExecutedCommand, rootDir + "/downloads/7/update.sh")148 })149 })150 //================================================================================151 it('can execute a js file', function() {152 testFixture.setDeviceId("deviceF")153 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {154 //Ensure that update.js was executed155 assert.equal(updater.lastExecutedCommand, "node " + rootDir + "/downloads/8/update.js")156 })157 })158 159 //================================================================================160 it('can receive a nested config', function() {161 testFixture.setDeviceId("deviceF")162 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function(err) {163 //Ensure that update.js was executed164 assert.equal(updater.lastExecutedCommand, "node " + rootDir + "/downloads/8/update.js")165 const configString = process.env.config166 const config = JSON.parse(configString)167 assert.equal(config.app1.color, "red")168 })169 })170 //================================================================================171 it('can receive an updateInterval change', function() {172 testFixture.setDeviceId("deviceG")173 return updater.checkForUpdateAndTellHubHowItWorkedOut().should.become(174 { 175 deviceId: "deviceG",176 snapshotId: 30,177 newUpdateInterval: 120,178 output: "update successful!",179 updated: true180 }181 )182 }) 183 184 it('can see version number from path', function() {185 assert.equal(util.getVersionNumberFromPath("/bla/yeah/updater-1.0.5"), "v1.0.5")186 })187 188 it('doesnt receive onUpdating event unless an update actually happened', function() {189 //Set it up so that no update is needed190 testFixture.setDeviceId("deviceA")191 testFixture.setSnapshotId("1")192 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {193 expect(updater.onUpdatingWasCalledWithTrue).to.not.be.true194 expect(updater.onUpdatingWasCalledWithFalse).to.not.be.true195 })196 })197 it('Receives onUpdating event when an update was done', function() {198 //Set it up so an update is needed199 testFixture.setDeviceId("deviceA")200 testFixture.setSnapshotId("0")201 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {202 expect(updater.onUpdatingWasCalledWithTrue).to.be.true203 expect(updater.onUpdatingWasCalledWithFalse).to.be.true204 })205 })206 //================================================================================207 it('Handles sshTunnelRequested: true', function() {208 testFixture.setDeviceId("deviceH")209 testFixture.setSnapshotId("1")210 return updater.checkForUpdateAndTellHubHowItWorkedOut().then(function() {211 //Ensure that update.js was executed212 assert.equal(updater.lastExecutedCommand, "echo 'No sshTunnelCommand configured'")213 })214 })...

Full Screen

Full Screen

vesselcall.test.js

Source:vesselcall.test.js Github

copy

Full Screen

1const assert = require('assert');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const expect = chai.expect;6const Updater = require("../updater.js");7var Config = require('../config');8var entity = {9 "id": "FR_BAS:9534066:20209659",10 "type": "VesselCall",11 "IMO": {12 "type": "Integer",13 "value": 9534066,14 "metadata": {}15 },16 "dataProvider": {17 "type": "Text",18 "value": "http://frbod/vcall",19 "metadata": {}20 },21 "journeyid": {22 "type": "Integer",23 "value": 20209659,24 "metadata": {}25 },26 "location": {27 "type": "geo:json",28 "value": {29 "type": "Point",30 "coordinates": [31 -0.5472,32 44.86333 ]34 },35 "metadata": {}36 },37 "name": {38 "type": "STRING_URL_ENCODED",39 "value": "ORALORA",40 "metadata": {}41 },42 "operation": {43 "type": "Text",44 "value": "unloading",45 "metadata": {}46 },47 "scheduled_arrival_dock": {48 "type": "DateTime",49 "value": "2020-10-25T07:00:00.00Z",50 "metadata": {}51 },52 "scheduled_leave_dock": {53 "type": "DateTime",54 "value": "2020-10-25T07:00:00.00Z",55 "metadata": {}56 },57 "source": {58 "type": "Text",59 "value": "urn:pixel:DataSource:frbod:VesselCall",60 "metadata": {}61 },62 "unloading_agent": {63 "type": "STRING_URL_ENCODED",64 "value": "SEAINVEST",65 "metadata": {}66 },67 "unloading_berth": {68 "type": "Integer",69 "value": 436,70 "metadata": {}71 },72 "loading_berth": {73 "type": "Integer",74 "value": 436,75 "metadata": {}76 },77 "unloading_cargo_fiscal_type": {78 "type": "Text",79 "value": "",80 "metadata": {}81 },82 "unloading_cargo_type": {83 "type": "STRING_URL_ENCODED",84 "value": "I.HUILE%20COLZA",85 "metadata": {}86 },87 "unloading_dangerous": {88 "type": "Boolean",89 "value": false,90 "metadata": {}91 },92 "unloading_tonnage": {93 "type": "Integer",94 "value": 3000,95 "metadata": {}96 }97};98Config.OrionAPI="http://orion:1026"99describe('UpdateVesselCall', () => {100 beforeEach(async () => {101 await expect(Updater.createEntity(entity)).to.be.fulfilled;102 })103 afterEach(async () => {104 await expect(Updater.deleteEntity(entity)).to.be.fulfilled;105 });106 it('checkIMO bad', async () => {107 var result = Updater.checkIMO(entity);108 expect(result).to.be.eql({109 "type": "Text",110 "value": "9534066"111 })112 });113 it('checkIMO good', async () => {114 entity.IMO = {115 type: "Text",116 value: "9534066"117 }118 var result = Updater.checkIMO(entity);119 expect(result).to.be.eql("")120 });121 it('checkIMO bad but string', async () => {122 entity.IMO = {123 type: "Integer",124 value: "9534066"125 }126 var result = Updater.checkIMO(entity);127 expect(result).to.be.eql({128 "type": "Text",129 "value": "9534066"130 })131 });132 it('patchIMO', async () => {133 var updated=await expect(Updater.patchIMO(entity)).to.be.fulfilled;134 expect(updated).to.be.eql(true)135 var checked=await expect(Updater.getEntity(entity)).to.be.fulfilled;136 var result = Updater.checkIMO(checked);137 expect(result).to.be.eql("")138 });139 it('checkOperation', async () => {140 var result = Updater.checkOperation(entity);141 expect(result).to.be.eql(true)142 });143 it('patchOperation', async () => {144 var result = Updater.checkOperation(entity);145 expect(result).to.be.eql(true)146 var updated=await expect(Updater.patchOperation(entity)).to.be.fulfilled;147 expect(updated).to.be.eql(true)148 var checked=await expect(Updater.getEntity(entity)).to.be.fulfilled;149 var result = Updater.checkOperation(checked);150 expect(result).to.be.eql(false);151 });152 it('patchUnloadingBerth', async () => {153 var result = Updater.checkUnloadingBerth(entity);154 expect(result).not.to.be.eql("")155 var updated=await expect(Updater.patchUnloadingBerth(entity)).to.be.fulfilled;156 expect(updated).to.be.eql(true)157 var checked=await expect(Updater.getEntity(entity)).to.be.fulfilled;158 var result = Updater.checkUnloadingBerth(checked);159 expect(result).to.be.eql("");160 });161 it('patchLoadingBerth', async () => {162 var result = Updater.checkLoadingBerth(entity);163 expect(result).not.to.be.eql("")164 var updated=await expect(Updater.patchLoadingBerth(entity)).to.be.fulfilled;165 expect(updated).to.be.eql(true)166 var checked=await expect(Updater.getEntity(entity)).to.be.fulfilled;167 var result = Updater.checkLoadingBerth(checked);168 expect(result).to.be.eql("");169 updated=await expect(Updater.patchLoadingBerth(checked)).to.be.fulfilled;170 expect(updated).to.be.eql(false)171 });172 it('patchScheduledLeaveDock', async () => {173 var result = Updater.checkScheduledLeaveDock(entity);174 var leave=entity.scheduled_leave_dock;175 expect(result).to.be.eql(true)176 var updated=await expect(Updater.patchScheduledLeaveDock(entity)).to.be.fulfilled;177 expect(updated).to.be.eql(true)178 var checked=await expect(Updater.getEntity(entity)).to.be.fulfilled;179 var result = Updater.checkScheduledLeaveDock(checked);180 expect(result).to.be.eql(false)181 expect(checked.hasOwnProperty("scheduled_departure_dock")).to.be.eql(true)182 expect(checked.scheduled_departure_dock).to.be.eql(leave);183 updated=await expect(Updater.patchScheduledLeaveDock(checked)).to.be.fulfilled;184 expect(updated).to.be.eql(false)185 });186 it('patchEntity', async () => {187 var updated=await expect(Updater.patchEntity(entity)).to.be.fulfilled;188 expect(updated).to.be.eql(true)189 var checked=await expect(Updater.getEntity(entity)).to.be.fulfilled;190 updated=await expect(Updater.patchEntity(checked)).to.be.fulfilled;191 expect(updated).to.be.eql(false)192 });...

Full Screen

Full Screen

update_modal_spec.js

Source:update_modal_spec.js Github

copy

Full Screen

1import human from 'human-interval'2import { deferred } from '../support/util'3const OLD_VERSION = '1.3.3'4const NEW_VERSION = '1.3.4'5describe('Update Modal', () => {6 let user7 let start8 let ipc9 let updaterCheck10 beforeEach(() => {11 cy.viewport(800, 500)12 cy.fixture('user').then((theUser) => user = theUser)13 cy.fixture('projects').as('projects')14 cy.fixture('config').as('config')15 cy.visitIndex({16 onBeforeLoad (win) {17 cy.spy(win, 'setInterval')18 },19 }).then((win) => {20 start = win.App.start21 ipc = win.App.ipc22 cy.stub(ipc, 'getCurrentUser').resolves(user)23 cy.stub(ipc, 'externalOpen')24 cy.stub(ipc, 'setClipboardText')25 updaterCheck = deferred()26 cy.stub(ipc, 'updaterCheck').returns(updaterCheck.promise)27 })28 })29 describe('general behavior', () => {30 beforeEach(() => {31 cy.stub(ipc, 'getOptions').resolves({ version: OLD_VERSION })32 start()33 })34 it('checks for updates every 60 minutes', () => {35 cy.window().then((win) => {36 expect(win.setInterval.firstCall.args[1]).to.eq(human('60 minutes'))37 })38 })39 it('checks for update on show', () => {40 cy.wrap(ipc.updaterCheck).should('be.called')41 })42 it('gracefully handles error', () => {43 updaterCheck.reject({ name: 'foo', message: 'Something bad happened' })44 cy.get('.footer').should('be.visible')45 })46 it('opens modal on click of Update link', () => {47 updaterCheck.resolve(NEW_VERSION)48 cy.get('.footer .version').click()49 cy.get('.modal').should('be.visible')50 })51 it('closes modal when X is clicked', () => {52 updaterCheck.resolve(NEW_VERSION)53 cy.get('.footer .version').click()54 cy.get('.modal').find('.close').click()55 cy.get('.modal').should('not.exist')56 })57 })58 describe('in global mode', () => {59 beforeEach(() => {60 cy.stub(ipc, 'getOptions').resolves({ version: OLD_VERSION, os: 'linux' })61 start()62 updaterCheck.resolve(NEW_VERSION)63 cy.get('.footer .version').click()64 })65 it('modal has info about downloading new version', () => {66 cy.get('.modal').contains('Download the new version')67 })68 it('opens download link when Download is clicked', () => {69 cy.contains('Download the new version').click().then(() => {70 expect(ipc.externalOpen).to.be.calledWith('https://download.cypress.io/desktop')71 })72 })73 })74 describe('in project mode', () => {75 const npmCommand = `npm install --save-dev cypress@${NEW_VERSION}`76 const yarnCommand = `yarn upgrade cypress@${NEW_VERSION}`77 beforeEach(() => {78 cy.stub(ipc, 'getOptions').resolves({ version: OLD_VERSION, projectRoot: '/foo/bar' })79 start()80 updaterCheck.resolve(NEW_VERSION)81 cy.get('.footer .version').click()82 })83 it('modal has info about upgrading via package manager', () => {84 cy.get('.modal').contains(npmCommand)85 cy.get('.modal').contains(yarnCommand)86 cy.percySnapshot()87 })88 it('copies npm upgrade command to clipboard', () => {89 cy.contains(npmCommand).find('button').click()90 .then(() => {91 expect(ipc.setClipboardText).to.be.calledWith(npmCommand)92 })93 })94 it('changes npm upgrade button icon after copying', () => {95 cy.contains(npmCommand).find('button').click()96 cy.contains(npmCommand).find('button i').should('have.class', 'fa-check')97 })98 it('disables npm upgrade button after copying', () => {99 cy.contains(npmCommand).find('button').click().should('be.disabled')100 })101 it('resets npm upgrade button after 5 seconds', () => {102 cy.clock()103 cy.contains(npmCommand).find('button').click()104 cy.tick(5000)105 cy.contains(npmCommand).find('button i').should('have.class', 'fa-copy')106 cy.contains(npmCommand).find('button').should('not.be.disabled')107 })108 it('copies yarn upgrade command to clipboard', () => {109 cy.contains(yarnCommand).find('button').click()110 .then(() => {111 expect(ipc.setClipboardText).to.be.calledWith(yarnCommand)112 })113 })114 it('changes yarn upgrade button icon after copying', () => {115 cy.contains(yarnCommand).find('button').click()116 cy.contains(yarnCommand).find('button i').should('have.class', 'fa-check')117 })118 it('disables yarn upgrade button after copying', () => {119 cy.contains(yarnCommand).find('button').click().should('be.disabled')120 })121 it('resets yarn upgrade button after 5 seconds', () => {122 cy.clock()123 cy.contains(yarnCommand).find('button').click()124 cy.tick(5000)125 cy.contains(yarnCommand).find('button i').should('have.class', 'fa-copy')126 cy.contains(yarnCommand).find('button').should('not.be.disabled')127 })128 it('links to \'open\' doc on click of open command', () => {129 cy.contains('cypress open').click().then(() => {130 expect(ipc.externalOpen).to.be.calledWith('https://on.cypress.io/how-to-open-cypress')131 })132 })133 })...

Full Screen

Full Screen

autoUpdateHelper-test.js

Source:autoUpdateHelper-test.js Github

copy

Full Screen

1/* eslint-disable global-require */2jest.useFakeTimers();3// Use mocks for modules invoking electron code4jest.mock('electron');5jest.mock('lodash');6jest.mock('../platformAutoUpdater');7jest.mock('../../service');8const FIVE_MINUTES_IN_MS = 5 * 60 * 1000;9const ONE_HOUR_IN_MS = 60 * 60 * 1000;10// a sample static value for uniqueInstallId11const UNIQUE_INSTALL_ID = '1234-5678';12describe('autoUpdateHelper', () => {13 // autoUpdateHelper and autoUpdater are singleton modules so don't import14 // them globally but per test15 let autoUpdateHelper;16 let autoUpdater;17 // a sample mock for `displayNotification` function18 let displayNotification;19 beforeEach(() => {20 jest.resetModules();21 autoUpdateHelper = require('../autoUpdateHelper');22 autoUpdater = require('../platformAutoUpdater');23 displayNotification = jest.fn();24 autoUpdateHelper.init({25 displayNotification,26 uniqueInstallId: UNIQUE_INSTALL_ID,27 });28 });29 afterEach(() => {30 autoUpdater.removeAllListeners();31 });32 it('should setup correct feed url', () => {33 expect(34 // eslint-disable-next-line no-underscore-dangle35 autoUpdater.__feedURL.startsWith(36 'https://update-2.crosscloud.me/updates/'37 )38 ).toBe(true);39 expect(40 // eslint-disable-next-line no-underscore-dangle41 autoUpdater.__feedURL.endsWith('?installId=1234-5678')42 ).toBe(true);43 });44 it('should check for updates on startup', () => {45 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);46 });47 it('should check for updates every hour', () => {48 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);49 jest.runTimersToTime(ONE_HOUR_IN_MS * 2);50 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(2);51 jest.runTimersToTime(ONE_HOUR_IN_MS * 3);52 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(5);53 });54 it('should submit next update check if an error happened', () => {55 autoUpdater.emit('error');56 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);57 jest.runTimersToTime(FIVE_MINUTES_IN_MS);58 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(2);59 });60 it('should throttle update checks in case of errors', () => {61 autoUpdater.emit('error');62 autoUpdater.emit('error');63 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);64 jest.runTimersToTime(FIVE_MINUTES_IN_MS);65 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(2);66 autoUpdater.emit('error');67 autoUpdater.emit('error');68 jest.runTimersToTime(FIVE_MINUTES_IN_MS * 3);69 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(3);70 });71 it('should stop checking for updates if there is already found one', () => {72 autoUpdater.emit('update-available');73 jest.runTimersToTime(ONE_HOUR_IN_MS * 5);74 expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);75 });76 it('should display a notification if an update is downloaded', () => {77 autoUpdater.emit('update-downloaded');78 expect(displayNotification).toHaveBeenCalledTimes(1);79 expect(displayNotification.mock.calls[0][0]).toBe('Update Found');80 });81 it('should close the app if an update is downloaded', () => {82 const { app } = require('electron');83 const service = require('../../service');84 autoUpdater.emit('update-downloaded');85 jest.runOnlyPendingTimers();86 expect(app.quit).toHaveBeenCalledTimes(1);87 expect(service.shutdown).toHaveBeenCalledTimes(1);88 });89 describe('updateReady', () => {90 it('should return `false` if the update was not downloaded', () => {91 expect(autoUpdateHelper.updateReady()).toBe(false);92 });93 it('should return `true` if the update was downloaded', () => {94 autoUpdater.emit('update-downloaded');95 expect(autoUpdateHelper.updateReady()).toBe(true);96 });97 });98 describe('applyUpdate', () => {99 it('should do nothing if the update was not downloaded', () => {100 autoUpdateHelper.applyUpdate();101 expect(autoUpdater.quitAndInstall).not.toHaveBeenCalled();102 });103 it('quit the app and install the update if it was downloaded', () => {104 autoUpdater.emit('update-downloaded');105 autoUpdateHelper.applyUpdate();106 expect(autoUpdater.quitAndInstall).toHaveBeenCalledTimes(1);107 });108 });...

Full Screen

Full Screen

update_select.js

Source:update_select.js Github

copy

Full Screen

1var a_bool = true;2var is_speech_available;3var choice;4if (document.createElement("input").webkitSpeech === undefined)5 is_speech_available = false;6else7 is_speech_available = true;8$(document).ready(function(){9 $('#firstname').click(function(){10 text_slider('#firstname');11 choice = 1;12 });13 $('#lastname').click(function(){14 text_slider('#lastname');15 choice = 2;16 });17 $('#email').click(function(){18 text_slider('#email');19 choice = 3;20 });21 $('#password').click(function(){22 text_slider('#password');23 choice = 4;24 });25 26 $('#the_update_button').click(process_info);27});28function text_slider(string){29 $('#the_update_button').removeClass('text_inputs');30 switch(string){31 case '#firstname':32 case '#lastname':33 $('#updater').attr('type', 'text');34 $('#updater_check').attr('type', 'text');35 break;36 case '#email':37 $('#updater').attr('type', 'email');38 $('#updater_check').attr('type', 'email');39 break;40 case '#password':41 $('#updater').attr('type', 'password');42 $('#updater_check').attr('type', 'password');43 break;44 }45 46 if(a_bool){47 $('.updater_label').text($(string).text());48 49 if(is_speech_available && (string === "#firstname" || string === "#lastname")){50 $('#updater').attr('x-webkit-speech', '');51 $('#updater_check').attr('x-webkit-speech', '');52 } else{53 $('#updater').removeAttr('x-webkit-speech');54 $('#updater_check').removeAttr('x-webkit-speech');55 }56 57 $('.text_inputs').slideDown(500);58 a_bool = false;59 } else{60 $('.text_inputs').slideUp(500, function(){61 $('#error1').text(''); //gets rid of prev error messages62 $('#error2').text('');63 $('#updater').val('');64 $('#updater_check').val('');65 a_bool = true;66 text_slider(string); //recursive function to slide down67 });68 }69}70function process_info(){71 var item1, item2;72 item1 = $('#updater').val();73 item2 = $('#updater_check').val();74 75 if(item1 === "")76 $('#error1').text('Please fill in this field!');77 if(item2 === "")78 $('#error2').text('Please fill in this field!');79 else if(item1 != item2){80 $('#error1').text('The fields do not match!');81 $('#error2').text('');82 }83 else{84 $('#info').html('<table><tr><td colspan="2">Are you sure?</td></tr><tr><td><input type="button" class="button_style" id="the_yes_button" value="Yes"></td><td><input type="button" class="button_style" id="the_no_button" value="No"></td></tr></table>');85 86 $('#the_yes_button').click(function(){87 $.post('includes/update_details.inc.php',88 {89 item: item1,90 choice: choice91 }92 );93 $('#updater').val('');94 $('#updater_check').val('');95 $('#info').html("<p>Your details have been successfully updated!</p>");96 });97 $('#the_no_button').click(function(){98 $('#info').html("<p>You have cancelled your update!</p>");99 });100 }101}102function keypress_func(e){103 switch(e.keyCode){104 case 13: process_info();105 break;106 } //end switch107}108$(document).on('keypress', function(e){109 keypress_func(e);...

Full Screen

Full Screen

update_notice_spec.js

Source:update_notice_spec.js Github

copy

Full Screen

1import human from 'human-interval'2import { deferred } from '../support/util'3describe('Update Notice', () => {4 let ipc5 let start6 let updaterCheck7 beforeEach(() => {8 let user9 cy.viewport(800, 500)10 cy.fixture('user').then((theUser) => user = theUser)11 cy.visitIndex().then((win) => {12 ipc = win.App.ipc13 start = win.App.start14 cy.stub(ipc, 'getCurrentUser').resolves(user)15 cy.stub(ipc, 'getOptions').resolves({ version: '1.0.0' })16 updaterCheck = deferred()17 cy.stub(ipc, 'updaterCheck').returns(updaterCheck.promise)18 })19 })20 it('does not appear if up-to-date', () => {21 start()22 cy.wait(500) // need to wait for animation or it will falsely appear invisible23 cy.get('.update-notice').should('not.be.visible')24 })25 describe('when there is an update', () => {26 beforeEach(() => {27 start()28 updaterCheck.resolve('1.0.1')29 })30 it('shows update notice', () => {31 cy.get('.update-notice').should('be.visible')32 cy.get('.update-notice .content').should('have.text', 'An update (1.0.1) is available. Learn more')33 cy.percySnapshot()34 })35 it('clicking on "Learn more" opens update modal and closes notice', () => {36 cy.get('.update-notice').contains('Learn more').click()37 cy.get('.update-modal').should('be.visible')38 cy.get('.update-notice').should('not.be.visible')39 })40 it('clicking close button closes notice', () => {41 cy.get('.update-notice .notification-close').click()42 cy.get('.update-notice').should('not.be.visible')43 })44 })45 describe('when there is an update that has already been dismissed', () => {46 let updaterCheck247 beforeEach(() => {48 cy.clock()49 cy.window().then((win) => {50 win.localStorage.setItem('dismissed-update-version', JSON.stringify('1.0.1'))51 updaterCheck2 = deferred()52 ipc.updaterCheck.onCall(1).returns(updaterCheck2.promise)53 start()54 updaterCheck.resolve('1.0.1')55 })56 })57 it('does not show update notice', () => {58 cy.wait(500) // need to wait for animation or it will falsely appear invisible59 cy.get('.update-notice').should('not.be.visible')60 })61 it('shows update notice when a newer version is available', () => {62 cy.tick(human('60 minutes')).then(() => {63 updaterCheck2.resolve('1.0.2')64 })65 cy.get('.update-notice').should('be.visible')66 cy.get('.update-notice .content').should('have.text', 'An update (1.0.2) is available. Learn more')67 })68 })...

Full Screen

Full Screen

updater.unit.js

Source:updater.unit.js Github

copy

Full Screen

1'use strict';2const proxyquire = require('proxyquire');3const expect = require('chai').expect;4describe('Updater', function() {5 describe('#checkForUpdates', function() {6 it('should fail if there is an error', function() {7 var updater = proxyquire('../../lib/updater', {8 request: function(url, callback) {9 callback(new Error('Unknown error'), {}, null);10 }11 });12 updater.once('error', function(err) {13 expect(err.message).to.equal('Unknown error');14 });15 updater.checkForUpdates();16 });17 it('should fail if there is a non-200 status code returned', function() {18 var updater = proxyquire('../../lib/updater', {19 request: function(url, callback) {20 callback(null, { statusCode: 400 }, null);21 }22 });23 updater.once('error', function(err) {24 expect(err.message).to.equal('Failed to check updates');25 });26 updater.checkForUpdates();27 });28 it('should fail if it cannot parse the body', function() {29 var updater = proxyquire('../../lib/updater', {30 request: function(url, callback) {31 callback(null, { statusCode: 200 }, 'NOT JSON');32 }33 });34 updater.once('error', function(err) {35 expect(err.message).to.equal('Failed to parse update info');36 });37 updater.checkForUpdates();38 });39 it('should not emit if version not greater than current', function(done) {40 var updater = proxyquire('../../lib/updater', {41 request: function(url, callback) {42 callback(null, { statusCode: 200 },43 { html_url: '', tag_name: '0.0.0' }44 );45 }46 });47 updater.once('update_available', function() {48 throw new Error();49 });50 updater.checkForUpdates();51 setImmediate(done);52 });53 it('should emit if the version is greater than current', function(done) {54 var updater = proxyquire('../../lib/updater', {55 request: function(url, callback) {56 callback(null, { statusCode: 200 },57 { html_url: '', tag_name: '100.0.0' }58 );59 }60 });61 updater.once('update_available', function() {62 done();63 });64 updater.checkForUpdates();65 });66 });...

Full Screen

Full Screen

check-for-updates-button.js

Source:check-for-updates-button.js Github

copy

Full Screen

1// @flow2import * as React from 'react';3import autobind from 'autobind-decorator';4import * as electron from 'electron';5type Props = {6 children: React.Node,7 className: ?string,8};9type State = {10 status: string,11 checking: boolean,12 updateAvailable: boolean,13};14@autobind15class CheckForUpdatesButton extends React.PureComponent<Props, State> {16 constructor(props: Props) {17 super(props);18 this.state = {19 status: '',20 checking: false,21 updateAvailable: false,22 };23 }24 _listenerCheckComplete(e: any, updateAvailable: true, status: string) {25 this.setState({ status, updateAvailable });26 }27 _listenerCheckStatus(e: any, status: string) {28 if (this.state.checking) {29 this.setState({ status });30 }31 }32 _handleCheckForUpdates() {33 electron.ipcRenderer.send('updater.check');34 this.setState({ checking: true });35 }36 componentDidMount() {37 electron.ipcRenderer.on('updater.check.status', this._listenerCheckStatus);38 electron.ipcRenderer.on('updater.check.complete', this._listenerCheckComplete);39 }40 componentWillUnmount() {41 electron.ipcRenderer.removeListener('updater.check.complete', this._listenerCheckComplete);42 electron.ipcRenderer.removeListener('updater.check.status', this._listenerCheckStatus);43 }44 render() {45 const { children, className } = this.props;46 const { status, checking } = this.state;47 return (48 <button className={className} disabled={checking} onClick={this._handleCheckForUpdates}>49 {status || children}50 </button>51 );52 }53}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Updater } = require('cypress-updater')2Updater.check()3const { Updater } = require('cypress-updater')4module.exports = (on, config) => {5 Updater.check()6}7### Updater.check(options)8const { Updater } = require('cypress-updater')9Updater.check({10})11const { Updater } = require('cypress-updater')12module.exports = (on, config) => {13 Updater.check({14 })15}16### Updater.getLatestVersion()17const { Updater } = require('cypress-updater')18Updater.getLatestVersion()19const { Updater } = require('cypress-updater')20module.exports = (on, config) => {21 Updater.getLatestVersion()22}23### Updater.getCurrentVersion()

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test Cypress Updater', function() {2 it('Test Updater', function() {3 cy.updater('check').then((result) => {4 if (result) {5 cy.updater('install').then(() => {6 cy.log('Cypress Updater installed')7 })8 } else {9 cy.log('Cypress Updater is already installed')10 }11 })12 })13})14{15}16{17 "scripts": {18 },19 "devDependencies": {20 }21}

Full Screen

Using AI Code Generation

copy

Full Screen

1const updater = require('cypress-updater')2updater.check()3const updater = require('cypress-updater')4updater.check()5const updater = require('cypress-updater')6updater.check()7const updater = require('cypress-updater')8updater.check()9const updater = require('cypress-updater')10updater.check()11const updater = require('cypress-updater')12updater.check()13const updater = require('cypress-updater')14updater.check()15const updater = require('cypress-updater')16updater.check()

Full Screen

Using AI Code Generation

copy

Full Screen

1const updater = require('cypress-updater');2updater.check();3const updater = require('cypress-updater');4module.exports = (on, config) => {5 on('task', {6 checkForUpdates: () => {7 updater.check();8 }9 });10};11describe('My First Test', () => {12 it('Does not do much!', () => {13 cy.task('checkForUpdates');14 });15});16const updater = require('cypress-updater');17updater.check().then((result) => {18 if (result) {19 console.log('Update found');20 } else {21 console.log('No update found');22 }23});24const updater = require('cypress-updater');25module.exports = (on, config) => {26 on('task', {27 checkForUpdates: () => {28 return updater.check().then((result) => {29 if (result) {30 console.log('Update found');31 } else {32 console.log('No update found');33 }34 });35 }36 });37};38describe('My First Test', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Updater } = require('@packages/server/lib/updater')2const log = require('debug')('cypress:server:updater')3Updater.check({ log })4 .then((update) => {5 if (update) {6 console.log('New version of Cypress available for download')7 console.log('Version:', update.version)8 console.log('Release Date:', update.releaseDate)9 console.log('Path:', update.path)10 console.log('Notes:', update.notes)11 } else {12 console.log('No new version of Cypress available for download')13 }14 })15 .catch((err) => {16 console.error('Error checking for new version of Cypress')17 console.error(err)18 })

Full Screen

Using AI Code Generation

copy

Full Screen

1const updater = require('cypress-updater');2const path = require('path');3updater.check(path.join(__dirname, '../node_modules/cypress')).then(updateInfo => {4 console.log(updateInfo);5}).catch(err => {6 console.log(err);7});8const updater = require('cypress-updater');9const path = require('path');10updater.update(path.join(__dirname, '../node_modules/cypress')).then(updateInfo => {11 console.log(updateInfo);12}).catch(err => {13 console.log(err);14});15const updater = require('cypress-updater');16const path = require('path');17updater.checkAndAutoUpdate(path.join(__dirname, '../node_modules/cypress')).then(updateInfo => {18 console.log(updateInfo);19}).catch(err => {20 console.log(err);21});22const updater = require('cypress-updater');23const path = require('path');24updater.checkAndAutoUpdate(path.join(__dirname, '../node_modules/cypress')).then(updateInfo => {25 console.log(updateInfo);26 updater.checkAndAutoUpdate(path.join(__dirname, '../node_modules/cypress')).then(updateInfo => {27 console.log(updateInfo);28 }).catch(err => {29 console.log(err);30 });31}).catch(err => {32 console.log(err);33});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Updater } = require('cypress-updater')2Updater.check()3.then((update) => {4 if (update) {5 console.log('Update available. Downloading...')6 return update.download()7 }8 console.log('No update available.')9})10.then((update) => {11 if (update) {12 console.log('Download complete. Installing...')13 return update.install()14 }15})16.then((update) => {17 if (update) {18 console.log('Installation complete. Running Cypress tests...')19 return update.run()20 }21})22.then(() => {23 console.log('Cypress tests complete. Exiting Node.js.')24 process.exit()25})26.catch((err) => {27 console.error('Error:', err)28 process.exit(1)29})30{31}32{33 "scripts": {34 },35 "devDependencies": {36 }37}38### Updater.check()39### Updater.download()40### Updater.install()41### Updater.run()42### Updater.update()

Full Screen

Cypress Tutorial

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.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

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.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful