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:
Rogee
2026-08-23 18:14:02 +08:00
committed by GitHub
co-authored by rogee
parent a635be6dc8
commit 867092fd99
107 changed files with 343 additions and 237 deletions
@@ -33,7 +33,10 @@ export default {
brandRedirectURL() {
try {
const referrerHost = this.$store.getters['appConfig/getReferrerHost'];
const url = new URL(this.globalConfig.widgetBrandURL);
const url = new URL(
this.globalConfig.widgetBrandURL,
window.location.origin
);
if (referrerHost) {
url.searchParams.set('utm_source', referrerHost);
url.searchParams.set('utm_medium', 'widget');
@@ -24,38 +24,46 @@ describe('useBranding', () => {
});
describe('replaceInstallationName', () => {
it('should replace "Chatwoot" with installation name when both text and installation name are provided', () => {
it('should replace "GoChat" with the installation name', () => {
const { replaceInstallationName } = useBranding();
const result = replaceInstallationName('Welcome to Chatwoot');
const result = replaceInstallationName('Welcome to GoChat');
expect(result).toBe('Welcome to MyCompany');
});
it('should replace multiple occurrences of "Chatwoot"', () => {
it('should replace multiple occurrences of "GoChat"', () => {
const { replaceInstallationName } = useBranding();
const result = replaceInstallationName(
'Chatwoot is great! Use Chatwoot today.'
'GoChat is great! Use GoChat today.'
);
expect(result).toBe('MyCompany is great! Use MyCompany today.');
});
it('should preserve legacy Chatwoot placeholders for custom branding', () => {
const { replaceInstallationName } = useBranding();
expect(replaceInstallationName('Welcome to Chatwoot')).toBe(
'Welcome to MyCompany'
);
});
it('should return original text when installation name is not provided', () => {
mockGlobalConfig.value = {};
const { replaceInstallationName } = useBranding();
const result = replaceInstallationName('Welcome to Chatwoot');
const result = replaceInstallationName('Welcome to GoChat');
expect(result).toBe('Welcome to Chatwoot');
expect(result).toBe('Welcome to GoChat');
});
it('should return original text when globalConfig is not available', () => {
mockGlobalConfig.value = undefined;
const { replaceInstallationName } = useBranding();
const result = replaceInstallationName('Welcome to Chatwoot');
const result = replaceInstallationName('Welcome to GoChat');
expect(result).toBe('Welcome to Chatwoot');
expect(result).toBe('Welcome to GoChat');
});
it('should return original text when text is empty or null', () => {
@@ -88,7 +96,7 @@ describe('useBranding', () => {
};
const { replaceInstallationName } = useBranding();
const result = replaceInstallationName('Welcome to Chatwoot');
const result = replaceInstallationName('Welcome to GoChat');
expect(result).toBe('Welcome to My-Company & Co.');
});
@@ -7,9 +7,9 @@ import { useMapGetter } from 'dashboard/composables/store.js';
export function useBranding() {
const globalConfig = useMapGetter('globalConfig/get');
/**
* Replaces "Chatwoot" in text with the installation name from global config
* Replaces the default product name in text with the configured installation name
* @param {string} text - The text to process
* @returns {string} - Text with "Chatwoot" replaced by installation name
* @returns {string} - Text with the default product name replaced
*/
const replaceInstallationName = text => {
if (!text) return text;
@@ -17,7 +17,7 @@ export function useBranding() {
const installationName = globalConfig.value?.installationName;
if (!installationName) return text;
return text.replace(/Chatwoot/g, installationName);
return text.replace(/GoChat|Chatwoot/g, installationName);
};
return {
@@ -54,8 +54,8 @@ const state = {
export const getters = {
get: $state => $state,
isOnChatwootCloud: $state => $state.deploymentEnv === 'cloud',
isACustomBrandedInstance: $state => $state.installationName !== 'Chatwoot',
isAChatwootInstance: $state => $state.installationName === 'Chatwoot',
isACustomBrandedInstance: $state => $state.installationName !== 'GoChat',
isAChatwootInstance: $state => $state.installationName === 'GoChat',
};
export const actions = {};
@@ -0,0 +1,17 @@
import { getters } from '../globalConfig';
describe('globalConfig branding getters', () => {
it('treats GoChat as the default branded installation', () => {
const state = { installationName: 'GoChat' };
expect(getters.isACustomBrandedInstance(state)).toBe(false);
expect(getters.isAChatwootInstance(state)).toBe(true);
});
it('recognizes a custom installation name', () => {
const state = { installationName: 'Acme Support' };
expect(getters.isACustomBrandedInstance(state)).toBe(true);
expect(getters.isAChatwootInstance(state)).toBe(false);
});
});