mirror of
https://github.com/chatwoot/chatwoot.git
synced 2026-06-04 21:02:35 +08:00
Upgrades the frontend toolchain to Vite 6 and tidies up the build config along the way. Behavior is unchanged for end users; this is dev/build infra. ## What changed - `vite` 5.4 → 6.4, `@vitejs/plugin-vue` → 5.2, `vite-plugin-ruby` → 5.2 (with matching `vite_rails`/`vite_ruby` gem bumps). - Dropped the `vite-node` 2.0.1 pnpm override — no longer needed now that vitest 3 runs on Vite 6 directly. - Split the single `vite.config.ts` into: - `vite.config.ts` (app), `vite.lib.config.ts` (SDK), `vite.shared.ts` (aliases / Vue options), `vitest.config.ts` (tests). - `pnpm build:sdk` now selects the SDK config explicitly instead of branching on `BUILD_MODE=library`. SDK output path is unchanged (`public/packs/js/sdk.js`). No changes needed to Docker images, deployment scripts, or CI — Node 24 and pnpm 10 are already past Vite 6's floor, and the rake `assets:precompile` hook still drives the SDK build via `pnpm`. ## How to test - `pnpm dev` and verify the dashboard, widget, and survey routes load and HMR works. - Load a Chatwoot site widget on a test page and confirm `sdk.js` is served and the widget mounts. - `RAILS_ENV=production bundle exec rake assets:precompile` and confirm `public/packs/js/sdk.js` plus the rest of the manifest are produced. - `pnpm test` for the JS suite. --------- Co-authored-by: Sivin Varghese <[email protected]> Co-authored-by: Sony Mathew <[email protected]>
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
import { emitter } from 'shared/helpers/mitt';
|
|
import analyticsHelper from 'dashboard/helper/AnalyticsHelper';
|
|
import { useTrack, useAlert } from '../index';
|
|
|
|
vi.mock('shared/helpers/mitt', () => ({
|
|
emitter: {
|
|
emit: vi.fn(),
|
|
},
|
|
}));
|
|
|
|
vi.mock('dashboard/helper/AnalyticsHelper/index', async importOriginal => {
|
|
const actual = await importOriginal();
|
|
return {
|
|
...actual,
|
|
default: {
|
|
track: vi.fn(),
|
|
},
|
|
};
|
|
});
|
|
|
|
describe('useTrack', () => {
|
|
it('should call analyticsHelper.track and return a function', () => {
|
|
const eventArgs = ['event-name', { some: 'data' }];
|
|
useTrack(...eventArgs);
|
|
expect(analyticsHelper.track).toHaveBeenCalledWith(...eventArgs);
|
|
});
|
|
});
|
|
|
|
describe('useAlert', () => {
|
|
it('should emit a newToastMessage event with the provided message and action', () => {
|
|
const message = 'Toast message';
|
|
const action = {
|
|
type: 'link',
|
|
to: '/app/accounts/1/conversations/1',
|
|
message: 'Navigate',
|
|
};
|
|
useAlert(message, action);
|
|
expect(emitter.emit).toHaveBeenCalledWith('newToastMessage', {
|
|
message,
|
|
action,
|
|
});
|
|
});
|
|
|
|
it('should emit a newToastMessage event with the provided message and no action if action is null', () => {
|
|
const message = 'Toast message';
|
|
useAlert(message);
|
|
expect(emitter.emit).toHaveBeenCalledWith('newToastMessage', {
|
|
message,
|
|
action: null,
|
|
});
|
|
});
|
|
});
|