Carry over pre-existing WABA outreach automation WIP

This work already existed uncommitted in the main working tree (not
authored by this branch) and is required as a runtime dependency for the
campaign outreach port (zpro-client, templates, outreach routes/UI). Copied
in as-is, untouched, so this feature branch has a working baseline; the
original uncommitted state in the main checkout is left exactly as it was.
This commit is contained in:
Gustavo
2026-08-01 10:12:25 -03:00
parent 0894ab68b3
commit 4f736562f3
33 changed files with 3537 additions and 342 deletions
+17 -1
View File
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { openDb, createLeadInserter, transaction, getSetting, setSetting, seedSegments, seedMunicipios, seedGeoCache, seedSettings } from '../src/db.mjs';
import { openDb, createLeadInserter, transaction, getSetting, setSetting, seedSegments, seedMunicipios, seedGeoCache, seedSettings, seedMessageTemplates, updateMessageTemplate } from '../src/db.mjs';
function sampleLead(overrides = {}) {
return {
@@ -90,6 +90,22 @@ test('settings: get/set e seed com defaults Z-PRO', () => {
db.close();
});
test('message_templates salva variaveis WABA automaticas por produto', () => {
const db = openDb(':memory:');
seedMessageTemplates(db, ['ERP']);
const updated = updateMessageTemplate(db, 'ERP', {
canal: 'oficial',
templateWabaNome: 'gti_inicio_atendimento_solicitado',
templateWabaIdioma: 'pt_BR',
templateWabaVariaveis: ['{empresa}', 'Assunto: {produto}', '']
});
assert.equal(updated.template_waba_nome, 'gti_inicio_atendimento_solicitado');
assert.deepEqual(JSON.parse(updated.template_waba_variaveis_json), ['{empresa}', 'Assunto: {produto}']);
db.close();
});
test('seeds de segments, municipios e geo_cache', () => {
const db = openDb(':memory:');