-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [eas-cli] Add tests Added tests for allowing to select in progress builds See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Allow in progress builds When prompting the user with a list of builds the in-progress builds are now returned first See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Adjust description When prompting the user with a list of builds the build status is now displayed let the user know which are finished and which are still in progress See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Reformat Adjusted formatting See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Reformat Adjusted formatting See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Lint fix lint --fix See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Add changelog Added the changelog entry since the bot does not seem to be working See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Return more statuses and sort Query returning the potential builds for submission now also returns build in `new` and `in-queue` statuses. All builds are then sorted decreasingly by `createdAt` and up to `limit` are returned See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Lint yarn lint --fix See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to * [eas-cli] Add mapping Created build status mapping instead string modification See: https://linear.app/expo/issue/ENG-10146/fr-add-option-to-trigger-auto-submit-while-waiting-for-build-to
- Loading branch information
1 parent
a7f939f
commit dadf58f
Showing
5 changed files
with
329 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
226 changes: 226 additions & 0 deletions
226
packages/eas-cli/src/submit/utils/__tests__/builds-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient'; | ||
import { | ||
AppPlatform, | ||
BuildFragment, | ||
BuildStatus, | ||
SubmissionArchiveSourceType, | ||
} from '../../../graphql/generated'; | ||
import { BuildQuery } from '../../../graphql/queries/BuildQuery'; | ||
import { getRecentBuildsForSubmissionAsync } from '../builds'; | ||
|
||
jest.mock('../../../graphql/queries/BuildQuery', () => ({ | ||
BuildQuery: { | ||
viewBuildsOnAppAsync: jest.fn(), | ||
}, | ||
})); | ||
|
||
const ARCHIVE_SOURCE = { | ||
type: SubmissionArchiveSourceType.Url, | ||
url: 'https://url.to/archive.tar.gz', | ||
}; | ||
|
||
const MOCK_BUILD_FRAGMENTS: Partial<BuildFragment>[] = Array(5).map(() => ({ | ||
id: uuidv4(), | ||
artifacts: { | ||
buildUrl: ARCHIVE_SOURCE.url, | ||
}, | ||
appVersion: '1.2.3', | ||
platform: AppPlatform.Android, | ||
updatedAt: Date.now(), | ||
createdAt: Date.now(), | ||
status: BuildStatus.Finished, | ||
})); | ||
const MOCK_IN_PROGRESS_BUILD_FRAGMENTS: Partial<BuildFragment>[] = Array(2).map(() => ({ | ||
id: uuidv4(), | ||
artifacts: { | ||
buildUrl: ARCHIVE_SOURCE.url, | ||
}, | ||
appVersion: '1.2.3', | ||
platform: AppPlatform.Android, | ||
updatedAt: Date.now(), | ||
createdAt: Date.now(), | ||
status: BuildStatus.InProgress, | ||
})); | ||
const MOCK_IN_QUEUE_BUILD_FRAGMENTS = Array(2).map(() => ({ | ||
id: uuidv4(), | ||
artifacts: { | ||
buildUrl: ARCHIVE_SOURCE.url, | ||
}, | ||
appVersion: '1.2.3', | ||
platform: AppPlatform.Android, | ||
updatedAt: Date.now(), | ||
createdAt: Date.now(), | ||
status: BuildStatus.InQueue, | ||
})); | ||
const MOCK_NEW_BUILD_FRAGMENTS = Array(1).map(() => ({ | ||
id: uuidv4(), | ||
artifacts: { | ||
buildUrl: ARCHIVE_SOURCE.url, | ||
}, | ||
appVersion: '1.2.3', | ||
platform: AppPlatform.Android, | ||
updatedAt: Date.now(), | ||
createdAt: Date.now(), | ||
status: BuildStatus.New, | ||
})); | ||
|
||
describe(getRecentBuildsForSubmissionAsync, () => { | ||
let graphqlClient: ExpoGraphqlClient; | ||
|
||
beforeEach(() => { | ||
graphqlClient = {} as any as ExpoGraphqlClient; | ||
}); | ||
|
||
it('returns finished builds', async () => { | ||
const appId = uuidv4(); | ||
const limit = 2; | ||
jest | ||
.mocked(BuildQuery.viewBuildsOnAppAsync) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce( | ||
MOCK_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
); | ||
|
||
const result = await getRecentBuildsForSubmissionAsync( | ||
graphqlClient, | ||
AppPlatform.Android, | ||
appId, | ||
{ limit } | ||
); | ||
|
||
expect(result).toMatchObject( | ||
MOCK_BUILD_FRAGMENTS.slice(0, Math.min(limit, MOCK_BUILD_FRAGMENTS.length)) | ||
); | ||
}); | ||
|
||
it('returns in-progress builds', async () => { | ||
const appId = uuidv4(); | ||
const limit = 2; | ||
jest | ||
.mocked(BuildQuery.viewBuildsOnAppAsync) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce( | ||
MOCK_IN_PROGRESS_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_IN_PROGRESS_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
) | ||
.mockResolvedValueOnce([] as BuildFragment[]); | ||
|
||
const result = await getRecentBuildsForSubmissionAsync( | ||
graphqlClient, | ||
AppPlatform.Android, | ||
appId, | ||
{ limit } | ||
); | ||
|
||
expect(result).toMatchObject( | ||
MOCK_IN_PROGRESS_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_IN_PROGRESS_BUILD_FRAGMENTS.length) | ||
) | ||
); | ||
}); | ||
|
||
it('returns in-queue builds', async () => { | ||
const appId = uuidv4(); | ||
const limit = 2; | ||
jest | ||
.mocked(BuildQuery.viewBuildsOnAppAsync) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce( | ||
MOCK_IN_QUEUE_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_IN_QUEUE_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce([] as BuildFragment[]); | ||
|
||
const result = await getRecentBuildsForSubmissionAsync( | ||
graphqlClient, | ||
AppPlatform.Android, | ||
appId, | ||
{ limit } | ||
); | ||
|
||
expect(result).toMatchObject( | ||
MOCK_IN_QUEUE_BUILD_FRAGMENTS.slice(0, Math.min(limit, MOCK_IN_QUEUE_BUILD_FRAGMENTS.length)) | ||
); | ||
}); | ||
|
||
it('returns new builds', async () => { | ||
const appId = uuidv4(); | ||
const limit = 2; | ||
jest | ||
.mocked(BuildQuery.viewBuildsOnAppAsync) | ||
.mockResolvedValueOnce( | ||
MOCK_NEW_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_NEW_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce([] as BuildFragment[]) | ||
.mockResolvedValueOnce([] as BuildFragment[]); | ||
|
||
const result = await getRecentBuildsForSubmissionAsync( | ||
graphqlClient, | ||
AppPlatform.Android, | ||
appId, | ||
{ limit } | ||
); | ||
|
||
expect(result).toMatchObject( | ||
MOCK_NEW_BUILD_FRAGMENTS.slice(0, Math.min(limit, MOCK_NEW_BUILD_FRAGMENTS.length)) | ||
); | ||
}); | ||
|
||
it('returns up to "limit" newest builds regardless of status', async () => { | ||
const appId = uuidv4(); | ||
const limit = 2; | ||
jest | ||
.mocked(BuildQuery.viewBuildsOnAppAsync) | ||
.mockResolvedValueOnce( | ||
MOCK_NEW_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_NEW_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
) | ||
.mockResolvedValueOnce( | ||
MOCK_IN_QUEUE_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_IN_QUEUE_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
) | ||
.mockResolvedValueOnce( | ||
MOCK_IN_PROGRESS_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_IN_PROGRESS_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
) | ||
.mockResolvedValueOnce( | ||
MOCK_BUILD_FRAGMENTS.slice( | ||
0, | ||
Math.min(limit, MOCK_BUILD_FRAGMENTS.length) | ||
) as BuildFragment[] | ||
); | ||
|
||
const result = await getRecentBuildsForSubmissionAsync( | ||
graphqlClient, | ||
AppPlatform.Android, | ||
appId, | ||
{ limit } | ||
); | ||
|
||
expect(result).toMatchObject([MOCK_NEW_BUILD_FRAGMENTS[0], MOCK_IN_QUEUE_BUILD_FRAGMENTS[1]]); | ||
}); | ||
}); |
Oops, something went wrong.