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

[CCI] Add bluebird replaces for test/functional #4029

Closed

Conversation

Nicksqain
Copy link
Contributor

Description

Issues Resolved

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Alexei Karikov <karikov.alist.ru@gmail.com>
@codecov
Copy link

codecov bot commented May 15, 2023

Codecov Report

Merging #4029 (8cc0403) into main (69b1854) will increase coverage by 0.05%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #4029      +/-   ##
==========================================
+ Coverage   66.38%   66.43%   +0.05%     
==========================================
  Files        3229     3229              
  Lines       62067    62067              
  Branches     9598     9598              
==========================================
+ Hits        41201    41233      +32     
+ Misses      18557    18530      -27     
+ Partials     2309     2304       -5     
Flag Coverage Δ
Linux 66.37% <ø> (-0.01%) ⬇️
Windows 66.38% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 7 files with indirect coverage changes

@Nicksqain Nicksqain marked this pull request as ready for review May 16, 2023 16:00
@abbyhu2000 abbyhu2000 self-assigned this May 16, 2023
@abbyhu2000 abbyhu2000 added the OSCI Open Source Contributor Initiative label May 16, 2023
@ananzh ananzh assigned ananzh and unassigned abbyhu2000 May 31, 2023
@ananzh ananzh added v2.9.0 technical debt If not paid, jeapardizes long-term success and maintainability of the repository. backport 2.x labels May 31, 2023
Copy link
Member

@ananzh ananzh left a comment

Choose a reason for hiding this comment

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

@Nicksqain thank you for the contribute. If you need some help to understand when need to add await, let me know or go to office hour~

import expect from '@osd/expect';
// @ts-ignore
import fetch from 'node-fetch';
import { FtrProviderContext } from '../ftr_provider_context';
// @ts-ignore not TS yet
import getUrl from '../../../src/test_utils/get_url';

function delay(ms: number) {
Copy link
Member

Choose a reason for hiding this comment

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

As @AMoo-Miki mentioned in ur other PR, let's move delay func to @osd/utils

import { FtrProviderContext } from '../ftr_provider_context';

function delay(ms: number) {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above comment

copySaveObjectsElement,
};
});
return await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

await is not needed here. when you return a Promise from an async function, you don't need to use await.

inspectElement,
};
});
return await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

Again, we only need to use await within the async function passing to map because we need to wait for each Promise to resolve before we return an object with their resolved values. But when returning from an async function, we could just return the Promise directly without using await.

return await mapAsync(fieldNameCells, async (cell) => {
return (await cell.getVisibleText()).trim();
});
return await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

same issue as above

return await mapAsync(fieldNameCells, async (cell) => {
return (await cell.getVisibleText()).trim();
});
return await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

same issue

return await mapAsync(indexPatterns, async (index) => {
return await index.getVisibleText();
});
return await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

same here

@@ -55,6 +54,10 @@ const RETRY_CLICK_RETRY_ON_ERRORS = [
'StaleElementReferenceError',
];

function delay(ms: number) {
Copy link
Member

Choose a reason for hiding this comment

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

same issue

@Nicksqain
Copy link
Contributor Author

@Nicksqain thank you for the contribute. If you need some help to understand when need to add await, let me know or go to office hour~

Thanks for reviewing the code!
Yes, I realised that I should just return all the promises, which are already asynchronous, that's my mistake. I saw await in the old lines and typed await :[

@joshuarrrr joshuarrrr added the needs more info Requires more information from poster label Jun 13, 2023
@@ -193,53 +192,55 @@ export function SavedObjectsPageProvider({ getService, getPageObjects }: FtrProv

async getElementsInTable() {
const rows = await testSubjects.findAll('~savedObjectsTableRow');
Copy link
Member

Choose a reason for hiding this comment

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

Also I don't think we need await here as well, do we? As Promise.all() function already waits for all the promises to resolve before returning, it will not have to wait for the await keyword to resolve before continuing and that way might be bit more efficient.

@manasvinibs manasvinibs added v2.10.0 and removed v2.9.0 labels Jul 5, 2023
@abbyhu2000
Copy link
Member

Convert to draft for now, can be marked as ready once the comments are addressed. Thanks!

@abbyhu2000 abbyhu2000 marked this pull request as draft July 25, 2023 19:18
@ananzh
Copy link
Member

ananzh commented Jul 25, 2024

@Nicksqain Due to an extended period without updates, we're going to close this issue for now. We appreciate your contribution and understand that priorities and availability can change. Please feel free to reopen this issue when you have the opportunity to revisit it. Thank you for your understanding.

@ananzh ananzh closed this Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Requires more information from poster OSCI Open Source Contributor Initiative repeat-contributor technical debt If not paid, jeapardizes long-term success and maintainability of the repository.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eliminate Bluebird in favor of native async functionality
5 participants