Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/renderer/utils/auth/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
.spyOn(comms, 'openExternalLink')
.mockImplementation(vi.fn());

beforeEach(() => {
// Mock OAUTH_DEVICE_FLOW_CLIENT_ID value
Constants.OAUTH_DEVICE_FLOW_CLIENT_ID = 'mock-oauth-client-id' as ClientID;
});

afterEach(() => {
vi.clearAllMocks();
});

describe('performGitHubDeviceOAuth', () => {
beforeEach(() => {
// Mock OAUTH_DEVICE_FLOW_CLIENT_ID value
Constants.OAUTH_DEVICE_FLOW_CLIENT_ID = 'FAKE_CLIENT_ID_123' as ClientID;
});

it('should authenticate using device flow for GitHub app', async () => {
createDeviceCodeMock.mockResolvedValueOnce({
data: {
Expand All @@ -94,7 +94,7 @@

const token = await authUtils.performGitHubDeviceOAuth();

expect(createDeviceCodeMock).toHaveBeenCalledWith({

Check failure on line 97 in src/renderer/utils/auth/utils.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Run Tests

[happy-dom [preload, renderer]] src/renderer/utils/auth/utils.test.ts > renderer/utils/auth/utils.ts > performGitHubDeviceOAuth > should authenticate using device flow for GitHub app

AssertionError: expected "vi.fn()" to be called with arguments: [ { clientType: 'oauth-app', …(3) } ] Received: 1st vi.fn() call: @@ -1,10 +1,10 @@ [ { - "clientId": "FAKE_CLIENT_ID_123", + "clientId": "mock-oauth-client-id", "clientType": "oauth-app", - "request": Any<Function>, + "request": [Function newApi], "scopes": [ "read:user", "notifications", "repo", ], Number of calls: 1 ❯ src/renderer/utils/auth/utils.test.ts:97:36
clientType: 'oauth-app',
clientId: 'FAKE_CLIENT_ID_123',
scopes: Constants.OAUTH_SCOPES.RECOMMENDED,
Expand Down Expand Up @@ -432,7 +432,7 @@
method: 'GitHub App',
} as Account),
).toBe(
'https://github.com/settings/connections/applications/27a352516d3341cee376',
'https://github.com/settings/connections/applications/mock-oauth-client-id',
);

expect(
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/utils/auth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ export function getDeveloperSettingsURL(account: Account): Link {

switch (account.method) {
case 'GitHub App':
settingsURL.pathname =
'/settings/connections/applications/27a352516d3341cee376';
settingsURL.pathname = `/settings/connections/applications/${Constants.OAUTH_DEVICE_FLOW_CLIENT_ID}`;
break;
case 'OAuth App':
settingsURL.pathname = '/settings/developers';
Expand Down
Loading