Skip to content

Commit

Permalink
[CCI] Add bluebird replaces for src/plugins/saved_objects (opensearch…
Browse files Browse the repository at this point in the history
…-project#4026)

* Add bluebird replaces for src/plugins/saved_objects
* Add changelog entry

---------

Signed-off-by: Alexei Karikov <[email protected]>
  • Loading branch information
Nicksqain authored Jun 8, 2023
1 parent cb27336 commit 55b293a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fix EUI/OUI type errors ([#3798](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3798))
- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
- [Table Visualization] Remove custom styling for text-align:center in favor of OUI utility class. ([#4164](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4164))
- Replace the use of `bluebird` in `saved_objects` plugin ([#4026](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4026))

### 🔩 Tests

Expand Down
19 changes: 9 additions & 10 deletions src/plugins/saved_objects/public/saved_object/saved_object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* under the License.
*/

import Bluebird from 'bluebird';
import { createSavedObjectClass } from './saved_object';
import {
SavedObject,
Expand Down Expand Up @@ -76,16 +75,16 @@ describe('Saved Object', () => {
*/
function stubOpenSearchResponse(mockDocResponse: SimpleSavedObject<SavedObjectAttributes>) {
// Stub out search for duplicate title:
savedObjectsClientStub.get = jest.fn().mockReturnValue(Bluebird.resolve(mockDocResponse));
savedObjectsClientStub.update = jest.fn().mockReturnValue(Bluebird.resolve(mockDocResponse));
savedObjectsClientStub.get = jest.fn().mockReturnValue(Promise.resolve(mockDocResponse));
savedObjectsClientStub.update = jest.fn().mockReturnValue(Promise.resolve(mockDocResponse));

savedObjectsClientStub.find = jest
.fn()
.mockReturnValue(Bluebird.resolve({ savedObjects: [], total: 0 }));
.mockReturnValue(Promise.resolve({ savedObjects: [], total: 0 }));

savedObjectsClientStub.bulkGet = jest
.fn()
.mockReturnValue(Bluebird.resolve({ savedObjects: [mockDocResponse] }));
.mockReturnValue(Promise.resolve({ savedObjects: [mockDocResponse] }));
}

function stubSavedObjectsClientCreate(
Expand All @@ -94,7 +93,7 @@ describe('Saved Object', () => {
) {
savedObjectsClientStub.create = jest
.fn()
.mockReturnValue(resolve ? Bluebird.resolve(resp) : Bluebird.reject(resp));
.mockReturnValue(resolve ? Promise.resolve(resp) : Promise.reject(resp));
}

/**
Expand Down Expand Up @@ -193,7 +192,7 @@ describe('Saved Object', () => {
return createInitializedSavedObject({ type: 'dashboard', id: myId }).then((savedObject) => {
savedObjectsClientStub.create = jest.fn().mockImplementation(() => {
expect(savedObject.id).toBe(myId);
return Bluebird.resolve({ id: myId });
return Promise.resolve({ id: myId });
});
savedObject.copyOnSave = false;

Expand Down Expand Up @@ -227,7 +226,7 @@ describe('Saved Object', () => {
return createInitializedSavedObject({ type: 'dashboard', id }).then((savedObject) => {
savedObjectsClientStub.create = jest.fn().mockImplementation(() => {
expect(savedObject.isSaving).toBe(true);
return Bluebird.resolve({
return Promise.resolve({
type: 'dashboard',
id,
_version: 'foo',
Expand All @@ -246,7 +245,7 @@ describe('Saved Object', () => {
return createInitializedSavedObject({ type: 'dashboard' }).then((savedObject) => {
savedObjectsClientStub.create = jest.fn().mockImplementation(() => {
expect(savedObject.isSaving).toBe(true);
return Bluebird.reject('');
return Promise.reject();
});

expect(savedObject.isSaving).toBe(false);
Expand Down Expand Up @@ -681,7 +680,7 @@ describe('Saved Object', () => {
);
indexPattern.title = indexPattern.id!;
savedObject.searchSource!.setField('index', indexPattern);
return Bluebird.resolve(indexPattern);
return Promise.resolve(indexPattern);
});
expect(!!savedObject.searchSource!.getField('index')).toBe(false);

Expand Down

0 comments on commit 55b293a

Please sign in to comment.