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

[Backport 2.x] [CCI] Add bluebird replaces for src/plugins/saved_objects #4261

Merged
merged 2 commits into from
Jun 12, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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
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