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

Fix part of #5002 remove GCS_RESOURCE_BUCKET_NAME from GLOBALS #7130

Merged
merged 23 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7e7435b
remove GCS_RESOURCE_BUCKET_NAME from GLOBALS
jameesjohn Jul 12, 2019
3c169e3
refactorings
jameesjohn Jul 12, 2019
a9b1b20
refactor test
jameesjohn Jul 12, 2019
5469744
work on failing FE test
jameesjohn Jul 12, 2019
f9d53ea
still on failing test
jameesjohn Jul 12, 2019
435c25a
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 14, 2019
5f95d2e
address review comments
jameesjohn Jul 15, 2019
f4d9ae3
address review comment
jameesjohn Jul 16, 2019
d79e4ba
remove unneeded initialize
jameesjohn Jul 17, 2019
197c774
address review comments
jameesjohn Jul 17, 2019
5345bdb
work on erroring backend test
jameesjohn Jul 17, 2019
3012216
work on failing tests
jameesjohn Jul 18, 2019
2efc78f
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 22, 2019
2ca6ff5
address review comments and made the service initialize itself
jameesjohn Jul 22, 2019
c28854c
address review comments
jameesjohn Jul 22, 2019
4d837e1
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 22, 2019
bcf0bec
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 22, 2019
f02a37c
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 22, 2019
5028a22
working on FE test
jameesjohn Jul 22, 2019
25470cf
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 23, 2019
c832832
address review comments
jameesjohn Jul 24, 2019
f82ad3b
Merge branch 'develop' of https://github.com/oppia/oppia into globals…
jameesjohn Jul 24, 2019
f6ee206
address review comments and work on failing backend test
jameesjohn Jul 24, 2019
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
/core/domain/storage_model_audit_jobs_test.py @ankita240796
/core/jobs*.py @seanlip
/core/platform/ @seanlip @DubeySandeep
/core/controllers/app_identity*.py @seanlip @DubeySandeep
/core/templates/dev/head/App*.ts @ankita240796
/core/templates/dev/head/app.constants.ts @ankita240796
/core/templates/dev/head/pages/interaction-specs.constants.ts @vojtechjelinek @Jamesjay4199
Expand Down
34 changes: 34 additions & 0 deletions core/controllers/app_identity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2019 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from core.controllers import acl_decorators
from core.controllers import base
from core.platform import models

import feconf

app_identity_services = models.Registry.import_app_identity_services()

class AppIdentityHandler(base.BaseHandler):
"""Provides app identity data."""

GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON

@acl_decorators.can_create_exploration
def get(self):
"""Handles GET requests."""
self.render_json({
'GCS_RESOURCE_BUCKET_NAME': (
app_identity_services.get_gcs_resource_bucket_name()),
})
jameesjohn marked this conversation as resolved.
Show resolved Hide resolved
46 changes: 46 additions & 0 deletions core/controllers/app_identity_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2019 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from constants import constants
from core.tests import test_utils

class AppIdentityHandlerTests(test_utils.GenericTestBase):
USERNAME_A = 'a'
EMAIL_A = 'a@example.com'

def setUp(self):
super(AppIdentityHandlerTests, self).setUp()
self.expected_application_id = test_utils.TestBase.EXPECTED_TEST_APP_ID
self.expected_bucket_name = (
'%s-resources' % self.expected_application_id)


def test_app_identity_handler(self):
"""Test returns correct app identity."""

self.signup(self.EMAIL_A, self.USERNAME_A)
self.login(self.EMAIL_A)

with self.swap(constants, 'DEV_MODE', False):
json_response = self.get_json('/appidentityhandler')
self.assertDictEqual({
"GCS_RESOURCE_BUCKET_NAME": self.expected_bucket_name
}, json_response)

with self.swap(constants, 'DEV_MODE', True):
json_response = self.get_json('/appidentityhandler')
self.assertDictEqual({
"GCS_RESOURCE_BUCKET_NAME": None
}, json_response)
self.logout()
1 change: 0 additions & 1 deletion core/templates/dev/head/pages/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
ADDITIONAL_ANGULAR_MODULES: JSON.parse(
'{{additional_angular_modules|js_string}}'),
status_code: JSON.parse('{{status_code}}'),
GCS_RESOURCE_BUCKET_NAME: JSON.parse('{{GCS_RESOURCE_BUCKET_NAME|js_string}}'),
jameesjohn marked this conversation as resolved.
Show resolved Hide resolved
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ oppia.directive('audioTranslationBar', [
$scope.unsavedAudioIsPlaying = false;
$scope.waveSurfer = null;

AssetsBackendApiService.initialize();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit icky that you're calling initialize() multiple times in a single file. Initialization of a service should be done at most once on an entire page.

Perhaps by initialize() you mean something else? Why should initialization ever need to happen twice (conceptually)?

document.body.onkeyup = function(e) {
if (e.code === 'KeyR' && !$scope.isAudioAvailable) {
// Used as shortcut key for recording
Expand Down Expand Up @@ -302,32 +303,34 @@ oppia.directive('audioTranslationBar', [
$scope.saveRecordedAudio = function() {
$scope.audioIsCurrentlyBeingSaved = true;
SiteAnalyticsService.registerSaveRecordedAudioEvent();
var filename = generateNewFilename();
var fileType = 'audio/mp3';
var contentId = $scope.contentId;
var languageCode = $scope.languageCode;
var recordedAudioFile = new File(
[$scope.audioBlob], filename, {type: fileType});
$scope.showRecorderWarning = false;
AssetsBackendApiService.saveAudio(
ContextService.getExplorationId(), filename,
recordedAudioFile).then(function() {
if ($scope.audioIsUpdating) {
StateRecordedVoiceoversService.displayed.deleteVoiceover(
contentId, languageCode);
$scope.audioIsUpdating = false;
}
StateRecordedVoiceoversService.displayed.addVoiceover(
contentId, languageCode, filename, recordedAudioFile.size);
saveRecordedVoiceoversChanges();
AlertsService.addSuccessMessage(
'Succesfuly uploaded recorded audio.');
$scope.audioIsCurrentlyBeingSaved = false;
$scope.initAudioBar();
}, function(errorResponse) {
$scope.audioIsCurrentlyBeingSaved = false;
AlertsService.addWarning(errorResponse.error);
$scope.initAudioBar();
AssetsBackendApiService.initialize().then(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we have to initialize the service every time, although I've initialized it in the begging. Can we move the GCS_RESOURCE_BUCKET_NAME check inside the saveAudio method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @DubeySandeep -- I'm surprised that you need to reinitialize this each time. That's a bit worrying and needs to be explained (or, ideally, removed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a leftover from a previous implementation.
Removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need similar changes for the image upload and retrieval?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this.
It has been removed.

var filename = generateNewFilename();
var fileType = 'audio/mp3';
var contentId = $scope.contentId;
var languageCode = $scope.languageCode;
var recordedAudioFile = new File(
[$scope.audioBlob], filename, {type: fileType});
$scope.showRecorderWarning = false;
AssetsBackendApiService.saveAudio(
ContextService.getExplorationId(), filename,
recordedAudioFile).then(function() {
if ($scope.audioIsUpdating) {
StateRecordedVoiceoversService.displayed.deleteVoiceover(
contentId, languageCode);
$scope.audioIsUpdating = false;
}
StateRecordedVoiceoversService.displayed.addVoiceover(
contentId, languageCode, filename, recordedAudioFile.size);
saveRecordedVoiceoversChanges();
AlertsService.addSuccessMessage(
'Succesfuly uploaded recorded audio.');
$scope.audioIsCurrentlyBeingSaved = false;
$scope.initAudioBar();
}, function(errorResponse) {
$scope.audioIsCurrentlyBeingSaved = false;
AlertsService.addWarning(errorResponse.error);
$scope.initAudioBar();
});
});
};
var toggleStartAndStopRecording = function() {
Expand Down Expand Up @@ -574,9 +577,11 @@ oppia.directive('audioTranslationBar', [
$scope.saveInProgress = true;
var explorationId = (
ContextService.getExplorationId());
AssetsBackendApiService.saveAudio(
explorationId, generatedFilename, uploadedFile
).then(function() {
AssetsBackendApiService.initialize().then(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove .initilize() here?

AssetsBackendApiService.saveAudio(
explorationId, generatedFilename, uploadedFile
);
}).then(function() {
$uibModalInstance.close({
languageCode: languageCode,
filename: generatedFilename,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ oppia.directive('audioBar', [
value: AudioTranslationLanguageService.getCurrentAudioLanguageCode()
};

AssetsBackendApiService.initialize();
$scope.$on(EVENT_AUTOPLAY_AUDIO, function(e, params) {
if ($scope.audioBarIsExpanded) {
AudioPlayerService.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require('pages/exploration-player-page/services/audio-preloader.service.ts');
require(
'pages/exploration-player-page/services/' +
'audio-translation-language.service.ts');
require('services/AssetsBackendApiService.ts');
require('services/ContextService.ts');

describe('Audio preloader service', function() {
Expand All @@ -44,7 +45,7 @@ describe('Audio preloader service', function() {
});
});

var aps, atls, eof, ecs;
var abas, aps, atls, eof, ecs;
var $httpBackend = null;
var UrlInterpolationService = null;
var $rootScope = null;
Expand All @@ -59,6 +60,8 @@ describe('Audio preloader service', function() {
ecs = $injector.get('ContextService');
spyOn(ecs, 'getExplorationId').and.returnValue('1');
$rootScope = $injector.get('$rootScope');
abas = $injector.get('AssetsBackendApiService');
abas.initialize();
explorationDict = {
id: 1,
title: 'My Title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ oppia.factory('AudioPreloaderService', [

var _init = function(exploration) {
_exploration = exploration;
AssetsBackendApiService.initialize()
};

var _getAudioFilenamesInBfsOrder = function(sourceStateName) {
Expand All @@ -67,9 +68,11 @@ oppia.factory('AudioPreloaderService', [
};

var _loadAudio = function(audioFilename) {
AssetsBackendApiService.loadAudio(
ContextService.getExplorationId(), audioFilename
).then(function(loadedAudio) {
AssetsBackendApiService.initialize().then(function() {
AssetsBackendApiService.loadAudio(
ContextService.getExplorationId(), audioFilename
);
}).then(function(loadedAudio) {
for (var i = 0;
i < _filenamesOfAudioCurrentlyDownloading.length; i++) {
if (_filenamesOfAudioCurrentlyDownloading[i] ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Image preloader service', function() {
eof = $injector.get('ExplorationObjectFactory');
ecs = $injector.get('ContextService');
abas = $injector.get('AssetsBackendApiService');
abas.initialize();
spyOn(ecs, 'getExplorationId').and.returnValue('1');
$rootScope = $injector.get('$rootScope');
explorationDict = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ oppia.factory('ImagePreloaderService', [
// attached with getInImageUrl method.
var _imageLoadedCallback = {};
var _hasImagePreloaderServiceStarted = false;
AssetsBackendApiService.initialize();

var _init = function(exploration) {
_exploration = exploration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
var GLOBALS = {
DEFAULT_OBJECT_VALUES: JSON.parse(
'{{DEFAULT_OBJECT_VALUES|js_string}}'),
GCS_RESOURCE_BUCKET_NAME: JSON.parse('{{GCS_RESOURCE_BUCKET_NAME|js_string}}'),
INTERACTION_SPECS: JSON.parse('{{INTERACTION_SPECS|js_string}}')
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
'{{additional_angular_modules|js_string}}'),
DEFAULT_OBJECT_VALUES: JSON.parse(
'{{DEFAULT_OBJECT_VALUES|js_string}}'),
GCS_RESOURCE_BUCKET_NAME: JSON.parse('{{GCS_RESOURCE_BUCKET_NAME|js_string}}'),
INTERACTION_SPECS: JSON.parse('{{INTERACTION_SPECS|js_string}}')
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
var GLOBALS = {
ADDITIONAL_ANGULAR_MODULES: JSON.parse(
'{{additional_angular_modules|js_string}}'),
GCS_RESOURCE_BUCKET_NAME: JSON.parse(
'{{GCS_RESOURCE_BUCKET_NAME|js_string}}'),
DEFAULT_OBJECT_VALUES: JSON.parse(
'{{DEFAULT_OBJECT_VALUES|js_string}}'),
INTERACTION_SPECS: JSON.parse('{{INTERACTION_SPECS|js_string}}'),
Expand Down
60 changes: 42 additions & 18 deletions core/templates/dev/head/services/AssetsBackendApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,52 @@ oppia.factory('AssetsBackendApiService', [
$http, $q, AudioFileObjectFactory, CsrfTokenService,
FileDownloadRequestObjectFactory, ImageFileObjectFactory,
UrlInterpolationService, DEV_MODE) {
if (!DEV_MODE && !GLOBALS.GCS_RESOURCE_BUCKET_NAME) {
throw Error('GCS_RESOURCE_BUCKET_NAME is not set in prod.');
}
var GCS_RESOURCE_BUCKET_NAME = null;
var ASSET_TYPE_AUDIO = 'audio';
var ASSET_TYPE_IMAGE = 'image';
var GCS_PREFIX = null;
var AUDIO_DOWNLOAD_URL_TEMPLATE = null;
var IMAGE_DOWNLOAD_URL_TEMPLATE = null;

// List of filenames that have been requested for but have
// yet to return a response.
var _audioFilesCurrentlyBeingRequested = [];
var _imageFilesCurrentlyBeingRequested = [];
var AUDIO_UPLOAD_URL_TEMPLATE =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to line 43.

'/createhandler/audioupload/<exploration_id>';

var ASSET_TYPE_AUDIO = 'audio';
var ASSET_TYPE_IMAGE = 'image';
var _initialize = function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for this new method/function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of what to test exactly, since this function is required for other functions to run, and it is made to run before each test so if it fails, other tests will fail.

if (DEV_MODE) {
// GCS_PREFIX = ('https://storage.googleapis.com/' +
// GCS_RESOURCE_BUCKET_NAME + '/exploration');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix is only used in PROD

AUDIO_DOWNLOAD_URL_TEMPLATE = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the file more carefully and I think I understand what the issue is. Now that we are fetching the bucket name asynchronously, you need to wait for that promise to resolve before you can actually do anything with regards to the assets.

I think the current approach is fraught, though. No developer is going to remember to call initialize() explicitly and there aren't really any rules for when it should be called. So this is not really maintainable, and that's why, typically, a service takes care of it's own initialization. The current approach is a bit scattershot and relies on other files telling this service when to initialize.

Instead, this service should still take care of its own initialization, but calls to this service should still always get the correct responses. Can you find a way to do this such that, if a (presumably async) call to serve stuff comes in when the GCS bucket data hasn't come in yet, that call gets served only when that data has come in? I think I saw a recent PR by you or @brianrodri that did something like this, but I can't remember which one it was -- IIRC it involved storing a promise in a local variable in the service and returning that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have refactored it to initialize itself and the other methods returns a promise which is fulfilled after the bucket name has been fetched.
PTAL.

'/assetsdevhandler/<exploration_id>/assets/audio/<filename>');
IMAGE_DOWNLOAD_URL_TEMPLATE = (
'/assetsdevhandler/<exploration_id>/assets/image/<filename>');
return $q.resolve();
}

var GCS_PREFIX = ('https://storage.googleapis.com/' +
GLOBALS.GCS_RESOURCE_BUCKET_NAME + '/exploration');
var AUDIO_DOWNLOAD_URL_TEMPLATE = (
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) +
'/<exploration_id>/assets/audio/<filename>');
var IMAGE_DOWNLOAD_URL_TEMPLATE = (
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) +
'/<exploration_id>/assets/image/<filename>');
if (GCS_RESOURCE_BUCKET_NAME) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are calling initialize() at the outset, wouldn't GCS_RESOURCE_BUCKET_NAME be null?

If you are not calling initialize() only at the outset, why call the method name "initialize"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize is called where the assets backend service is needed.
the check is done for caching purposes. On prod, after sending the request, the response is being cached and a further call to initialize shouldn't do anything again since the service has already been initialized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is messy. Initialization of a service should be done exactly once per page.

If you're exposing this method publicly for others to call, then you would need to raise an exception if it's called more than once.

return $q.resolve();
}

var AUDIO_UPLOAD_URL_TEMPLATE =
'/createhandler/audioupload/<exploration_id>';
$http.get('/appidentityhandler').then(function(response) {
if (!DEV_MODE && !response.data.GCS_RESOURCE_BUCKET_NAME) {
throw Error('GCS_RESOURCE_BUCKET_NAME is not set in prod.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think of it. Remove this if altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this if should be removed since it validated the result gotten from the handler

GCS_RESOURCE_BUCKET_NAME = response.data.GCS_RESOURCE_BUCKET_NAME;
}).then(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to chain the .then( here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No
Removed. Thanks.

GCS_PREFIX = ('https://storage.googleapis.com/' +
GCS_RESOURCE_BUCKET_NAME + '/exploration');
AUDIO_DOWNLOAD_URL_TEMPLATE = (
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to check DEV_MODE here? Shouldn't this be handled on line 51?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removed.

'/<exploration_id>/assets/audio/<filename>');
IMAGE_DOWNLOAD_URL_TEMPLATE = (
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) +
'/<exploration_id>/assets/image/<filename>');
return $q.resolve();
});
};

// Map from asset filename to asset blob.
var assetsCache = {};
Expand Down Expand Up @@ -87,9 +110,9 @@ oppia.factory('AssetsBackendApiService', [
}
} catch (exception) {
window.BlobBuilder = window.BlobBuilder ||
window.WebKitBlobBuilder ||
window.MozBlobBuilder ||
window.MSBlobBuilder;
window.WebKitBlobBuilder ||
window.MozBlobBuilder ||
window.MSBlobBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary. I think it is due to my editor formatting.
Removed.

if (exception.name === 'TypeError' && window.BlobBuilder) {
try {
var blobBuilder = new BlobBuilder();
Expand Down Expand Up @@ -235,6 +258,7 @@ oppia.factory('AssetsBackendApiService', [
};

return {
initialize: _initialize,
loadAudio: function(explorationId, filename) {
return $q(function(resolve, reject) {
if (_isCached(filename)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('Assets Backend API Service', function() {
$httpBackend = $injector.get('$httpBackend');
$rootScope = $injector.get('$rootScope');
$q = $injector.get('$q');

AssetsBackendApiService.initialize();
}));

afterEach(function() {
Expand Down
1 change: 0 additions & 1 deletion core/tests/build_sources/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
'{{additional_angular_modules|js_string}}'),
DEV_MODE: JSON.parse('{{DEV_MODE|js_string}}'),
status_code: JSON.parse('{{status_code}}'),
GCS_RESOURCE_BUCKET_NAME: JSON.parse('{{GCS_RESOURCE_BUCKET_NAME|js_string}}'),
isAdmin: JSON.parse('{{is_admin|js_string}}'),
isModerator: JSON.parse('{{is_moderator|js_string}}'),
isSuperAdmin: JSON.parse('{{is_super_admin|js_string}}'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ oppia.directive('oppiaInteractiveImageClickInput', [
ctrl.isLoadingIndicatorShown = false;
ctrl.isTryAgainShown = false;

AssetsBackendApiService.initialize();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be here... (and in the next file).

if (ImagePreloaderService.inExplorationPlayer()) {
ctrl.isLoadingIndicatorShown = true;
ctrl.dimensions = (
Expand Down
Loading