docs: archive whatsapp-inbox, zh-cn-messages, messages-colite-filter and landing-pages
The owner deferred the WhatsApp e2e (add-whatsapp-inbox task 6.3) until the business account can be linked; the task stays open with a note. Specs are synced and the new capabilities have their Purpose written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
1 parent
e70e1084d9
commit
2c6a4dc8ce
42 files changed
+709
-3
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
@@ -108,3 +108,4 @@ Verify commands:
|
||||
- the unread badge.
|
||||
- Earlier in 5.1: media, ticks and the 360 px layout. The staff-only view (Mine only, no owner select) is covered by tests only: no staff password was available, and staff passwords were not reset for it. The test rows were removed.
|
||||
- [ ] 6.3 The owner's manual click-every-button e2e on a production build covers the inbox too (record the result here).
|
||||
- Deferred by the owner on 2026-12-02: the WhatsApp business account cannot be linked yet, so the change is archived with this check open. Run it once the account is linked; any fix goes in a new change.
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -129,10 +129,15 @@ A table wider than its container SHALL show a fade on each edge where more colum
|
||||
|
||||
The sidebar SHALL show Dashboard first, then the labelled sections Events, Leads, Access and System, each with a fixed set and order of pages. A page not in any section SHALL appear in a final section without a label. A section SHALL be marked by a divider and a small muted label, with only the divider in the collapsed rail, and SHALL NOT show when it has no page the user may open. Every page SHALL have a distinct icon.
|
||||
|
||||
#### Scenario: WhatsApp inbox in the Leads section
|
||||
|
||||
- **WHEN** a user with `BO_WHATSAPP` and two unread conversations opens the portal
|
||||
- **THEN** the Leads section lists Leads, WhatsApp and Interests, with a badge showing 2
|
||||
|
||||
#### Scenario: Super admin sidebar
|
||||
|
||||
- **WHEN** a super admin opens the portal
|
||||
- **THEN** the sidebar shows Dashboard, then "Events" with Events and Event leads, "Leads" with Leads and Interests, "Access" with Users, Roles and Login security, and "System" with Companies, Emails and Audit log
|
||||
- **THEN** the sidebar shows Dashboard, then "Events" with Events, Event leads and Pages, "Leads" with Leads, WhatsApp and Interests, "Access" with Users, Roles and Login security, and "System" with Companies, Emails, Audit log, Translations and Languages
|
||||
|
||||
#### Scenario: Staff without admin pages
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ On the event days, a registered guest's invite link SHALL show a "Check in" butt
|
||||
|
||||
### Requirement: Attendance at capture
|
||||
|
||||
Each event lead SHALL have an attended time. A staff capture, a walk-in code registration or a check-in-page capture made during the event days SHALL set it. A registration made before the event days SHALL NOT set it. Event leads that exist before this change SHALL count as not attended.
|
||||
Each event lead SHALL have an attended time. A staff capture, a walk-in code registration or a check-in-page capture made during the event days SHALL set it. A registration made before the event days SHALL NOT set it. A web page sign-up SHALL NOT set it, whenever it is made. Event leads that exist before this change SHALL count as not attended.
|
||||
|
||||
#### Scenario: Walk-in on the day
|
||||
|
||||
@@ -84,15 +84,27 @@ Each event lead SHALL have an attended time. A staff capture, a walk-in code reg
|
||||
- **WHEN** a visitor registers through the event's walk-in code
|
||||
- **THEN** the event lead is registered but not attended
|
||||
|
||||
#### Scenario: Web enquiry during a standing event
|
||||
|
||||
- **GIVEN** the running event `INS website enquiries`
|
||||
- **WHEN** a visitor submits the form on a landing page that points at it
|
||||
- **THEN** the event lead is registered but not attended
|
||||
|
||||
### Requirement: Attendance in staff screens
|
||||
|
||||
Users who can edit event leads SHALL tick or untick Attended. The event leads listing SHALL show an Attended column and filter, and each event lead's source (Staff, QR, Invite).
|
||||
Users who can edit event leads SHALL tick or untick Attended. The event leads listing SHALL show an Attended column and filter, and each event lead's source (Staff, QR, Invite, Web page).
|
||||
|
||||
#### Scenario: Staff untick
|
||||
|
||||
- **WHEN** staff untick Attended on an event lead linked to a guest
|
||||
- **THEN** the guest list shows that guest as Registered
|
||||
|
||||
#### Scenario: Web page source
|
||||
|
||||
- **GIVEN** an event lead created by a landing-page form
|
||||
- **WHEN** staff open the event leads listing
|
||||
- **THEN** its source shows "Web page"
|
||||
|
||||
### Requirement: Guest linking across routes
|
||||
|
||||
A guest's status SHALL be derived from the event lead it is linked to: Registered when linked, Attended when that event lead is attended. Whenever a capture for an event creates or finds an event lead, by staff, walk-in code, invite or check-in, an unlinked guest of the same event SHALL be linked to it. The guest is matched by mobile first, else by email. The guest then SHALL count as a guest, not as a walk-in.
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
# landing-pages Specification
|
||||
|
||||
## Purpose
|
||||
|
||||
Public landing pages per company, built by staff from blocks in the back office without a developer. A page's sign-up form registers visitors into an event as web sign-ups, with the page address and campaign tags, so they enter the lead pipeline. Each page shows its company's logo and accent colour.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: A Page Is An Ordered List Of Typed Blocks
|
||||
|
||||
A page SHALL belong to one company and have a slug, a title, an optional meta description, a status (Draft or Published) and an ordered list of zero to 30 blocks. The block types SHALL be HERO, RICH_TEXT, IMAGE_TEXT, FAQ and FORM. Blocks SHALL be returned in the order they were saved, and a valid save SHALL replace all of a page's blocks.
|
||||
|
||||
#### Scenario: Blocks read back in order
|
||||
|
||||
- **WHEN** staff save page `hotel-technology` with blocks HERO, RICH_TEXT, FORM
|
||||
- **THEN** reading the page returns those three blocks in that order with their fields
|
||||
|
||||
#### Scenario: A save replaces the blocks
|
||||
|
||||
- **GIVEN** a page whose blocks are HERO and FAQ
|
||||
- **WHEN** it is saved with only a RICH_TEXT block
|
||||
- **THEN** the page has only that RICH_TEXT block
|
||||
|
||||
### Requirement: Page Fields Are Validated Server-Side
|
||||
|
||||
A page save SHALL be refused with the offending field path, writing nothing, when the slug does not match `^[a-z0-9]+(-[a-z0-9]+)*$`, is longer than 80 characters or is used by another page of the same company, ignoring case; or when the title is blank or longer than 120 characters; or when the meta description is longer than 160 characters.
|
||||
|
||||
#### Scenario: Duplicate slug in one company
|
||||
|
||||
- **GIVEN** INS has a page `hotel-technology`
|
||||
- **WHEN** INS staff save another page with slug `hotel-technology`
|
||||
- **THEN** the save is refused on field `slug`
|
||||
|
||||
#### Scenario: Same slug in two companies
|
||||
|
||||
- **GIVEN** INS has a page `about`
|
||||
- **WHEN** CV staff save a page with slug `about`
|
||||
- **THEN** the save succeeds
|
||||
|
||||
### Requirement: Block Fields Are Validated Server-Side
|
||||
|
||||
A page save SHALL be refused with the offending field path, writing nothing, when a block has an unknown type, a required field is blank, or a text exceeds its limit: heading 120, text and FAQ question 300, button label 40, FAQ answer 2000, HTML 100000 characters. A FAQ SHALL have 1 to 30 items. `imagePosition` SHALL be LEFT or RIGHT.
|
||||
|
||||
#### Scenario: Too many blocks
|
||||
|
||||
- **WHEN** a page is saved with 31 blocks
|
||||
- **THEN** the save is refused and nothing is written
|
||||
|
||||
### Requirement: Block References Stay Inside The Company
|
||||
|
||||
A block's image SHALL be an image of the page's company, and a FORM block's event SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
|
||||
|
||||
#### Scenario: Another company's event
|
||||
|
||||
- **GIVEN** event `CV Roadshow` belongs to CV
|
||||
- **WHEN** INS staff save a FORM block pointing at `CV Roadshow`
|
||||
- **THEN** the save is refused on that block's event field
|
||||
|
||||
### Requirement: Page Content Cannot Run Scripts
|
||||
|
||||
A button SHALL have both a label and a link or neither. The link SHALL be a same-site path starting with a single `/`, an `https://` URL, a `mailto:` link or a `tel:` link. A save SHALL be refused when any HTML holds a `script` element, an `on*` attribute or a `javascript:` URL. The public page SHALL also sanitise all HTML against an allow-list before rendering it.
|
||||
|
||||
#### Scenario: Script link on a button
|
||||
|
||||
- **WHEN** a page is saved with a HERO button link `javascript:alert(1)`
|
||||
- **THEN** the save is refused on field `blocks[0].buttonUrl`
|
||||
|
||||
#### Scenario: Script in rich text
|
||||
|
||||
- **WHEN** a page is saved with rich text holding `<img src=x onerror=alert(1)>`
|
||||
- **THEN** the save is refused on that block's HTML field
|
||||
|
||||
### Requirement: Page Images
|
||||
|
||||
Staff with `BO_PAGES` SHALL upload images for their company in PNG, JPEG or WebP, each at most 2 MB, checked by the file's content and not by its name. Anyone SHALL be able to read an image by its id, so that public pages can show it.
|
||||
|
||||
#### Scenario: Wrong file type
|
||||
|
||||
- **WHEN** staff upload a PDF renamed to `banner.png`
|
||||
- **THEN** the upload is refused and nothing is stored
|
||||
|
||||
#### Scenario: Too large
|
||||
|
||||
- **WHEN** staff upload a 3 MB JPEG
|
||||
- **THEN** the upload is refused and nothing is stored
|
||||
|
||||
### Requirement: Company Branding
|
||||
|
||||
Each company SHALL have an optional logo, an image of that company, and an optional accent colour in `#RRGGBB` form. These SHALL be edited on the Companies screen. Its public pages SHALL show the logo in the header and use the accent colour on buttons, with black or white button text, whichever contrasts more. Without these, the pages SHALL use the neutral Co-Lite look.
|
||||
|
||||
#### Scenario: Accent colour
|
||||
|
||||
- **GIVEN** INS has accent colour `#0B5FFF`
|
||||
- **WHEN** a visitor opens an INS page
|
||||
- **THEN** its buttons are `#0B5FFF` with white text
|
||||
|
||||
#### Scenario: Invalid colour
|
||||
|
||||
- **WHEN** a super admin saves the accent colour `blue`
|
||||
- **THEN** the save is refused on that field
|
||||
|
||||
### Requirement: Public Page Address
|
||||
|
||||
A published page SHALL be public at `/p/<company-code>/<slug>`, matching the company code and the slug ignoring case. It SHALL be rendered on the server with the page title, the meta description and Open Graph tags. An unknown company, an unknown slug or a draft SHALL show the same not-found page to a visitor.
|
||||
|
||||
#### Scenario: Draft hidden from visitors
|
||||
|
||||
- **GIVEN** INS page `launch` is a draft
|
||||
- **WHEN** a signed-out visitor opens `/p/INS/launch`
|
||||
- **THEN** they see the not-found page
|
||||
|
||||
#### Scenario: Staff preview a draft
|
||||
|
||||
- **GIVEN** INS page `launch` is a draft
|
||||
- **WHEN** INS staff with `BO_PAGES` open its preview from the editor
|
||||
- **THEN** they see the page as it would be published, marked as a preview
|
||||
|
||||
### Requirement: The Form Block Registers For An Event
|
||||
|
||||
A FORM block SHALL show Co-Lite's sign-up form for its event, with that event's interests and the company's privacy notice. A submit SHALL follow the QR registration rules for matching, the existing-lead notes, consent and abuse limits. It SHALL create the event lead with source Web page and no salesperson, and SHALL record the page address and the `utm_source`, `utm_medium` and `utm_campaign` values from the page URL, each cut to 100 characters.
|
||||
|
||||
#### Scenario: New enquiry
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology` has a FORM block for `INS website enquiries`
|
||||
- **WHEN** a new visitor submits it from a URL with `utm_source=facebook`
|
||||
- **THEN** a new lead and an event lead with source Web page, no salesperson and UTM source `facebook` are created
|
||||
|
||||
#### Scenario: Known visitor
|
||||
|
||||
- **GIVEN** a lead with the same mobile exists in INS
|
||||
- **WHEN** they submit the form with a different email
|
||||
- **THEN** the lead is not edited, and the new email is written into the event lead's notes
|
||||
|
||||
### Requirement: The Form Block Closes With Its Event
|
||||
|
||||
A FORM block SHALL accept a submit only while its event is enabled, the event's end date in Malaysia time has not passed and the company has a privacy notice. Otherwise the page SHALL still show its other blocks, and the form area SHALL say that sign-up is closed.
|
||||
|
||||
#### Scenario: Ended event
|
||||
|
||||
- **GIVEN** the FORM block's event ended yesterday
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the other blocks show and the form area says sign-up is closed
|
||||
|
||||
### Requirement: Web Sign-Up Details For Staff
|
||||
|
||||
The event lead detail SHALL show the page address and the UTM values of a Web page sign-up.
|
||||
|
||||
#### Scenario: Campaign shown
|
||||
|
||||
- **GIVEN** an event lead from a page opened with `utm_campaign=jan-launch`
|
||||
- **WHEN** staff open the event lead
|
||||
- **THEN** its detail shows the page address and campaign `jan-launch`
|
||||
|
||||
### Requirement: Pages Are Company-Scoped
|
||||
|
||||
Pages and page images SHALL follow the company scoping rules: staff see, edit and delete only their own company's pages, and a super admin sees every company's pages with their company. The Pages screens SHALL need `BO_PAGES`, which no role has at first. Page saves and deletes SHALL be audited.
|
||||
|
||||
#### Scenario: Another company's page
|
||||
|
||||
- **GIVEN** page 12 belongs to CV
|
||||
- **WHEN** INS staff ask for page 12
|
||||
- **THEN** they get not found
|
||||
|
||||
### Requirement: The Pages List
|
||||
|
||||
`/pages` SHALL list the pages in scope with their title, public address, status and last update, with a search by title or slug and an Add page action. Each row SHALL open its editor. Pages SHALL appear in the sidebar for users with `BO_PAGES`.
|
||||
|
||||
#### Scenario: Draft in the list
|
||||
|
||||
- **GIVEN** INS page `launch` is a draft
|
||||
- **WHEN** INS staff open `/pages`
|
||||
- **THEN** its row shows status Draft and address `/p/INS/launch`
|
||||
|
||||
### Requirement: The Page Editor
|
||||
|
||||
The editor SHALL offer the title, a slug filled from the title until edited, a meta description with a 160-character counter, the status and the block list. Blocks SHALL be added, moved up or down and removed. A chosen image SHALL be uploaded only when the page is saved. A FORM block SHALL pick from the company's enabled events that have not ended.
|
||||
|
||||
#### Scenario: Slug follows the title until edited
|
||||
|
||||
- **GIVEN** a new page
|
||||
- **WHEN** staff type the title "Hotel Technology"
|
||||
- **THEN** the slug becomes `hotel-technology`
|
||||
|
||||
### Requirement: Saving And Deleting In The Editor
|
||||
|
||||
Server field errors SHALL show next to their fields, keeping all entered values. After a save the editor SHALL offer a link to view the page. Deleting a page SHALL ask first, and unsaved edits SHALL be guarded.
|
||||
|
||||
#### Scenario: Server error at its field
|
||||
|
||||
- **WHEN** staff save a HERO button link `javascript:alert(1)`
|
||||
- **THEN** the error shows next to that button link and every entered value stays
|
||||
@@ -0,0 +1,286 @@
|
||||
# ui-translations Specification
|
||||
|
||||
## Purpose
|
||||
|
||||
Back-office labels load from a database message catalog per language, with English built in as the fallback. Staff can correct wording and add Chinese (zh_CN) translations on the Translations and Languages screens without a release.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: The Portal Shows Labels In The Chosen Language
|
||||
|
||||
The admin portal SHALL show every label in the language the user picked, read from the back-office message catalog. A label with no text in that language SHALL fall back to its English text, then to the portal's built-in English, and never show blank. The catalog read SHALL need no session, because the sign-in page shows labels too, and it SHALL return label text only.
|
||||
|
||||
#### Scenario: Chinese picked
|
||||
|
||||
- **GIVEN** the catalog has Chinese text for the label `Leads`
|
||||
- **WHEN** a signed-in user picks 简体中文
|
||||
- **THEN** the sidebar shows the Chinese text instead of "Leads"
|
||||
|
||||
#### Scenario: A label without Chinese
|
||||
|
||||
- **GIVEN** a label has English text in the catalog and no Chinese text
|
||||
- **WHEN** a user who picked 简体中文 opens a page with that label
|
||||
- **THEN** the label shows its English text
|
||||
|
||||
#### Scenario: Catalog unavailable
|
||||
|
||||
- **WHEN** the catalog cannot be read
|
||||
- **THEN** the portal shows the last catalog it loaded, or its built-in English if it has none
|
||||
- **AND** no label is blank
|
||||
|
||||
### Requirement: A Wording Change Shows On The Next Page Load
|
||||
|
||||
The system SHALL keep a catalog version that increases with every saved or imported label and every language change, within the same write. The portal SHALL check the version on each page load and reload the catalog when it has changed, on every portal instance, with no fixed waiting time.
|
||||
|
||||
#### Scenario: A label is edited
|
||||
|
||||
- **GIVEN** a user sees a label's Chinese text
|
||||
- **WHEN** a translator saves new Chinese text for that label
|
||||
- **THEN** the next page load shows the new text
|
||||
|
||||
#### Scenario: A refused save
|
||||
|
||||
- **WHEN** a label save or language change is refused
|
||||
- **THEN** the catalog version does not change
|
||||
|
||||
### Requirement: Supported Languages Are Kept In A Registry
|
||||
|
||||
The system SHALL keep the supported languages in a registry, each with a code that matches the catalog's language keys, a label, an enabled flag and an order. It SHALL start with English (`en_US`) and 简体中文 (`zh_CN`) enabled, and Bahasa Melayu (`ms_MY`), 繁體中文 (`zh_TW`) and Bahasa Indonesia (`in_ID`) disabled. The language picker SHALL list only enabled languages in their order, before and after sign-in. If the registry cannot be read, the picker SHALL offer English and 简体中文.
|
||||
|
||||
#### Scenario: Picker after rollout
|
||||
|
||||
- **WHEN** a user opens the language picker
|
||||
- **THEN** it lists English and 简体中文 only
|
||||
|
||||
#### Scenario: A language is enabled
|
||||
|
||||
- **WHEN** an admin enables Bahasa Melayu on the Languages page
|
||||
- **THEN** the picker lists it on the next page load, with no redeploy
|
||||
|
||||
#### Scenario: Registry unavailable
|
||||
|
||||
- **WHEN** the language list cannot be read
|
||||
- **THEN** the picker lists English and 简体中文
|
||||
|
||||
### Requirement: A Language Change Cannot Break The Registry
|
||||
|
||||
The system SHALL refuse:
|
||||
- a new language whose code already exists;
|
||||
- a change of a language's code;
|
||||
- switching English off;
|
||||
- switching off the last enabled language.
|
||||
|
||||
Each refusal SHALL leave the registry unchanged and SHALL reach the user as a named reason, not a generic error.
|
||||
|
||||
#### Scenario: Duplicate code
|
||||
|
||||
- **WHEN** an admin adds a language with the code `zh_CN`
|
||||
- **THEN** it is refused and the page says the code already exists
|
||||
|
||||
#### Scenario: English cannot be switched off
|
||||
|
||||
- **WHEN** the Languages page lists English
|
||||
- **THEN** its switch is disabled and the page says why
|
||||
- **AND** a direct request to disable English is refused
|
||||
|
||||
#### Scenario: Last enabled language
|
||||
|
||||
- **GIVEN** only one language is enabled
|
||||
- **WHEN** a request disables it
|
||||
- **THEN** it is refused
|
||||
|
||||
### Requirement: The Languages Page
|
||||
|
||||
The portal SHALL provide a Languages page at `/locales` that lists every language with its code, label, order and an enabled switch. It SHALL let the user add a language and edit a label and order. The code SHALL be editable only when adding. Switching a language off SHALL ask for confirmation first. Refusals SHALL show on the page.
|
||||
|
||||
#### Scenario: Switching a language off asks first
|
||||
|
||||
- **WHEN** a user switches 简体中文 off
|
||||
- **THEN** a confirmation is shown
|
||||
- **AND** nothing changes unless the user confirms
|
||||
|
||||
#### Scenario: Code read-only when editing
|
||||
|
||||
- **WHEN** a user edits an existing language
|
||||
- **THEN** its code is shown read-only
|
||||
|
||||
### Requirement: The Translations Page Lists And Finds Back-Office Labels
|
||||
|
||||
The portal SHALL provide a Translations page at `/messages` listing the back-office labels in pages, each with its code, English text and Chinese text. The search SHALL match the code, the English text or the Chinese text, ignoring case. A "Missing Chinese" filter SHALL list labels whose Chinese text is absent, blank or the same as the English text. Each such label SHALL be marked with a text badge, not colour alone. The page SHALL offer no way to add or delete a label.
|
||||
|
||||
#### Scenario: Search by Chinese wording
|
||||
|
||||
- **GIVEN** a label whose Chinese text contains "线索"
|
||||
- **WHEN** the user searches "线索"
|
||||
- **THEN** that label is listed
|
||||
|
||||
#### Scenario: Copied English counts as missing
|
||||
|
||||
- **GIVEN** a label whose English and Chinese text are both "WhatsApp"
|
||||
- **WHEN** the user turns on "Missing Chinese"
|
||||
- **THEN** that label is listed with a badge that says why
|
||||
|
||||
#### Scenario: No add or delete
|
||||
|
||||
- **WHEN** the Translations page and its row actions are inspected
|
||||
- **THEN** there is no add and no delete action
|
||||
|
||||
### Requirement: Editing A Translation
|
||||
|
||||
Opening a label SHALL show an edit panel with one multi-line field per enabled language and the code read-only. Closing it with unsaved changes SHALL ask before discarding them. The server SHALL refuse a save that changes a label's code, or that creates a label whose code already exists ignoring case. Label text SHALL always be shown as text, never as markup.
|
||||
|
||||
#### Scenario: Unsaved edits
|
||||
|
||||
- **WHEN** the user changes a field and closes the panel
|
||||
- **THEN** the panel asks before discarding the change
|
||||
|
||||
#### Scenario: Code change refused
|
||||
|
||||
- **WHEN** a save request changes an existing label's code
|
||||
- **THEN** it is refused and the label is unchanged
|
||||
|
||||
#### Scenario: Markup is shown as text
|
||||
|
||||
- **GIVEN** a translator saves `<b>Leads</b>` as a label's Chinese text
|
||||
- **WHEN** a page shows that label
|
||||
- **THEN** the angle brackets show as text and nothing is bold
|
||||
|
||||
### Requirement: Placeholders Are Kept In Translations
|
||||
|
||||
Each non-English text SHALL keep the same placeholders as the English text, in the `{name}` and `{0}` forms. When an edit creates a mismatch, the edit panel SHALL name the missing or extra placeholders and block Save. When the label was mismatched before the edit, it SHALL warn without blocking.
|
||||
|
||||
#### Scenario: A new placeholder mismatch blocks Save
|
||||
|
||||
- **GIVEN** a label whose English is "{n} unread" and Chinese is "{n} 条未读"
|
||||
- **WHEN** the user changes the Chinese to "条未读"
|
||||
- **THEN** the panel names `{n}` as missing
|
||||
- **AND** Save is disabled
|
||||
|
||||
#### Scenario: An old mismatch only warns
|
||||
|
||||
- **GIVEN** a label whose English is "{n} unread" and Chinese is "未读"
|
||||
- **WHEN** the user edits the English
|
||||
- **THEN** the panel warns that `{n}` is missing in Chinese
|
||||
- **AND** Save stays enabled
|
||||
|
||||
### Requirement: Translations Export
|
||||
|
||||
The Translations page SHALL export every back-office label, with the text in every language, as a JSON file download, without leaving the page.
|
||||
|
||||
#### Scenario: Export downloads
|
||||
|
||||
- **WHEN** the user clicks Export
|
||||
- **THEN** the browser offers a JSON file with every back-office label
|
||||
- **AND** the page stays on `/messages`
|
||||
|
||||
### Requirement: Translations Import With A Preview
|
||||
|
||||
The Translations page SHALL import a file in the export shape. It SHALL first show a preview that marks each row as an update, matched by code ignoring case and never by an id in the file, or as a new label. It SHALL apply nothing until the user confirms. A file that is not a JSON list SHALL be rejected on the page without sending anything. Each row SHALL be saved on its own, and a summary SHALL show the counts created and updated and name the failed rows.
|
||||
|
||||
#### Scenario: Preview before import
|
||||
|
||||
- **WHEN** the user picks an export file
|
||||
- **THEN** the page lists every row as an update or a new label
|
||||
- **AND** nothing is saved until the user confirms
|
||||
|
||||
#### Scenario: Matched by code
|
||||
|
||||
- **GIVEN** a file row with code `leads` and the id of another label
|
||||
- **AND** the catalog holds the label `Leads`
|
||||
- **WHEN** the file is imported
|
||||
- **THEN** the `Leads` label is updated
|
||||
|
||||
#### Scenario: Not a list
|
||||
|
||||
- **WHEN** the user picks a file that is not a JSON list
|
||||
- **THEN** the page shows an error and sends nothing
|
||||
|
||||
#### Scenario: One bad row
|
||||
|
||||
- **WHEN** an import has one row that fails and others that succeed
|
||||
- **THEN** the other rows are saved
|
||||
- **AND** the summary names the failed row
|
||||
|
||||
### Requirement: Access To Translations And Languages
|
||||
|
||||
The Translations page SHALL require `BO_MESSAGES` and the Languages page `BO_LOCALES`, checked on the server for every list, detail, export and write, with a signed-in admin. Both modules SHALL be granted to no role, so only super admins have them until a super admin grants them. Saves, imports, exports and language changes SHALL be audited.
|
||||
|
||||
#### Scenario: Without the module
|
||||
|
||||
- **WHEN** a staff user without `BO_MESSAGES` opens `/messages`
|
||||
- **THEN** the not-authorised page is shown
|
||||
- **AND** a direct save request is refused
|
||||
|
||||
#### Scenario: A save is audited
|
||||
|
||||
- **WHEN** a super admin saves a translation
|
||||
- **THEN** the audit log records who saved which label
|
||||
|
||||
### Requirement: Internal Catalog Writes Need A Token
|
||||
|
||||
Inside the system, message and language writes and full listings SHALL need a user token. Only the catalog, its version and the enabled-language list SHALL be readable without one.
|
||||
|
||||
#### Scenario: Internal write without a token
|
||||
|
||||
- **WHEN** a request without a user token tries to save a message or language inside the system
|
||||
- **THEN** it is refused
|
||||
|
||||
#### Scenario: Catalog read without a token
|
||||
|
||||
- **WHEN** the sign-in page loads the catalog without a session
|
||||
- **THEN** the catalog is returned
|
||||
|
||||
### Requirement: Every Back-Office Label Has Chinese
|
||||
|
||||
Every back-office label SHALL have Simplified Chinese text with the same placeholders as its English, using one consistent glossary, as a first pass for a native speaker to review. Every new back-office label SHALL ship with its Chinese text.
|
||||
|
||||
#### Scenario: Back office in Chinese
|
||||
|
||||
- **WHEN** a user picks 简体中文 and opens any back-office page
|
||||
- **THEN** every label on it shows Chinese text
|
||||
|
||||
#### Scenario: A new label without Chinese
|
||||
|
||||
- **WHEN** a developer adds a back-office label with no Chinese text
|
||||
- **THEN** the portal's tests fail and name the label
|
||||
|
||||
### Requirement: Loading The Chinese Keeps English Unchanged
|
||||
|
||||
Loading the Chinese SHALL replace earlier Chinese for the back-office labels, leave other languages unchanged, and add missing labels with their English. It SHALL reset the English of any label whose old database text differs from the portal's English, so nobody who keeps English sees a change.
|
||||
|
||||
#### Scenario: English unchanged
|
||||
|
||||
- **GIVEN** the old database English for the sign-in button is "Login"
|
||||
- **WHEN** the Chinese is loaded and a user who keeps English opens the sign-in page
|
||||
- **THEN** the button reads "Log in"
|
||||
|
||||
### Requirement: Translations Can Be Limited To Co-Lite Labels
|
||||
|
||||
The Translations page SHALL offer a "Co-Lite labels only" checkbox, on by default, that limits the list, the search and the "Missing Chinese" filter to the labels in the portal's built-in English list. Codes SHALL match ignoring case. Turning the checkbox off SHALL list every back-office label.
|
||||
|
||||
#### Scenario: Inherited labels hidden by default
|
||||
|
||||
- **GIVEN** a back-office label "OrderPayment" that is not in the portal's built-in list, and a label "Leads" that is
|
||||
- **WHEN** the user opens the Translations page
|
||||
- **THEN** "Leads" is listed and "OrderPayment" is not
|
||||
- **AND** "Co-Lite labels only" is checked
|
||||
|
||||
#### Scenario: Missing Chinese counts only Co-Lite labels
|
||||
|
||||
- **GIVEN** every label in the built-in list has Chinese and some inherited labels have none
|
||||
- **WHEN** the user turns on "Missing Chinese" with "Co-Lite labels only" checked
|
||||
- **THEN** no label is listed
|
||||
|
||||
#### Scenario: Every label on request
|
||||
|
||||
- **WHEN** the user unchecks "Co-Lite labels only"
|
||||
- **THEN** "OrderPayment" is listed too
|
||||
|
||||
### Requirement: The Co-Lite Code List Comes From The Portal Server
|
||||
|
||||
The portal's server SHALL build the Co-Lite code list from its built-in list and SHALL NOT take codes from the browser. mobile-api SHALL refuse with 400 a code list that is not a list of strings or holds more than 5,000 entries. Export and import SHALL keep covering every back-office label.
|
||||
|
||||
#### Scenario: Code list too long
|
||||
|
||||
- **WHEN** mobile-api receives a search with 5,001 codes
|
||||
- **THEN** it answers 400 and does not call services-system
|
||||
@@ -0,0 +1,211 @@
|
||||
# whatsapp-inbox Specification
|
||||
|
||||
## Purpose
|
||||
|
||||
A two-way WhatsApp inbox inside Co-Lite on each company's business number. Sales staff follow up leads from the back office, every message is recorded, and any colleague with access can pick up a chat.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: Company WhatsApp settings
|
||||
|
||||
The system SHALL read each company's WhatsApp number id, business account id, access token and app secret from the environment, and SHALL never store or log them. A company without complete settings SHALL have WhatsApp switched off. Its inbox SHALL say "WhatsApp is not configured", and the rest of the system SHALL keep working.
|
||||
|
||||
#### Scenario: Company not configured
|
||||
|
||||
- **GIVEN** CV has no WhatsApp settings
|
||||
- **WHEN** a CV admin with `BO_WHATSAPP` opens the inbox
|
||||
- **THEN** the page says "WhatsApp is not configured" and offers no composer
|
||||
|
||||
### Requirement: Webhook handshake
|
||||
|
||||
The public webhook SHALL answer Meta's subscription check with the given challenge only when the verify token matches the configured one. Otherwise it SHALL answer 403.
|
||||
|
||||
#### Scenario: Wrong verify token
|
||||
|
||||
- **WHEN** a subscription check arrives with a verify token that does not match
|
||||
- **THEN** the webhook answers 403 and does not echo the challenge
|
||||
|
||||
### Requirement: Webhook signature
|
||||
|
||||
The webhook SHALL accept an event only when its `X-Hub-Signature-256` header is a valid HMAC-SHA256 of the raw body under the app secret of the company the event's number belongs to. A missing or invalid signature SHALL get 401, and nothing SHALL be stored.
|
||||
|
||||
#### Scenario: Forged event
|
||||
|
||||
- **WHEN** an event for INS's number arrives without a valid signature
|
||||
- **THEN** the webhook answers 401 and no message is stored
|
||||
|
||||
#### Scenario: Signed with the other company's secret
|
||||
|
||||
- **GIVEN** INS and CV have different app secrets
|
||||
- **WHEN** an event for INS's number is signed with CV's app secret
|
||||
- **THEN** the event is rejected and no message is stored
|
||||
|
||||
### Requirement: Inbound messages
|
||||
|
||||
An accepted inbound message SHALL be stored once, in the conversation of the company that owns the receiving number, for the sender's WhatsApp number. Meta redelivering the same message id SHALL NOT create a second message. An event for a number no company owns SHALL be dropped. An event the inbox cannot take yet (the service is down, or the company of a configured number is not known yet) SHALL be refused, so that Meta redelivers it. Receiving a message SHALL open the 24-hour reply window.
|
||||
|
||||
#### Scenario: Lead writes to INS
|
||||
|
||||
- **GIVEN** INS lead Aisyah has mobile `+60123456701`
|
||||
- **WHEN** she sends "Hi, about the expo" to INS's number
|
||||
- **THEN** an INS conversation for `60123456701` holds the message, linked to Aisyah's lead
|
||||
- **AND** no CV user can see it
|
||||
|
||||
#### Scenario: Redelivery
|
||||
|
||||
- **WHEN** Meta delivers the same message id twice
|
||||
- **THEN** the conversation holds the message once
|
||||
|
||||
#### Scenario: Inbox not ready
|
||||
|
||||
- **GIVEN** the WhatsApp service has just started and cannot reach the system service yet
|
||||
- **WHEN** Meta delivers a message to INS's number
|
||||
- **THEN** the webhook answers 503 and stores nothing
|
||||
- **AND** when Meta redelivers after the service has resolved INS, the message is stored once
|
||||
|
||||
### Requirement: Delivery status
|
||||
|
||||
The status of a sent message SHALL move only forward, from pending to sent to delivered to read, except that failed SHALL be recorded at any point, together with Meta's error code and title. The thread SHALL show the status as ticks, or as a failure with its reason.
|
||||
|
||||
#### Scenario: Late delivered after read
|
||||
|
||||
- **WHEN** a "read" status arrives and then a "delivered" status arrives for the same message
|
||||
- **THEN** the message stays "read"
|
||||
|
||||
#### Scenario: Send failed
|
||||
|
||||
- **WHEN** Meta rejects a sent message
|
||||
- **THEN** the thread shows the message as failed with Meta's error title
|
||||
|
||||
### Requirement: Automatic ownership
|
||||
|
||||
A conversation without a manual owner SHALL be owned by the lead's latest salesperson (the salesperson of its most recently captured event lead that has one) when that user is active and holds `BO_WHATSAPP`. Otherwise the current owner SHALL be kept while still active with `BO_WHATSAPP`, and the conversation SHALL be unassigned when not. Ownership SHALL be recomputed when the conversation is created and when an event lead of that lead is captured or changes salesperson.
|
||||
|
||||
#### Scenario: Chat follows the latest salesperson
|
||||
|
||||
- **GIVEN** Aisyah's latest event lead has salesperson `sales1`, who holds `BO_WHATSAPP`
|
||||
- **WHEN** Aisyah writes for the first time
|
||||
- **THEN** the conversation is owned by `sales1`
|
||||
|
||||
#### Scenario: Latest event has no salesperson
|
||||
|
||||
- **GIVEN** a conversation owned by `sales1`
|
||||
- **WHEN** Aisyah is captured at a new event without a salesperson
|
||||
- **THEN** the conversation stays with `sales1`
|
||||
|
||||
#### Scenario: Salesperson without WhatsApp access
|
||||
|
||||
- **GIVEN** Aisyah's latest salesperson `sales2` does not hold `BO_WHATSAPP` and the conversation has no owner
|
||||
- **WHEN** ownership is recomputed
|
||||
- **THEN** the conversation is unassigned
|
||||
|
||||
#### Scenario: Unknown sender
|
||||
|
||||
- **WHEN** a number with no lead in INS writes to INS
|
||||
- **THEN** an unassigned conversation without a lead link is created
|
||||
|
||||
### Requirement: Manual assignment
|
||||
|
||||
A WhatsApp Admin SHALL be able to assign a conversation of their company to any active user of that company who holds `BO_WHATSAPP`, including themselves. A manual owner SHALL NOT change when event leads change. "Return to automatic" SHALL clear the manual owner and recompute it.
|
||||
|
||||
#### Scenario: Manual owner sticks
|
||||
|
||||
- **GIVEN** a WhatsApp Admin assigned Aisyah's conversation to `sales3`
|
||||
- **WHEN** Aisyah is captured at a new event with salesperson `sales1`
|
||||
- **THEN** the conversation stays with `sales3`
|
||||
|
||||
#### Scenario: Owner outside WhatsApp
|
||||
|
||||
- **WHEN** a WhatsApp Admin tries to assign a conversation to a user without `BO_WHATSAPP`
|
||||
- **THEN** the request is refused and the owner does not change
|
||||
|
||||
### Requirement: Owner loses access
|
||||
|
||||
When a user is disabled, or their roles no longer grant `BO_WHATSAPP`, the system SHALL make their conversations unassigned and clear any manual assignment. A user locked out by failed logins SHALL keep their conversations.
|
||||
|
||||
#### Scenario: Owner disabled
|
||||
|
||||
- **GIVEN** `sales1` owns three conversations
|
||||
- **WHEN** an admin disables `sales1`
|
||||
- **THEN** the three conversations are unassigned
|
||||
|
||||
### Requirement: Inbox access
|
||||
|
||||
A user with `BO_WHATSAPP` SHALL see, read and reply only in conversations they own. A user with `BO_WHATSAPP_ADMIN` SHALL see every conversation of their company, including unassigned ones, and SHALL be able to read and reply in any of them. A super admin SHALL see the conversations of every company. Every request SHALL be limited to the caller's company, and SHALL fail closed when the caller's company cannot be determined.
|
||||
|
||||
#### Scenario: Staff opens someone else's chat
|
||||
|
||||
- **WHEN** `sales1` requests a conversation owned by `sales3`
|
||||
- **THEN** the request answers 404
|
||||
|
||||
#### Scenario: WhatsApp Admin sees the queue
|
||||
|
||||
- **WHEN** an INS WhatsApp Admin opens the Unassigned tab
|
||||
- **THEN** it lists INS's unassigned conversations and none of CV's
|
||||
|
||||
### Requirement: Replies inside the 24-hour window
|
||||
|
||||
A user SHALL be able to send a text message only while less than 24 hours have passed since the contact's last inbound message. Outside the window a text send SHALL be refused with "The 24-hour window has closed. Send a template." The composer SHALL show the window's state and offer only templates when the window is closed.
|
||||
|
||||
#### Scenario: Window closed
|
||||
|
||||
- **GIVEN** Aisyah last wrote 25 hours ago
|
||||
- **WHEN** `sales1` sends a text reply
|
||||
- **THEN** it is refused and nothing is sent to Meta
|
||||
|
||||
### Requirement: Templates
|
||||
|
||||
A WhatsApp Admin SHALL be able to sync a company's approved templates from that company's business account, and the system SHALL also sync them nightly. Staff SHALL be able to send a synced template with every body parameter filled, inside or outside the window. Templates whose header or buttons need parameters SHALL be listed as not supported and SHALL NOT be sendable.
|
||||
|
||||
#### Scenario: Missing parameter
|
||||
|
||||
- **WHEN** a user sends template `expo_followup` with one of its two parameters empty
|
||||
- **THEN** it is refused and nothing is sent to Meta
|
||||
|
||||
### Requirement: Starting a chat from a lead
|
||||
|
||||
A user with `BO_WHATSAPP` SHALL be able to start a chat from a lead or event lead that has a mobile number, in that lead's company. If the conversation has no owner it SHALL become the starter's as a manual assignment. If another user owns it, the starter SHALL be told who owns it. Until the contact replies, only templates SHALL be offered.
|
||||
|
||||
#### Scenario: Start an unowned chat
|
||||
|
||||
- **GIVEN** Aisyah has no conversation yet and no salesperson with WhatsApp
|
||||
- **WHEN** `sales1` presses WhatsApp on her event lead
|
||||
- **THEN** a conversation owned by `sales1` opens with the template composer
|
||||
|
||||
### Requirement: Incoming media
|
||||
|
||||
Incoming images, documents, audio, video, stickers and locations SHALL be shown in the thread. Media SHALL be fetched from Meta only when a user with access opens it. Media that Meta no longer holds SHALL show "Media expired".
|
||||
|
||||
#### Scenario: Image opened by someone without access
|
||||
|
||||
- **WHEN** a user who cannot see the conversation requests one of its images
|
||||
- **THEN** the request answers 404
|
||||
|
||||
### Requirement: Unread counts
|
||||
|
||||
The system SHALL track, per user, the last message they read in each conversation they can see. It SHALL show unread conversations in the list and the number of unread conversations as a badge on the sidebar's inbox item.
|
||||
|
||||
#### Scenario: Reading clears the badge
|
||||
|
||||
- **GIVEN** `sales1` has one unread conversation
|
||||
- **WHEN** `sales1` opens it
|
||||
- **THEN** the sidebar badge clears
|
||||
|
||||
### Requirement: WhatsApp audit and privacy
|
||||
|
||||
Sending a message, reassigning a conversation and syncing templates SHALL be recorded in the audit log with the conversation and template names but not the message text. Message text, phone numbers, media, tokens and signatures SHALL NOT be written to application logs.
|
||||
|
||||
#### Scenario: Template send audited
|
||||
|
||||
- **WHEN** `sales1` sends template `expo_followup`
|
||||
- **THEN** the audit log records the send by `sales1` with the conversation and template name
|
||||
- **AND** not the filled-in text
|
||||
|
||||
### Requirement: Local Meta stand-in
|
||||
|
||||
The local stack SHALL include a test-only stand-in for Meta's API. It SHALL accept sends, serve templates and media, and post signed inbound events to the webhook on request, so the inbox can be developed and tested without a Meta account. The stand-in SHALL NOT be part of any release.
|
||||
|
||||
#### Scenario: Simulated inbound message
|
||||
|
||||
- **WHEN** a developer asks the stand-in to deliver "Hello" from `+60123456701` to INS's number
|
||||
- **THEN** the INS inbox shows the message within one polling interval
|
||||
Reference in new issue
Block a user