How to use getOrgs method in Cypress

Best JavaScript code snippet using cypress

orgs.controller.ut.js

Source:orgs.controller.ut.js Github

copy

Full Screen

1(function() {2 'use strict';3 define(['orgs'], function() {4 describe('OrgsController', function() {5 var $rootScope,6 $scope,7 $log,8 $q,9 $controller,10 OrgsCtrl,11 account,12 appData,13 mockOrgs,14 mockUsers,15 ConfirmDialogService;16 beforeEach(function() {17 module('c6.proshop');18 appData = {19 appUser : null,20 user: null, users: null, org: null, orgs: null,21 'mini-reel-maker': {22 id: 'e-MRinator',23 data: {24 modes: [25 {26 value: 'lightbox',27 modes:[28 {29 value: 'lightbox',30 name: 'Lightbox Player'31 },32 {33 value: 'lightbox-playlist',34 name: 'Lightbox, with Playlist'35 }36 ]37 },38 {39 value: 'inline',40 modes:[41 {42 value: 'light',43 name: 'Embedded'44 },45 {46 value: 'full',47 deprecated: true48 }49 ]50 }51 ]52 }53 },54 };55 mockOrgs = [56 {57 id: 'o-1',58 name: 'Org1',59 status: 'active',60 config: {},61 waterfalls: {62 video: ['cinema6'],63 display: ['cinema6']64 }65 },66 {67 id: 'o-2',68 name: 'Org2',69 status: 'active',70 config: {},71 waterfalls: {72 video: ['cinema6'],73 display: ['cinema6']74 }75 }76 ];77 mockUsers = [78 {79 id: 'u-1',80 email: 'e@mail.com',81 firstName: 'J',82 lastName: 'F',83 org: 'o-1',84 config: {}85 },86 {87 id: 'u-2',88 email: 'mail@e.net',89 firstName: 'B',90 lastName: 'D',91 org: 'o-2',92 config: {}93 }94 ];95 ConfirmDialogService = {96 display: jasmine.createSpy('ConfirmDialogService.display()'),97 close: jasmine.createSpy('ConfirmDialogService.close()')98 };99 inject(function($injector) {100 $controller = $injector.get('$controller');101 $log = $injector.get('$log');102 $q = $injector.get('$q');103 $rootScope = $injector.get('$rootScope');104 account = $injector.get('account');105 spyOn(account, 'getOrgs');106 spyOn(account, 'getUsers');107 spyOn(account, 'putOrg');108 spyOn(account, 'postOrg');109 spyOn(account, 'deleteOrg');110 spyOn(account, 'convertOrgForEditing').and.callThrough();111 account.getOrgs.deferred = $q.defer();112 account.getOrgs.and.returnValue(account.getOrgs.deferred.promise);113 account.getUsers.deferred = $q.defer();114 account.getUsers.and.returnValue(account.getUsers.deferred.promise);115 account.putOrg.deferred = $q.defer();116 account.putOrg.and.returnValue(account.putOrg.deferred.promise);117 account.postOrg.deferred = $q.defer();118 account.postOrg.and.returnValue(account.postOrg.deferred.promise);119 account.deleteOrg.deferred = $q.defer();120 account.deleteOrg.and.returnValue(account.deleteOrg.deferred.promise);121 $log.context = function(){ return $log; }122 $scope = $rootScope.$new();123 $scope.data = {124 appData: appData125 };126 OrgsCtrl = $controller('OrgsController', {127 $log: $log,128 $scope: $scope,129 account: account,130 ConfirmDialogService: ConfirmDialogService,131 appData: appData132 });133 });134 });135 describe('initialization', function() {136 it('should exist', function() {137 expect(OrgsCtrl).toBeDefined();138 });139 it('should set some defaults', function() {140 expect(OrgsCtrl.action).toBe('all');141 });142 it('should call the account service to get all Orgs', function() {143 expect(account.getOrgs).toHaveBeenCalled();144 });145 it('should put the orgs data on the scope and appData', function() {146 $scope.$apply(function() {147 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));148 });149 expect($scope.data.orgs).toEqual(mockOrgs);150 expect($scope.data.appData.orgs).toEqual(mockOrgs);151 });152 });153 describe('$scope.doSort()', function() {154 it('should sort', function() {155 $scope.doSort('status');156 expect($scope.sort).toEqual({column:'status',descending:false});157 $scope.doSort('status');158 expect($scope.sort).toEqual({column:'status',descending:true});159 $scope.doSort('minAdCount');160 expect($scope.sort).toEqual({column:'minAdCount',descending:false});161 $scope.doSort('name');162 expect($scope.sort).toEqual({column:'name',descending:false});163 });164 });165 describe('properties', function() {166 describe('defaultModes', function() {167 it('should copy from MRinator experience on appData, excluding deprecated modes', function() {168 expect(OrgsCtrl.defaultModes).toEqual([169 {170 value: 'lightbox',171 name: 'Lightbox Player'172 },173 {174 value: 'lightbox-playlist',175 name: 'Lightbox, with Playlist'176 },177 {178 value: 'light',179 name: 'Embedded'180 }181 ]);182 });183 });184 describe('total', function() {185 it('should be undefined by default', function() {186 expect(OrgsCtrl.total).toBe(undefined);187 });188 it('should be 1 if all results fit within the limit', function() {189 OrgsCtrl.limit = 5;190 $scope.data.orgs = [{},{},{}];191 expect(OrgsCtrl.total).toBe(1);192 $scope.data.orgs = [{},{},{},{},{},{},{}];193 expect(OrgsCtrl.total).toBe(2);194 OrgsCtrl.limit = 10;195 expect(OrgsCtrl.total).toBe(1);196 });197 });198 describe('loading', function() {199 it('should be true on initialization', function() {200 expect(OrgsCtrl.loading).toBe(true);201 });202 it('should be false after all data promises resolve', function() {203 $scope.$apply(function() {204 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));205 });206 expect(OrgsCtrl.loading).toBe(false);207 });208 it('should be false even if there are errors loading data', function() {209 $scope.$apply(function() {210 account.getOrgs.deferred.reject();211 });212 expect(OrgsCtrl.loading).toBe(false);213 });214 });215 });216 describe('methods', function() {217 describe('formIsValid()', function() {218 beforeEach(function() {219 $scope.$apply(function() {220 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));221 });222 OrgsCtrl.editOrg($scope.data.orgs[0]);223 });224 it('should be true by default because the defualts should be set!', function() {225 expect(OrgsCtrl.formIsValid()).toBe(true);226 });227 it('should be false if video or display waterfalls or embedTypes are not set', function() {228 $scope.data.org._data.videoWaterfalls = [];229 expect(OrgsCtrl.formIsValid()).toBe(false);230 $scope.data.org._data.videoWaterfalls = [{enabled: true}];231 expect(OrgsCtrl.formIsValid()).toBe(true);232 $scope.data.org._data.displayWaterfalls = [];233 expect(OrgsCtrl.formIsValid()).toBe(false);234 $scope.data.org._data.displayWaterfalls = [{enabled: true}];235 expect(OrgsCtrl.formIsValid()).toBe(true);236 $scope.data.org._data.config.minireelinator.embedTypes = [];237 expect(OrgsCtrl.formIsValid()).toBe(false);238 $scope.data.org._data.config.minireelinator.embedTypes = [{enabled: true}];239 expect(OrgsCtrl.formIsValid()).toBe(true);240 $scope.data.org.config.minireelinator.embedDefaults.size = { width: '100px', height: '200px'};241 expect(OrgsCtrl.formIsValid()).toBe(true);242 $scope.data.org.config.minireelinator.embedDefaults.size = { width: '100px', height: ''};243 expect(OrgsCtrl.formIsValid()).toBe(false);244 $scope.data.org.config.minireelinator.embedDefaults.size = { width: '', height: ''};245 expect(OrgsCtrl.formIsValid()).toBe(true);246 });247 });248 describe('editOrg()', function() {249 it('should reset message, change the action, put the org on the scope, and get users by org', function() {250 $scope.$apply(function() {251 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));252 $scope.message = 'This is a test message';253 });254 OrgsCtrl.editOrg($scope.data.orgs[1]);255 expect($scope.message).toBe(null);256 expect(OrgsCtrl.action).toBe('edit');257 expect($scope.data.org).toEqual(jasmine.any(Object));258 expect(account.getUsers).toHaveBeenCalledWith({orgs: $scope.data.orgs[1].id });259 expect($scope.data.users).toBe(null);260 $scope.$apply(function() {261 account.getUsers.deferred.resolve([mockUsers[1]]);262 });263 expect($scope.data.users).toEqual([mockUsers[1]]);264 });265 });266 describe('addNewOrg()', function() {267 it('should reset message, change action, reset org data', function() {268 $scope.message = 'This is a test message';269 $scope.data.org = { name: 'Test', status: 'pending' };270 OrgsCtrl.addNewOrg();271 expect($scope.message).toBe(null);272 expect(OrgsCtrl.action).toBe('new');273 expect($scope.data.org.name).toBe(null);274 expect($scope.data.org.status).toBe('active');275 expect(account.convertOrgForEditing).toHaveBeenCalled();276 });277 });278 describe('filterData()', function() {279 it('should filter orgs by name', function() {280 $scope.$apply(function() {281 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));282 });283 expect($scope.data.orgs.length).toBe(2);284 $scope.data.query = '1';285 OrgsCtrl.filterData();286 expect($scope.data.orgs.length).toBe(1);287 $scope.data.query = 'o';288 OrgsCtrl.filterData();289 expect($scope.data.orgs.length).toBe(2);290 $scope.data.query = 'x';291 OrgsCtrl.filterData();292 expect($scope.data.orgs.length).toBe(0);293 $scope.data.query = 'ORG';294 OrgsCtrl.filterData();295 expect($scope.data.orgs.length).toBe(2);296 });297 });298 describe('saveOrg()', function() {299 describe('when updating an org', function() {300 beforeEach(function() {301 $scope.$apply(function() {302 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));303 });304 OrgsCtrl.editOrg($scope.data.orgs[0]);305 });306 it('should PUT the org', function() {307 OrgsCtrl.saveOrg();308 expect(account.putOrg).toHaveBeenCalledWith($scope.data.org);309 });310 it('on success should put a message on the scope, set the action, reload all the orgs data', function() {311 OrgsCtrl.saveOrg();312 expect(account.getOrgs.calls.count()).toBe(1);313 $scope.$apply(function() {314 account.putOrg.deferred.resolve($scope.data.org);315 });316 expect($scope.message).toBe('Successfully saved org: ' + $scope.data.org.name);317 expect(account.getOrgs.calls.count()).toBe(2);318 expect(OrgsCtrl.action).toBe('all');319 });320 it('on error should stay on the edit page and display an error message', function() {321 OrgsCtrl.saveOrg();322 $scope.$apply(function() {323 account.putOrg.deferred.reject();324 });325 expect(ConfirmDialogService.display).toHaveBeenCalled();326 });327 });328 describe('when creating an org', function() {329 beforeEach(function() {330 $scope.$apply(function() {331 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));332 });333 OrgsCtrl.addNewOrg();334 $scope.data.org.name = 'New Org';335 });336 it('should reset the message and the org data', function() {337 OrgsCtrl.saveOrg();338 expect(account.postOrg).toHaveBeenCalledWith($scope.data.org);339 });340 it('on success should put a message on the scope, set the action, reload all the orgs data', function() {341 OrgsCtrl.saveOrg();342 expect(account.getOrgs.calls.count()).toBe(1);343 $scope.$apply(function() {344 account.postOrg.deferred.resolve($scope.data.org);345 });346 expect($scope.message).toBe('Successfully saved org: ' + $scope.data.org.name);347 expect(account.getOrgs.calls.count()).toBe(2);348 expect(OrgsCtrl.action).toBe('all');349 });350 it('on error should stay on the edit page and display an error message', function() {351 OrgsCtrl.saveOrg();352 $scope.$apply(function() {353 account.postOrg.deferred.reject();354 });355 expect(ConfirmDialogService.display).toHaveBeenCalled();356 });357 });358 });359 describe('deleteOrg()', function() {360 beforeEach(function() {361 $scope.$apply(function() {362 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));363 });364 OrgsCtrl.editOrg($scope.data.orgs[0]);365 });366 it('should not DELETE the org if there are users belonging to it', function() {367 $scope.$apply(function() {368 account.getUsers.deferred.resolve([mockUsers[0]]);369 });370 OrgsCtrl.confirmDelete();371 ConfirmDialogService.display.calls.mostRecent().args[0].onAffirm();372 expect(ConfirmDialogService.display.calls.mostRecent().args[0].prompt).toBe('You must delete or move the Users belonging to this Org before deleting it.');373 expect(account.deleteOrg).not.toHaveBeenCalled();374 });375 it('should DELETE the org', function() {376 OrgsCtrl.confirmDelete();377 ConfirmDialogService.display.calls.mostRecent().args[0].onAffirm();378 expect(account.deleteOrg).toHaveBeenCalled();379 });380 it('on success should put a message on the scope, set the action, reload all the orgs data', function() {381 OrgsCtrl.confirmDelete();382 ConfirmDialogService.display.calls.mostRecent().args[0].onAffirm();383 expect(account.getOrgs.calls.count()).toBe(1);384 $scope.$apply(function() {385 account.deleteOrg.deferred.resolve($scope.data.org);386 });387 expect($scope.message).toBe('Successfully deleted org: ' + $scope.data.org.name);388 expect(account.getOrgs.calls.count()).toBe(2);389 expect(OrgsCtrl.action).toBe('all');390 });391 it('on error should stay on the edit page and display an error message', function() {392 OrgsCtrl.confirmDelete();393 ConfirmDialogService.display.calls.mostRecent().args[0].onAffirm();394 $scope.$apply(function() {395 account.deleteOrg.deferred.reject();396 });397 expect(OrgsCtrl.action).toBe('edit');398 expect(ConfirmDialogService.display.calls.count()).toBe(2);399 });400 });401 });402 describe('$watchers', function() {403 describe('page + limit', function() {404 it('should set page to 1 if limit changes', function() {405 OrgsCtrl.limit = 50;406 OrgsCtrl.page = 2;407 $scope.$digest();408 expect(OrgsCtrl.page).toBe(2);409 OrgsCtrl.limit = 10;410 $scope.$digest();411 expect(OrgsCtrl.page).toBe(1);412 });413 });414 });415 });416 });...

Full Screen

Full Screen

setup_project_modal_spec.js

Source:setup_project_modal_spec.js Github

copy

Full Screen

1describe('Connect to Dashboard', function () {2 beforeEach(function () {3 cy.fixture('user').as('user')4 cy.fixture('projects').as('projects')5 cy.fixture('projects_statuses').as('projectStatuses')6 cy.fixture('config').as('config')7 cy.fixture('specs').as('specs')8 cy.fixture('organizations').as('orgs')9 cy.fixture('keys').as('keys')10 cy.visitIndex().then(function (win) {11 let start = win.App.start12 this.win = win13 this.ipc = win.App.ipc14 this.config.projectName = 'my-kitchen-sink'15 cy.stub(this.ipc, 'getOptions').resolves({ projectRoot: '/foo/bar' })16 cy.stub(this.ipc, 'updaterCheck').resolves(false)17 cy.stub(this.ipc, 'closeBrowser').resolves(null)18 this.config.projectId = null19 cy.stub(this.ipc, 'openProject').resolves(this.config)20 cy.stub(this.ipc, 'getSpecs').yields(null, this.specs)21 cy.stub(this.ipc, 'getRuns').resolves([])22 cy.stub(this.ipc, 'getRecordKeys').resolves(this.keys)23 cy.stub(this.ipc, 'pingApiServer').resolves()24 cy.stub(this.ipc, 'externalOpen')25 this.getCurrentUser = this.util.deferred()26 cy.stub(this.ipc, 'getCurrentUser').resolves(this.getCurrentUser.promise)27 this.getOrgs = this.util.deferred()28 cy.stub(this.ipc, 'getOrgs').returns(this.getOrgs.promise)29 this.getProjectStatus = this.util.deferred()30 cy.stub(this.ipc, 'getProjectStatus').returns(this.getProjectStatus.promise)31 this.setupDashboardProject = this.util.deferred()32 cy.stub(this.ipc, 'setupDashboardProject').returns(this.setupDashboardProject.promise)33 start()34 cy.get('.navbar-default a')35 .contains('Runs').click()36 })37 })38 it('displays "need to set up" message', () => {39 cy.contains('You could see test recordings here')40 })41 describe('when there is a current user', function () {42 beforeEach(function () {43 this.getCurrentUser.resolve(this.user)44 })45 describe('general behavior', function () {46 beforeEach(function () {47 this.getOrgs.resolve(this.orgs)48 cy.get('.btn').contains('Connect to Dashboard').click()49 })50 it('clicking link opens setup project window', () => {51 cy.get('.modal').should('be.visible')52 })53 it('submit button is disabled', () => {54 cy.get('.modal').contains('.btn', 'Set up project')55 .should('be.disabled')56 })57 it('prefills Project Name', function () {58 cy.get('#projectName').should('have.value', this.config.projectName)59 })60 it('allows me to change Project Name value', () => {61 cy.get('#projectName').clear().type('New Project Here')62 .should('have.value', 'New Project Here')63 })64 it('org docs are linked', () => {65 cy.contains('label', 'Who should own this')66 .find('a').click().then(function () {67 expect(this.ipc.externalOpen).to.be.calledWith('https://on.cypress.io/what-are-organizations')68 })69 })70 })71 describe('loading behavior', function () {72 beforeEach(function () {73 cy.get('.btn').contains('Connect to Dashboard').click()74 })75 it('calls getOrgs', function () {76 expect(this.ipc.getOrgs).to.be.calledOnce77 })78 it('displays loading view before orgs load', function () {79 cy.get('.loader').then(function () {80 this.getOrgs.resolve(this.orgs)81 })82 cy.get('.loader').should('not.exist')83 })84 })85 describe('selecting an org', function () {86 describe('selecting Personal org', function () {87 beforeEach(function () {88 this.getOrgs.resolve(this.orgs)89 cy.get('.btn').contains('Connect to Dashboard').click()90 cy.get('.modal-content')91 cy.get('.organizations-select__dropdown-indicator').click()92 cy.get('.organizations-select__menu').should('be.visible')93 cy.get('.organizations-select__option')94 .contains('Your personal organization').click()95 })96 it('access docs are linked', () => {97 cy.contains('label', 'Who should see the runs')98 .find('a').click().then(function () {99 expect(this.ipc.externalOpen).to.be.calledWith('https://on.cypress.io/what-is-project-access')100 })101 })102 it('displays public & private radios with no preselects', () => {103 cy.get('.privacy-radio').should('be.visible')104 .find('input').should('not.be.checked')105 })106 })107 context('with orgs', function () {108 beforeEach(function () {109 this.getOrgs.resolve(this.orgs)110 cy.get('.btn').contains('Connect to Dashboard').click()111 cy.get('.modal-content')112 })113 it('lists organizations to assign to project', function () {114 cy.get('.empty-select-orgs').should('not.be.visible')115 cy.get('.organizations-select__dropdown-indicator').click()116 cy.get('.organizations-select__menu').should('be.visible')117 cy.get('.organizations-select__option')118 .should('have.length', this.orgs.length)119 })120 it('selects personal org by default', function () {121 cy.get('.organizations-select').contains(122 'Your personal organization',123 )124 cy.get('.privacy-radio').should('be.visible')125 })126 it('opens external link on click of manage', () => {127 cy.get('.manage-orgs-btn').click().then(function () {128 expect(this.ipc.externalOpen).to.be.calledWith('https://on.cypress.io/dashboard/organizations')129 })130 })131 it('displays public & private radios on select', function () {132 cy.get('.organizations-select__dropdown-indicator').click()133 cy.get('.organizations-select__menu').should('be.visible')134 cy.get('.organizations-select__option')135 .contains('Acme Developers').click()136 cy.get('.privacy-radio').should('be.visible')137 .find('input').should('not.be.checked')138 })139 })140 context('orgs with no default org', function () {141 beforeEach(function () {142 this.getOrgs.resolve(Cypress._.filter(this.orgs, { 'default': false }))143 cy.get('.btn').contains('Connect to Dashboard').click()144 })145 it('lists organizations to assign to project', function () {146 cy.get('.empty-select-orgs').should('not.be.visible')147 cy.get('.organizations-select__dropdown-indicator').click()148 cy.get('.organizations-select__menu').should('be.visible')149 cy.get('.organizations-select__option')150 // do not count the default org we removed151 .should('have.length', this.orgs.length - 1)152 })153 it('selects first org by default', function () {154 cy.get('.organizations-select').contains(this.orgs[1].name)155 })156 it('opens external link on click of manage', () => {157 cy.get('.manage-orgs-btn').click().then(function () {158 expect(this.ipc.externalOpen).to.be.calledWith('https://on.cypress.io/dashboard/organizations')159 })160 })161 it('displays public & private radios on select', function () {162 cy.get('.organizations-select__dropdown-indicator').click()163 cy.get('.organizations-select__menu').should('be.visible')164 cy.get('.organizations-select__option')165 .contains('Acme Developers').click()166 cy.get('.privacy-radio').should('be.visible')167 .find('input').should('not.be.checked')168 })169 })170 context('without orgs', function () {171 beforeEach(function () {172 this.getOrgs.resolve([])173 cy.get('.btn').contains('Connect to Dashboard').click()174 })175 it('displays empty message', () => {176 cy.get('.empty-select-orgs').should('be.visible')177 cy.get('.organizations-select').should('not.be.visible')178 cy.get('.privacy-radio').should('not.be.visible')179 })180 it('opens dashboard organizations when \'create org\' is clicked', () => {181 cy.contains('Create organization').click().then(function () {182 expect(this.ipc.externalOpen).to.be.calledWith('https://on.cypress.io/dashboard/organizations')183 })184 })185 })186 context('with only default org', function () {187 beforeEach(function () {188 this.getOrgs.resolve([{189 'id': '000',190 'name': 'Jane Lane',191 'default': true,192 }])193 cy.get('.btn').contains('Connect to Dashboard').click()194 cy.get('.modal-content')195 })196 it('displays in dropdown', () => {197 cy.get('.organizations-select__dropdown-indicator').click()198 cy.get('.organizations-select__menu').should('be.visible')199 cy.get('.organizations-select__option').should('have.length', 1)200 })201 it('sends values during submit', function () {202 cy.get('.privacy-radio').find('input').first().check()203 cy.get('.modal-body')204 .contains('.btn', 'Set up project').click()205 .then(() => {206 expect(this.ipc.setupDashboardProject).to.be.calledWith({207 projectName: 'my-kitchen-sink',208 orgId: '000',209 public: true,210 })211 })212 })213 })214 context('polls for updates to organizations', function () {215 beforeEach(function () {216 cy.clock()217 this.getOrgs.resolve(this.orgs)218 cy.get('.btn').contains('Connect to Dashboard').click()219 })220 it('polls for orgs twice in 10+sec on click of org', function () {221 cy.tick(11000).then(() => {222 expect(this.ipc.getOrgs).to.be.calledTwice223 })224 })225 it('updates org name on list on successful poll', function () {226 this.name = 'Foo Bar Devs'227 this.orgs[1].name = this.name228 this.getOrgsAgain = this.ipc.getOrgs.onCall(2).resolves(this.orgs)229 cy.tick(11000)230 cy.get('.organizations-select__dropdown-indicator').click()231 cy.get('.organizations-select__menu').should('be.visible')232 cy.get('.organizations-select__option')233 .contains(this.name)234 })235 it('adds new org to list on successful poll', function () {236 this.orgs.push({237 'id': '333',238 'name': 'Ivory Developers',239 'default': false,240 })241 this.getOrgsAgain = this.ipc.getOrgs.onCall(2).resolves(this.orgs)242 cy.tick(11000)243 cy.get('.organizations-select__dropdown-indicator').click()244 cy.get('.organizations-select__menu').should('be.visible')245 cy.get('.organizations-select__option')246 .should('have.length', this.orgs.length)247 })248 })249 })250 describe('on submit', function () {251 beforeEach(function () {252 this.getOrgs.resolve(this.orgs)253 cy.contains('.btn', 'Connect to Dashboard').click()254 cy.get('.organizations-select__dropdown-indicator').click()255 cy.get('.organizations-select__menu').should('be.visible')256 cy.get('.organizations-select__option')257 .contains('Your personal organization').click()258 cy.get('.privacy-radio').find('input').last().check()259 cy.get('.modal-body')260 .contains('.btn', 'Set up project').click()261 })262 it('disables button', () => {263 cy.get('.modal-body')264 .contains('.btn', 'Set up project')265 .should('be.disabled')266 })267 it('shows spinner', () => {268 cy.get('.modal-body')269 .contains('.btn', 'Set up project')270 .find('i')271 .should('be.visible')272 })273 })274 describe('successfully submit form', function () {275 beforeEach(function () {276 this.getOrgs.resolve(this.orgs)277 this.setupDashboardProject.resolve({278 id: 'project-id-123',279 public: true,280 orgId: '000',281 })282 cy.contains('.btn', 'Connect to Dashboard').click()283 })284 it('sends project name, org id, and public flag to ipc event', function () {285 cy.get('#projectName').clear().type('New Project')286 cy.get('.organizations-select__dropdown-indicator').click()287 cy.get('.organizations-select__menu').should('be.visible')288 cy.get('.organizations-select__option')289 .contains('Acme Developers').click()290 cy.get('.privacy-radio').find('input').first().check()291 cy.get('.modal-body')292 .contains('.btn', 'Set up project').click()293 .then(() => {294 expect(this.ipc.setupDashboardProject).to.be.calledWith({295 projectName: 'New Project',296 orgId: '777',297 public: true,298 })299 })300 })301 context('org/public', function () {302 beforeEach(function () {303 cy.get('.organizations-select__dropdown-indicator').click()304 cy.get('.organizations-select__menu').should('be.visible')305 cy.get('.organizations-select__option')306 .contains('Acme Developers').click()307 cy.get('.privacy-radio').find('input').first().check()308 cy.get('.modal-body')309 .contains('.btn', 'Set up project').click()310 })311 it('sends data from form to ipc event', function () {312 expect(this.ipc.setupDashboardProject).to.be.calledWith({313 projectName: this.config.projectName,314 orgId: '777',315 public: true,316 })317 })318 })319 context('me/private', function () {320 beforeEach(function () {321 cy.get('.organizations-select__dropdown-indicator').click()322 cy.get('.organizations-select__menu').should('be.visible')323 cy.get('.organizations-select__option')324 .contains('Your personal organization').click()325 cy.get('.privacy-radio').find('input').last().check()326 cy.get('.modal-body')327 .contains('.btn', 'Set up project').click()328 })329 it('sends data from form to ipc event', function () {330 expect(this.ipc.setupDashboardProject).to.be.calledWith({331 projectName: this.config.projectName,332 orgId: '000',333 public: false,334 })335 })336 })337 context('me/public', function () {338 beforeEach(function () {339 cy.get('.organizations-select__dropdown-indicator').click()340 cy.get('.organizations-select__menu').should('be.visible')341 cy.get('.organizations-select__option')342 .contains('Your personal organization').click()343 cy.get('.privacy-radio').find('input').first().check()344 cy.get('.modal-body')345 .contains('.btn', 'Set up project').click()346 })347 it('sends data from form to ipc event', function () {348 expect(this.ipc.setupDashboardProject).to.be.calledWith({349 projectName: this.config.projectName,350 orgId: '000',351 public: true,352 })353 })354 it('closes modal', () => {355 cy.get('.modal').should('not.be.visible')356 })357 it('updates localStorage projects cache', () => {358 expect(JSON.parse(localStorage.projects || '[]')[0].orgName).to.equal('Jane Lane')359 })360 it('displays empty runs page', () => {361 cy.contains('To record your first')362 })363 it('displays command to run with the record key', () => {364 cy.contains('cypress run --record --key record-key-123')365 })366 })367 })368 describe('errors', function () {369 beforeEach(function () {370 this.getOrgs.resolve(this.orgs)371 cy.contains('.btn', 'Connect to Dashboard').click()372 cy.get('.organizations-select__dropdown-indicator').click()373 cy.get('.organizations-select__menu').should('be.visible')374 cy.get('.organizations-select__option')375 .contains('Your personal organization').click()376 cy.get('.privacy-radio').find('input').last().check()377 cy.get('.modal-body')378 .contains('.btn', 'Set up project').click()379 })380 it('logs user out when 401', function () {381 this.setupDashboardProject.reject({ name: '', message: '', statusCode: 401 })382 cy.shouldBeLoggedOut()383 })384 it('displays error name and message when unexpected', function () {385 this.setupDashboardProject.reject({386 name: 'Fatal Error!',387 message: `{ "system": "down", "toxicity": "of the city" }`,388 })389 cy.contains('"system": "down"')390 })391 })392 describe('when get orgs 401s', function () {393 beforeEach(function () {394 cy.contains('.btn', 'Connect to Dashboard').click()395 .then(() => {396 this.getOrgs.reject({ name: '', message: '', statusCode: 401 })397 })398 })399 it('logs user out', () => {400 cy.shouldBeLoggedOut()401 })402 })403 })404 describe('when there is no current user', function () {405 beforeEach(function () {406 this.getCurrentUser.resolve(null)407 cy.get('.btn').contains('Connect to Dashboard').click()408 })409 it('shows login', () => {410 cy.get('.modal').contains('Log In to Dashboard')411 })412 it('closes login modal', () => {413 cy.get('.modal').contains('Log In to Dashboard')414 cy.get('.close').click()415 cy.get('.btn').contains('Connect to Dashboard').click()416 })417 describe('when login succeeds', function () {418 beforeEach(function () {419 cy.stub(this.ipc, 'beginAuth').resolves(this.user)420 cy.contains('button', 'Log In to Dashboard').click()421 })422 it('shows setup', () => {423 cy.get('.login-content > .btn').click()424 cy.contains('h4', 'Set up project')425 })426 })427 })...

Full Screen

Full Screen

getOrganizationsFiltered.js

Source:getOrganizationsFiltered.js Github

copy

Full Screen

1'use strict';2const expect = require('chai').expect;3const env = require('../../../functions/lib/env.js').withMockContext();4const databaseHelper = require('../../../functions/lib/helpers/databaseHelper.js').withEnv(env);5const stringUtil = require('../../../functions/lib/util/string.js');6const functionRunner = require('../../functionRunner.js');7describe('getOrganizations - filtered', function () {8 /**9 * Replaces a string into another string at a given index10 *11 * @param target12 * @param str13 * @param index14 * @return {string}15 */16 function replaceStringAtPosition(target, str, index) {17 if (index < 0) {18 str = str.substr(-index);19 }20 index = Math.max(0, index);21 return (target.substr(0, index) + str + target.substr(index+str.length)).substr(0,target.length);22 }23 let stringToFind = 'AAAAAAA';24 let rootOrgId = stringUtil.randomString(36);25 26 // populate the database with 250 randomized orgs27 let organizations = Array(250).fill(0).map((elem, i) => {28 return {29 OrganizationID: i === 0 ? rootOrgId : stringUtil.randomString(36),30 OrganizationName: stringUtil.randomString(80),31 ExternalID: stringUtil.randomString(30),32 ParentOrganizationID: i === 0 ? null : rootOrgId,33 OrganizationType: stringUtil.randomString(35),34 Active: 135 };36 });37 // Within the list of 250 orgs,38 // 150 are inactive,39 // 150 have org names that contain the substring 'AAAAAAA', and40 // 150 have a ParentOrganizationID set as the fifth OrganizationID, which is not the root. (using an org that will not create a circular hierarchy)41 // in each of the latter two sets, 50 orgs are active and 100 are inactive.42 //43 // The intersection between these two sets of orgs is 50 for active, and 50 for inactive.44 let otherParentOrgId = organizations[5].OrganizationID;45 for (let i = 0; i < organizations.length; i++) {46 if ([1,2,3].indexOf(i % 5) !== -1) {47 organizations[i].ParentOrganizationID = otherParentOrgId;48 }49 if ([2,3,4].indexOf(i % 5) !== -1) {50 // replace the string with "AAAAAAA" at index 1051 organizations[i].OrganizationName = replaceStringAtPosition(organizations[i].OrganizationName, stringToFind, 10);52 }53 if ([1,3,4].indexOf(i % 5) !== -1) {54 organizations[i].Active = 0;55 }56 }57 organizations.sort((orgA, orgB) => {58 let nameA = orgA.OrganizationName.toLowerCase();59 let nameB = orgB.OrganizationName.toLowerCase();60 return nameA <= nameB ? nameA < nameB ? -1 : 0 : 1;61 });62 before(function () {63 return databaseHelper.getQueryBuilder().then(knex => {64 return knex('organization').insert(organizations);65 });66 });67 after(function() {68 return databaseHelper.getQueryBuilder().then(knex => {69 return knex('organization').del();70 });71 });72 it('should only return active results by default', function () {73 let getOrgs = functionRunner.runFunction('getOrganizations');74 let filteredOrgs = organizations.filter(organization => {75 return organization.Active;76 });77 return Promise.all([78 expect(getOrgs).to.be.fulfilled,79 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),80 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),81 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),82 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),83 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),84 expect(getOrgs).to.eventually.have.lengthOf(50)85 ]);86 });87 it('return inactive organizations if Active is false', function () {88 let getOrgs = functionRunner.runFunction('getOrganizations', null, {89 querystring: {90 Active: 'false'91 }92 }).then(data => {93 return data;94 });95 let filteredOrgs = organizations.filter(organization => {96 return !organization.Active;97 });98 return Promise.all([99 expect(getOrgs).to.be.fulfilled,100 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),101 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),102 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),103 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),104 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),105 expect(getOrgs).to.eventually.have.lengthOf(50)106 ]);107 });108 it('should get a filtered list based on a substring search on a given value for OrganizationName', function () {109 let getOrgs = functionRunner.runFunction('getOrganizations', null, {110 querystring: {111 OrganizationName: stringToFind112 }113 });114 let filteredOrgs = organizations.filter(organization => {115 return organization.OrganizationName.indexOf(stringToFind) !== -1 && organization.Active;116 });117 return Promise.all([118 expect(getOrgs).to.be.fulfilled,119 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),120 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),121 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),122 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),123 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),124 expect(getOrgs).to.eventually.have.lengthOf(50)125 ]);126 });127 it('should get a filtered list based on an exact search on a given value for ParentOrganizationID', function () {128 let getOrgs = functionRunner.runFunction('getOrganizations', null, {129 querystring: {130 ParentOrganizationID: otherParentOrgId131 }132 });133 let filteredOrgs = organizations.filter(organization => {134 return organization.ParentOrganizationID === otherParentOrgId && organization.Active;135 });136 return Promise.all([137 expect(getOrgs).to.be.fulfilled,138 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),139 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),140 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),141 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),142 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),143 expect(getOrgs).to.eventually.have.lengthOf(50)144 ]);145 });146 it('should ignore case when searching', function () {147 let getOrgs = functionRunner.runFunction('getOrganizations', null, {148 querystring: {149 ParentOrganizationID: otherParentOrgId.toLowerCase(),150 OrganizationName: stringToFind.toLowerCase()151 }152 });153 let filteredOrgs = organizations.filter(organization => {154 return (155 organization.ParentOrganizationID === otherParentOrgId &&156 organization.OrganizationName.indexOf(stringToFind) !== -1 &&157 organization.Active158 );159 });160 return Promise.all([161 expect(getOrgs).to.be.fulfilled,162 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),163 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),164 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),165 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),166 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),167 expect(getOrgs).to.eventually.have.lengthOf(50)168 ]);169 });170 it('should get a filtered list based on both ParentOrganizationID and OrganizationName', function () {171 let getOrgs = functionRunner.runFunction('getOrganizations', null, {172 querystring: {173 ParentOrganizationID: otherParentOrgId,174 OrganizationName: stringToFind175 }176 });177 let filteredOrgs = organizations.filter(organization => {178 return (179 organization.ParentOrganizationID === otherParentOrgId &&180 organization.OrganizationName.indexOf(stringToFind) !== -1 &&181 organization.Active182 );183 });184 return Promise.all([185 expect(getOrgs).to.be.fulfilled,186 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),187 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),188 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),189 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),190 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),191 expect(getOrgs).to.eventually.have.lengthOf(50)192 ]);193 });194 it('should get a filtered list based on ParentOrganizationID, OrganizationName, and Active', function () {195 let getOrgs = functionRunner.runFunction('getOrganizations', null, {196 querystring: {197 ParentOrganizationID: otherParentOrgId,198 OrganizationName: stringToFind,199 Active: 'false'200 }201 });202 let filteredOrgs = organizations.filter(organization => {203 return (204 organization.ParentOrganizationID === otherParentOrgId &&205 organization.OrganizationName.indexOf(stringToFind) !== -1 &&206 !organization.Active207 );208 });209 return Promise.all([210 expect(getOrgs).to.be.fulfilled,211 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', filteredOrgs[0].OrganizationID),212 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', filteredOrgs[49].OrganizationID),213 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),214 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),215 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', filteredOrgs.length),216 expect(getOrgs).to.eventually.have.lengthOf(50)217 ]);218 });219 it('should not allow non-boolean values for Active', function() {220 let getOrgs = functionRunner.runFunction('getOrganizations', null, {221 querystring: {222 Active: "foo"223 }224 });225 return expect(getOrgs).to.be.rejectedWith(JSON.stringify({226 "responseCode": 400,227 "errorMessage": "Active must be a boolean value"228 }));229 });230 it('should not allow invalid field names', function () {231 let getOrgs = functionRunner.runFunction('getOrganizations', null, {232 querystring: {233 OrganizationID: "12345"234 }235 });236 return expect(getOrgs).to.be.rejectedWith(JSON.stringify({237 "responseCode": 400,238 "errorMessage": "Invalid filter: OrganizationID"239 }));240 });241 it('should return a 404 if the filter returns no results', function () {242 let getOrgs = functionRunner.runFunction('getOrganizations', null, {243 querystring: {244 ParentOrganizationID: "12345"245 }246 });247 return expect(getOrgs).to.be.rejectedWith(JSON.stringify({248 "responseCode": 404,249 "errorMessage": "Page not found"250 }));251 });...

Full Screen

Full Screen

sites.controller.ut.js

Source:sites.controller.ut.js Github

copy

Full Screen

1(function() {2 'user strict';3 define(['app'], function() {4 describe('SitesController', function() {5 var $rootScope,6 $scope,7 $controller,8 $q,9 $log,10 $location,11 SitesCtrl,12 SitesService,13 account,14 mockSites,15 mockOrgs;16 beforeEach(function() {17 module('c6.proshop');18 account = {19 getOrg: jasmine.createSpy('account.getOrg'),20 getOrgs: jasmine.createSpy('account.getOrgs'),21 };22 SitesService = {23 getSites: jasmine.createSpy('SitesService.getSites'),24 };25 mockSites = [26 /* jshint quotmark:false */27 {28 "id": "s-1",29 "status": "active",30 "created": "2014-06-13T19:28:39.408Z",31 "lastUpdated": "2014-06-13T19:28:39.408Z",32 "org": "o-112",33 "branding": "site1_branding",34 "placementId": "111111",35 "wildCardPlacement": "121212",36 "name": "Best Website Ever",37 "host": "bestever.com"38 },39 {40 "id": "s-2",41 "status": "pending",42 "created": "2014-05-13T19:28:39.408Z",43 "lastUpdated": "2014-07-13T19:28:39.408Z",44 "org": "o-111",45 "branding": "site2_branding",46 "placementId": "111112",47 "name": "News Site",48 "host": "thenews.com"49 },50 {51 "id": "s-3",52 "status": "inactive",53 "created": "2014-06-17T19:28:39.408Z",54 "lastUpdated": "2014-06-20T19:28:39.408Z",55 "org": "o-114",56 "branding": "site3_branding",57 "placementId": "111113",58 "name": "Sports Are Fun",59 "host": "sportsarefun.com"60 }61 /* jshint quotmark:single */62 ];63 mockOrgs = [64 {65 name: 'Org1',66 id: 'o-111'67 },68 {69 name: 'Org2',70 id: 'o-112'71 },72 {73 name: 'Org3',74 id: 'o-114'75 }76 ];77 inject(function($injector) {78 $controller = $injector.get('$controller');79 $log = $injector.get('$log');80 $q = $injector.get('$q');81 $rootScope = $injector.get('$rootScope');82 $location = $injector.get('$location');83 account.getOrg.and.callFake(function(arg) {84 account.getOrg.deferred = $q.defer();85 var org = mockOrgs.filter(function(o) {86 return o.id === arg;87 })[0];88 account.getOrg.deferred.resolve(org);89 return account.getOrg.deferred.promise;90 });91 account.getOrgs.deferred = $q.defer();92 account.getOrgs.and.returnValue(account.getOrgs.deferred.promise);93 SitesService.getSites.deferred = $q.defer();94 SitesService.getSites.and.returnValue(SitesService.getSites.deferred.promise);95 $log.context = function(){ return $log; }96 $scope = $rootScope.$new();97 SitesCtrl = $controller('SitesController', {98 $log: $log,99 $scope: $scope,100 account: account,101 SitesService: SitesService102 });103 });104 });105 describe('initialization', function() {106 it('should exist', function() {107 expect(SitesCtrl).toBeDefined();108 });109 it('should load Sites from service', function() {110 expect(SitesService.getSites).toHaveBeenCalled();111 expect(account.getOrgs).toHaveBeenCalled();112 });113 it('should load Site\'s org if defined', function() {114 $scope.$apply(function() {115 SitesService.getSites.deferred.resolve(angular.copy(mockSites));116 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));117 });118 mockSites.forEach(function(site) {119 if (site.org) {120 expect(account.getOrg).toHaveBeenCalledWith(site.org);121 }122 });123 });124 });125 describe('methods', function() {126 describe('filterData(query)', function() {127 it('should match case-insensitively against name, domain, and org name', function() {128 $scope.$apply(function() {129 SitesService.getSites.deferred.resolve(angular.copy(mockSites));130 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));131 });132 expect(SitesCtrl.sites.length).toBe(3);133 SitesCtrl.filterData('B'); // site 1's name only134 expect(SitesCtrl.sites.length).toBe(1);135 expect(SitesCtrl.sites[0].id).toBe('s-1');136 SitesCtrl.filterData('ws.c'); // site 2's domain only137 expect(SitesCtrl.sites.length).toBe(1);138 expect(SitesCtrl.sites[0].id).toBe('s-2');139 SitesCtrl.filterData('Org3'); // site 3's org name only140 expect(SitesCtrl.sites.length).toBe(1);141 expect(SitesCtrl.sites[0].id).toBe('s-3');142 SitesCtrl.filterData('xxx');143 expect(SitesCtrl.sites.length).toBe(0);144 SitesCtrl.filterData('');145 expect(SitesCtrl.sites.length).toBe(3);146 });147 });148 describe('addNewSite()', function() {149 it('should redirect to /sites/new', function() {150 spyOn($location, 'path');151 SitesCtrl.addNewSite();152 expect($location.path).toHaveBeenCalledWith('/sites/new');153 });154 });155 });156 describe('properties', function() {157 describe('loading', function() {158 it('should be true on initialization', function() {159 expect(SitesCtrl.loading).toBe(true);160 });161 it('should be false after all data promises resolve', function() {162 $scope.$apply(function() {163 SitesService.getSites.deferred.resolve(angular.copy(mockSites));164 account.getOrgs.deferred.resolve(angular.copy(mockOrgs));165 });166 expect(SitesCtrl.loading).toBe(false);167 });168 it('should be false even if there are errors loading data', function() {169 $scope.$apply(function() {170 SitesService.getSites.deferred.reject();171 account.getOrgs.deferred.reject();172 });173 expect(SitesCtrl.loading).toBe(false);174 });175 });176 });177 describe('$scope.doSort()', function() {178 it('should sort', function() {179 $scope.doSort('domain');180 expect($scope.sort).toEqual({column:'domain',descending:false});181 $scope.doSort('domain');182 expect($scope.sort).toEqual({column:'domain',descending:true});183 $scope.doSort('org.name');184 expect($scope.sort).toEqual({column:'org.name',descending:false});185 $scope.doSort('branding');186 expect($scope.sort).toEqual({column:'branding',descending:false});187 });188 });189 });190 });...

Full Screen

Full Screen

getOrganizationsPaged.js

Source:getOrganizationsPaged.js Github

copy

Full Screen

1'use strict';2const expect = require('chai').expect;3const env = require('../../../functions/lib/env.js').withMockContext();4const databaseHelper = require('../../../functions/lib/helpers/databaseHelper.js').withEnv(env);5const stringUtil = require('../../../functions/lib/util/string.js');6const functionRunner = require('../../functionRunner.js');7describe('getOrganizations - paged', function () {8 let rootOrgId = stringUtil.randomString(36);9 // populate the database with 200 randomized orgs10 let organizations = Array(200).fill(0).map((elem, i) => {11 return {12 OrganizationID: i === 0 ? rootOrgId : stringUtil.randomString(36),13 OrganizationName: stringUtil.randomString(80),14 ExternalID: stringUtil.randomString(30),15 ParentOrganizationID: i === 0 ? null : rootOrgId,16 OrganizationType: stringUtil.randomString(35)17 };18 }).sort((orgA, orgB) => {19 let nameA = orgA.OrganizationName.toLowerCase();20 let nameB = orgB.OrganizationName.toLowerCase();21 return nameA <= nameB ? nameA < nameB ? -1 : 0 : 1;22 });23 before(function () {24 return databaseHelper.getQueryBuilder().then(knex => {25 return knex('organization').insert(organizations);26 });27 });28 after(function() {29 return databaseHelper.getQueryBuilder().then(knex => {30 return knex('organization').del();31 });32 });33 it('should give the first 50 organzations by default', function () {34 let getOrgs = functionRunner.runFunction('getOrganizations');35 return Promise.all([36 expect(getOrgs).to.be.fulfilled,37 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', organizations[0].OrganizationID),38 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', organizations[49].OrganizationID),39 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),40 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),41 expect(getOrgs).to.eventually.have.deep.property('pagination.rowCount', organizations.length),42 expect(getOrgs).to.eventually.have.lengthOf(50)43 ]);44 });45 it('should give the first 50 organizations after a given offset, if given no limit', function () {46 let offset = 10;47 let getOrgs = functionRunner.runFunction('getOrganizations', null, {48 querystring: {49 offset: offset50 }51 });52 return Promise.all([53 expect(getOrgs).to.be.fulfilled,54 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', organizations[0 + offset].OrganizationID),55 expect(getOrgs).to.eventually.have.deep.property('models[49].OrganizationID', organizations[49 + offset].OrganizationID),56 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', offset),57 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', 50),58 expect(getOrgs).to.eventually.have.lengthOf(50)59 ]);60 });61 it('should give the first n organizations as described by the limit, if given no offset', function () {62 let limit = 10;63 let getOrgs = functionRunner.runFunction('getOrganizations', null, {64 querystring: {65 limit: limit66 }67 });68 return Promise.all([69 expect(getOrgs).to.be.fulfilled,70 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', organizations[0].OrganizationID),71 expect(getOrgs).to.eventually.have.deep.property(`models[${limit - 1}].OrganizationID`, organizations[limit - 1].OrganizationID),72 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', 0),73 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', limit),74 expect(getOrgs).to.eventually.have.lengthOf(limit)75 ]);76 });77 it('should give the first n organizations after a given offset, if given both offset and limit', function () {78 let limit = 10;79 let offset = 10;80 let getOrgs = functionRunner.runFunction('getOrganizations', null, {81 querystring: {82 limit: limit,83 offset: offset84 }85 });86 return Promise.all([87 expect(getOrgs).to.be.fulfilled,88 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', organizations[0 + offset].OrganizationID),89 expect(getOrgs).to.eventually.have.deep.property(`models[${limit - 1}].OrganizationID`, organizations[limit - 1 + offset].OrganizationID),90 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', offset),91 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', limit),92 expect(getOrgs).to.eventually.have.lengthOf(limit)93 ]);94 });95 it('should be sorted by name', function () {96 let getOrgs = functionRunner.runFunction('getOrganizations');97 return Promise.all([98 expect(getOrgs).to.be.fulfilled,99 getOrgs.then(pagination => {100 let orgs = pagination.models;101 // iterate through result set and confirm that each org name is less than or equal to the next, alphabetically102 let sorted = true;103 for (var i = 0; i < orgs.length - 1; i++) {104 if (orgs[i].OrganizationName.toLowerCase() > orgs[i+1].OrganizationName.toLowerCase()) {105 sorted = false;106 break;107 }108 }109 return expect(sorted).to.be.true;110 })111 ]);112 });113 it('should not allow a request beyond the bounds of the database', function () {114 let offset = 201;115 let getOrgs = functionRunner.runFunction('getOrganizations', null, {116 querystring: {117 offset: offset118 }119 });120 121 return expect(getOrgs).to.be.rejectedWith(JSON.stringify({122 "responseCode": 404,123 "errorMessage": "Page not found"124 }));125 });126 it('should return partial data if the limit is higher than the number of rows found at the given offset', function () {127 let offset = 190;128 let limit = 20;129 let getOrgs = functionRunner.runFunction('getOrganizations', null, {130 querystring: {131 offset: offset,132 limit: limit133 }134 });135 return Promise.all([136 expect(getOrgs).to.be.fulfilled,137 expect(getOrgs).to.eventually.have.deep.property('models[0].OrganizationID', organizations[0 + offset].OrganizationID),138 expect(getOrgs).to.eventually.have.deep.property('models[9].OrganizationID', organizations[9 + offset].OrganizationID),139 expect(getOrgs).to.eventually.have.deep.property('models[9].OrganizationID', organizations[9 + offset].OrganizationID),140 expect(getOrgs).to.eventually.have.deep.property('pagination.offset', offset),141 expect(getOrgs).to.eventually.have.deep.property('pagination.limit', limit),142 expect(getOrgs).to.eventually.have.lengthOf(10)143 ]);144 });...

Full Screen

Full Screen

OrgTable.js

Source:OrgTable.js Github

copy

Full Screen

...9 orgs: [],10 selectedState: 'NC',11 }12 }13 async getOrgs(state) {14 let url = 'https://api.data.charitynavigator.org/v2/Organizations?app_id=906ba8ca&app_key=1527cbf5cf17fdad91e0cdf4a31ff787&causeID=18&state=' + state;15 let temp = [];16 await fetch(url)17 .then(response => response.json())18 .then(response => {19 for (let i = 0; i < response.length; i++) {20 temp.push(response[i]);21 }22 this.setState({orgs: temp, selectedState: state})23 });24 }25 componentDidMount() {26 this.getOrgs(this.state.selectedState);27 }28 render() {29 return (30 <div>31 <Dropdown className="ml-5">32 <Dropdown.Toggle id="dropdown-basic">{this.state.selectedState}</Dropdown.Toggle>33 <Dropdown.Menu>34 <Dropdown.Item onClick={() => this.getOrgs('AL')}>AL</Dropdown.Item>35 <Dropdown.Item onClick={() => this.getOrgs('AS')}>AS</Dropdown.Item>36 <Dropdown.Item onClick={() => this.getOrgs('AZ')}>AZ</Dropdown.Item>37 <Dropdown.Item onClick={() => this.getOrgs('AR')}>AR</Dropdown.Item>38 <Dropdown.Item onClick={() => this.getOrgs('CA')}>CA</Dropdown.Item>39 <Dropdown.Item onClick={() => this.getOrgs('CO')}>CO</Dropdown.Item>40 <Dropdown.Item onClick={() => this.getOrgs('CT')}>CT</Dropdown.Item>41 <Dropdown.Item onClick={() => this.getOrgs('DE')}>DE</Dropdown.Item>42 <Dropdown.Item onClick={() => this.getOrgs('FL')}>FL</Dropdown.Item>43 <Dropdown.Item onClick={() => this.getOrgs('GA')}>GA</Dropdown.Item>44 <Dropdown.Item onClick={() => this.getOrgs('HI')}>HI</Dropdown.Item>45 <Dropdown.Item onClick={() => this.getOrgs('ID')}>ID</Dropdown.Item>46 <Dropdown.Item onClick={() => this.getOrgs('IL')}>IL</Dropdown.Item>47 <Dropdown.Item onClick={() => this.getOrgs('IN')}>IN</Dropdown.Item>48 <Dropdown.Item onClick={() => this.getOrgs('IA')}>IA</Dropdown.Item>49 <Dropdown.Item onClick={() => this.getOrgs('KS')}>KS</Dropdown.Item>50 <Dropdown.Item onClick={() => this.getOrgs('KY')}>KY</Dropdown.Item>51 <Dropdown.Item onClick={() => this.getOrgs('LA')}>LA</Dropdown.Item>52 <Dropdown.Item onClick={() => this.getOrgs('ME')}>ME</Dropdown.Item>53 <Dropdown.Item onClick={() => this.getOrgs('MD')}>MD</Dropdown.Item>54 <Dropdown.Item onClick={() => this.getOrgs('MA')}>MA</Dropdown.Item>55 <Dropdown.Item onClick={() => this.getOrgs('MI')}>MI</Dropdown.Item>56 <Dropdown.Item onClick={() => this.getOrgs('MN')}>MN</Dropdown.Item>57 <Dropdown.Item onClick={() => this.getOrgs('MS')}>MS</Dropdown.Item>58 <Dropdown.Item onClick={() => this.getOrgs('MO')}>MO</Dropdown.Item>59 <Dropdown.Item onClick={() => this.getOrgs('MT')}>MT</Dropdown.Item>60 <Dropdown.Item onClick={() => this.getOrgs('NE')}>NE</Dropdown.Item>61 <Dropdown.Item onClick={() => this.getOrgs('NV')}>NV</Dropdown.Item>62 <Dropdown.Item onClick={() => this.getOrgs('NH')}>NH</Dropdown.Item>63 <Dropdown.Item onClick={() => this.getOrgs('NJ')}>NJ</Dropdown.Item>64 <Dropdown.Item onClick={() => this.getOrgs('NM')}>NM</Dropdown.Item>65 <Dropdown.Item onClick={() => this.getOrgs('NY')}>NY</Dropdown.Item>66 <Dropdown.Item onClick={() => this.getOrgs('NC')}>NC</Dropdown.Item>67 <Dropdown.Item onClick={() => this.getOrgs('ND')}>ND</Dropdown.Item>68 <Dropdown.Item onClick={() => this.getOrgs('OH')}>OH</Dropdown.Item>69 <Dropdown.Item onClick={() => this.getOrgs('OK')}>OK</Dropdown.Item>70 <Dropdown.Item onClick={() => this.getOrgs('OR')}>OR</Dropdown.Item>71 <Dropdown.Item onClick={() => this.getOrgs('PA')}>PA</Dropdown.Item>72 <Dropdown.Item onClick={() => this.getOrgs('RI')}>RI</Dropdown.Item>73 <Dropdown.Item onClick={() => this.getOrgs('SC')}>SC</Dropdown.Item>74 <Dropdown.Item onClick={() => this.getOrgs('SD')}>SD</Dropdown.Item>75 <Dropdown.Item onClick={() => this.getOrgs('TN')}>TN</Dropdown.Item>76 <Dropdown.Item onClick={() => this.getOrgs('TX')}>TX</Dropdown.Item>77 <Dropdown.Item onClick={() => this.getOrgs('UT')}>UT</Dropdown.Item>78 <Dropdown.Item onClick={() => this.getOrgs('VT')}>VT</Dropdown.Item>79 <Dropdown.Item onClick={() => this.getOrgs('VA')}>VA</Dropdown.Item>80 <Dropdown.Item onClick={() => this.getOrgs('WA')}>WA</Dropdown.Item>81 <Dropdown.Item onClick={() => this.getOrgs('WV')}>WV</Dropdown.Item>82 <Dropdown.Item onClick={() => this.getOrgs('WI')}>WI</Dropdown.Item>83 <Dropdown.Item onClick={() => this.getOrgs('WY')}>WY</Dropdown.Item>84 </Dropdown.Menu>85 </Dropdown>86 <CardColumns className="px-4 mt-5">87 {this.state.orgs.map(org => (88 <Card className="text-center p-4 mb-4 orgCell">89 <Card.Title className="title my-2"><a href={org.websiteURL} target="_blank">{org.charityName}</a></Card.Title>90 <Card.Text>{ReactHtmlParser(org.mission)}</Card.Text>91 <Card.Footer>{org.mailingAddress.city}, {org.mailingAddress.stateOrProvince}</Card.Footer>92 <Card.Footer>93 <Button onClick={() => this.props.addFavoriteHandler(org.charityName, org.websiteURL, org.mailingAddress.city, org.mailingAddress.stateOrProvince)}>Add to Favorites</Button>94 </Card.Footer>95 </Card>96 ))}97 </CardColumns>...

Full Screen

Full Screen

getOrganizationsSorted.js

Source:getOrganizationsSorted.js Github

copy

Full Screen

1'use strict';2const expect = require('chai').expect;3const env = require('../../../functions/lib/env.js').withMockContext();4const databaseHelper = require('../../../functions/lib/helpers/databaseHelper.js').withEnv(env);5const stringUtil = require('../../../functions/lib/util/string.js');6const dateUtil = require('../../../functions/lib/util/date.js');7const testingUtil = require('../../../functions/lib/util/testing.js');8const functionRunner = require('../../functionRunner.js');9function testSort(promise, field, ascending, caseSensitive) {10 let models = promise.then(pagination => pagination.models);11 12 return Promise.all([13 expect(promise).to.be.fulfilled,14 testingUtil.expect(expect, models).toBeSortedByField(field, ascending, caseSensitive)15 ]);16}17describe('getOrganizations - sorted', function () {18 let rootOrgId = stringUtil.randomString(36);19 // populate the database with 200 randomized orgs20 let organizations = Array(200).fill(0).map((elem, i) => {21 let createdAt = dateUtil.randomDate();22 let updatedAt = dateUtil.yearAfter(createdAt);23 return {24 OrganizationID: i === 0 ? rootOrgId : stringUtil.randomString(36),25 OrganizationName: stringUtil.randomString(80),26 ExternalID: stringUtil.randomString(30),27 ParentOrganizationID: i === 0 ? null : rootOrgId,28 OrganizationType: stringUtil.randomString(35),29 CreatedAt: createdAt,30 UpdatedAt: updatedAt31 };32 }).sort((orgA, orgB) => {33 let nameA = orgA.OrganizationName.toLowerCase();34 let nameB = orgB.OrganizationName.toLowerCase();35 return nameA <= nameB ? nameA < nameB ? -1 : 0 : 1;36 });37 before(function () {38 return databaseHelper.getQueryBuilder().then(knex => {39 return knex('organization').insert(organizations).catch(e => {40 console.log(e);41 throw e;42 });43 });44 });45 after(function() {46 return databaseHelper.getQueryBuilder().then(knex => {47 return knex('organization').del();48 });49 });50 it('should be sorted by OrganizationName by default', function () {51 let getOrgs = functionRunner.runFunction('getOrganizations');52 return testSort(getOrgs, 'OrganizationName', true);53 });54 it('should allow sorting by OrganizationType ascending', function () {55 let getOrgs = functionRunner.runFunction('getOrganizations', null, {56 querystring: {57 sort: 'OrganizationType'58 }59 });60 return testSort(getOrgs, 'OrganizationType', true);61 });62 it('should allow sorting by OrganizationType descending', function () {63 let getOrgs = functionRunner.runFunction('getOrganizations', null, {64 querystring: {65 sort: '-OrganizationType'66 }67 });68 return testSort(getOrgs, 'OrganizationType', false);69 });70 it('should allow sorting by OrganizationName ascending', function () {71 let getOrgs = functionRunner.runFunction('getOrganizations', null, {72 querystring: {73 sort: 'OrganizationName'74 }75 });76 return testSort(getOrgs, 'OrganizationName', true);77 });78 it('should allow sorting by OrganizationName descending', function () {79 let getOrgs = functionRunner.runFunction('getOrganizations', null, {80 querystring: {81 sort: '-OrganizationName'82 }83 });84 return testSort(getOrgs, 'OrganizationName', false);85 });86 it('should allow sorting by CreatedAt ascending', function () {87 let getOrgs = functionRunner.runFunction('getOrganizations', null, {88 querystring: {89 sort: 'CreatedAt'90 }91 });92 return testSort(getOrgs, 'CreatedAt', true);93 });94 it('should allow sorting by CreatedAt descending', function () {95 let getOrgs = functionRunner.runFunction('getOrganizations', null, {96 querystring: {97 sort: '-CreatedAt'98 }99 });100 return testSort(getOrgs, 'CreatedAt', false);101 });102 it('should allow sorting by UpdatedAt ascending', function () {103 let getOrgs = functionRunner.runFunction('getOrganizations', null, {104 querystring: {105 sort: 'UpdatedAt'106 }107 });108 return testSort(getOrgs, 'UpdatedAt', true);109 });110 it('should allow sorting by UpdatedAt descending', function () {111 let getOrgs = functionRunner.runFunction('getOrganizations', null, {112 querystring: {113 sort: '-UpdatedAt'114 }115 });116 return testSort(getOrgs, 'UpdatedAt', false);117 });118 it('should not allow sorting of invalid fields', function () {119 let getOrgs = functionRunner.runFunction('getOrganizations', null, {120 querystring: {121 sort: 'Foo'122 }123 });124 return expect(getOrgs).to.be.rejectedWith(JSON.stringify({125 responseCode: 400,126 errorMessage: "Invalid sort: Foo"127 }));128 });...

Full Screen

Full Screen

organizations-api.js

Source:organizations-api.js Github

copy

Full Screen

1import ipc from '../lib/ipc'2import orgsStore from './organizations-store'3let pollId4const getOrgs = () => {5 ipc.getOrgs()6 .then((orgs = []) => {7 orgsStore.setOrgs(orgs)8 return null9 })10 .catch(ipc.isUnauthed, ipc.handleUnauthed)11 .catch((err) => {12 orgsStore.setError(err)13 return null14 })15 return null16}17const isPolling = () => {18 return !!pollId19}20const pollOrgs = () => {21 if (pollId) return22 pollId = setInterval(() => {23 getOrgs()24 }, 10000)25}26const stopPollingOrgs = () => {27 clearInterval(pollId)28 pollId = null29}30export default {31 getOrgs,32 isPolling,33 pollOrgs,34 stopPollingOrgs,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Gets, types and asserts', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('getOrgs', () => {2 cy.request({3 headers: {4 }5 }).then((response) => {6 expect(response.status).to.eq(200)7 expect(response.body).to.have.property('organizations')8 })9})10Cypress.Commands.add('getOrgs', () => {11 cy.request({12 headers: {13 }14 }).then((response) => {15 expect(response.status).to.eq(200)16 expect(response.body).to.have.property('organizations')17 })18})19Cypress.Commands.add('getOrgs', () => {20 cy.request({21 headers: {22 }23 }).then((response) => {24 expect(response.status).to.eq(200)25 expect(response.body).to.have.property('organizations')26 })27})28Cypress.Commands.add('getOrgs', () => {29 cy.request({30 headers: {31 }32 }).then((response) => {33 expect(response.status).to.eq(200)34 expect(response.body).to.have.property('organizations')35 })36})37Cypress.Commands.add('getOrgs', () => {38 cy.request({39 headers: {40 }41 }).then((response) => {42 expect(response.status).to.eq(200)43 expect(response.body).to.have.property('organizations')44 })45})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress', () => {2 it('is working', () => {3 expect(true).to.equal(true)4 })5 it('can get organizations', () => {6 cy.getOrgs().then((orgs) => {7 expect(orgs).to.have.length(1)8 })9 })10})11Cypress.Commands.add('getOrgs', () => {12 return cy.request({13 headers: {14 },15 })16})17const getOrgs = (req) => {18 return req.reply({19 body: [{ id: 1, name: 'Cypress' }],20 })21}22module.exports = (on) => {23 on('task', {24 })25}26Cypress.Commands.add('getOrgs', () => {27 return cy.task('getOrgs')28})29Cypress.Commands.add('getOrgs', () => {30 return cy.request({31 headers: {32 },33 })34})35Cypress.Commands.add('getOrgs', () => {36 return cy.task('getOrgs')37})38const getOrgs = (req) => {39 return req.reply({40 body: [{ id: 1, name: 'Cypress' }],41 })42}43module.exports = (on) => {44 on('task', {45 })46}47Cypress.Commands.add('getOrgs', () => {48 return cy.task('getOrgs')49})50Cypress.Commands.add('getOrgs', () => {51 return cy.request({52 headers: {53 },54 })55})56Cypress.Commands.add('getOrgs', () => {57 return cy.task('getOrgs')58})

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypressOrgs = require('./cypressOrgs.js');2cypressOrgs.getOrgs().then((orgs) => {3 console.log(orgs);4});5const CypressOrgs = require('./cypressOrgs.js');6const cypressOrgs = new CypressOrgs();7cypressOrgs.getOrgs().then((orgs) => {8 console.log(orgs);9});10const cypressOrgs = new CypressOrgs();11cypressOrgs.getOrgs().then((orgs) => {12 console.log(orgs);13});14const cypressOrgs = new CypressOrgs();15cypressOrgs.getOrgs().then((orgs) => {16 console.log(orgs);17});18const cypressOrgs = new CypressOrgs();19cypressOrgs.getOrgs().then((orgs) => {20 console.log(orgs);21});22const cypressOrgs = new CypressOrgs();23cypressOrgs.getOrgs().then((orgs) => {24 console.log(orgs);25});26const cypressOrgs = new CypressOrgs();27cypressOrgs.getOrgs().then((orgs) => {28 console.log(orgs);29});30const cypressOrgs = new CypressOrgs();31cypressOrgs.getOrgs().then((orgs) => {32 console.log(orgs);33});34const cypressOrgs = new CypressOrgs();35cypressOrgs.getOrgs().then((orgs) => {36 console.log(orgs);

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.getOrgs().then((orgs) => {2})3Cypress.Commands.add('getOrgs', () => {4 cy.request({5 headers: {6 'Authorization': 'Bearer ' + Cypress.env('token'),7 },8 }).then((response) => {9 expect(response.status).to.eq(200)10 })11})

Full Screen

Using AI Code Generation

copy

Full Screen

1var orgs = Cypress.Api.getOrgs();2console.log(orgs);3Cypress.Commands.add('getOrgs', function () {4 return cy.request({5 })6})7import './commands'8describe('test', function () {9 it('test', function () {10 cy.getOrgs().then((response) => {11 console.log(response.body);12 })13 })14})15{16}17module.exports = (on, config) => {18 on('task', {19 log(message) {20 console.log(message)21 }22 })23}24Cypress.Commands.add('getOrgs', function () {25 return cy.request({26 })27})28describe('test', function () {29 it('test', function () {30 cy.getOrgs().then((response) => {31 console.log(response.body);32 })33 })34})35{36}37module.exports = (on, config) => {38 on('task', {39 log(message) {40 console.log(message)41 }42 })43}44Cypress.Commands.add('getOrgs', function () {45 return cy.request({46 })47})48describe('test', function () {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Test Cypress", () => {2 it("should get all organizations", () => {3 cy.getOrgs().then((response) => {4 expect(response.status).to.eq(200);5 expect(response.body).to.have.length(3);6 });7 });8});9Cypress.Commands.add("getOrgs", () => {10 return cy.request({11 headers: {12 },13 });14});15describe("Test Cypress", () => {16 it("should get all organizations", () => {17 cy.getOrgs().then((response) => {18 expect(response.status).to.eq(200);19 expect(response.body).to.have.length(3);20 });21 });22});23Cypress.Commands.add("getOrgs", () => {24 return cy.request({25 headers: {26 },27 });28});29describe("Test Cypress", () => {30 it("should get all organizations", () => {31 cy.getOrgs().then((response) => {32 expect(response.status).to.eq(200);33 expect(response.body).to.have.length(3);34 });35 });36});37Cypress.Commands.add("getOrgs", () => {38 return cy.request({39 headers: {40 },41 });42});43describe("Test Cypress", () => {44 it("should get all organizations", () => {45 cy.getOrgs().then((response) => {46 expect(response.status).to.eq(200);47 expect(response.body).to.have.length(3);48 });49 });50});51Cypress.Commands.add("getOrgs", () => {52 return cy.request({

Full Screen

Using AI Code Generation

copy

Full Screen

1var cypressAPI = require('./cypressAPI');2var getOrgs = cypressAPI.getOrgs;3getOrgs(function(err, orgs){4 if(err){5 console.log(err);6 }7 else{8 console.log(orgs);9 }10});11var request = require('request');12var getOrgs = function(callback){13 if(err){14 callback(err, null);15 }16 else{17 callback(null, body);18 }19 });20};21module.exports.getOrgs = getOrgs;22var cypressAPI = require('./cypressAPI');23var getOrgs = cypressAPI.getOrgs;24getOrgs().then(function(orgs){25 console.log(orgs);26}, function(err){27 console.log(err);28});29var request = require('request');30var getOrgs = function(){31 return new Promise(function(resolve, reject){32 if(err){33 reject(err);34 }35 else{36 resolve(body);37 }38 });39 });40};41module.exports.getOrgs = getOrgs;42var cypressAPI = require('./cypressAPI');43var getOrgs = cypressAPI.getOrgs;

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.getOrgs().then(function(orgs){2 console.log(orgs);3 for(var i=0;i<orgs.length;i++){4 console.log(orgs[i].name);5 }6});

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