Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 1f03f4f

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: fixing websocket and endpoint
1 parent defdfd4 commit 1f03f4f

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/hooks/useLoginUrl/__tests__/useLoginUrl.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as utils from '@site/src/utils';
55

66
jest
77
.spyOn(utils, 'getServerConfig')
8-
.mockReturnValue({ appId: '1234', serverUrl: 'test.binary.sx' });
8+
.mockReturnValue({ appId: '1234', serverUrl: 'test.binary.sx', oauth: 'test.oauth.sx' });
99

1010
describe('Use Login URL', () => {
1111
afterEach(() => {
@@ -23,7 +23,7 @@ describe('Use Login URL', () => {
2323

2424
expect(loginUrl).toContain('l=en');
2525
expect(utils.getServerConfig).toHaveBeenCalled();
26-
expect(loginUrl).toMatch('https://test.binary.sx/oauth2/authorize?app_id=1234&l=en');
26+
expect(loginUrl).toMatch('https://test.oauth.sx/oauth2/authorize?app_id=1234&l=en');
2727
expect(loginUrl).toMatch(/app_id=1234/);
2828
});
2929

@@ -37,7 +37,7 @@ describe('Use Login URL', () => {
3737

3838
expect(loginUrl).toContain('l=es');
3939
expect(utils.getServerConfig).toHaveBeenCalled();
40-
expect(loginUrl).toMatch('https://test.binary.sx/oauth2/authorize?app_id=1234&l=es');
40+
expect(loginUrl).toMatch('https://test.oauth.sx/oauth2/authorize?app_id=1234&l=es');
4141
expect(loginUrl).toMatch(/app_id=1234/);
4242
});
4343
});

src/hooks/useLoginUrl/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useCallback } from 'react';
33

44
const useLoginUrl = () => {
55
const getUrl = useCallback((language = 'en') => {
6-
const { appId, serverUrl } = getServerConfig();
7-
return generateLoginUrl(language, serverUrl, appId);
6+
const { appId, oauth } = getServerConfig();
7+
return generateLoginUrl(language, oauth, appId);
88
}, []);
99

1010
return { getUrl };

src/utils/__tests__/utils.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as utils from '@site/src/utils';
2-
import { LOCALHOST_APP_ID, VERCEL_DEPLOYMENT_APP_ID, OAUTH_URL } from '../constants';
2+
import {
3+
LOCALHOST_APP_ID,
4+
VERCEL_DEPLOYMENT_APP_ID,
5+
OAUTH_URL,
6+
DEFAULT_WS_SERVER,
7+
} from '../constants';
38
const {
49
getAccountsFromSearchParams,
510
getAppId,
@@ -157,7 +162,7 @@ describe('Get Server Config', () => {
157162
jest.spyOn(utils, 'getIsBrowser').mockReturnValueOnce(false);
158163
const serverConfig = getServerConfig();
159164
expect(serverConfig.appId).toEqual(VERCEL_DEPLOYMENT_APP_ID);
160-
expect(serverConfig.serverUrl).toEqual(OAUTH_URL);
165+
expect(serverConfig.serverUrl).toEqual(DEFAULT_WS_SERVER);
161166
});
162167
});
163168
describe('Given we are in Browser', () => {
@@ -166,7 +171,7 @@ describe('Get Server Config', () => {
166171
it('Should return default ws server url and vercel deployment appId in LOCALHOST ', () => {
167172
const serverConfig = getServerConfig();
168173
expect(serverConfig.appId).toEqual(LOCALHOST_APP_ID);
169-
expect(serverConfig.serverUrl).toEqual(OAUTH_URL);
174+
expect(serverConfig.serverUrl).toEqual(DEFAULT_WS_SERVER);
170175
});
171176
it('Should return serverUrl and appId from localstorage in production', () => {
172177
jest.spyOn(localStorage, 'getItem').mockReturnValueOnce('test.binary.sx');

src/utils/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
STAGING_APP_ID,
88
VERCEL_DEPLOYMENT_APP_ID,
99
OAUTH_URL,
10+
DEFAULT_WS_SERVER,
1011
} from './constants';
1112

1213
const CURRENCY_MAP = new Map([
@@ -130,18 +131,21 @@ export const getServerConfig = () => {
130131
return {
131132
serverUrl: config_server_url,
132133
appId: config_app_id,
134+
oauth: OAUTH_URL,
133135
};
134136
} else {
135137
const isLocalHost = isHost('localhost');
136138
return {
137-
serverUrl: OAUTH_URL,
139+
serverUrl: DEFAULT_WS_SERVER,
138140
appId: getAppId(isLocalHost),
141+
oauth: OAUTH_URL,
139142
};
140143
}
141144
} else {
142145
return {
143-
serverUrl: OAUTH_URL,
146+
serverUrl: DEFAULT_WS_SERVER,
144147
appId: getAppId(false),
148+
oauth: OAUTH_URL,
145149
};
146150
}
147151
};

0 commit comments

Comments
 (0)