Vendor Chatwoot Vue 3 frontend into frontend/

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/
This commit is contained in:
2026-07-07 14:56:01 +08:00
parent aeddedf2a3
commit 321c61aaae
5737 changed files with 945861 additions and 3 deletions
@@ -0,0 +1,84 @@
import { API } from 'widget/helpers/axios';
import { sendMessage } from 'widget/helpers/utils';
import { actions } from '../../contacts';
const commit = vi.fn();
const dispatch = vi.fn();
vi.mock('widget/helpers/axios');
vi.mock('widget/helpers/utils', () => ({
sendMessage: vi.fn(),
}));
describe('#actions', () => {
describe('#setUser', () => {
it('sends correct actions if contact object is refreshed ', async () => {
const user = {
email: 'thoma@sphadikam.com',
name: 'Adu Thoma',
avatar_url: '',
};
vi.spyOn(API, 'patch').mockResolvedValue({
data: { widget_auth_token: 'token' },
});
await actions.setUser({ commit, dispatch }, { identifier: 1, user });
expect(sendMessage.mock.calls).toEqual([
[{ data: { widgetAuthToken: 'token' }, event: 'setAuthCookie' }],
]);
expect(commit.mock.calls).toEqual([]);
expect(dispatch.mock.calls).toEqual([
['get'],
['conversation/clearConversations', {}, { root: true }],
['conversation/fetchOldConversations', {}, { root: true }],
['conversationAttributes/getAttributes', {}, { root: true }],
]);
});
it('sends correct actions if identifierHash is passed ', async () => {
const user = {
email: 'thoma@sphadikam.com',
name: 'Adu Thoma',
avatar_url: '',
identifier_hash: '12345',
};
vi.spyOn(API, 'patch').mockResolvedValue({ data: { id: 1 } });
await actions.setUser({ commit, dispatch }, { identifier: 1, user });
expect(sendMessage.mock.calls).toEqual([]);
expect(commit.mock.calls).toEqual([]);
expect(dispatch.mock.calls).toEqual([
['get'],
['conversation/clearConversations', {}, { root: true }],
['conversation/fetchOldConversations', {}, { root: true }],
['conversationAttributes/getAttributes', {}, { root: true }],
]);
});
it('does not call sendMessage if contact object is not refreshed ', async () => {
const user = {
email: 'thoma@sphadikam.com',
name: 'Adu Thoma',
avatar_url: '',
};
API.patch.mockResolvedValue({ data: { id: 1 } });
await actions.setUser({ commit, dispatch }, { identifier: 1, user });
expect(sendMessage.mock.calls).toEqual([]);
expect(commit.mock.calls).toEqual([]);
expect(dispatch.mock.calls).toEqual([['get']]);
});
});
describe('#update', () => {
it('sends correct actions', async () => {
const user = {
email: 'thoma@sphadikam.com',
name: 'Adu Thoma',
avatar_url: '',
identifier_hash: 'random_hex_identifier_hash',
};
API.patch.mockResolvedValue({ data: { id: 1 } });
await actions.update({ commit, dispatch }, { identifier: 1, user });
expect(commit.mock.calls).toEqual([]);
expect(dispatch.mock.calls).toEqual([['get']]);
});
});
});
@@ -0,0 +1,21 @@
import { getters } from '../../contacts';
describe('#getters', () => {
it('getCurrentUser', () => {
const user = {
has_email: true,
has_name: true,
avatar_url: '',
identifier_hash: 'malana_hash',
};
const state = {
currentUser: user,
};
expect(getters.getCurrentUser(state)).toEqual({
has_email: true,
has_name: true,
avatar_url: '',
identifier_hash: 'malana_hash',
});
});
});
@@ -0,0 +1,17 @@
import { mutations } from '../../contacts';
describe('#mutations', () => {
describe('#SET_CURRENT_USER', () => {
it('set current user', () => {
const user = {
has_email: true,
has_name: true,
avatar_url: '',
identifier_hash: 'malana_hash',
};
const state = { currentUser: {} };
mutations.SET_CURRENT_USER(state, user);
expect(state.currentUser).toEqual(user);
});
});
});