HH-530: replace user-facing Chatwoot branding with GoChat (#117)
* fix(HH-530): replace user-facing Chatwoot branding * fix(HH-530): close branding review blockers * test(HH-530): cover update banner binding --------- Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -29,9 +29,13 @@ window.chatwootConfig = Object.assign(
|
||||
window.globalConfig = Object.assign(
|
||||
{
|
||||
INSTALLATION_NAME: 'GoChat',
|
||||
BRAND_NAME: 'GoChat',
|
||||
CREATE_NEW_ACCOUNT_FROM_DASHBOARD: false,
|
||||
DISPLAY_MANIFEST: false,
|
||||
LOGO_THUMBNAIL: '/favicon-32x32.png',
|
||||
LOGO: '/brand-assets/logo.svg',
|
||||
LOGO_DARK: '/brand-assets/logo_dark.svg',
|
||||
LOGO_THUMBNAIL: '/brand-assets/logo_thumbnail.svg',
|
||||
WIDGET_BRAND_URL: '/',
|
||||
},
|
||||
config.globalConfig || {}
|
||||
);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
|
||||
const customBrand = {
|
||||
INSTALLATION_NAME: 'Acme Support',
|
||||
BRAND_NAME: 'Acme',
|
||||
LOGO: '/acme/logo.svg',
|
||||
LOGO_DARK: '/acme/logo-dark.svg',
|
||||
LOGO_THUMBNAIL: '/acme/icon.svg',
|
||||
};
|
||||
|
||||
const initializeEntrypoint = filename => {
|
||||
const html = readFileSync(filename, 'utf8');
|
||||
const inlineScript = html.match(/<script>\s*([\s\S]*?)<\/script>/);
|
||||
const runtimeConfigIndex = html.indexOf('/runtime-config.js');
|
||||
|
||||
expect(runtimeConfigIndex).toBeGreaterThan(-1);
|
||||
expect(runtimeConfigIndex).toBeLessThan(inlineScript.index);
|
||||
|
||||
const entrypointWindow = {
|
||||
__GOCHAT_CONFIG__: { globalConfig: customBrand },
|
||||
location: { search: '' },
|
||||
};
|
||||
runInNewContext(inlineScript[1], {
|
||||
window: entrypointWindow,
|
||||
navigator: { userAgent: 'test' },
|
||||
URLSearchParams,
|
||||
localStorage: { getItem: () => null, setItem: () => {} },
|
||||
});
|
||||
return entrypointWindow.globalConfig;
|
||||
};
|
||||
|
||||
it.each(['widget.html', 'super_admin.html'])(
|
||||
'applies custom runtime branding in %s',
|
||||
filename => {
|
||||
expect(initializeEntrypoint(filename)).toMatchObject(customBrand);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user