Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sinon from 2.3.2 to 19.0.2 #35127

Merged
merged 8 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env mocha */

import $ from "jquery";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";

import asyncDownloader from "app_manager/js/download_async_modal";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "underscore";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";

import Toggles from "hqwebapp/js/toggles";
import FormWorkflow from "app_manager/js/forms/form_workflow";
Expand All @@ -8,9 +8,8 @@ describe('Form Workflow', function () {
var workflow;

describe('#workflowOptions', function () {
const sandbox = sinon.sandbox.create();

sandbox.stub(Toggles, 'toggleEnabled').withArgs('FORM_LINK_ADVANCED_MODE').returns(true);
sinon.stub(Toggles, 'toggleEnabled').withArgs('FORM_LINK_ADVANCED_MODE').returns(true);

beforeEach(function () {
var labels = {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from "jquery";
import _ from "underscore";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";

import initialPageData from "hqwebapp/js/initial_page_data";
import releasesModels from "app_manager/js/releases/releases";
Expand Down Expand Up @@ -58,7 +58,7 @@
releases.savedApps(getSavedApps(5, {}, releases));
});

afterEach(function () {

Check failure on line 61 in corehq/apps/app_manager/static/app_manager/spec/releases_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'afterEach' is not defined
ajaxStub.restore();
});

Expand Down Expand Up @@ -110,12 +110,12 @@
this.server.respondWith(
"GET",
new RegExp(savedAppModel.URL_TYPES.SHORT_ODK_MEDIA_URL),
[200, { "Content-type": "text/html" }, 'http://bit.ly/media/']

Check warning on line 113 in corehq/apps/app_manager/static/app_manager/spec/releases_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

Missing trailing comma
);
this.server.respondWith(
"GET",
new RegExp(savedAppModel.URL_TYPES.SHORT_ODK_URL),
[200, { "Content-type": "text/html" }, 'http://bit.ly/nomedia/']

Check warning on line 118 in corehq/apps/app_manager/static/app_manager/spec/releases_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

Missing trailing comma
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "underscore";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import moment from "moment";
import initialPageData from "hqwebapp/js/initial_page_data";
import constants from "cloudcare/js/form_entry/const";
Expand All @@ -11,7 +11,7 @@
var questionJSON,
spy;

before(function () {

Check failure on line 14 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/entries_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'before' is not defined
initialPageData.register(
"has_geocoder_privs",
true,
Expand All @@ -25,7 +25,7 @@
);
});

after(function () {

Check failure on line 28 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/entries_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'after' is not defined
initialPageData.unregister("toggles_dict");
});

Expand Down Expand Up @@ -55,7 +55,7 @@
this.clock = sinon.useFakeTimers(new Date("2020-03-15 15:41").getTime());
});

afterEach(function () {

Check failure on line 58 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/entries_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'afterEach' is not defined
$.unsubscribe();
this.clock.restore();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "underscore";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import initialPageData from "hqwebapp/js/initial_page_data";
import constants from "cloudcare/js/form_entry/const";
import formUI from "cloudcare/js/form_entry/form_ui";
Expand All @@ -13,7 +13,7 @@
nestedGroupJSON,
spy;

before(function () {

Check failure on line 16 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/form_ui_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'before' is not defined
initialPageData.register(
"toggles_dict",
{
Expand All @@ -23,7 +23,7 @@
);
});

after(function () {

Check failure on line 26 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/form_ui_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'after' is not defined
initialPageData.unregister("toggles_dict");
});

Expand Down Expand Up @@ -57,7 +57,7 @@

});

afterEach(function () {

Check failure on line 60 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/form_ui_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'afterEach' is not defined
$.unsubscribe();
this.clock.restore();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from "underscore";
import initialPageData from "hqwebapp/js/initial_page_data";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import constants from "cloudcare/js/form_entry/const";
import formUI from "cloudcare/js/form_entry/form_ui";

Expand All @@ -9,11 +9,11 @@
questionJSONMulti,
questionJSONString;

before(function () {

Check failure on line 12 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/integration_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'before' is not defined
initialPageData.register("toggles_dict", { WEB_APPS_ANCHORED_SUBMIT: false });
});

after(function () {

Check failure on line 16 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/integration_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'after' is not defined
initialPageData.unregister("toggles_dict");
});

Expand Down Expand Up @@ -70,7 +70,7 @@
this.clock = sinon.useFakeTimers();
});

afterEach(function () {

Check failure on line 73 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/spec/integration_spec.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'afterEach' is not defined
$.unsubscribe();
this.clock.restore();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import initialPageData from "hqwebapp/js/initial_page_data";
import constants from "cloudcare/js/form_entry/const";
import errors from "cloudcare/js/form_entry/errors";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import Debugger from "cloudcare/js/debugger/debugger";

describe('Debugger', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import FormplayerFrontend from "cloudcare/js/formplayer/app";
import hqEvents from "cloudcare/js/formplayer/hq_events";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import Backbone from "backbone";
import initialPageData from "hqwebapp/js/initial_page_data";
import FormplayerFrontend from "cloudcare/js/formplayer/app";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Backbone from "backbone";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import initialPageData from "hqwebapp/js/initial_page_data";
import Utils from "cloudcare/js/formplayer/utils/utils";
import QueryListView from "cloudcare/js/formplayer/menus/views/query";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import Middleware from "cloudcare/js/formplayer/middleware";

describe('SessionMiddle', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from "underscore";
import Backbone from "backbone";
import Marionette from "backbone.marionette";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import Toggles from "hqwebapp/js/toggles";
import FormplayerFrontend from "cloudcare/js/formplayer/app";
import API from "cloudcare/js/formplayer/menus/api";
Expand All @@ -13,36 +13,35 @@ import UsersModels from "cloudcare/js/formplayer/users/models";

describe('Split Screen Case Search', function () {
const currentUrl = new Utils.CloudcareUrl({ appId: 'abc123' }),
sandbox = sinon.sandbox.create(),
stubs = {};

before(function () {
sandbox.stub(Marionette.CollectionView.prototype, 'render').returns();
sandbox.stub(Utils, 'currentUrlToObject').callsFake(function () {
sinon.stub(Marionette.CollectionView.prototype, 'render').returns();
sinon.stub(Utils, 'currentUrlToObject').callsFake(function () {
return currentUrl;
});

sandbox.stub(Backbone.history, 'start').callsFake(sandbox.spy());
sandbox.stub(Backbone.history, 'getFragment').callsFake(function () {
sinon.stub(Backbone.history, 'start').callsFake(sinon.spy());
sinon.stub(Backbone.history, 'getFragment').callsFake(function () {
return JSON.stringify(currentUrl);
});
sandbox.stub(API, 'queryFormplayer').callsFake(FakeFormplayer.queryFormplayer);
sinon.stub(API, 'queryFormplayer').callsFake(FakeFormplayer.queryFormplayer);

stubs.regions = {};
FormplayerFrontend.regions = {
getRegion: function (region) {
if (!_.has(stubs.regions, region)) {
stubs.regions[region] = {
region: region,
show: sandbox.stub().callsFake(function () { return; }),
empty: sandbox.stub().callsFake(function () { return; }),
show: sinon.stub().callsFake(function () { return; }),
empty: sinon.stub().callsFake(function () { return; }),
};
}
return stubs.regions[region];
},
addRegions: function () { return; },
};
stubs.splitScreenToggleEnabled = sandbox.stub(Toggles, 'toggleEnabled').withArgs('SPLIT_SCREEN_CASE_SEARCH');
stubs.splitScreenToggleEnabled = sinon.stub(Toggles, 'toggleEnabled').withArgs('SPLIT_SCREEN_CASE_SEARCH');
});

beforeEach(function () {
Expand All @@ -54,11 +53,11 @@ describe('Split Screen Case Search', function () {
});

afterEach(function () {
sandbox.resetHistory();
sinon.resetHistory();
});

after(function () {
sandbox.restore();
sinon.restore();
});

describe('Controller actions', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "underscore";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import FormplayerFrontend from "cloudcare/js/formplayer/app";
import UsersCollections from "cloudcare/js/formplayer/users/collections";
import UsersModels from "cloudcare/js/formplayer/users/models";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from "underscore";
import Backbone from "backbone";
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import initialPageData from "hqwebapp/js/initial_page_data";
import FormplayerFrontend from "cloudcare/js/formplayer/app";
import API from "cloudcare/js/formplayer/menus/api";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import initialPageData from "hqwebapp/js/initial_page_data";
import hmacCallout from "integration/js/hmac_callout";
import markdown from "cloudcare/js/markdown";

describe('Markdown', function () {
let render = markdown.render;

let sandbox;
beforeEach(function () {
initialPageData.clear();
initialPageData.register("toggles_dict", { CASE_LIST_TILE_CUSTOM: false });
sandbox = sinon.sandbox.create();
});

afterEach(function () {
initialPageData.unregister("toggles_dict");
sandbox.restore();
sinon.restore();
});

describe('Markdown basics', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sinon from "sinon/pkg/sinon";
import sinon from "sinon";
import constants from "cloudcare/js/formplayer/constants";
import utils from "cloudcare/js/utils";

Expand Down
6 changes: 2 additions & 4 deletions corehq/apps/export/static/export/spec/ExportInstance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
hqDefine("export/spec/ExportInstance.spec", [
'jquery',
'underscore',
'sinon/pkg/sinon',
'sinon',
'hqwebapp/js/initial_page_data',
'export/js/const',
'export/js/models',
Expand Down Expand Up @@ -182,10 +182,8 @@ hqDefine("export/spec/ExportInstance.spec", [

beforeEach(function () {
instance = new viewModels.ExportInstance(basicFormExport);
recordSaveAnalyticsSpy = sinon.spy();
recordSaveAnalyticsSpy = sinon.stub(instance, 'recordSaveAnalytics'),
server = sinon.fakeServer.create();

sinon.stub(instance, 'recordSaveAnalytics', recordSaveAnalyticsSpy);
});

afterEach(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ hqDefine("hqwebapp/js/bootstrap3/hq.helpers", [
// Ignore HTTP methods that do not require CSRF protection
if (!/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type)) {
if (!this.crossDomain) {
var $csrfToken = $("#csrfTokenContainer").val();
xhr.setRequestHeader("X-CSRFToken", $csrfToken);
var csrfToken = $("#csrfTokenContainer").val();
if (csrfToken) {
xhr.setRequestHeader("X-CSRFToken", csrfToken);
}
}
var xsrfToken = $.cookie('XSRF-TOKEN');
xhr.setRequestHeader('X-XSRF-TOKEN', xsrfToken);
if (xsrfToken) {
xhr.setRequestHeader('X-XSRF-TOKEN', xsrfToken);
}
}
xhr.withCredentials = true;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ hqDefine("hqwebapp/js/bootstrap5/hq.helpers", [
// Ignore HTTP methods that do not require CSRF protection
if (!/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type)) {
if (!this.crossDomain) {
var $csrfToken = $("#csrfTokenContainer").val();
xhr.setRequestHeader("X-CSRFToken", $csrfToken);
var csrfToken = $("#csrfTokenContainer").val();
if (csrfToken) {
xhr.setRequestHeader("X-CSRFToken", csrfToken);
}
}
var xsrfToken = $.cookie('XSRF-TOKEN');
xhr.setRequestHeader('X-XSRF-TOKEN', xsrfToken);
if (xsrfToken) {
xhr.setRequestHeader('X-XSRF-TOKEN', xsrfToken);
}
}
xhr.withCredentials = true;
},
Expand Down
1 change: 0 additions & 1 deletion corehq/apps/hqwebapp/static/hqwebapp/js/hqModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function hqDefine(path, dependencies, moduleAccessor) {
'moment/moment': 'moment',
'crypto-js/crypto-js': 'CryptoJS',
'hqwebapp/js/lib/modernizr': 'Modernizr',
'sinon/pkg/sinon': 'sinon',
};
if (window.USE_BOOTSTRAP5) {
thirdPartyGlobals['es6!hqwebapp/js/bootstrap5_loader'] = 'bootstrap';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-hqDefine("notifications/spec/bootstrap3/NotificationsService.spec.mo", [
+hqDefine("notifications/spec/bootstrap5/NotificationsService.spec.mo", [
'jquery',
'sinon/pkg/sinon',
'sinon',
- 'notifications/js/bootstrap3/notifications_service',
+ 'notifications/js/bootstrap5/notifications_service',
], function (
Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/mocha/static/mocha/js/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
hqDefine("mocha/js/main", [
"mocha/mocha",
"chai/chai",
"sinon/pkg/sinon",
"sinon",
"analytix/js/google",
"analytix/js/kissmetrix",
], function (
Expand All @@ -9,7 +9,7 @@
chai,
sinon,
googleAnalytics,
kissAnalytics

Check warning on line 12 in corehq/apps/mocha/static/mocha/js/main.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

Missing trailing comma
) {
mocha.setup('bdd');
window.assert = chai.assert;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
hqDefine("notifications/spec/bootstrap3/NotificationsService.spec.mo", [
'jquery',
'sinon/pkg/sinon',
'sinon',
'notifications/js/bootstrap3/notifications_service',
], function (
$,
Expand Down Expand Up @@ -29,7 +29,7 @@ hqDefine("notifications/spec/bootstrap3/NotificationsService.spec.mo", [
};

var fakePromise = new FakePromise({});
sinon.stub($, 'ajax', fakePromise.mock);
sinon.stub($, 'ajax').callsFake(fakePromise.mock);

it('Initialization', function () {
var csrfToken = $("#csrfTokenContainer").val();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
hqDefine("notifications/spec/bootstrap5/NotificationsService.spec.mo", [
'jquery',
'sinon/pkg/sinon',
'sinon',
'notifications/js/bootstrap5/notifications_service',
], function (
$,
Expand Down Expand Up @@ -29,7 +29,7 @@ hqDefine("notifications/spec/bootstrap5/NotificationsService.spec.mo", [
};

var fakePromise = new FakePromise({});
sinon.stub($, 'ajax', fakePromise.mock);
sinon.stub($, 'ajax').callsFake(fakePromise.mock);

it('Initialization', function () {
var csrfToken = $("#csrfTokenContainer").val();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"mocha-headless-chrome": "4.0.0",
"prettier": "^3.3.3",
"prettier-plugin-jinja-template": "^2.0.0",
"sinon": "2.3.2"
"sinon": "19.0.2"
},
"engines": {
"yarn": ">= 1.0.0"
Expand Down
Loading