-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate Crisp chatbot for immediate user support access. This enables real-time interaction, enhancing user experience by providing quick assistance.
- Loading branch information
Showing
10 changed files
with
120 additions
and
5 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
40 changes: 40 additions & 0 deletions
40
src/frontend/apps/impress/src/core/auth/__tests__/useAuthStore.test.tsx
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,40 @@ | ||
import { Crisp } from 'crisp-sdk-web'; | ||
import fetchMock from 'fetch-mock'; | ||
|
||
import { useAuthStore } from '../useAuthStore'; | ||
|
||
jest.mock('crisp-sdk-web', () => ({ | ||
...jest.requireActual('crisp-sdk-web'), | ||
Crisp: { | ||
isCrispInjected: jest.fn().mockReturnValue(true), | ||
setTokenId: jest.fn(), | ||
user: { | ||
setEmail: jest.fn(), | ||
}, | ||
session: { | ||
reset: jest.fn(), | ||
}, | ||
}, | ||
})); | ||
|
||
describe('useAuthStore', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
fetchMock.restore(); | ||
}); | ||
|
||
it('checks support session is terminated when logout', () => { | ||
window.$crisp = true; | ||
Object.defineProperty(window, 'location', { | ||
value: { | ||
...window.location, | ||
replace: jest.fn(), | ||
}, | ||
writable: true, | ||
}); | ||
|
||
useAuthStore.getState().logout(); | ||
|
||
expect(Crisp.session.reset).toHaveBeenCalled(); | ||
}); | ||
}); |
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
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,30 @@ | ||
/** | ||
* Configure Crisp chat for real-time support across all pages. | ||
*/ | ||
|
||
import { Crisp } from 'crisp-sdk-web'; | ||
|
||
import { User } from '@/core'; | ||
|
||
export const initializeCrispSession = (user: User) => { | ||
if (!Crisp.isCrispInjected()) { | ||
return; | ||
} | ||
Crisp.setTokenId(`impress-${user.id}`); | ||
Crisp.user.setEmail(user.email); | ||
}; | ||
|
||
export const configureCrispSession = (websiteId: string) => { | ||
if (Crisp.isCrispInjected()) { | ||
return; | ||
} | ||
Crisp.configure(websiteId); | ||
}; | ||
|
||
export const terminateCrispSession = () => { | ||
if (!Crisp.isCrispInjected()) { | ||
return; | ||
} | ||
Crisp.setTokenId(); | ||
Crisp.session.reset(); | ||
}; |
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 @@ | ||
export * from './Crisp'; |
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