-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: refactor msg template components; add telegram character limit #1148
Conversation
@@ -11,40 +12,51 @@ import { | |||
StepSection, | |||
} from 'components/common' | |||
import SaveDraftModal from 'components/dashboard/create/save-draft-modal' | |||
import { exceedsCharacterThreshold, saveTemplate } from 'services/sms.service' | |||
import { saveTemplate } from 'services/sms.service' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component does not work with Telegram.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my bad. I guess this is a case where frontend tests would've caught the error haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fix to make it work for Telegram. Maybe pass the saveTemplate
function as a prop?
I think I'll move the unit tests for this component to this PR |
Features: * Disable the next button when the body lengh is greater than the error limit * Define a warning threshold of 3000 chars and an error threshold of 4096 chars for Telegram (4096 chars is the char limit for Telegram)
7be2fa8
to
9cc7c23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! Tested the following an works as expected:
- Existing Telegram/SMS template saving should works as expected
- Warning shown when character limits are reached for both SMS/Telegram
* develop: feat: refactor msg template components; add telegram character limit (#1148) refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153) feat: add unit tests for error states in critical workflows (#1118) feat: support whitelisting domains through `agencies` table (#1141) feat: add tests for happy paths in critical workflows (#1110) fix: prevent campaign names from causing dashboard rows to overflow (#1147)
* develop: fix: fix error when updating Telegram ID for an existing phone number (#1178) chore: upgrade React; use new JSX transform; sort imports (#1129) fix(backend): docker build and tsc output directory structure (#1177) feat: refactor msg template components; add telegram character limit (#1148) refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153)
Problem
Currently, the
SMSTemplate
andTelegramTemplate
components are nearly identical. The only difference is thatSMSTemplate
has an error message (which I'll also add to the Telegram template in this PR)Since they're nearly identical, some unit tests written for both components will be duplicated for both of them as well (ref: #1118 (comment)).
To reduce code and test duplication, refactor both components to a common component.
Solution
Features:
exceedsCharacterThreshold
withwarningCharacterCount
anderrorCharacterCount
thresholdswarningCharacterCount
merely displays an error messageerrorCharacterCount
displays an error message and disables the Next buttonImprovements:
SMSTemplate
andTelegramTemplate
to a common componentBefore & After Screenshots
To be added
The only visual difference is the Telegram template should look exactly the same as the SMS template now.
Tests
SMS and Telegram templates should function just as before
Exceeding error threshold should display error msg and disable the next button
Deploy Notes
No deploy notes.
Todo