-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[No QA][TS migration] Migrate postTestBuildComment to typescript #37027
[No QA][TS migration] Migrate postTestBuildComment to typescript #37027
Conversation
import ghAction from '../../.github/actions/javascript/postTestBuildComment/postTestBuildComment'; | ||
import GithubUtils from '../../.github/libs/GithubUtils'; | ||
|
||
const mockGetInput = jest.fn(); | ||
const mockCreateComment = jest.fn(); | ||
const createCommentMock = jest.spyOn(GithubUtils, 'createComment'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this is changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
tests/unit/postTestBuildComment.ts
Outdated
@@ -49,15 +54,18 @@ const message = `:test_tube::test_tube: Use the links below to test this adhoc b | |||
: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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, suggested the same in another PR
tests/unit/postTestBuildComment.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why number is casted to string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/types/utils/AsMutable.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename to asMutable.ts
?
tests/unit/postTestBuildComment.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.mockReturnValue(12 as unknown as string); | |
.mockReturnValue('12'); |
See my next comment
tests/unit/postTestBuildComment.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
src/types/utils/asMutable.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asMutable
is already on main, right? Let's sync main here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No QA
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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