[No QA][TS migration] Migrate postTestBuildComment to typescript#37027
Conversation
|
|
||
| const mockGetInput = jest.fn(); | ||
| const mockCreateComment = jest.fn(); | ||
| const createCommentMock = jest.spyOn(GithubUtils, 'createComment'); |
There was a problem hiding this comment.
why this is changed?
There was a problem hiding this comment.
This was changed because we couldn't assign a jest.mock into GithubUtils.createComment, this way we mock the createComment correctly and avoid TS errors.
| :eyes: [View the workflow run that generated this build](https://github.com/Expensify/App/actions/runs/1234) :eyes: | ||
| `; | ||
|
|
||
| const asMutable = <T>(value: T): Writable<T> => value as Writable<T>; |
There was a problem hiding this comment.
I see you are creating this function in second PR , maybe its worth to move it to some utils folder?
There was a problem hiding this comment.
I agree, suggested the same in another PR
| when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue(12); | ||
| when(core.getInput) | ||
| .calledWith('PR_NUMBER', {required: true}) | ||
| .mockReturnValue(12 as unknown as string); |
There was a problem hiding this comment.
why number is casted to string?
There was a problem hiding this comment.
This is casted to string to comply with TS as the return type of code.getInput is a string and if we just change 12 to string the test is not passing, so this was the best solution I could find without changing the logic.
There was a problem hiding this comment.
Could we rename to asMutable.ts?
| when(core.getInput).calledWith('PR_NUMBER', {required: true}).mockReturnValue(12); | ||
| when(core.getInput) | ||
| .calledWith('PR_NUMBER', {required: true}) | ||
| .mockReturnValue(12 as unknown as string); |
There was a problem hiding this comment.
| .mockReturnValue(12 as unknown as string); | |
| .mockReturnValue('12'); |
See my next comment
| expect(GithubUtils.createComment).toBeCalledTimes(1); | ||
| expect(GithubUtils.createComment).toBeCalledWith('App', 12, message); | ||
| expect(createCommentMock).toBeCalledTimes(1); | ||
| expect(createCommentMock).toBeCalledWith('App', 12, message); |
There was a problem hiding this comment.
| expect(createCommentMock).toBeCalledWith('App', 12, message); | |
| expect(createCommentMock).toBeCalledWith('App', '12', message); |
With this change the test should pass correctly
…ub.com/ruben-rebelo/App into ts-migration/unit-postTestBuildComment
| import type {Writable} from 'type-fest'; | ||
|
|
||
| const asMutable = <T>(value: T): Writable<T> => value as Writable<T>; | ||
|
|
||
| export default asMutable; |
There was a problem hiding this comment.
asMutable is already on main, right? Let's sync main here
There was a problem hiding this comment.
Synced, thank you!
|
@paultsimura Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25296 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
🚀 Deployed to staging by https://github.com/jasperhuangg in version: 1.4.53-0 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.4.53-2 🚀
|
Details
[TS migration] Migrate *postTestBuildComment to TypeScript
Fixed Issues
$ #25296
PROPOSAL: N/A
Tests
Verify that no errors appear in the JS console
Run postTestBuildComment unit test should run successfully
Offline tests
N/A
QA Steps
Same as in the Tests section.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/a
Android: mWeb Chrome
N/a
iOS: Native
N/a
iOS: mWeb Safari
N/a
MacOS: Chrome / Safari
N/a
MacOS: Desktop
N/a