-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat(eas-cli): Use a fallback generated name during EAS Submit #2842
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
168 changes: 168 additions & 0 deletions
168
packages/eas-cli/src/credentials/ios/appstore/__tests__/ensureAppExists-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,168 @@ | ||
import { Session } from '@expo/apple-utils'; | ||
import nock from 'nock'; | ||
|
||
import { createAppAsync } from '../ensureAppExists'; | ||
|
||
const FIXTURE_SUCCESS = { | ||
data: { | ||
type: 'apps', | ||
id: '6741087677', | ||
attributes: { | ||
name: 'expo (xxx)', | ||
bundleId: 'com.bacon.jan27.x', | ||
}, | ||
}, | ||
}; | ||
|
||
const FIXTURE_INVALID_NAME = { | ||
errors: [ | ||
{ | ||
id: 'b3e7ca18-e4ce-4e55-83ce-8fff35dbaeca', | ||
status: '409', | ||
code: 'ENTITY_ERROR.ATTRIBUTE.INVALID.INVALID_CHARACTERS', | ||
title: 'An attribute value has invalid characters.', | ||
detail: | ||
'App Name contains certain Unicode symbols, emoticons, diacritics, special characters, or private use characters that are not permitted.', | ||
source: { | ||
pointer: '/included/1/name', | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
const FIXTURE_ALREADY_USED_ON_ACCOUNT = { | ||
errors: [ | ||
{ | ||
id: 'b91aefc5-0e94-48d9-8613-5b1a464a20f0', | ||
status: '409', | ||
code: 'ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE.SAME_ACCOUNT', | ||
title: | ||
'The provided entity includes an attribute with a value that has already been used on this account.', | ||
detail: | ||
'The app name you entered is already being used for another app in your account. If you would like to use the name for this app you will need to submit an update to your other app to change the name, or remove it from App Store Connect.', | ||
source: { | ||
pointer: '/included/1/name', | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
const FIXTURE_ALREADY_USED_ON_ANOTHER_ACCOUNT = { | ||
errors: [ | ||
{ | ||
id: '72b960f2-9e51-4f19-8d83-7cc08d42fec4', | ||
status: '409', | ||
code: 'ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE.DIFFERENT_ACCOUNT', | ||
title: | ||
'The provided entity includes an attribute with a value that has already been used on a different account.', | ||
detail: | ||
'The App Name you entered is already being used. If you have trademark rights to this name and would like it released for your use, submit a claim.', | ||
source: { | ||
pointer: '/included/1/name', | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
const MOCK_CONTEXT = { | ||
providerId: 1337, | ||
teamId: 'test-team-id', | ||
token: 'test-token', | ||
}; | ||
|
||
beforeAll(async () => { | ||
// Mock setup cookies API calls. | ||
nock('https://appstoreconnect.apple.com') | ||
.get(`/olympus/v1/session`) | ||
.reply(200, { | ||
provider: { | ||
providerId: 1337, | ||
publicProviderId: 'xxx-xxx-xxx-xxx-xxx', | ||
name: 'Evan Bacon', | ||
contentTypes: ['SOFTWARE'], | ||
subType: 'INDIVIDUAL', | ||
}, | ||
}); | ||
|
||
await Session.fetchCurrentSessionInfoAsync(); | ||
}); | ||
|
||
function getNameFromBody(body: any): any { | ||
return body.included.find((item: any) => item.id === '${new-appInfoLocalization-id}')?.attributes | ||
?.name; | ||
} | ||
|
||
it('asserts invalid name cases', async () => { | ||
const scope = nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`, body => { | ||
expect(getNameFromBody(body)).toBe('Expo 🚀'); | ||
|
||
return true; | ||
}) | ||
.reply(409, FIXTURE_INVALID_NAME); | ||
|
||
// Already used on same account | ||
nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`, body => { | ||
expect(getNameFromBody(body)).toBe('Expo -'); | ||
return true; | ||
}) | ||
.reply(409, FIXTURE_ALREADY_USED_ON_ACCOUNT); | ||
|
||
// Already used on different account | ||
nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`, body => { | ||
expect(getNameFromBody(body)).toMatch(/Expo - \([\w\d]+\)/); | ||
return true; | ||
}) | ||
.reply(409, FIXTURE_ALREADY_USED_ON_ANOTHER_ACCOUNT); | ||
|
||
// Success | ||
nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`, body => { | ||
expect(getNameFromBody(body)).toMatch(/Expo - \([\w\d]+\)/); | ||
return true; | ||
}) | ||
.reply(200, FIXTURE_SUCCESS); | ||
|
||
await createAppAsync(MOCK_CONTEXT, { | ||
bundleId: 'com.bacon.jan27.x', | ||
name: 'Expo 🚀', | ||
companyName: 'expo', | ||
}); | ||
|
||
expect(scope.isDone()).toBeTruthy(); | ||
}); | ||
|
||
it('works on first try', async () => { | ||
nock('https://appstoreconnect.apple.com').post(`/iris/v1/apps`).reply(200, FIXTURE_SUCCESS); | ||
|
||
await createAppAsync(MOCK_CONTEXT, { | ||
bundleId: 'com.bacon.jan27.x', | ||
name: 'Expo', | ||
companyName: 'expo', | ||
}); | ||
}); | ||
|
||
it('doubles up entropy', async () => { | ||
nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`) | ||
.reply(409, FIXTURE_ALREADY_USED_ON_ANOTHER_ACCOUNT); | ||
|
||
nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`) | ||
.reply(409, FIXTURE_ALREADY_USED_ON_ANOTHER_ACCOUNT); | ||
|
||
nock('https://appstoreconnect.apple.com') | ||
.post(`/iris/v1/apps`, body => { | ||
expect(getNameFromBody(body)).toMatch(/Expo \([\w\d]+\) \([\w\d]+\)/); | ||
return true; | ||
}) | ||
.reply(200, FIXTURE_SUCCESS); | ||
|
||
await createAppAsync(MOCK_CONTEXT, { | ||
bundleId: 'com.bacon.jan27.x', | ||
name: 'Expo', | ||
companyName: 'expo', | ||
}); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We can try to validate this data against a scheme by using
zod
orjoi
instead of writing if statements manually