@dev.smartpricing/message-composer-layer 5.0.0-automations.0 → 5.0.0-automations.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +2 -2
  2. package/app/api/meta.ts +36 -0
  3. package/app/components/Automations/ActionCard.vue +12 -1
  4. package/app/components/Automations/ActionEditor.vue +25 -3
  5. package/app/components/Automations/Actions.vue +8 -1
  6. package/app/components/Automations/CloneModal.vue +4 -0
  7. package/app/components/Automations/Conditions.vue +12 -3
  8. package/app/components/Automations/Create.vue +8 -0
  9. package/app/components/Automations/DeleteModal.vue +15 -3
  10. package/app/components/Automations/Edit.vue +10 -0
  11. package/app/components/Automations/Form.vue +3 -0
  12. package/app/components/Automations/List.vue +32 -5
  13. package/app/components/Automations/SaveProblems.vue +2 -0
  14. package/app/components/Composer/MessageLibrary.vue +8 -0
  15. package/app/components/Composer/WabaSelectModal.vue +1 -3
  16. package/app/components/MetaImport/Button.vue +50 -0
  17. package/app/components/MetaImport/Dialog.vue +261 -0
  18. package/app/components/MetaImport/Outcome.vue +136 -0
  19. package/app/components/MetaImport/ProposalList.vue +192 -0
  20. package/app/components/TemplateList/BaseTable.vue +22 -1
  21. package/app/composables/apiErrorMessages.ts +1 -0
  22. package/app/composables/composerContext.ts +3 -3
  23. package/app/composables/useMessageGroupWaba.ts +10 -7
  24. package/app/pages/automations/[id].vue +3 -1
  25. package/app/pages/automations/index.vue +2 -1
  26. package/app/pages/automations/new.vue +3 -1
  27. package/app/pages/index.vue +5 -1
  28. package/app/queries/messageGroups.ts +29 -20
  29. package/app/queries/meta.ts +91 -1
  30. package/app/stores/appContext.ts +1 -1
  31. package/app/utils/automations/form.ts +21 -0
  32. package/app/utils/testIds.const.ts +108 -0
  33. package/i18n/locales/de.ts +65 -0
  34. package/i18n/locales/en.ts +62 -0
  35. package/i18n/locales/es.ts +63 -0
  36. package/i18n/locales/fr.ts +64 -0
  37. package/i18n/locales/it.ts +66 -0
  38. package/package.json +2 -2
package/README.md CHANGED
@@ -85,14 +85,14 @@ watch(
85
85
  )
86
86
  ```
87
87
 
88
- **WABA.** The Host does not supply the WABA: the WABAs follow the Organization and the backend resolves them (ADR [0015](../../docs/adr/0015-message-group-waba-fixed-at-first-submission.md)). WhatsApp is configured when the Host's `channels` include `whatsapp` and the Organization has at least one WABA. A Message Group is submitted to one WABA, chosen at its first submission and fixed from then on; with several WABAs the user picks one when requesting approval. `metaWabaId` in the context is optional and is only the preselection in that picker.
88
+ **WABA.** The Host does not have to supply the WABA: the WABAs follow the Organization and the backend resolves them (ADR [0015](../../docs/adr/0015-message-group-waba-fixed-at-first-submission.md)). WhatsApp is configured when the Host's `channels` include `whatsapp` and the Organization has at least one WABA. A Message Group is submitted to one WABA, chosen at its first submission and fixed from then on; with several WABAs it is the `metaWabaId` the Host passed, when that is one of them, and otherwise the user picks one when requesting approval. `metaWabaId` in the context is optional.
89
89
 
90
90
  ### Upgrading to 4.5.0
91
91
 
92
92
  Nothing is required: a Host that keeps passing `organization_id` and `metaWabaId` behaves as before.
93
93
 
94
94
  - **Removed** from `ComposerContext` and from `AppContextConfig` in utils (no code read them): `authenticationToken`, `strategy`, `metaAccessToken`, `dinamicValues`. Remove them from the `defineComposerContext()` call. The utils types `AppContextState` and `ContextSource` are gone too.
95
- - **Changed**: `metaWabaId` no longer decides where a WhatsApp submission goes and is no longer required for the WhatsApp channel; it preselects the WABA when the user has to pick one.
95
+ - **Changed**: `metaWabaId` no longer decides where a WhatsApp submission goes and is no longer required for the WhatsApp channel; with several WABAs on the Organization it names the one a new Message Group is submitted to, and the user is asked only without it.
96
96
  - **Deprecated**, removed in 5.0.0: the `sm-organization-id` and `x-meta-waba-id` request headers. The layer no longer sends them; the backend still accepts them from Hosts on an older layer.
97
97
  - **New**: `organization_id` is optional, the Organization selector, `useEffectiveOrganization()`, and the `organizationId` and `wabaId` props of the Message Send Flow.
98
98
 
package/app/api/meta.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import type {
2
+ MetaImportCheck,
3
+ MetaImportConfirmBody,
4
+ MetaImportProposal,
5
+ MetaImportResult,
6
+ MetaImportScope,
2
7
  OrganizationWaba,
3
8
  SubmissionJob,
4
9
  SubmissionJobResponse,
@@ -8,7 +13,38 @@ import { apiClient } from './client'
8
13
 
9
14
  const submitBody = (wabaId?: string): SubmitToWabaBody => (wabaId ? { waba_id: wabaId } : {})
10
15
 
16
+ /** The Organization, Product and WABA of an Import, as a query string. */
17
+ const importQuery = ({ organization_id, product, waba_id }: MetaImportScope) =>
18
+ new URLSearchParams({ organization_id, product, waba_id }).toString()
19
+
11
20
  export const metaApi = {
21
+ /**
22
+ * How many Meta Templates of the WABA an Import would offer (ADR 0020). No
23
+ * error toast: it runs in the background of the list, and a failure only
24
+ * means no Import button.
25
+ */
26
+ checkImport: (scope: MetaImportScope) =>
27
+ apiClient<MetaImportCheck>(`/integrations/meta/import/check?${importQuery(scope)}`, {
28
+ _skipErrorToast: true,
29
+ } as Record<string, unknown>),
30
+
31
+ /**
32
+ * What an Import of the WABA would write, read from Meta now. Writes
33
+ * nothing. No error toast: the import dialog says itself that Meta could
34
+ * not be read (a 502).
35
+ */
36
+ getImportProposal: (scope: MetaImportScope) =>
37
+ apiClient<MetaImportProposal>(`/integrations/meta/import/proposal?${importQuery(scope)}`, {
38
+ _skipErrorToast: true,
39
+ } as Record<string, unknown>),
40
+
41
+ /** Confirms an Import: only Meta Template ids and how they are grouped. */
42
+ confirmImport: (body: MetaImportConfirmBody) =>
43
+ apiClient<MetaImportResult>('/integrations/meta/import', {
44
+ method: 'POST',
45
+ body,
46
+ }),
47
+
12
48
  /**
13
49
  * The WABAs of an Organization, empty when it has none (ADR 0015). No error
14
50
  * toast: a failed lookup leaves the WhatsApp configuration unknown, and the
@@ -121,6 +121,7 @@ const cannotBeActive = computed(
121
121
  size="sm"
122
122
  color="secondary"
123
123
  :label="t('automations.list.active')"
124
+ :data-testid="automationsTestIds.actionEnabledSwitch"
124
125
  @update:model-value="emit('toggle', $event)"
125
126
  />
126
127
  </span>
@@ -133,14 +134,23 @@ const cannotBeActive = computed(
133
134
  variant="ghost"
134
135
  size="sm"
135
136
  :label="t('common.actions.delete')"
137
+ :data-testid="automationsTestIds.actionDeleteButton"
136
138
  @click="emit('remove')"
137
139
  />
138
140
  <USlideover
139
141
  close-icon="ph:x"
142
+ :close="{ 'data-testid': automationsTestIds.previewSlideoverCloseButton }"
140
143
  :title="t('common.preview')"
144
+ :content="dialogTestId(automationsTestIds.previewSlideover)"
141
145
  :ui="{ content: 'max-w-2xl', body: 'p-0 sm:p-0' }"
142
146
  >
143
- <UButton color="primary" variant="outline" size="sm" :label="t('common.preview')" />
147
+ <UButton
148
+ color="primary"
149
+ variant="outline"
150
+ size="sm"
151
+ :label="t('common.preview')"
152
+ :data-testid="automationsTestIds.actionPreviewButton"
153
+ />
144
154
 
145
155
  <template #body>
146
156
  <CommonPreviewById
@@ -154,6 +164,7 @@ const cannotBeActive = computed(
154
164
  v-if="!readOnly"
155
165
  size="sm"
156
166
  :label="t('common.actions.edit')"
167
+ :data-testid="automationsTestIds.actionEditButton"
157
168
  @click="emit('edit')"
158
169
  />
159
170
  </div>
@@ -193,8 +193,10 @@ function save() {
193
193
  <USlideover
194
194
  v-model:open="open"
195
195
  close-icon="ph:x"
196
+ :close="{ 'data-testid': automationsTestIds.channelSlideoverCloseButton }"
196
197
  :title="isNew ? t('automations.channel.addTitle') : t('automations.channel.editTitle')"
197
198
  :ui="{ content: 'max-w-4xl', body: 'p-0 sm:p-0', footer: 'justify-end' }"
199
+ :content="dialogTestId(automationsTestIds.channelSlideover)"
198
200
  >
199
201
  <template #body>
200
202
  <div v-if="edited" class="grid grid-cols-2 h-full divide-muted divide-x">
@@ -211,6 +213,7 @@ function save() {
211
213
  :model-value="edited.channel"
212
214
  :items="channelOptions"
213
215
  class="w-full"
216
+ :data-testid="automationsTestIds.channelTypeSelect"
214
217
  @update:model-value="setChannel"
215
218
  />
216
219
  </UFormField>
@@ -246,6 +249,7 @@ function save() {
246
249
  size="sm"
247
250
  color="secondary"
248
251
  :label="t('automations.channel.createNew')"
252
+ :data-testid="automationsTestIds.channelCreateNewButton"
249
253
  @click="editMessage('create')"
250
254
  />
251
255
  <UButton
@@ -254,6 +258,7 @@ function save() {
254
258
  size="sm"
255
259
  color="secondary"
256
260
  :label="t('common.actions.edit')"
261
+ :data-testid="automationsTestIds.channelEditTemplateButton"
257
262
  @click="editMessage('edit')"
258
263
  />
259
264
  </p>
@@ -276,6 +281,7 @@ function save() {
276
281
  :min="0"
277
282
  :decrement="false"
278
283
  :increment="false"
284
+ :data-testid="automationsTestIds.channelDaysInput"
279
285
  />
280
286
  <UBadge color="neutral" variant="outline" size="sm">
281
287
  {{ t('automations.channel.chooseDays') }}
@@ -286,18 +292,28 @@ function save() {
286
292
  :model-value="dateReferenceValue(edited)"
287
293
  :items="dateReferenceOptions"
288
294
  class="w-full"
295
+ :data-testid="automationsTestIds.channelDateRefSelect"
289
296
  @update:model-value="setDateReference"
290
297
  />
291
298
  </div>
292
299
  </UFormField>
293
300
 
294
301
  <UFormField class="w-1/2 px-6" :label="t('automations.channel.sendingTime')">
295
- <USelect v-model="edited.sendingTimeUTC" :items="sendingTimeOptions" class="w-full" />
302
+ <USelect
303
+ v-model="edited.sendingTimeUTC"
304
+ :items="sendingTimeOptions"
305
+ class="w-full"
306
+ :data-testid="automationsTestIds.channelSendingTimeSelect"
307
+ />
296
308
  </UFormField>
297
309
 
298
310
  <USeparator />
299
311
 
300
- <UCollapsible v-model:open="advancedOpen" class="px-6">
312
+ <UCollapsible
313
+ v-model:open="advancedOpen"
314
+ class="px-6"
315
+ :data-testid="automationsTestIds.channelAdvancedCollapse"
316
+ >
301
317
  <UButton
302
318
  :label="t('automations.advanced')"
303
319
  color="neutral"
@@ -305,6 +321,7 @@ function save() {
305
321
  size="sm"
306
322
  :trailing-icon="advancedOpen ? 'ph:caret-up-bold' : 'ph:caret-down-bold'"
307
323
  block
324
+ :data-testid="automationsTestIds.channelAdvancedCollapseButton"
308
325
  />
309
326
 
310
327
  <template #content>
@@ -315,6 +332,7 @@ function save() {
315
332
  :items="recurrenceOptions"
316
333
  class="w-full"
317
334
  :disabled="edited.strictDelay"
335
+ :data-testid="automationsTestIds.channelRecurrenceSelect"
318
336
  @update:model-value="setRecurrence"
319
337
  />
320
338
  </UFormField>
@@ -323,6 +341,7 @@ function save() {
323
341
  :model-value="edited.strictDelay"
324
342
  :label="t('automations.strictDelay.label')"
325
343
  :description="t('automations.strictDelay.hint')"
344
+ :data-testid="automationsTestIds.channelStrictDelaySwitch"
326
345
  @update:model-value="setStrictDelay"
327
346
  />
328
347
 
@@ -330,6 +349,7 @@ function save() {
330
349
  v-model="edited.preventDuplicates"
331
350
  :label="t('automations.preventDuplicates.label')"
332
351
  :description="t('automations.preventDuplicates.hint')"
352
+ :data-testid="automationsTestIds.channelPreventDuplicatesSwitch"
333
353
  />
334
354
  </div>
335
355
  </template>
@@ -339,7 +359,7 @@ function save() {
339
359
  <div class="flex flex-col h-full p-6">
340
360
  <p class="label-lg mb-3">{{ t('automations.channel.preview') }}</p>
341
361
 
342
- <div class="flex-1">
362
+ <div class="flex-1" :data-testid="automationsTestIds.channelPreview">
343
363
  <CommonPreviewById
344
364
  v-if="edited.messageGroupId"
345
365
  :id="edited.messageGroupId"
@@ -363,12 +383,14 @@ function save() {
363
383
  color="neutral"
364
384
  variant="outline"
365
385
  :label="t('common.actions.cancel')"
386
+ :data-testid="automationsTestIds.channelSlideoverCancel"
366
387
  @click="open = false"
367
388
  />
368
389
  <UButton
369
390
  color="primary"
370
391
  :label="t('common.actions.save')"
371
392
  :disabled="!edited?.messageGroupId"
393
+ :data-testid="automationsTestIds.channelSlideoverSave"
372
394
  @click="save"
373
395
  />
374
396
  </template>
@@ -97,7 +97,11 @@ async function remove(action: AutomationFormAction) {
97
97
  :error="submitted && actions.length === 0 ? t('automations.form.required') : undefined"
98
98
  >
99
99
  <div class="space-y-4">
100
- <p v-if="actions.length === 0" class="paragraph-sm text-muted">
100
+ <p
101
+ v-if="actions.length === 0"
102
+ class="paragraph-sm text-muted"
103
+ :data-testid="automationsTestIds.actionsEmpty"
104
+ >
101
105
  {{ t('automations.form.actions.empty') }}
102
106
  </p>
103
107
 
@@ -111,6 +115,8 @@ async function remove(action: AutomationFormAction) {
111
115
  :unavailable="unavailable.get(action.key) ?? []"
112
116
  :invalid="invalidKeys?.includes(action.key)"
113
117
  :read-only="readOnly"
118
+ :data-testid="`${automationsTestIds.actionCard}-${action.key}`"
119
+ :data-testvalue="action.key"
114
120
  @edit="edit(action)"
115
121
  @remove="remove(action)"
116
122
  @toggle="toggle(action, $event)"
@@ -123,6 +129,7 @@ async function remove(action: AutomationFormAction) {
123
129
  variant="outline"
124
130
  :label="t('automations.actions.addChannel')"
125
131
  :disabled="channels.length === 0"
132
+ :data-testid="automationsTestIds.addChannelButton"
126
133
  @click="add"
127
134
  />
128
135
  </div>
@@ -39,6 +39,7 @@ async function confirmClone() {
39
39
  close-icon="ph:x"
40
40
  :close="{ disabled: cloning, onClick: () => emit('close') }"
41
41
  :dismissible="false"
42
+ :content="dialogTestId(automationsTestIds.cloneModal)"
42
43
  >
43
44
  <template #body>
44
45
  <UFormField :label="t('automations.form.name')">
@@ -48,6 +49,7 @@ async function confirmClone() {
48
49
  :disabled="cloning"
49
50
  autofocus
50
51
  class="w-full"
52
+ :data-testid="automationsTestIds.cloneModalNameInput"
51
53
  @keyup.enter="confirmClone"
52
54
  />
53
55
  </UFormField>
@@ -60,12 +62,14 @@ async function confirmClone() {
60
62
  color="neutral"
61
63
  :label="t('common.actions.cancel')"
62
64
  :disabled="cloning"
65
+ :data-testid="automationsTestIds.cloneModalCancel"
63
66
  @click="emit('close')"
64
67
  />
65
68
  <UButton
66
69
  :label="t('common.actions.duplicate')"
67
70
  :loading="cloning"
68
71
  :disabled="!trimmedName"
72
+ :data-testid="automationsTestIds.cloneModalConfirm"
69
73
  @click="confirmClone"
70
74
  />
71
75
  </div>
@@ -78,7 +78,7 @@ function save() {
78
78
  :label="t('automations.form.sendTotitle')"
79
79
  :description="t('automations.form.sendToHint')"
80
80
  >
81
- <div class="flex items-center gap-1">
81
+ <div class="flex items-center gap-1" :data-testid="automationsTestIds.sendToSummary">
82
82
  <p class="paragraph-sm text-primary-800">
83
83
  {{
84
84
  filterCount > 0
@@ -91,9 +91,11 @@ function save() {
91
91
  v-if="!readOnly"
92
92
  v-model:open="open"
93
93
  close-icon="ph:x"
94
+ :close="{ 'data-testid': automationsTestIds.filtersSlideoverCloseButton }"
94
95
  :title="t('automations.form.create_specific_audience')"
95
96
  :description="t('automations.form.create_specific_audience_hint')"
96
97
  :ui="{ content: 'max-w-4xl', footer: 'justify-end' }"
98
+ :content="dialogTestId(automationsTestIds.filtersSlideover)"
97
99
  >
98
100
  <UButton
99
101
  color="secondary"
@@ -101,6 +103,11 @@ function save() {
101
103
  size="sm"
102
104
  :icon="filterCount > 0 ? 'ph:pencil-simple-line-bold' : 'ph:plus-bold'"
103
105
  :label="filterCount > 0 ? t('common.actions.edit') : t('automations.form.addFilters')"
106
+ :data-testid="
107
+ filterCount > 0
108
+ ? automationsTestIds.editFiltersButton
109
+ : automationsTestIds.addFiltersButton
110
+ "
104
111
  />
105
112
 
106
113
  <template #body>
@@ -110,7 +117,7 @@ function save() {
110
117
  :fields="fields"
111
118
  :currency="currency"
112
119
  :title="t('automations.form.includeIf')"
113
- test-id-prefix="automation"
120
+ test-id-prefix="audience"
114
121
  @report="report = $event"
115
122
  />
116
123
  </template>
@@ -120,6 +127,7 @@ function save() {
120
127
  color="primary"
121
128
  variant="outline"
122
129
  :label="t('common.actions.cancel')"
130
+ :data-testid="automationsTestIds.filtersSlideoverCancel"
123
131
  @click="open = false"
124
132
  />
125
133
  <!-- A half-filled row is in no Condition: saving would drop it without a word. -->
@@ -127,6 +135,7 @@ function save() {
127
135
  color="primary"
128
136
  :label="t('common.actions.save')"
129
137
  :disabled="Boolean(report?.halfFilled)"
138
+ :data-testid="automationsTestIds.filtersSlideoverSave"
130
139
  @click="save"
131
140
  />
132
141
  </template>
@@ -138,7 +147,7 @@ function save() {
138
147
  :model-value="conditions"
139
148
  :fields="fields"
140
149
  :currency="currency"
141
- test-id-prefix="automation"
150
+ test-id-prefix="audience"
142
151
  class="mt-3"
143
152
  @report="emit('report', $event)"
144
153
  />
@@ -7,6 +7,7 @@ import { resolveErrorToast } from '~/composables/apiErrorMessages'
7
7
  import type { AutomationsContext } from '~/composables/automationsContext'
8
8
  import { useCreateAutomationMutation } from '~/queries'
9
9
  import {
10
+ automationEngineRejected,
10
11
  automationSaveProblems,
11
12
  automationSetupProperties,
12
13
  cloneFormData,
@@ -60,8 +61,15 @@ async function submit() {
60
61
  created = await createAutomation(toCreateAutomationBody(sent))
61
62
  } catch (error) {
62
63
  const refused = automationSaveProblems(error)
64
+ const rejected = automationEngineRejected(error)
63
65
  if (refused) {
64
66
  problems.show(refused, sent)
67
+ } else if (rejected !== undefined) {
68
+ toast.add({
69
+ title: t('automations.toast.engine_rejected'),
70
+ description: rejected,
71
+ color: 'error',
72
+ })
65
73
  } else {
66
74
  // The request carries no error toast of its own, so a 422 gets none.
67
75
  const { data, status = 0 } = error as { data?: { code?: string }; status?: number }
@@ -36,9 +36,20 @@ async function confirmDelete() {
36
36
 
37
37
  <template>
38
38
  <SConfirmModal
39
- :modal-props="{ title: t('automations.delete.title') }"
40
- :confirm-props="{ label: t('common.actions.delete'), disabled: isPending }"
41
- :cancel-props="{ label: t('common.actions.cancel') }"
39
+ :modal-props="{
40
+ title: t('automations.delete.title'),
41
+ close: { 'data-testid': automationsTestIds.deleteModalCloseButton },
42
+ content: dialogTestId(automationsTestIds.deleteModal),
43
+ }"
44
+ :confirm-props="{
45
+ label: t('common.actions.delete'),
46
+ disabled: isPending,
47
+ 'data-testid': automationsTestIds.deleteModalConfirm,
48
+ }"
49
+ :cancel-props="{
50
+ label: t('common.actions.cancel'),
51
+ 'data-testid': automationsTestIds.deleteModalCancel,
52
+ }"
42
53
  :loading="deleting"
43
54
  :action="confirmDelete"
44
55
  destructive
@@ -56,6 +67,7 @@ async function confirmDelete() {
56
67
  :items="items"
57
68
  :legend="t('automations.delete.messages')"
58
69
  :disabled="deleting"
70
+ :data-testid="automationsTestIds.deleteModalMessages"
59
71
  />
60
72
  <p class="my-0 flex items-start gap-1.5 paragraph-sm text-warning">
61
73
  <UIcon name="ph:warning" class="mt-0.5 shrink-0" />
@@ -4,6 +4,7 @@ import { resolveErrorToast } from '~/composables/apiErrorMessages'
4
4
  import type { AutomationsContext } from '~/composables/automationsContext'
5
5
  import { useUpdateAutomationMutation } from '~/queries'
6
6
  import {
7
+ automationEngineRejected,
7
8
  automationPartlySaved,
8
9
  automationSaveProblems,
9
10
  automationSetupProperties,
@@ -66,8 +67,15 @@ async function submit() {
66
67
  } catch (error) {
67
68
  const refused = automationSaveProblems(error)
68
69
  const partlySaved = automationPartlySaved(error)
70
+ const rejected = automationEngineRejected(error)
69
71
  if (refused) {
70
72
  problems.show(refused, sent)
73
+ } else if (rejected !== undefined) {
74
+ toast.add({
75
+ title: t('automations.toast.engine_rejected'),
76
+ description: rejected,
77
+ color: 'error',
78
+ })
71
79
  } else if (partlySaved) {
72
80
  // Nothing was rolled back (ADR 0016): the next save is an update of
73
81
  // what the Automation Engine now holds; the form stays as the user left it.
@@ -107,12 +115,14 @@ defineExpose({ submit, saving })
107
115
  variant="soft"
108
116
  icon="ph:lock-simple-bold"
109
117
  :title="t('automations.system.alert')"
118
+ :data-testid="automationsTestIds.lockedAlert"
110
119
  :actions="[
111
120
  {
112
121
  label: t('common.actions.duplicate'),
113
122
  color: 'info',
114
123
  variant: 'outline',
115
124
  size: 'sm',
125
+ 'data-testid': automationsTestIds.lockedDuplicateButton,
116
126
  onClick: () => askClone(stored),
117
127
  },
118
128
  ]"
@@ -209,6 +209,7 @@ defineExpose({
209
209
  root: 'flex flex-col flex-1 min-h-0',
210
210
  body: 'flex-1 w-full max-w-3xl mx-auto px-3 sm:pt-10 overflow-auto space-y-6',
211
211
  }"
212
+ :data-testid="automationsTestIds.form"
212
213
  >
213
214
  <AutomationsUnavailable :id="UNAVAILABLE_ELEMENT_ID" :items="unavailableItems" @show="show" />
214
215
 
@@ -223,6 +224,7 @@ defineExpose({
223
224
  :placeholder="t('automations.form.namePlaceholder')"
224
225
  :disabled="system"
225
226
  class="w-full"
227
+ :data-testid="automationsTestIds.nameInput"
226
228
  />
227
229
  </UFormField>
228
230
 
@@ -242,6 +244,7 @@ defineExpose({
242
244
  :model-value="form.triggerType"
243
245
  :items="triggerOptions"
244
246
  :disabled="system"
247
+ :data-testid="automationsTestIds.triggerSelect"
245
248
  @update:model-value="changeTrigger"
246
249
  />
247
250
  </UFormField>
@@ -158,7 +158,6 @@ const columns: TableColumn<Automation>[] = [
158
158
  id: 'channel',
159
159
  accessorFn: (automation) => automation.actions.length,
160
160
  header: (ctx) => getSortableHeader(ctx, t('automations.list.headers.channels')),
161
- cell: ({ row }) => getChannels(row.original) || '-',
162
161
  },
163
162
  {
164
163
  id: 'audience',
@@ -238,6 +237,7 @@ function getRowActions(automation: Automation) {
238
237
  {
239
238
  label: t('common.actions.edit'),
240
239
  icon: 'ph:pencil-simple',
240
+ 'data-testid': automationsTestIds.editAction,
241
241
  onSelect: () => {
242
242
  trackEvent('automation_list.edit', {
243
243
  automation_name: automation.name,
@@ -249,6 +249,7 @@ function getRowActions(automation: Automation) {
249
249
  {
250
250
  label: t('common.actions.duplicate'),
251
251
  icon: 'ph:copy',
252
+ 'data-testid': automationsTestIds.duplicateAction,
252
253
  onSelect: () => {
253
254
  trackEvent('automation_list.duplicate', {
254
255
  automation_name: automation.name,
@@ -264,6 +265,7 @@ function getRowActions(automation: Automation) {
264
265
  label: t('common.actions.delete'),
265
266
  icon: 'ph:trash',
266
267
  color: 'error' as const,
268
+ 'data-testid': automationsTestIds.deleteAction,
267
269
  onSelect: () => askDelete(automation),
268
270
  },
269
271
  ]),
@@ -279,10 +281,23 @@ function getRowActions(automation: Automation) {
279
281
  type="search"
280
282
  leading-icon="ph:magnifying-glass-bold"
281
283
  :placeholder="t('automations.list.search')"
284
+ :data-testid="automationsTestIds.searchInput"
285
+ />
286
+ <USelect
287
+ v-model="filterTrigger"
288
+ :items="triggerOptions"
289
+ :data-testid="automationsTestIds.filterTrigger"
290
+ />
291
+ <USelect
292
+ v-model="filterStatus"
293
+ :items="statusOptions"
294
+ :data-testid="automationsTestIds.filterStatus"
295
+ />
296
+ <USelect
297
+ v-model="filterChannel"
298
+ :items="channelOptions"
299
+ :data-testid="automationsTestIds.filterChannel"
282
300
  />
283
- <USelect v-model="filterTrigger" :items="triggerOptions" />
284
- <USelect v-model="filterStatus" :items="statusOptions" />
285
- <USelect v-model="filterChannel" :items="channelOptions" />
286
301
  </div>
287
302
 
288
303
  <UCard
@@ -302,6 +317,7 @@ function getRowActions(automation: Automation) {
302
317
  :empty="t('automations.list.empty')"
303
318
  sticky
304
319
  class="flex-1 bg-white"
320
+ :data-testid="automationsTestIds.table"
305
321
  :ui="{
306
322
  tr: 'hover:bg-muted',
307
323
  root: 'overflow-visible static',
@@ -319,6 +335,7 @@ function getRowActions(automation: Automation) {
319
335
  color="info"
320
336
  variant="subtle"
321
337
  size="sm"
338
+ :data-testid="automationsTestIds.lockedBadge"
322
339
  />
323
340
  </UTooltip>
324
341
  </div>
@@ -331,11 +348,21 @@ function getRowActions(automation: Automation) {
331
348
  "
332
349
  :color="row.original.active ? 'success' : 'neutral'"
333
350
  variant="soft"
351
+ :data-testid="automationsTestIds.statusCell"
334
352
  />
335
353
  </template>
336
354
 
355
+ <template #channel-cell="{ row }">
356
+ <span :data-testid="automationsTestIds.channelsCell">{{
357
+ getChannels(row.original) || '-'
358
+ }}</span>
359
+ </template>
360
+
337
361
  <template #actions-cell="{ row }">
338
- <SMoreActions :actions="getRowActions(row.original)" />
362
+ <SMoreActions
363
+ :actions="getRowActions(row.original)"
364
+ :button-props="{ 'data-testid': automationsTestIds.rowActionsButton }"
365
+ />
339
366
  </template>
340
367
  </UTable>
341
368
  </UCard>
@@ -24,6 +24,7 @@ function scrollTo(line: AutomationProblemLine) {
24
24
  variant="soft"
25
25
  icon="ph:warning-circle-bold"
26
26
  :title="t('automations.problems.title')"
27
+ :data-testid="automationsTestIds.errorAlert"
27
28
  >
28
29
  <template #description>
29
30
  <ul class="space-y-1">
@@ -48,5 +49,6 @@ function scrollTo(line: AutomationProblemLine) {
48
49
  variant="soft"
49
50
  icon="ph:warning-circle-bold"
50
51
  :title="t('automations.form.error_banner')"
52
+ :data-testid="automationsTestIds.errorAlert"
51
53
  />
52
54
  </template>
@@ -19,6 +19,8 @@ const emit = defineEmits<{
19
19
  duplicated: [result: { id: string | number; sourceId: string | number; name: string }]
20
20
  published: [row: MessageGroupWithMessageSummary]
21
21
  unpublished: [row: MessageGroupWithMessageSummary]
22
+ /** Once, when the list has loaded for the first time. */
23
+ loaded: []
22
24
  }>()
23
25
 
24
26
  const { trackEvent } = useTracking()
@@ -36,6 +38,12 @@ const {
36
38
  refetch: execute,
37
39
  } = useMessageGroupList(renderType)
38
40
 
41
+ whenever(
42
+ () => !isFetching.value,
43
+ () => emit('loaded'),
44
+ { immediate: true, once: true },
45
+ )
46
+
39
47
  // Polling
40
48
  const interval = setInterval(() => execute(), 15000)
41
49
  onBeforeUnmount(() => clearInterval(interval))
@@ -8,13 +8,11 @@ import type { OrganizationWaba } from '@dev.smartpricing/message-composer-utils/
8
8
  */
9
9
  const props = defineProps<{
10
10
  wabas: OrganizationWaba[]
11
- /** The Host's WABA, already checked to be one of `wabas`. */
12
- preselected?: string
13
11
  }>()
14
12
 
15
13
  const emit = defineEmits<{ close: [wabaId?: string] }>()
16
14
 
17
- const selected = ref<string | undefined>(props.preselected)
15
+ const selected = ref<string>()
18
16
 
19
17
  const items = computed(() =>
20
18
  props.wabas.map((waba) => ({