Skip to content

Commit

Permalink
[Backport 2.x] [CCI] Add bluebird replaces for src/plugins/saved_obje…
Browse files Browse the repository at this point in the history
…cts (#4261)

* [CCI] Add bluebird replaces for src/plugins/saved_objects (#4026)

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

---------

Signed-off-by: Alexei Karikov <karikov.alist.ru@gmail.com>
(cherry picked from commit 55b293a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

* update changelog

Signed-off-by: Josh Romero <rmerqg@amazon.com>

---------

Signed-off-by: Josh Romero <rmerqg@amazon.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Josh Romero <rmerqg@amazon.com>
  • Loading branch information
3 people authored Jun 12, 2023
1 parent 3409412 commit 3363c09
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 @@ -90,6 +90,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple DataSource] Refactor dev tool console to use opensearch-js client to send requests ([#3544](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3544))
- [Multiple DataSource] Present the authentication type choices in a drop-down ([#3693](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3693))
- [Table Visualization] Move format table, consolidate types and add unit tests ([#3397](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3397))
- 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 3363c09

Please sign in to comment.