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/
90 lines
2.6 KiB
JavaScript
90 lines
2.6 KiB
JavaScript
import accountAPI from '../account';
|
|
import ApiClient from '../../ApiClient';
|
|
|
|
describe('#enterpriseAccountAPI', () => {
|
|
it('creates correct instance', () => {
|
|
expect(accountAPI).toBeInstanceOf(ApiClient);
|
|
expect(accountAPI).toHaveProperty('get');
|
|
expect(accountAPI).toHaveProperty('show');
|
|
expect(accountAPI).toHaveProperty('create');
|
|
expect(accountAPI).toHaveProperty('update');
|
|
expect(accountAPI).toHaveProperty('delete');
|
|
expect(accountAPI).toHaveProperty('checkout');
|
|
expect(accountAPI).toHaveProperty('toggleDeletion');
|
|
expect(accountAPI).toHaveProperty('createTopupCheckout');
|
|
expect(accountAPI).toHaveProperty('getLimits');
|
|
});
|
|
|
|
describe('API calls', () => {
|
|
const originalAxios = window.axios;
|
|
const axiosMock = {
|
|
post: vi.fn(() => Promise.resolve()),
|
|
get: vi.fn(() => Promise.resolve()),
|
|
patch: vi.fn(() => Promise.resolve()),
|
|
delete: vi.fn(() => Promise.resolve()),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
window.axios = axiosMock;
|
|
});
|
|
|
|
afterEach(() => {
|
|
window.axios = originalAxios;
|
|
});
|
|
|
|
it('#checkout', () => {
|
|
accountAPI.checkout();
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/checkout'
|
|
);
|
|
});
|
|
|
|
it('#subscription', () => {
|
|
accountAPI.subscription();
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/subscription'
|
|
);
|
|
});
|
|
|
|
it('#toggleDeletion with delete action', () => {
|
|
accountAPI.toggleDeletion('delete');
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/toggle_deletion',
|
|
{ action_type: 'delete' }
|
|
);
|
|
});
|
|
|
|
it('#toggleDeletion with undelete action', () => {
|
|
accountAPI.toggleDeletion('undelete');
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/toggle_deletion',
|
|
{ action_type: 'undelete' }
|
|
);
|
|
});
|
|
|
|
it('#createTopupCheckout with credits', () => {
|
|
accountAPI.createTopupCheckout(1000);
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/topup_checkout',
|
|
{ credits: 1000 }
|
|
);
|
|
});
|
|
|
|
it('#createTopupCheckout with different credit amounts', () => {
|
|
const creditAmounts = [1000, 2500, 6000, 12000];
|
|
creditAmounts.forEach(credits => {
|
|
accountAPI.createTopupCheckout(credits);
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/topup_checkout',
|
|
{ credits }
|
|
);
|
|
});
|
|
});
|
|
|
|
it('#getLimits', () => {
|
|
accountAPI.getLimits();
|
|
expect(axiosMock.get).toHaveBeenCalledWith('/enterprise/api/v1/limits');
|
|
});
|
|
});
|
|
});
|