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,93 @@
import axios from 'axios';
import { actions } from '../../attributes';
import * as types from '../../../mutation-types';
import attributesList from './fixtures';
const commit = vi.fn();
global.axios = axios;
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
it('sends correct actions if API is success', async () => {
axios.get.mockResolvedValue({ data: attributesList });
await actions.get({ commit });
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isFetching: true }],
[types.default.SET_CUSTOM_ATTRIBUTE, attributesList],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isFetching: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.get.mockRejectedValue({ message: 'Incorrect header' });
await actions.get({ commit });
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isFetching: true }],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isFetching: false }],
]);
});
});
describe('#create', () => {
it('sends correct actions if API is success', async () => {
axios.post.mockResolvedValue({ data: attributesList[0] });
await actions.create({ commit }, attributesList[0]);
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isCreating: true }],
[types.default.ADD_CUSTOM_ATTRIBUTE, attributesList[0]],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isCreating: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.post.mockRejectedValue({ message: 'Incorrect header' });
await expect(actions.create({ commit })).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isCreating: true }],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isCreating: false }],
]);
});
});
describe('#update', () => {
it('sends correct actions if API is success', async () => {
axios.patch.mockResolvedValue({ data: attributesList[0] });
await actions.update({ commit }, attributesList[0]);
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isUpdating: true }],
[types.default.EDIT_CUSTOM_ATTRIBUTE, attributesList[0]],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isUpdating: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
await expect(
actions.update({ commit }, attributesList[0])
).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isUpdating: true }],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isUpdating: false }],
]);
});
});
describe('#delete', () => {
it('sends correct actions if API is success', async () => {
axios.delete.mockResolvedValue({ data: attributesList[0] });
await actions.delete({ commit }, attributesList[0].id);
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isDeleting: true }],
[types.default.DELETE_CUSTOM_ATTRIBUTE, attributesList[0].id],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isDeleting: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.delete.mockRejectedValue({ message: 'Incorrect header' });
await expect(
actions.delete({ commit }, attributesList[0].id)
).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isDeleting: true }],
[types.default.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isDeleting: false }],
]);
});
});
});
@@ -0,0 +1,16 @@
export default [
{
attribute_display_name: 'Language',
attribute_display_type: 1,
attribute_description: 'The conversation language',
attribute_key: 'language',
attribute_model: 0,
},
{
attribute_display_name: 'Language one',
attribute_display_type: 2,
attribute_description: 'The conversation language one',
attribute_key: 'language_one',
attribute_model: 1,
},
];
@@ -0,0 +1,80 @@
import { getters } from '../../attributes';
import attributesList from './fixtures';
describe('#getters', () => {
it('getAttributes', () => {
const state = { records: attributesList };
expect(getters.getAttributes(state)).toEqual([
{
attribute_display_name: 'Language',
attribute_display_type: 1,
attribute_description: 'The conversation language',
attribute_key: 'language',
attribute_model: 0,
},
{
attribute_display_name: 'Language one',
attribute_display_type: 2,
attribute_description: 'The conversation language one',
attribute_key: 'language_one',
attribute_model: 1,
},
]);
});
it('getAttributesByModel', () => {
const state = { records: attributesList };
expect(getters.getAttributesByModel(state)(1)).toEqual([
{
attribute_display_name: 'Language one',
attribute_display_type: 2,
attribute_description: 'The conversation language one',
attribute_key: 'language_one',
attribute_model: 1,
},
]);
});
it('getCompanyAttributes', () => {
const state = {
records: [
{
attribute_display_name: 'Industry',
attribute_display_type: 0,
attribute_description: 'Company industry',
attribute_key: 'industry',
attribute_model: 'company_attribute',
},
{
attribute_display_name: 'Language',
attribute_display_type: 1,
attribute_description: 'Conversation language',
attribute_key: 'language',
attribute_model: 'conversation_attribute',
},
],
};
expect(getters.getCompanyAttributes(state)).toEqual([
{
attributeDisplayName: 'Industry',
attributeDisplayType: 0,
attributeDescription: 'Company industry',
attributeKey: 'industry',
attributeModel: 'company_attribute',
},
]);
});
it('getUIFlags', () => {
const state = {
uiFlags: {
isFetching: true,
isCreating: false,
},
};
expect(getters.getUIFlags(state)).toEqual({
isFetching: true,
isCreating: false,
});
});
});
@@ -0,0 +1,44 @@
import types from '../../../mutation-types';
import { mutations } from '../../attributes';
import attributesList from './fixtures';
describe('#mutations', () => {
describe('#SET_CUSTOM_ATTRIBUTE', () => {
it('set attribute records', () => {
const state = { records: [] };
mutations[types.SET_CUSTOM_ATTRIBUTE](state, attributesList);
expect(state.records).toEqual(attributesList);
});
});
describe('#ADD_CUSTOM_ATTRIBUTE', () => {
it('push newly created attributes to the store', () => {
const state = { records: [attributesList[0]] };
mutations[types.ADD_CUSTOM_ATTRIBUTE](state, attributesList[1]);
expect(state.records).toEqual([attributesList[0], attributesList[1]]);
});
});
describe('#EDIT_CUSTOM_ATTRIBUTE', () => {
it('update attribute record', () => {
const state = { records: [attributesList[0]] };
mutations[types.EDIT_CUSTOM_ATTRIBUTE](state, {
attribute_display_name: 'Language',
attribute_display_type: 0,
attribute_description: 'The conversation language',
attribute_key: 'language',
attribute_model: 0,
});
expect(state.records[0].attribute_description).toEqual(
'The conversation language'
);
});
});
describe('#DELETE_CUSTOM_ATTRIBUTE', () => {
it('delete attribute record', () => {
const state = { records: [attributesList[0]] };
mutations[types.DELETE_CUSTOM_ATTRIBUTE](state, attributesList[0]);
expect(state.records).toEqual([attributesList[0]]);
});
});
});