From 31be95e2a6a5353287ea3ad9ee54e0dd3dc37d3b Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 30 Oct 2024 19:30:07 +0100 Subject: [PATCH] test: Adjust `files_external` tests for password confirmation Signed-off-by: Ferdinand Thiessen --- apps/files_external/tests/js/settingsSpec.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js index 4032f6f6a37d4..354bf7c6b51e4 100644 --- a/apps/files_external/tests/js/settingsSpec.js +++ b/apps/files_external/tests/js/settingsSpec.js @@ -32,9 +32,16 @@ describe('OCA.Files_External.Settings tests', function() { var clock; var select2Stub; var select2ApplicableUsers; + var passwordConfirmationStub; - beforeEach(function() { + beforeAll(() => { clock = sinon.useFakeTimers(); + passwordConfirmationStub = sinon.stub(window.OC.PasswordConfirmation, 'requirePasswordConfirmation'); + passwordConfirmationStub.callsArg(0); + }) + + beforeEach(function() { + passwordConfirmationStub.resetHistory() select2ApplicableUsers = []; select2Stub = sinon.stub($.fn, 'select2').callsFake(function(args) { if (args === 'val') { @@ -236,6 +243,8 @@ describe('OCA.Files_External.Settings tests', function() { var $saveButton = $tr.find('td.save .icon-checkmark'); $saveButton.click(); + sinon.assert.calledOnce(passwordConfirmationStub); + expect(fakeServer.requests.length).toEqual(1); var request = fakeServer.requests[0]; expect(request.url).toEqual(OC.getRootPath() + '/index.php/apps/files_external/globalstorages'); @@ -270,6 +279,8 @@ describe('OCA.Files_External.Settings tests', function() { var $saveButton = $tr.find('td.save .icon-checkmark'); $saveButton.click(); + sinon.assert.calledOnce(passwordConfirmationStub); + expect(fakeServer.requests.length).toEqual(1); var request = fakeServer.requests[0]; expect(request.url).toEqual(OC.getRootPath() + '/index.php/apps/files_external/globalstorages');