From 36eeae10712561cdbd70edce8f4aba1eedd2070c Mon Sep 17 00:00:00 2001 From: Miguel Cabrerizo <30386061+doncicuto@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:55:39 +0200 Subject: [PATCH] fix(console): update Twilio sms provider settings (#6732) fix: update sms provider settings Co-authored-by: Elio Bischof --- .../dialog-add-sms-provider.component.html | 2 +- .../dialog-add-sms-provider.component.ts | 5 +- .../notification-sms-provider.component.html | 1 + .../notification-sms-provider.component.ts | 3 +- console/src/assets/i18n/bg.json | 1 + console/src/assets/i18n/de.json | 1 + console/src/assets/i18n/en.json | 1 + console/src/assets/i18n/es.json | 1 + console/src/assets/i18n/fr.json | 1 + console/src/assets/i18n/it.json | 1 + console/src/assets/i18n/ja.json | 1 + console/src/assets/i18n/mk.json | 1 + console/src/assets/i18n/pl.json | 1 + console/src/assets/i18n/pt.json | 1 + console/src/assets/i18n/zh.json | 1 + .../e2e/instance/settings/notifications.cy.ts | 53 ++++++++++++++++++- 16 files changed, 68 insertions(+), 7 deletions(-) diff --git a/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.html b/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.html index b8d239ef18..78f70c7fbe 100644 --- a/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.html +++ b/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.html @@ -18,7 +18,7 @@ - diff --git a/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.ts b/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.ts index 2594dd0728..01c1d6890f 100644 --- a/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.ts +++ b/console/src/app/modules/policies/notification-sms-provider/dialog-add-sms-provider/dialog-add-sms-provider.component.ts @@ -61,15 +61,14 @@ export class DialogAddSMSProviderComponent { } public closeDialogWithRequest(): void { - if (!!this.twilio) { + if (!!this.twilio && this.twilioProvider && this.twilioProvider.id) { this.req = new UpdateSMSProviderTwilioRequest(); - + this.req.setId(this.twilioProvider.id); this.req.setSid(this.sid?.value); this.req.setSenderNumber(this.senderNumber?.value); this.dialogRef.close(this.req); } else { this.req = new AddSMSProviderTwilioRequest(); - this.req.setSid(this.sid?.value); this.req.setToken(this.token?.value); this.req.setSenderNumber(this.senderNumber?.value); diff --git a/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.html b/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.html index adde321c63..33a2521e57 100644 --- a/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.html +++ b/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.html @@ -24,6 +24,7 @@ *ngIf="twilio && twilio.id" [disabled]="(['iam.write'] | hasRole | async) === false" mat-stroked-button + data-e2e="activate-sms-provider-button" (click)="toggleSMSProviderState(twilio.id)" > {{ diff --git a/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.ts b/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.ts index f13a3e6992..dc8b2115d4 100644 --- a/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.ts +++ b/console/src/app/modules/policies/notification-sms-provider/notification-sms-provider.component.ts @@ -33,6 +33,7 @@ export class NotificationSMSProviderComponent implements OnInit { ngOnInit(): void { this.fetchData(); } + private fetchData(): void { this.smsProvidersLoading = true; this.service @@ -63,7 +64,7 @@ export class NotificationSMSProviderComponent implements OnInit { this.service .updateSMSProviderTwilio(req as UpdateSMSProviderTwilioRequest) .then(() => { - this.toast.showInfo('SETTING.SMS.TWILIO.ADDED', true); + this.toast.showInfo('SETTING.SMS.TWILIO.UPDATED', true); this.fetchData(); }) .catch((error) => { diff --git a/console/src/assets/i18n/bg.json b/console/src/assets/i18n/bg.json index 2bb72ca7d6..e9907811e0 100644 --- a/console/src/assets/i18n/bg.json +++ b/console/src/assets/i18n/bg.json @@ -1085,6 +1085,7 @@ "TOKEN": "Токен", "SENDERNUMBER": "Номер на изпращача", "ADDED": "Twilio добави успешно.", + "UPDATED": "Twilio се актуализира успешно.", "REMOVED": "Twilio премахнат", "CHANGETOKEN": "Промяна на токена", "SETTOKEN": "Задаване на токен", diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index 9ae13c827c..fc3c9633a8 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -1091,6 +1091,7 @@ "TOKEN": "Token", "SENDERNUMBER": "Sender Number", "ADDED": "Twilio erfolgreich hinzugefügt.", + "UPDATED": "Twilio wurde erfolgreich aktualisiert.", "REMOVED": "Twilio entfernt", "CHANGETOKEN": "Token ändern", "SETTOKEN": "Token setzen", diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index 25ff13be26..5166c33f5e 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -1092,6 +1092,7 @@ "TOKEN": "Token", "SENDERNUMBER": "Sender Number", "ADDED": "Twilio added successfully.", + "UPDATED": "Twilio updated successfully.", "REMOVED": "Twilio removed", "CHANGETOKEN": "Change Token", "SETTOKEN": "Set Token", diff --git a/console/src/assets/i18n/es.json b/console/src/assets/i18n/es.json index 34c0c6de46..d4faf3abf4 100644 --- a/console/src/assets/i18n/es.json +++ b/console/src/assets/i18n/es.json @@ -1092,6 +1092,7 @@ "TOKEN": "Token", "SENDERNUMBER": "Número de emisor", "ADDED": "Twilio añadido con éxito.", + "UPDATED": "Twilio actualizado con éxito", "REMOVED": "Twilio eliminado", "CHANGETOKEN": "Cambiar token", "SETTOKEN": "Establecer token", diff --git a/console/src/assets/i18n/fr.json b/console/src/assets/i18n/fr.json index 373feb32a2..bc52d02dd7 100644 --- a/console/src/assets/i18n/fr.json +++ b/console/src/assets/i18n/fr.json @@ -1091,6 +1091,7 @@ "TOKEN": "Jeton", "SENDERNUMBER": "Numéro d'expéditeur", "ADDED": "Twilio a été ajouté avec succès.", + "UPDATED": "Twilio a été mis à jour avec succès.", "REMOVED": "Twilio a été supprimé avec succès", "CHANGETOKEN": "Changer de Token", "SETTOKEN": "Définir le jeton", diff --git a/console/src/assets/i18n/it.json b/console/src/assets/i18n/it.json index cae3b1cf13..635d42c301 100644 --- a/console/src/assets/i18n/it.json +++ b/console/src/assets/i18n/it.json @@ -1091,6 +1091,7 @@ "TOKEN": "Token", "SENDERNUMBER": "Sender Number", "ADDED": "Twilio aggiunto con successo.", + "UPDATED": "Twilio aggiornato correttamente.", "REMOVED": "Twilio rimosso con successo.", "CHANGETOKEN": "Cambia Token", "SETTOKEN": "Cambia Token", diff --git a/console/src/assets/i18n/ja.json b/console/src/assets/i18n/ja.json index 651d00a263..3f6bd719a9 100644 --- a/console/src/assets/i18n/ja.json +++ b/console/src/assets/i18n/ja.json @@ -1092,6 +1092,7 @@ "TOKEN": "トークン", "SENDERNUMBER": "送信者番号", "ADDED": "Twilioは正常に追加されました。", + "UPDATED": "Twilio が正常に更新されました。", "REMOVED": "Twilioが削除されました", "CHANGETOKEN": "トークンを変更する", "SETTOKEN": "トークンを設定する", diff --git a/console/src/assets/i18n/mk.json b/console/src/assets/i18n/mk.json index cad724be75..40360136b2 100644 --- a/console/src/assets/i18n/mk.json +++ b/console/src/assets/i18n/mk.json @@ -1093,6 +1093,7 @@ "TOKEN": "Токен", "SENDERNUMBER": "Број на испраќач", "ADDED": "Twilio e успешно додаден.", + "UPDATED": "Twilio се ажурираше успешно.", "REMOVED": "Twilio отстранет", "CHANGETOKEN": "Смени токен", "SETTOKEN": "Постави токен", diff --git a/console/src/assets/i18n/pl.json b/console/src/assets/i18n/pl.json index a6ef90e0e8..c78c6eef10 100644 --- a/console/src/assets/i18n/pl.json +++ b/console/src/assets/i18n/pl.json @@ -1091,6 +1091,7 @@ "TOKEN": "Token", "SENDERNUMBER": "Numer nadawcy", "ADDED": "Twilio dodano pomyślnie.", + "UPDATED": "Twilio zostało pomyślnie zaktualizowane.", "REMOVED": "Twilio usunięte", "CHANGETOKEN": "Zmień Token", "SETTOKEN": "Ustaw Token", diff --git a/console/src/assets/i18n/pt.json b/console/src/assets/i18n/pt.json index fb03b6c71a..bd2a648a0a 100644 --- a/console/src/assets/i18n/pt.json +++ b/console/src/assets/i18n/pt.json @@ -1093,6 +1093,7 @@ "TOKEN": "Token", "SENDERNUMBER": "Número do remetente", "ADDED": "Twilio adicionado com sucesso.", + "UPDATED": "Twilio atualizado com sucesso.", "REMOVED": "Twilio removido", "CHANGETOKEN": "Alterar token", "SETTOKEN": "Definir token", diff --git a/console/src/assets/i18n/zh.json b/console/src/assets/i18n/zh.json index 4192baed91..7d34e7a47f 100644 --- a/console/src/assets/i18n/zh.json +++ b/console/src/assets/i18n/zh.json @@ -1091,6 +1091,7 @@ "TOKEN": "令牌", "SENDERNUMBER": "发件人号码", "ADDED": "Twilio 添加成功。", + "UPDATED": "Twilio 更新成功。", "REMOVED": "Twilio 已删除", "CHANGETOKEN": "更改令牌", "SETTOKEN": "设置令牌", diff --git a/e2e/cypress/e2e/instance/settings/notifications.cy.ts b/e2e/cypress/e2e/instance/settings/notifications.cy.ts index f2685c5d92..06207ce524 100644 --- a/e2e/cypress/e2e/instance/settings/notifications.cy.ts +++ b/e2e/cypress/e2e/instance/settings/notifications.cy.ts @@ -19,7 +19,6 @@ describe('instance notifications', () => { cy.visit(smtpPath); cy.contains('SMTP Settings'); }); - it(`should add SMTP provider settings`, () => { cy.visit(smtpPath); cy.get('[formcontrolname="senderAddress"]').clear().type('sender@example.com'); @@ -33,7 +32,6 @@ describe('instance notifications', () => { cy.get('[formcontrolname="hostAndPort"]').should('have.value', 'smtp.mailtrap.io:2525'); cy.get('[formcontrolname="user"]').should('have.value', 'user@example.com'); }); - it(`should add SMTP provider password`, () => { cy.visit(smtpPath); cy.get('[data-e2e="add-smtp-password-button"]').click(); @@ -60,5 +58,56 @@ describe('instance notifications', () => { cy.get('h4').contains('Twilio'); cy.get('.state').contains('Inactive'); }); + + it(`should activate SMS provider`, () => { + cy.visit(smsPath); + cy.get('h4').contains('Twilio'); + cy.get('.state').contains('Inactive'); + cy.get('[data-e2e="activate-sms-provider-button"]').click(); + cy.shouldConfirmSuccess(); + cy.get('.state').contains('Active'); + }); + + it(`should edit SMS provider`, () => { + cy.visit(smsPath); + cy.get('h4').contains('Twilio'); + cy.get('.state').contains('Active'); + cy.get('[data-e2e="new-twilio-button"]').click(); + cy.get('[formcontrolname="sid"]').should('have.value', 'test'); + cy.get('[formcontrolname="senderNumber"]').should('have.value', '2312123132'); + cy.get('[formcontrolname="sid"]').clear().type('test2'); + cy.get('[formcontrolname="senderNumber"]').clear().type('6666666666'); + cy.get('[data-e2e="save-sms-settings-button"]').click(); + cy.shouldConfirmSuccess(); + }); + + it(`should contain edited values`, () => { + cy.visit(smsPath); + cy.get('h4').contains('Twilio'); + cy.get('.state').contains('Active'); + cy.get('[data-e2e="new-twilio-button"]').click(); + cy.get('[formcontrolname="sid"]').should('have.value', 'test2'); + cy.get('[formcontrolname="senderNumber"]').should('have.value', '6666666666'); + }); + + it(`should edit SMS provider token`, () => { + cy.visit(smsPath); + cy.get('h4').contains('Twilio'); + cy.get('.state').contains('Active'); + cy.get('[data-e2e="new-twilio-button"]').click(); + cy.get('[data-e2e="edit-sms-token-button"]').click(); + cy.get('[data-e2e="notification-setting-password"]').clear().type('newsupertoken'); + cy.get('[data-e2e="save-notification-setting-password-button"]').click(); + cy.shouldConfirmSuccess(); + }); + + it(`should remove SMS provider`, () => { + cy.visit(smsPath); + cy.get('h4').contains('Twilio'); + cy.get('.state').contains('Active'); + cy.get('[data-e2e="remove-sms-provider-button"]').click(); + cy.get('[data-e2e="confirm-dialog-button"]').click(); + cy.shouldConfirmSuccess(); + }); }); });