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/
45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
import { sanitizeLabel } from '../sanitizeData';
|
|
|
|
describe('sanitizeLabel', () => {
|
|
it('should return an empty string when given an empty string', () => {
|
|
const label = '';
|
|
const sanitizedLabel = sanitizeLabel(label);
|
|
expect(sanitizedLabel).toEqual('');
|
|
});
|
|
|
|
it('should remove leading and trailing whitespace', () => {
|
|
const label = ' My Label ';
|
|
const sanitizedLabel = sanitizeLabel(label);
|
|
expect(sanitizedLabel).toEqual('my-label');
|
|
});
|
|
|
|
it('should convert all characters to lowercase', () => {
|
|
const label = 'My Label';
|
|
const sanitizedLabel = sanitizeLabel(label);
|
|
expect(sanitizedLabel).toEqual('my-label');
|
|
});
|
|
|
|
it('should replace spaces with hyphens', () => {
|
|
const label = 'My Label 123';
|
|
const sanitizedLabel = sanitizeLabel(label);
|
|
expect(sanitizedLabel).toEqual('my-label-123');
|
|
});
|
|
|
|
it('should remove any characters that are not alphanumeric, underscore, or hyphen', () => {
|
|
const label = 'My_Label!123';
|
|
const sanitizedLabel = sanitizeLabel(label);
|
|
expect(sanitizedLabel).toEqual('my_label123');
|
|
});
|
|
|
|
it('should handle null and undefined input', () => {
|
|
const nullLabel = null;
|
|
const undefinedLabel = undefined;
|
|
|
|
// @ts-ignore - intentionally passing null and undefined to test
|
|
const sanitizedNullLabel = sanitizeLabel(nullLabel);
|
|
const sanitizedUndefinedLabel = sanitizeLabel(undefinedLabel);
|
|
expect(sanitizedNullLabel).toEqual('');
|
|
expect(sanitizedUndefinedLabel).toEqual('');
|
|
});
|
|
});
|