-
-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added scripts for REACT_APP_BACKEND_WEBSOCKET_URL (#2350)
* Added scripts for talawa websocket url * Fixed naming inconsistency Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Fixed naming inconsistencies * Added error handling Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Improved test coverage * Fixed scripts for websocketurl * updated INSTALLATION.md * Updated logic to handle duplicate entries * Fixed errors * Added tests * Undo changes to .env.example * Chore/organization people UI changes (#2358) * changed color scheme for the organization people screen * fix precommit * merge * Update pre-commit * fix conflicts * fix type checks * fix type checks * fix type checks * fix ts eslint errors * fix ts eslint errors * fix ts eslint errors * fix ts eslint errors * testing * testing * testing * reverted changes in yaml file * cr comments * Update pull-request.yml * cr comments * cr comments and single css file * CR comments * delete button margin from top * prettier for commit and pull request * remove hard coded colors * fix failing test cases * Upgraded dicebear (#2411) --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Peter Harrison <[email protected]> Co-authored-by: ANKIT VARSHNEY <[email protected]>
- Loading branch information
1 parent
e8b49a4
commit 470be76
Showing
4 changed files
with
126 additions
and
55 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
38 changes: 38 additions & 0 deletions
38
src/setup/askForTalawaApiUrl/setupTalawaWebSocketUrl.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,38 @@ | ||
import fs from 'fs'; | ||
import inquirer from 'inquirer'; | ||
import { askForTalawaApiUrl } from './askForTalawaApiUrl'; | ||
|
||
jest.mock('fs'); | ||
jest.mock('inquirer', () => ({ | ||
prompt: jest.fn(), | ||
})); | ||
|
||
describe('WebSocket URL Configuration', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
test('should convert http URL to ws WebSocket URL', async () => { | ||
const endpoint = 'http://example.com/graphql'; | ||
const websocketUrl = endpoint.replace(/^http(s)?:\/\//, 'ws$1://'); | ||
|
||
expect(websocketUrl).toBe('ws://example.com/graphql'); | ||
}); | ||
|
||
test('should convert https URL to wss WebSocket URL', async () => { | ||
const endpoint = 'https://example.com/graphql'; | ||
const websocketUrl = endpoint.replace(/^http(s)?:\/\//, 'ws$1://'); | ||
|
||
expect(websocketUrl).toBe('wss://example.com/graphql'); | ||
}); | ||
|
||
test('should retain default WebSocket URL if no new endpoint is provided', async () => { | ||
jest | ||
.spyOn(inquirer, 'prompt') | ||
.mockResolvedValueOnce({ endpoint: 'http://localhost:4000/graphql/' }); | ||
await askForTalawaApiUrl(); | ||
|
||
const writeFileSyncSpy = jest.spyOn(fs, 'writeFileSync'); | ||
expect(writeFileSyncSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); |