-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[TS migration] Migrate GithubUtilsTest to typescript #36427
[TS migration] Migrate GithubUtilsTest to typescript #36427
Conversation
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.
Please check @octokit/*
and @actions/*
libraries that we use to see if we can reuse any types declared here.
tests/unit/GithubUtilsTest.ts
Outdated
PRList: Array<{ | ||
url: string; | ||
number: number; | ||
isVerified: boolean; | ||
}>; |
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 you extract this object into a separate type and use it here?
tests/unit/GithubUtilsTest.ts
Outdated
labels: Array<{ | ||
color: string; | ||
default: boolean; | ||
description: string; | ||
id: number; | ||
name: string; | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
node_id: string; | ||
url: 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.
Same
tests/unit/GithubUtilsTest.ts
Outdated
labels: Array<{ | ||
id: number; | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
node_id: string; | ||
url: string; | ||
name: string; | ||
color: string; | ||
default: boolean; | ||
description: 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.
Same
tests/unit/GithubUtilsTest.ts
Outdated
|
||
type Mutable<T> = {-readonly [P in keyof T]: T[P]}; | ||
|
||
const asMutable = <T>(value: T): Mutable<T> => value as Mutable<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.
Nice usage ❤️
beforeAll(() => { | ||
// Mock core module | ||
core.getInput = mockGetInput; | ||
asMutable(core).getInput = mockGetInput; | ||
|
||
// Mock octokit module | ||
const moctokit = { |
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.
Is possible to use a type from GitHub library 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.
I couldn't find a way to make the mock complaint with the GitHub lib typing.
There was too a lot of missing fields which we do not use on the unit test that needed to be populated and couldn't find a solution for all of them, the best way I think is to have GithubUtils correctly typed so this one would automatically get the correct types.
tests/unit/GithubUtilsTest.ts
Outdated
@@ -13,22 +13,28 @@ type DeployBlockers = { | |||
isResolved: boolean; | |||
}; | |||
|
|||
type PR = { |
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.
type PR = { | |
type PullRequest = { |
tests/unit/GithubUtilsTest.ts
Outdated
data: T; | ||
}; | ||
|
||
type Mutable<T> = {-readonly [P in keyof T]: T[P]}; |
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.
Maybe you can reuse Writable
type form type-fest lib
tests/unit/GithubUtilsTest.ts
Outdated
html_url: 'https://github.com/Expensify/App/pull/2', | ||
user: {login: 'testUser'}, | ||
labels: [], | ||
}, | ||
{ | ||
number: 3, | ||
title: 'Test PR 3', | ||
// eslint-disable-next-line @typescript-eslint/naming-convention |
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.
How about disabling it in whole file?
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
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.
Based on this conv, it seems that c+ does not need to review the migration of test files, so approve it. :)
cc @yuwenmemon
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25283 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
🚀 Deployed to staging by https://github.com/yuwenmemon in version: 1.4.44-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.44-13 🚀
|
Details
[TS migration] Migrate *GithubUtilsTest to TypeScript
Fixed Issues
$ #25283
PROPOSAL: N/A
Tests
Verify that no errors appear in the JS console
Run GithubUtilsTest unit test works as before
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