Copy the Chatwoot (v4.14.0) frontend runnable subset into frontend/ for customization: - app/javascript/ (Vue SPA: dashboard, widget, sdk, portal, superadmin) - app/views/ (ERB templates for vite-plugin-ruby entrypoint resolution) - app/helpers/, app/assets/ (Rails view helpers, static assets) - enterprise/ (Enterprise edition frontend overlay) - config/vite.json, vite.config.ts, bin/vite (Vite-Rails toolchain) - package.json, pnpm-lock.yaml, tailwind/postcss/eslint configs - Gemfile, Gemfile.lock (vite_rails gem for bin/vite binstub) Excluded Rails backend: controllers, models, services, jobs, mailers, policies, db, lib, spec, public, node_modules. Update references to the new frontend location: - .gitignore: exclude frontend build artifacts (node_modules, tmp, packs), keep frontend/bin/ and frontend/vendor/ via negation - backend/scripts/parity_frontend_smoke.sh: CHATWOOT_DIR default reference/chatwoot -> ../frontend - backend/scripts/parity_frontend_browser_smoke.mjs: same default update - AGENTS.md: add frontend section with Rails/Vite coupling notes - README: architecture tree includes frontend/
111 lines
3.2 KiB
JavaScript
111 lines
3.2 KiB
JavaScript
import {
|
|
buildLocaleMenuItems,
|
|
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');
|
|
});
|
|
});
|
|
|
|
describe('buildLocaleMenuItems', () => {
|
|
it('returns disabled actions for the default locale', () => {
|
|
expect(
|
|
buildLocaleMenuItems({
|
|
isDefault: true,
|
|
isDraft: false,
|
|
})
|
|
).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({ action: 'change-default', disabled: true }),
|
|
expect.objectContaining({ action: 'move-to-draft', disabled: true }),
|
|
expect.objectContaining({ action: 'delete', disabled: true }),
|
|
])
|
|
);
|
|
});
|
|
|
|
it('returns publish and delete actions for draft locales', () => {
|
|
expect(
|
|
buildLocaleMenuItems({
|
|
isDefault: false,
|
|
isDraft: true,
|
|
}).map(({ action }) => action)
|
|
).toEqual(['publish-locale', 'delete']);
|
|
});
|
|
|
|
it('returns default, draft, and delete actions for live locales', () => {
|
|
expect(
|
|
buildLocaleMenuItems({
|
|
isDefault: false,
|
|
isDraft: false,
|
|
}).map(({ action }) => action)
|
|
).toEqual(['change-default', 'move-to-draft', 'delete']);
|
|
});
|
|
});
|
|
});
|