Skip to content

Commit 136258e

Browse files
committed
Fix new upstream tests
1 parent 493b222 commit 136258e

8 files changed

Lines changed: 54 additions & 17 deletions

app/test/helpers/mock-api.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ type APIMethodOverrides = {
2222
* ```
2323
*/
2424
export function createMockAPI(overrides: APIMethodOverrides = {}): API {
25-
const api = new API('https://api.github.com', 'mock-token-for-testing')
25+
const api = new API(
26+
'https://api.github.com',
27+
'mock-token-for-testing',
28+
'mock-login-for-testing'
29+
)
2630
const mockedMethods = new Set(Object.keys(overrides))
2731

2832
for (const [method, impl] of Object.entries(overrides)) {

app/test/unit/app-store-test-harness-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ describe('app-store-test-harness', () => {
4141
'test-user',
4242
getDotComAPIEndpoint(),
4343
'test-token',
44+
'',
45+
0,
4446
[],
4547
'',
4648
1,

app/test/unit/cloning-repositories-store-test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ describe('CloningRepositoriesStore', () => {
1414
const store = new CloningRepositoriesStore()
1515
const repo = new CloningRepository(
1616
'/tmp/test',
17-
'https://github.com/owner/repo.git'
17+
'https://github.com/owner/repo.git',
18+
null
1819
)
1920

2021
// Manually push to simulate the clone starting
@@ -29,7 +30,8 @@ describe('CloningRepositoriesStore', () => {
2930
const store = new CloningRepositoriesStore()
3031
const repo = new CloningRepository(
3132
'/tmp/test',
32-
'https://github.com/owner/repo.git'
33+
'https://github.com/owner/repo.git',
34+
null
3335
)
3436

3537
// Should not throw
@@ -43,7 +45,8 @@ describe('CloningRepositoriesStore', () => {
4345
const store = new CloningRepositoriesStore()
4446
const repo = new CloningRepository(
4547
'/tmp/test',
46-
'https://github.com/owner/repo.git'
48+
'https://github.com/owner/repo.git',
49+
null
4750
)
4851
assert.equal(store.getRepositoryState(repo), null)
4952
})
@@ -59,7 +62,8 @@ describe('CloningRepositoriesStore', () => {
5962

6063
const repo = new CloningRepository(
6164
'/tmp/test',
62-
'https://github.com/owner/repo.git'
65+
'https://github.com/owner/repo.git',
66+
null
6367
)
6468
store.remove(repo) // triggers emitUpdate
6569

app/test/unit/cloning-repository-test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ describe('CloningRepository', () => {
3939
it('generates unique IDs', () => {
4040
const firstRepository = new CloningRepository(
4141
'/tmp/a',
42-
'https://github.com/owner/a.git'
42+
'https://github.com/owner/a.git',
43+
null
4344
)
4445
const secondRepository = new CloningRepository(
4546
'/tmp/b',
46-
'https://github.com/owner/b.git'
47+
'https://github.com/owner/b.git',
48+
null
4749
)
4850

4951
assert.notEqual(firstRepository.id, secondRepository.id)
@@ -52,7 +54,8 @@ describe('CloningRepository', () => {
5254
it('generates a hash from the repository identity', () => {
5355
const repository = new CloningRepository(
5456
'/tmp/test',
55-
'https://github.com/owner/repo.git'
57+
'https://github.com/owner/repo.git',
58+
null
5659
)
5760

5861
assert.ok(repository.hash.length > 0)

app/test/unit/git/clone-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('git/clone', () => {
3131
const destPath = await createTempDirectory(t)
3232
const clonePath = path.join(destPath, 'cloned')
3333

34-
await clone(source.path, clonePath, {})
34+
await clone(source.path, clonePath, {}, null)
3535

3636
assert.equal(existsSync(path.join(clonePath, '.git')), true)
3737
assert.equal(existsSync(path.join(clonePath, 'README.md')), true)
@@ -56,7 +56,7 @@ describe('git/clone', () => {
5656
const destPath = await createTempDirectory(t)
5757
const clonePath = path.join(destPath, 'cloned')
5858

59-
await clone(source.path, clonePath, { branch: 'feature' })
59+
await clone(source.path, clonePath, { branch: 'feature' }, null)
6060

6161
// Verify the feature branch was checked out
6262
const result = await exec(['rev-parse', '--abbrev-ref', 'HEAD'], clonePath)
@@ -75,7 +75,7 @@ describe('git/clone', () => {
7575
const clonePath = path.join(destPath, 'cloned')
7676

7777
const progressEvents: Array<{ kind: string }> = []
78-
await clone(source.path, clonePath, {}, progress => {
78+
await clone(source.path, clonePath, {}, null, progress => {
7979
progressEvents.push({ kind: progress.kind })
8080
})
8181

@@ -104,7 +104,7 @@ describe('git/clone', () => {
104104
const destPath = await createTempDirectory(t)
105105
const clonePath = path.join(destPath, 'cloned')
106106

107-
await clone(source, clonePath, { defaultBranch: 'trunk' })
107+
await clone(source, clonePath, { defaultBranch: 'trunk' }, null)
108108

109109
assert.equal(existsSync(path.join(clonePath, '.git')), true)
110110

app/test/unit/ipc-contract-test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ describe('IPC channel contract', () => {
6969
'show-installing-update',
7070
'install-windows-cli',
7171
'uninstall-windows-cli',
72+
'open-repository-in-new-window',
73+
'set-window-title',
74+
'restart-app',
7275
] as const
7376

7477
const expectedResponseChannels = [
@@ -98,6 +101,8 @@ describe('IPC channel contract', () => {
98101
'show-notification',
99102
'get-notifications-permission',
100103
'request-notifications-permission',
104+
'update-main-process-config',
105+
'get-main-process-config',
101106
] as const
102107

103108
describe('RequestChannels', () => {

app/test/unit/model-type-guards-test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ function createGitHubRepository(): Repository {
1818
const owner = new Owner('owner', 'https://api.github.com', 1)
1919
const ghRepo = new GitHubRepository(
2020
'repo',
21+
'github',
2122
owner,
23+
null,
2224
1,
2325
false,
2426
'https://github.com/owner/repo',
@@ -35,7 +37,9 @@ function createForkedGitHubRepository(): Repository {
3537
const upstreamOwner = new Owner('upstream-owner', 'https://api.github.com', 1)
3638
const parentGhRepo = new GitHubRepository(
3739
'repo',
40+
'github',
3841
upstreamOwner,
42+
null,
3943
1,
4044
false,
4145
'https://github.com/upstream-owner/repo',
@@ -48,7 +52,9 @@ function createForkedGitHubRepository(): Repository {
4852
const forkOwner = new Owner('fork-owner', 'https://api.github.com', 2)
4953
const forkedGhRepo = new GitHubRepository(
5054
'repo',
55+
'github',
5156
forkOwner,
57+
null,
5258
2,
5359
false,
5460
'https://github.com/fork-owner/repo',

app/test/unit/sign-in-store-test.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ function createDotComAccount(login = 'octocat'): Account {
3131
login,
3232
getDotComAPIEndpoint(),
3333
'test-token',
34+
'',
35+
0,
3436
[],
3537
'https://avatars.githubusercontent.com/u/1',
3638
1,
@@ -43,7 +45,18 @@ function createEnterpriseAccount(
4345
login = 'enterprise-user',
4446
endpoint = 'https://github.example.com/api/v3'
4547
): Account {
46-
return new Account(login, endpoint, 'ent-token', [], '', 2, login, 'free')
48+
return new Account(
49+
login,
50+
endpoint,
51+
'ent-token',
52+
'',
53+
0,
54+
[],
55+
'',
56+
2,
57+
login,
58+
'free'
59+
)
4760
}
4861

4962
describe('SignInStore', () => {
@@ -74,7 +87,7 @@ describe('SignInStore', () => {
7487
}
7588
})
7689

77-
it('transitions to ExistingAccountWarning when a dotcom account exists', async () => {
90+
it('transitions to Authentication even if a dotcom account exists', async () => {
7891
const existingAccount = createDotComAccount()
7992
accountsStore = createAccountsStore()
8093
signInStore = new SignInStore(accountsStore)
@@ -84,7 +97,7 @@ describe('SignInStore', () => {
8497
signInStore.beginDotComSignIn()
8598
const state = signInStore.getState()
8699
assert.notEqual(state, null)
87-
assert.equal(state?.kind, SignInStep.ExistingAccountWarning)
100+
assert.equal(state?.kind, SignInStep.Authentication)
88101
})
89102

90103
it('calls resultCallback when provided', async () => {
@@ -171,7 +184,7 @@ describe('SignInStore', () => {
171184
}
172185
})
173186

174-
it('shows ExistingAccountWarning if enterprise account exists', async () => {
187+
it('shows Authentication even if enterprise account exists', async () => {
175188
const endpoint = 'https://github.example.com/api/v3'
176189
const existingAccount = createEnterpriseAccount('user', endpoint)
177190
accountsStore = createAccountsStore()
@@ -183,7 +196,7 @@ describe('SignInStore', () => {
183196
await signInStore.setEndpoint('https://github.example.com')
184197

185198
const state = signInStore.getState()
186-
assert.equal(state?.kind, SignInStep.ExistingAccountWarning)
199+
assert.equal(state?.kind, SignInStep.Authentication)
187200
})
188201
})
189202

0 commit comments

Comments
 (0)