mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
import { buildPortalArticleURL, buildPortalURL } from '../portalHelper';
|
|
|
|
describe('PortalHelper', () => {
|
|
describe('buildPortalURL', () => {
|
|
it('returns the correct url', () => {
|
|
window.chatwootConfig = {
|
|
hostURL: 'https://app.chatwoot.com',
|
|
helpCenterURL: 'https://help.chatwoot.com',
|
|
};
|
|
expect(buildPortalURL('handbook')).toEqual(
|
|
'https://help.chatwoot.com/hc/handbook'
|
|
);
|
|
window.chatwootConfig = {};
|
|
});
|
|
});
|
|
|
|
describe('buildPortalArticleURL', () => {
|
|
it('returns the correct url', () => {
|
|
window.chatwootConfig = {
|
|
hostURL: 'https://app.chatwoot.com',
|
|
helpCenterURL: 'https://help.chatwoot.com',
|
|
};
|
|
expect(
|
|
buildPortalArticleURL('handbook', 'culture', 'fr', 'article-slug')
|
|
).toEqual('https://help.chatwoot.com/hc/handbook/articles/article-slug');
|
|
window.chatwootConfig = {};
|
|
});
|
|
|
|
it('returns the correct url with custom domain', () => {
|
|
window.chatwootConfig = {
|
|
hostURL: 'https://app.chatwoot.com',
|
|
helpCenterURL: 'https://help.chatwoot.com',
|
|
};
|
|
expect(
|
|
buildPortalArticleURL(
|
|
'handbook',
|
|
'culture',
|
|
'fr',
|
|
'article-slug',
|
|
'custom-domain.dev'
|
|
)
|
|
).toEqual('https://custom-domain.dev/hc/handbook/articles/article-slug');
|
|
});
|
|
|
|
it('handles https in custom domain correctly', () => {
|
|
window.chatwootConfig = {
|
|
hostURL: 'https://app.chatwoot.com',
|
|
helpCenterURL: 'https://help.chatwoot.com',
|
|
};
|
|
expect(
|
|
buildPortalArticleURL(
|
|
'handbook',
|
|
'culture',
|
|
'fr',
|
|
'article-slug',
|
|
'https://custom-domain.dev'
|
|
)
|
|
).toEqual('https://custom-domain.dev/hc/handbook/articles/article-slug');
|
|
});
|
|
|
|
it('uses hostURL when helpCenterURL is not available', () => {
|
|
window.chatwootConfig = {
|
|
hostURL: 'https://app.chatwoot.com',
|
|
helpCenterURL: '',
|
|
};
|
|
expect(
|
|
buildPortalArticleURL('handbook', 'culture', 'fr', 'article-slug')
|
|
).toEqual('https://app.chatwoot.com/hc/handbook/articles/article-slug');
|
|
});
|
|
});
|
|
});
|