Skip to content
Snippets Groups Projects
Commit 9180e37a authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

feat: added ecolyo links in custom popups

parent a2c62ebb
No related branches found
No related tags found
2 merge requests!10622.7 Release,!1018Resolve "[3] Mettre des liens vers les pages du service dans la modale custom"
import mockClient from 'tests/__mocks__/client.mock' import mockClient from 'tests/__mocks__/client.mock'
import { mockCustomPopup } from 'tests/__mocks__/customPopup.mock' import {
mockCustomPopup,
mockCustomPopupWithLink,
} from 'tests/__mocks__/customPopup.mock'
import CustomPopupService from './customPopup.service' import CustomPopupService from './customPopup.service'
jest.mock('services/environment.service', () => { jest.mock('services/environment.service', () => {
...@@ -17,6 +20,18 @@ describe('PartnersInfo service', () => { ...@@ -17,6 +20,18 @@ describe('PartnersInfo service', () => {
expect(result).toBe(mockCustomPopup) expect(result).toBe(mockCustomPopup)
}) })
it('should return customPopup data with replaced link', async () => {
mockClient
.getStackClient()
.fetchJSON.mockResolvedValueOnce(mockCustomPopupWithLink)
const result = await customPopupService.getCustomPopup()
expect(result).toStrictEqual({
...mockCustomPopupWithLink,
description:
'<p>Allez voir la page <a href="./#/ecogestures" target="_self">astuces</a> !!</p>',
})
})
it('should return an error', async () => { it('should return an error', async () => {
mockClient.getStackClient().fetchJSON.mockRejectedValue(new Error()) mockClient.getStackClient().fetchJSON.mockRejectedValue(new Error())
let res let res
......
...@@ -29,10 +29,12 @@ export default class CustomPopupService { ...@@ -29,10 +29,12 @@ export default class CustomPopupService {
: REMOTE_ORG_ECOLYO_AGENT_CUSTOM_POPUP_REC : REMOTE_ORG_ECOLYO_AGENT_CUSTOM_POPUP_REC
try { try {
logApp.info('[Initialization] Getting CustomPopup') logApp.info('[Initialization] Getting CustomPopup')
const result = await this._client const result: CustomPopup = await this._client
.getStackClient() .getStackClient()
.fetchJSON('GET', remoteUrl) .fetchJSON('GET', remoteUrl)
return result as CustomPopup
result.description = result.description.replace(/{cozyUrl}/g, './#/')
return result
} catch (error) { } catch (error) {
const errorMessage = `getCustomPopup: Failed to get custom popup:${JSON.stringify( const errorMessage = `getCustomPopup: Failed to get custom popup:${JSON.stringify(
error error
......
...@@ -7,6 +7,14 @@ export const mockCustomPopup: CustomPopup = { ...@@ -7,6 +7,14 @@ export const mockCustomPopup: CustomPopup = {
endDate: '2099-10-04T15:10:53.219+02:00', endDate: '2099-10-04T15:10:53.219+02:00',
} }
export const mockCustomPopupWithLink: CustomPopup = {
popupEnabled: true,
title: 'Bold title',
description:
'<p>Allez voir la page <a href="{cozyUrl}ecogestures" target="_self">astuces</a> !!</p>',
endDate: '2099-10-04T15:10:53.219+02:00',
}
export const mockCustomPopupOff: CustomPopup = { export const mockCustomPopupOff: CustomPopup = {
popupEnabled: false, popupEnabled: false,
title: '', title: '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment