Compare commits

..
Author SHA1 Message Date
ngqileandClaude Opus 5.5 b55b8d2d86 feat(pages): a hero can run full width with points and a form card heading
A full-width hero spans the window with a larger serif headline and a lighter
left-to-right shade. It may list up to 6 points and give its form card a heading
and text. Full-width neighbours join with no gap. Custom HTML frames now shrink
to 20 px and re-report their height when the page asks, so a short top bar no
longer leaves a blank band.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-04 09:46:32 +08:00
ngqile dbb58e6e94 Merge pull request 'fix(pages): a short Custom HTML block shrinks to its content height' (#71) from fix-frame-content-height into main
CI / build-and-publish (push) Failing after 0s
2026-12-03 12:07:10 +00:00
25 changed files with 576 additions and 47 deletions

No files matched your search

+2
View File
@@ -466,4 +466,6 @@ A form stops taking sign-ups when its event is disabled, its end date has passed
**Release add-hero-signup-form (SQL, in its OpenSpec change folder):** deploy services-counter, mobile-api and the portal (any order), then run `sql/01-hero-form-labels.sql` (labels only). A hero section can now carry the sign-up form for an event, beside its text. Rollback: the previous images. A hero saved with an event keeps it in its JSON. The old code ignores it and shows the hero without a form, so add a Sign-up form section to those pages if you roll back. **Release add-hero-signup-form (SQL, in its OpenSpec change folder):** deploy services-counter, mobile-api and the portal (any order), then run `sql/01-hero-form-labels.sql` (labels only). A hero section can now carry the sign-up form for an event, beside its text. Rollback: the previous images. A hero saved with an event keeps it in its JSON. The old code ignores it and shows the hero without a form, so add a Sign-up form section to those pages if you roll back.
**Release add-hero-full-width (SQL, in its OpenSpec change folder):** deploy services-counter, then the portal, then run `sql/01-hero-full-width-labels.sql` (labels only). Deploy services-counter first, because the portal's editor saves the new hero fields. A hero can now run full width, carry bullet points, and give its form card a heading. Custom HTML frames now shrink to fit short content and no longer leave a gap next to a full-width hero. Rollback: the previous images. Saved heroes keep the new fields in their JSON; the old code ignores them and shows the boxed hero. The old services-counter refuses to save a hero that has points or a form heading, so remove them before saving such a page.
**New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand. **New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand.
+10
View File
@@ -1717,6 +1717,16 @@ INSERT INTO message (code, content, area) SELECT 'PagesHeroForm', JSON_OBJECT('e
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名表单') WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A'; UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名表单') WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesNoForm', JSON_OBJECT('en_US', 'No form', 'zh_CN', '不显示表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A'); INSERT INTO message (code, content, area) SELECT 'PagesNoForm', JSON_OBJECT('en_US', 'No form', 'zh_CN', '不显示表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不显示表单') WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A'; UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不显示表单') WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFullWidth', JSON_OBJECT('en_US', 'Full width', 'zh_CN', '全宽'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '全宽') WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPointN', JSON_OBJECT('en_US', 'Point {number}', 'zh_CN', '要点 {number}'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '要点 {number}') WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddPoint', JSON_OBJECT('en_US', 'Add point', 'zh_CN', '添加要点'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加要点') WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT('en_US', 'Form heading', 'zh_CN', '表单标题'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesToolbar', JSON_OBJECT('en_US', 'Formatting', 'zh_CN', '格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A'); INSERT INTO message (code, content, area) SELECT 'PagesToolbar', JSON_OBJECT('en_US', 'Formatting', 'zh_CN', '格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '格式') WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A'; UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '格式') WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesTextStyle', JSON_OBJECT('en_US', 'Text style', 'zh_CN', '文字样式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTextStyle') AND area = 'A'); INSERT INTO message (code, content, area) SELECT 'PagesTextStyle', JSON_OBJECT('en_US', 'Text style', 'zh_CN', '文字样式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTextStyle') AND area = 'A');
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,25 @@
# Design
## Context
The HERO block renders inside `Section`, which wraps every non-HTML block in the page width (`max-w-5xl px-4`). The page's block list is `space-y-10`. Custom HTML blocks already render outside `Section`, so they run full width. The hero-with-form layout comes from add-hero-signup-form.
## Approaches
1. **A `fullWidth` option on HERO (chosen).** Explicit and opt-in, so existing heroes and templates do not change. It costs one boolean and one switch in the editor.
2. **Make every hero with a form full width.** This needs no new field, but it silently changes existing pages and ties two unrelated choices together.
3. **Build the hero in Custom HTML.** This cannot work: a sealed frame cannot hold the real sign-up form (see add-hero-signup-form).
## Decisions
- **Points reuse `cards`.** They use title-only cards, as the trust strip does. The DTO does not change, and the editor reuses the trust strip's item list (`PagesItemN`, `PagesAddItem`). On a HERO the validator allows 0 to 6 cards. FEATURES, STEPS and TRUST keep their 2 to 6 rule.
- **Joins.** A block counts as "bleed" when it is HTML, or when it is a full-width HERO. When a block and the block before it are both bleed, the block gets no top margin. Two Custom HTML blocks next to each other therefore join as well. That changes current pages, but only toward what Custom HTML sections expect: built sections are designed to stack.
- **A full-width hero is not wrapped in `Section`.** It renders outside the page width, in the same way as `HtmlSpot`. Its inner content uses a wider container (`max-w-6xl px-4`).
- **Font.** The headline uses Tailwind's `font-serif`, the system serif. No web font is added, so there is no new dependency and no third-party request.
- **Shade.** The full-width shade is a left-to-right gradient, from `black/75` through `black/45` to `black/10`. It stays black-based, because the design-token test refuses raw colours, and the white text sits on the dark side. On phones the layout stacks and the form card is solid, so contrast holds.
- **Form heading and text.** These are plain text fields edited with `Text` in place, in the same way as the hero heading. They are refused on a hero without an event, so they cannot hide in saved data.
## Risks
- **Contrast with a light photo on the right.** The text sits on the left, over the darkest part of the shade, and the right side holds the solid form card. This is acceptable.
- **Editor controls on the edge.** On the full-width canvas, the image button and the toolbar sit at the window's edge. They are already positioned inside the section by the PR #66 fix.
@@ -0,0 +1,59 @@
# Proposal
## Why
The INS Hotel technology page is being rebuilt in Co-Lite to match INS's standalone landing page (`~/Projects/ins-landing-page`). Since add-hero-signup-form, the form sits beside the hero text, but the hero still looks unlike the original in five ways:
- it is a rounded box inside the page width, with grey space around it, where the original runs edge to edge directly under the top bar;
- its shade is near-black over the whole photo, where the original fades from dark on the left to a clear photo on the right;
- its headline is small and pinned to the top, where the original's is large, serif and vertically centred;
- it has no bullet points under the text;
- the form card has no title or subtitle ("Get a free consultation" / "Tell us about your property…").
Marketing staff cannot fix any of these from the editor.
## What Changes
- A HERO block gains a **Full width** option (`fullWidth`). A full-width hero:
- spans the whole window, with square corners and no page margin;
- is taller, with a larger serif headline, vertically centred;
- uses a lighter shade that runs from dark on the left to almost clear on the right.
- Full-width heroes and Custom HTML blocks that sit next to each other join with no gap, so a Custom HTML top bar runs straight into the hero.
- Custom HTML frames (found in the live check):
- they may shrink to 20 px instead of 100 px, so a 68 px top bar leaves no blank band;
- the page asks each frame for its height once it listens and when the frame loads, because the frame's first report could arrive before the page was ready, leaving it at 600 px.
- A HERO block may carry up to 6 **points**, short title-only lines (`cards`, 80 characters each) shown as a bullet list under its text. The editor reuses the trust strip's item list.
- A HERO with an event may carry a **form heading** (`formHeading`, 80 characters) and **form text** (`formText`, 200 characters), shown at the top of the form card. Both can be typed in place on the canvas.
- The server validates the new fields:
- `fullWidth` is a boolean;
- the hero takes 0 to 6 points, each a non-empty title of at most 80 characters, with no icon or text;
- the form heading and form text are refused on a hero without an event.
- New editor labels in English and Chinese, with an SQL label file for real environments.
Not changing:
- The heroes that exist today. Without the option they look as they do now.
- The sign-up form's fields, the privacy notice and the consent box. They are shared with QR sign-up, and the notice and consent are required by the data-protection rules.
- Field labels and the interests checkboxes.
- The submit button colour, which follows the company's accent colour. For INS's gold button, set INS's accent colour in Companies; that is a setting, not code.
- The red wave decoration at the bottom of the INS hero, which is left out.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Full-Width Hero", "Hero Points" and "Hero Form Heading".
## Impact
- services-counter: `CmsBlock` gains `fullWidth`, `formHeading` and `formText`. `CmsBlockValidator` lets a HERO carry `cards` as points and checks the new fields.
- mobile-api: none. Public blocks pass through as maps.
- Portal:
- `CmsBlocks.tsx` renders the hero layout and the joins between full-width blocks;
- `BlockFields.tsx` gets the Full width switch, the points list and the form heading and text;
- `cmsPages.ts` gets the types;
- new labels in `defaultMessages.ts` and `zh_CN.seed.json`.
- Data: no schema change, because the blocks are JSON. The new labels need a SQL label file in this change folder for real environments.
@@ -0,0 +1,86 @@
## ADDED Requirements
### Requirement: Full-Width Hero
A HERO block MAY be marked full width. A full-width hero SHALL span the whole window with square corners, show its heading larger and centred top to bottom in the hero's opening height (not beside a long form), and use a shade that is darker on the text side than on the far side. A hero that is not marked full width SHALL look as it did before. The server SHALL refuse a `fullWidth` value that is not true or false.
#### Scenario: Hero runs edge to edge under a Custom HTML top bar
- **GIVEN** page `/p/INS/hotel-technology` with a Custom HTML top bar followed by a full-width HERO with an image and an event
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the hero spans the full window width
- **AND** the form card sits beside the heading
#### Scenario: Existing hero unchanged
- **WHEN** a visitor opens a page whose HERO block is not marked full width
- **THEN** the hero sits inside the page width with rounded corners, as before
#### Scenario: Turn on full width in the editor
- **GIVEN** staff editing a page with a HERO block
- **WHEN** they switch on "Full width" in the hero's settings
- **THEN** the canvas shows the hero across the full width
### Requirement: Full-Width Blocks Join Without Gaps
A full-width HERO and a Custom HTML block next to each other SHALL join with no gap between them, and so SHALL two Custom HTML blocks next to each other. Other blocks SHALL keep their usual spacing.
#### Scenario: Top bar runs straight into the hero
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
- **WHEN** a visitor opens the page
- **THEN** the hero starts directly under the top bar, with no gap
### Requirement: Hero Points
A HERO block MAY carry up to 6 points, each a non-empty title of at most 80 characters, with no icon and no text. The hero SHALL show its points as a bulleted list under its text. The server SHALL refuse more than 6 points, an empty or over-long point, and a point with an icon or text, naming the field.
#### Scenario: Points under the hero text
- **GIVEN** a HERO block with points "One accountable partner instead of five vendors" and "Local support team in Malaysia"
- **WHEN** a visitor opens the page
- **THEN** both points show as a bulleted list under the hero text
#### Scenario: Too many points refused
- **WHEN** staff save a HERO block with 7 points
- **THEN** the save is refused at `blocks[n].cards`
### Requirement: Hero Form Heading
A HERO block with an event MAY carry a form heading of at most 80 characters and a form text of at most 200 characters. The hero SHALL show them at the top of its form card, above the form. The server SHALL refuse either on a hero without an event. On the canvas, staff SHALL be able to type both in place.
#### Scenario: Card shows its heading
- **GIVEN** a HERO block with an event, form heading "Get a free consultation" and form text "Tell us about your property. It takes under a minute."
- **WHEN** a visitor opens the page
- **THEN** the form card starts with that heading and text, followed by the form
#### Scenario: Form heading without a form refused
- **WHEN** staff save a HERO block with a form heading and no event
- **THEN** the save is refused at `blocks[n].formHeading`
## MODIFIED Requirements
### Requirement: Custom HTML Frame Height
The frame SHALL grow or shrink to fit its content, between 20 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall. The frame SHALL report the height of its content, not of its own window, and SHALL report again whenever the page asks, which the page SHALL do once it listens and when the frame loads.
#### Scenario: A tall paste grows the frame
- **GIVEN** a published HTML block whose content is 3000 pixels tall
- **WHEN** a visitor opens the page
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
#### Scenario: A short top bar shrinks the frame
- **GIVEN** a published HTML block holding only a 68 pixel top bar
- **WHEN** a visitor opens the page, even if the frame loaded before the page was ready
- **THEN** the frame is 68 pixels tall, with no blank space below the bar
#### Scenario: Another frame cannot resize it
- **WHEN** a different window posts a height report to the page
- **THEN** the frame's height does not change
@@ -0,0 +1,13 @@
-- The labels added by add-hero-full-width, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesFullWidth', JSON_OBJECT('en_US', 'Full width', 'zh_CN', '全宽'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '全宽') WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesPointN', JSON_OBJECT('en_US', 'Point {number}', 'zh_CN', '要点 {number}'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '要点 {number}') WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddPoint', JSON_OBJECT('en_US', 'Add point', 'zh_CN', '添加要点'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加要点') WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT('en_US', 'Form heading', 'zh_CN', '表单标题'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
@@ -0,0 +1,69 @@
# Tasks
## 1. Server
- [x] 1.1 services-counter `CmsBlock`: add `fullWidth` (Boolean), `formHeading` and `formText`. `CmsBlockValidator` HERO rules:
- allow `cards` on a HERO, 0 to 6 of them, each with a title that is required and at most 80 characters, and no icon or text;
- `formHeading` at most 80 characters and `formText` at most 200;
- refuse `formHeading` or `formText` without `eventUuid` (`PagesUnusedField`).
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
## 2. Portal
- [x] 2.1 `cmsPages.ts` types. In `CmsBlocks.tsx`:
- the HERO shows its points as a bulleted list;
- the form card shows `formHeading` and `formText`, editable in place;
- a full-width HERO renders outside the page width, with a larger serif heading, vertical centring and the lighter left-to-right shade;
- adjacent bleed blocks (HTML, or a full-width HERO) get no gap between them.
Verify: render tests fail first, then pass; vitest exit 0.
- [x] 2.2 `BlockFields.tsx`:
- the Hero gets a "Full width" switch, the points list (reusing the trust strip's item list), and the form heading and text fields, shown only when an event is picked;
- `INLINE.HERO` includes `formHeading`, `formText` and the points;
- add the labels to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-hero-full-width-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
Verify: editor tests fail first, then pass; tsc and lint clean.
## 3. Verification
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology` through the editor:
- turn on Full width;
- add the three INS points;
- set the form heading and text;
- publish the page.
Then check the published page at 1280 px and 390 px against the INS page, and check a save with 7 points shows the refusal on the canvas.
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-hero-full-width --strict`.
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:**
- the validator tests failed on points and the form heading;
- the render tests failed on full width, points, the card heading and the joins;
- the editor and company-switch tests failed;
- the frame floor, ask and answer tests failed.
- **Changed existing tests:**
- `CmsBlocks.html.test.tsx` "starts a header-less page flush at the top" now checks that the first block row has no top margin. It used to check for a `space-y` class, which is no longer how spacing works. It still asserts that the hidden title is outside the spacing.
- `frameHtml.test.ts` clamp test: the floor is now 20 px, per the modified "Custom HTML Frame Height" requirement. It also checks that 68 stays 68.
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology` through the editor:
- Full width switched on;
- three points and the form heading and text typed on the canvas;
- saved and published.
- **Published result at 1280 px:**
- the hero runs flush under the top bar and into the rest of the page;
- the serif headline is centred in the first screen;
- the points show in the accent colour, and the card has its heading.
- **Published result at 390 px:** the layout stacks, with the card below the text.
- **Fixes from the live check:**
- the text is centred in the opening height, not beside the long form;
- the frame floor is 20 px;
- the page asks frames for their height (both added to the spec).
- **Not reachable in the UI, covered by the validator tests:**
- 7 points, because Add point stops at 6;
- a form heading without a form, because No form clears it.
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
@@ -6,6 +6,7 @@ import { BLOCK_LABELS, ICONS, LOOKS, imageSrc, type CmsBlock, type CmsCard, type
import { Button } from "@/app/components/ui/button"; import { Button } from "@/app/components/ui/button";
import { Input } from "@/app/components/ui/input"; import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label"; import { Label } from "@/app/components/ui/label";
import { Switch } from "@/app/components/ui/switch";
import { Textarea } from "@/app/components/ui/textarea"; import { Textarea } from "@/app/components/ui/textarea";
import { useT } from "@/app/lib/i18n/MessagesProvider"; import { useT } from "@/app/lib/i18n/MessagesProvider";
import { RichTextEditor } from "./RichTextEditor"; import { RichTextEditor } from "./RichTextEditor";
@@ -14,7 +15,7 @@ import { RichTextEditor } from "./RichTextEditor";
/** Field paths (relative to the block) each type shows inline; any other error shows at the block's top. Every type also shows "anchor". */ /** Field paths (relative to the block) each type shows inline; any other error shows at the block's top. Every type also shows "anchor". */
const INLINE: Record<string, string[]> = { const INLINE: Record<string, string[]> = {
HERO: ["imageId", "heading", "text", "buttonLabel", "buttonUrl", "eventUuid"], HERO: ["imageId", "heading", "text", "buttonLabel", "buttonUrl", "eventUuid", "fullWidth", "formHeading", "formText", "cards"],
RICH_TEXT: ["html"], RICH_TEXT: ["html"],
IMAGE_TEXT: ["imageId", "imagePosition", "heading", "html", "buttonLabel", "buttonUrl"], IMAGE_TEXT: ["imageId", "imagePosition", "heading", "html", "buttonLabel", "buttonUrl"],
FAQ: ["heading", "items"], FAQ: ["heading", "items"],
@@ -34,10 +35,12 @@ const ICON_LABELS: Record<string, string> = {
"shield-check": "PagesIconShieldCheck", cloud: "PagesIconCloud", wrench: "PagesIconWrench", headset: "PagesIconHeadset", "shield-check": "PagesIconShieldCheck", cloud: "PagesIconCloud", wrench: "PagesIconWrench", headset: "PagesIconHeadset",
users: "PagesIconUsers", calendar: "PagesIconCalendar", star: "PagesIconStar", users: "PagesIconUsers", calendar: "PagesIconCalendar", star: "PagesIconStar",
}; };
const CARD_KINDS: Record<string, { legend: string; add: string; icon: boolean; text: boolean; empty: CmsCard }> = { // add-hero-full-width: a hero's points are title-only cards, and it may have none.
FEATURES: { legend: "PagesCardN", add: "PagesAddCard", icon: true, text: true, empty: { icon: "star", title: "", text: "" } }, const CARD_KINDS: Record<string, { legend: string; add: string; icon: boolean; text: boolean; min: number; empty: CmsCard }> = {
STEPS: { legend: "PagesStepN", add: "PagesAddStep", icon: false, text: true, empty: { title: "", text: "" } }, FEATURES: { legend: "PagesCardN", add: "PagesAddCard", icon: true, text: true, min: 2, empty: { icon: "star", title: "", text: "" } },
TRUST: { legend: "PagesItemN", add: "PagesAddItem", icon: false, text: false, empty: { title: "" } }, STEPS: { legend: "PagesStepN", add: "PagesAddStep", icon: false, text: true, min: 2, empty: { title: "", text: "" } },
TRUST: { legend: "PagesItemN", add: "PagesAddItem", icon: false, text: false, min: 2, empty: { title: "" } },
HERO: { legend: "PagesPointN", add: "PagesAddPoint", icon: false, text: false, min: 0, empty: { title: "" } },
}; };
const SELECT = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm disabled:cursor-not-allowed disabled:opacity-50"; const SELECT = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm disabled:cursor-not-allowed disabled:opacity-50";
@@ -83,7 +86,7 @@ export function BlockFields(props: {
const fid = (name: string) => `block-${id}-${name}`; const fid = (name: string) => `block-${id}-${name}`;
const topErrors = Object.entries(errors).filter(([path]) => path !== "anchor" && path !== "look" && !INLINE[block.type]?.includes(path) && !LISTED.test(path)); const topErrors = Object.entries(errors).filter(([path]) => path !== "anchor" && path !== "look" && !INLINE[block.type]?.includes(path) && !LISTED.test(path));
const text = (name: "heading" | "text" | "buttonLabel" | "buttonUrl" | "anchor", labelCode: string) => ( const text = (name: "heading" | "text" | "buttonLabel" | "buttonUrl" | "anchor" | "formHeading" | "formText", labelCode: string) => (
<Field id={fid(name)} label={t(labelCode)} error={errors[name]}> <Field id={fid(name)} label={t(labelCode)} error={errors[name]}>
<Input id={fid(name)} value={block[name] ?? ""} disabled={saving} aria-invalid={!!errors[name]} onChange={(e) => set({ [name]: e.target.value })} /> <Input id={fid(name)} value={block[name] ?? ""} disabled={saving} aria-invalid={!!errors[name]} onChange={(e) => set({ [name]: e.target.value })} />
</Field> </Field>
@@ -100,7 +103,7 @@ export function BlockFields(props: {
const eventPicker = (labelCode: string, emptyCode: string) => ( const eventPicker = (labelCode: string, emptyCode: string) => (
<Field id={fid("event")} label={t(labelCode)} error={errors.eventUuid}> <Field id={fid("event")} label={t(labelCode)} error={errors.eventUuid}>
<select id={fid("event")} className={SELECT} value={block.eventUuid ?? ""} disabled={saving} aria-invalid={!!errors.eventUuid} <select id={fid("event")} className={SELECT} value={block.eventUuid ?? ""} disabled={saving} aria-invalid={!!errors.eventUuid}
onChange={(e) => set({ eventUuid: e.target.value || null })}> onChange={(e) => set(e.target.value ? { eventUuid: e.target.value } : { eventUuid: null, formHeading: undefined, formText: undefined })}>
<option value="">{t(emptyCode)}</option> <option value="">{t(emptyCode)}</option>
{events.map((ev) => <option key={ev.uuid} value={ev.uuid}>{ev.name}</option>)} {events.map((ev) => <option key={ev.uuid} value={ev.uuid}>{ev.name}</option>)}
{block.eventUuid && !events.some((ev) => ev.uuid === block.eventUuid) ? ( {block.eventUuid && !events.some((ev) => ev.uuid === block.eventUuid) ? (
@@ -140,8 +143,8 @@ export function BlockFields(props: {
<> <>
{cards.map((card, i) => { {cards.map((card, i) => {
const err = (f: string) => errors[`cards[${i}].${f}`]; const err = (f: string) => errors[`cards[${i}].${f}`];
const cardField = (f: "title" | "text", labelCode: string, multiline: boolean) => ( const cardField = (f: "title" | "text", label: string, multiline: boolean) => (
<Field id={fid(`c${i}${f}`)} label={t(labelCode)} error={err(f)}> <Field id={fid(`c${i}${f}`)} label={label} error={err(f)}>
{multiline {multiline
? <Textarea id={fid(`c${i}${f}`)} rows={2} value={card[f] ?? ""} disabled={saving} aria-invalid={!!err(f)} ? <Textarea id={fid(`c${i}${f}`)} rows={2} value={card[f] ?? ""} disabled={saving} aria-invalid={!!err(f)}
onChange={(e) => setCards(cards.map((c, j) => (j === i ? { ...c, [f]: e.target.value } : c)))} /> onChange={(e) => setCards(cards.map((c, j) => (j === i ? { ...c, [f]: e.target.value } : c)))} />
@@ -160,12 +163,12 @@ export function BlockFields(props: {
</select> </select>
</Field> </Field>
) : null} ) : null}
{cardField("title", "PagesCardTitle", false)} {cardField("title", kind.min ? t("PagesCardTitle") : t(kind.legend, { number: i + 1 }), false)}
{kind.text ? cardField("text", "PagesCardText", true) : null} {kind.text ? cardField("text", t("PagesCardText"), true) : null}
<div className="flex flex-wrap gap-1"> <div className="flex flex-wrap gap-1">
<Button type="button" variant="ghost" size="sm" disabled={saving || i === 0} onClick={() => moveCard(i, -1)}>{t("PagesMoveUp")}</Button> <Button type="button" variant="ghost" size="sm" disabled={saving || i === 0} onClick={() => moveCard(i, -1)}>{t("PagesMoveUp")}</Button>
<Button type="button" variant="ghost" size="sm" disabled={saving || i === cards.length - 1} onClick={() => moveCard(i, 1)}>{t("PagesMoveDown")}</Button> <Button type="button" variant="ghost" size="sm" disabled={saving || i === cards.length - 1} onClick={() => moveCard(i, 1)}>{t("PagesMoveDown")}</Button>
<Button type="button" variant="ghost" size="sm" disabled={saving || cards.length <= 2} onClick={() => setCards(cards.filter((_, j) => j !== i))}>{t("PagesRemoveCard")}</Button> <Button type="button" variant="ghost" size="sm" disabled={saving || cards.length <= kind.min} onClick={() => setCards(cards.filter((_, j) => j !== i))}>{t("PagesRemoveCard")}</Button>
</div> </div>
</fieldset> </fieldset>
); );
@@ -204,7 +207,18 @@ export function BlockFields(props: {
{text("text", "PagesText")} {text("text", "PagesText")}
{text("buttonLabel", "PagesButtonLabel")} {text("buttonLabel", "PagesButtonLabel")}
{text("buttonUrl", "PagesButtonLink")} {text("buttonUrl", "PagesButtonLink")}
<div className="flex items-center gap-2">
<Switch id={fid("fullWidth")} checked={!!block.fullWidth} disabled={saving} onCheckedChange={(on) => set({ fullWidth: on || undefined })} />
<Label htmlFor={fid("fullWidth")}>{t("PagesFullWidth")}</Label>
</div>
{cardList}
{eventPicker("PagesHeroForm", "PagesNoForm")} {eventPicker("PagesHeroForm", "PagesNoForm")}
{block.eventUuid ? (
<>
{text("formHeading", "PagesFormHeading")}
{text("formText", "PagesFormText")}
</>
) : null}
</> </>
)} )}
@@ -58,6 +58,18 @@ describe("LandingPage: Custom HTML", () => {
expect(frame().style.height).toBe("2400px"); expect(frame().style.height).toBe("2400px");
}); });
// add-hero-full-width: the frame's first report can arrive before the page listens, so the page asks once it does.
it("asks its frame for a height report once it listens, and again when the frame loads", () => {
const sealed = { postMessage: vi.fn() };
const getter = vi.spyOn(HTMLIFrameElement.prototype, "contentWindow", "get").mockReturnValue(sealed as unknown as Window);
onTestFinished(() => getter.mockRestore());
render(<LandingPage company={company} page={page([HTML])} />);
expect(sealed.postMessage).toHaveBeenCalledWith({ type: "colite-frame-ask" }, "*");
sealed.postMessage.mockClear();
act(() => { frame().dispatchEvent(new Event("load")); });
expect(sealed.postMessage).toHaveBeenCalledWith({ type: "colite-frame-ask" }, "*");
});
it("grows inside another document too: it listens on its own document's window (add-page-visual-editor)", () => { it("grows inside another document too: it listens on its own document's window (add-page-visual-editor)", () => {
const host = document.createElement("iframe"); const host = document.createElement("iframe");
document.body.appendChild(host); document.body.appendChild(host);
@@ -80,6 +92,7 @@ describe("LandingPage: Custom HTML", () => {
render(<LandingPage company={company} page={page([HTML], true)} />); render(<LandingPage company={company} page={page([HTML], true)} />);
const title = screen.getByRole("heading", { level: 1, name: "Hotel day" }); const title = screen.getByRole("heading", { level: 1, name: "Hotel day" });
expect(title.parentElement!.className).not.toMatch(/space-y/); expect(title.parentElement!.className).not.toMatch(/space-y/);
expect(frame().parentElement!.className).toMatch(/space-y/); // add-hero-full-width: spacing is a top margin on each block row after the first, so the first row has none.
expect(frame().closest("main > div > div")).not.toHaveClass("mt-10");
}); });
}); });
@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react"; import { render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
import { describe, it, expect, vi, beforeEach } from "vitest"; import { describe, it, expect, vi, beforeEach } from "vitest";
import { LandingPage, type PublicBlock } from "./CmsBlocks"; import { LandingPage, type PublicBlock } from "./CmsBlocks";
@@ -103,6 +103,46 @@ describe("LandingPage", () => {
}); });
}); });
// add-hero-full-width: edge-to-edge hero, points, the form card's heading, and flush full-width neighbours.
describe("LandingPage full-width hero", () => {
const ins = { type: "HERO" as const, heading: "One partner", fullWidth: true, eventUuid: "77", closed: true,
cards: [{ title: "One accountable partner" }, { title: "Local support team in Malaysia" }],
formHeading: "Get a free consultation", formText: "Tell us about your property." };
it("runs outside the page width with square corners; a plain hero stays boxed in the page width", () => {
render(<LandingPage company={company} page={page([ins, { type: "HERO", heading: "Boxed" }])} />);
const wide = screen.getByRole("heading", { name: "One partner" }).closest("section")!;
expect(wide.closest(".max-w-5xl")).toBeNull();
expect(wide).not.toHaveClass("rounded-lg");
const boxed = screen.getByRole("heading", { name: "Boxed" }).closest("section")!;
expect(boxed.closest(".max-w-5xl")).not.toBeNull();
expect(boxed).toHaveClass("rounded-lg");
});
it("shows its points as a list under the text", () => {
render(<LandingPage company={company} page={page([ins])} />);
const hero = screen.getByRole("heading", { name: "One partner" }).closest("section")!;
const items = within(hero).getAllByRole("listitem");
expect(items.map((li) => li.textContent)).toEqual(["One accountable partner", "Local support team in Malaysia"]);
});
it("starts the form card with its heading and text", () => {
render(<LandingPage company={company} page={page([ins])} />);
const title = screen.getByRole("heading", { name: "Get a free consultation" });
const card = title.parentElement!.parentElement!;
expect(card).toHaveTextContent(/^Get a free consultation\s*Tell us about your property\./);
expect(card).toHaveTextContent("Sign-up is closed.");
});
it("joins a Custom HTML block and a full-width hero with no gap; other blocks keep theirs", () => {
render(<LandingPage company={company} frameBase="/f" page={page([
{ type: "HTML", html: "<header>Top</header>" }, ins, { type: "HTML", html: "<p>Rest</p>" }, { type: "RICH_TEXT", html: "<p>After</p>" },
])} />);
const rows = Array.from(document.querySelector("main > div")!.children);
expect(rows.map((r) => r.classList.contains("mt-10"))).toEqual([false, false, false, true]);
});
});
describe("utmTags", () => { describe("utmTags", () => {
it("reads the three tags, capped at 100 characters", () => { it("reads the three tags, capped at 100 characters", () => {
expect(utmTags("?utm_source=" + "x".repeat(150))).toEqual({ utmSource: "x".repeat(100), utmMedium: undefined, utmCampaign: undefined }); expect(utmTags("?utm_source=" + "x".repeat(150))).toEqual({ utmSource: "x".repeat(100), utmMedium: undefined, utmCampaign: undefined });
@@ -47,31 +47,70 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
const button = <ButtonLink block={block} index={index} edit={edit} />; const button = <ButtonLink block={block} index={index} edit={edit} />;
switch (block.type) { switch (block.type) {
case "HERO": { case "HERO": {
const wide = !!block.fullWidth;
const points = block.cards?.length ? (
<ul className="space-y-2">
{block.cards.map((card, i) => (
<li key={i} className="flex items-baseline gap-3 before:size-2 before:shrink-0 before:rounded-full before:bg-primary">
<Text as="span" index={index} path={`cards.${i}.title`} value={card.title} max={80} code="PagesPointN" n={i + 1} />
</li>
))}
</ul>
) : null;
const words = ( const words = (
<> <>
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-3xl font-semibold sm:text-4xl" /> <Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading"
className={wide ? "font-serif text-4xl leading-tight font-semibold sm:text-5xl" : "text-3xl font-semibold sm:text-4xl"} />
<Text as="p" index={index} path="text" value={block.text} max={300} code="PagesText" className="max-w-2xl text-lg" /> <Text as="p" index={index} path="text" value={block.text} max={300} code="PagesText" className="max-w-2xl text-lg" />
{points}
<div>{button}</div> <div>{button}</div>
</> </>
); );
// add-hero-signup-form: with an event, the sign-up form sits in a card beside the text (below it on phones). // add-hero-signup-form: with an event, the sign-up form sits in a card beside the text (below it on phones).
if (block.eventUuid) { // add-hero-full-width: the card may open with its own heading and text.
// Top padding leaves room for the editor's image button in the corner. const card = block.eventUuid ? (
const grid = "grid items-start gap-6 px-6 pt-16 pb-6 md:grid-cols-[minmax(0,1fr)_minmax(0,26rem)] md:px-10 md:pb-10"; <div className="space-y-4 rounded-lg border bg-card p-6 text-card-foreground shadow-card">
return ( {block.formHeading || block.formText || edit ? (
<section className={`relative overflow-hidden rounded-lg ${bandOf(block.look) ? "" : "bg-muted"}`}> <div className="space-y-1">
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner /> <Text as="h3" index={index} path="formHeading" value={block.formHeading} max={80} code="PagesFormHeading" className="font-serif text-2xl font-semibold" />
<HeroShade index={index} image={!!image} shaded={`relative ${grid} bg-gradient-to-r from-black/80 via-black/60 to-black/40 text-white sm:min-h-96`} plain={grid}> <Text as="p" index={index} path="formText" value={block.formText} max={200} code="PagesFormText" className="text-sm text-muted-foreground" />
<div className="flex flex-col gap-3">{words}</div> </div>
<div className="rounded-lg border bg-card p-6 text-card-foreground shadow-card"> ) : null}
<LandingForm companyCode={company} slug={slug} index={index} info={block.closed ? undefined : block.form} preview={preview} /> <LandingForm companyCode={company} slug={slug} index={index} info={block.closed ? undefined : block.form} preview={preview} />
</div> </div>
) : null;
const back = bandOf(block.look) ? "" : "bg-muted";
if (wide) {
// Edge to edge; the shade is darkest behind the text and clears toward the far side. The text is centred in the
// hero's opening height, not beside a long form, so it stays in the first screen.
const grid = `mx-auto grid w-full max-w-6xl items-start gap-8 px-4 pt-16 pb-12 ${card ? "md:grid-cols-[minmax(0,1fr)_minmax(0,28rem)]" : ""}`;
return (
<section className={`relative overflow-hidden ${back}`}>
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner />
<HeroShade index={index} image={!!image} shaded="relative bg-gradient-to-r from-black/75 via-black/45 to-black/10 text-white" plain="">
<div className={grid}>
<div className="flex flex-col justify-center gap-4 md:min-h-[32rem]">{words}</div>
{card}
</div>
</HeroShade> </HeroShade>
</section> </section>
); );
} }
if (card) {
// Top padding leaves room for the editor's image button in the corner.
const grid = "grid items-start gap-6 px-6 pt-16 pb-6 md:grid-cols-[minmax(0,1fr)_minmax(0,26rem)] md:px-10 md:pb-10";
return ( return (
<section className={`relative overflow-hidden rounded-lg ${bandOf(block.look) ? "" : "bg-muted"}`}> <section className={`relative overflow-hidden rounded-lg ${back}`}>
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner />
<HeroShade index={index} image={!!image} shaded={`relative ${grid} bg-gradient-to-r from-black/80 via-black/60 to-black/40 text-white sm:min-h-96`} plain={grid}>
<div className="flex flex-col gap-3">{words}</div>
{card}
</HeroShade>
</section>
);
}
return (
<section className={`relative overflow-hidden rounded-lg ${back}`}>
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner /> <ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner />
<HeroShade index={index} image={!!image} <HeroShade index={index} image={!!image}
shaded="relative flex min-h-72 flex-col justify-end gap-3 bg-gradient-to-t from-black/80 via-black/50 to-transparent p-6 text-white sm:min-h-96" shaded="relative flex min-h-72 flex-col justify-end gap-3 bg-gradient-to-t from-black/80 via-black/50 to-transparent p-6 text-white sm:min-h-96"
@@ -189,9 +228,14 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
const WIDTH = "mx-auto w-full max-w-5xl px-4"; const WIDTH = "mx-auto w-full max-w-5xl px-4";
/** Blocks that run the full window width: Custom HTML, and a full-width hero. Two of them in a row join with no gap. */
const bleeds = (block: PublicBlock) => block.type === "HTML" || (block.type === "HERO" && !!block.fullWidth);
/** A block in the page width; with a non-default look, inside a full-width band of that colour. */ /** A block in the page width; with a non-default look, inside a full-width band of that colour. */
function Section({ block, index, children }: { block: PublicBlock; index: number; children: ReactNode }) { function Section({ block, index, children }: { block: PublicBlock; index: number; children: ReactNode }) {
const band = bandOf(block.look); const band = bandOf(block.look);
// add-hero-full-width: a full-width hero sets its own width.
if (bleeds(block)) return <EditSection index={index}><div id={anchorId(block.anchor)}>{children}</div></EditSection>;
if (!band) return <EditSection index={index}><div id={anchorId(block.anchor)} className={WIDTH}>{children}</div></EditSection>; if (!band) return <EditSection index={index}><div id={anchorId(block.anchor)} className={WIDTH}>{children}</div></EditSection>;
return ( return (
<EditSection index={index}> <EditSection index={index}>
@@ -235,10 +279,14 @@ export function LandingPage({ company, page, banner, preview, frameBase, edit }:
</header>} </header>}
<main className={page.hideHeader ? "pb-8" : "py-8"}> <main className={page.hideHeader ? "pb-8" : "py-8"}>
<h1 className={page.hideHeader ? "sr-only" : `${WIDTH} mb-10 text-3xl font-semibold sm:text-4xl`}>{page.title}</h1> <h1 className={page.hideHeader ? "sr-only" : `${WIDTH} mb-10 text-3xl font-semibold sm:text-4xl`}>{page.title}</h1>
<div className="space-y-10"> <div>
{page.blocks.map((block, i) => block.type === "HTML" {page.blocks.map((block, i) => (
? <HtmlSpot key={i} index={i}><HtmlFrame id={anchorId(block.anchor)} src={`${frames}/${i}${edit ? `?v=${edit.frameVersion}` : ""}`} title={page.title} /></HtmlSpot> <div key={i} className={i > 0 && !(bleeds(block) && bleeds(page.blocks[i - 1])) ? "mt-10" : undefined}>
: <Section key={i} block={block} index={i}><Block block={block} index={i} company={company.code} slug={page.slug} preview={preview} edit={!!edit} /></Section>)} {block.type === "HTML"
? <HtmlSpot index={i}><HtmlFrame id={anchorId(block.anchor)} src={`${frames}/${i}${edit ? `?v=${edit.frameVersion}` : ""}`} title={page.title} /></HtmlSpot>
: <Section block={block} index={i}><Block block={block} index={i} company={company.code} slug={page.slug} preview={preview} edit={!!edit} /></Section>}
</div>
))}
</div> </div>
</main> </main>
</div> </div>
@@ -1,7 +1,10 @@
"use client"; "use client";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { FRAME_SANDBOX, frameAnchor, nextFrameHeight, START_HEIGHT, type FrameHeight } from "@/app/lib/frameHtml"; import { FRAME_ASK_MESSAGE, FRAME_SANDBOX, frameAnchor, nextFrameHeight, START_HEIGHT, type FrameHeight } from "@/app/lib/frameHtml";
// add-hero-full-width: the frame may have reported before this page listened; ask on mount, and again when it loads.
const ask = (frame: HTMLIFrameElement | null) => frame?.contentWindow?.postMessage({ type: FRAME_ASK_MESSAGE }, "*");
/** A Custom HTML block: the sealed frame, sized by height reports and scrolled to by #name requests from that frame's own window only. */ /** A Custom HTML block: the sealed frame, sized by height reports and scrolled to by #name requests from that frame's own window only. */
export function HtmlFrame({ id, src, title }: { id?: string; src: string; title: string }) { export function HtmlFrame({ id, src, title }: { id?: string; src: string; title: string }) {
@@ -22,7 +25,8 @@ export function HtmlFrame({ id, src, title }: { id?: string; src: string; title:
if (block?.closest("main")) block.scrollIntoView({ behavior: "smooth" }); if (block?.closest("main")) block.scrollIntoView({ behavior: "smooth" });
}; };
host.addEventListener("message", onMessage); host.addEventListener("message", onMessage);
ask(ref.current);
return () => host.removeEventListener("message", onMessage); return () => host.removeEventListener("message", onMessage);
}, []); }, []);
return <iframe ref={ref} id={id} src={src} title={title} sandbox={FRAME_SANDBOX} loading="lazy" className="block w-full border-0" style={{ height: `${size.height}px` }} />; return <iframe ref={ref} id={id} src={src} title={title} sandbox={FRAME_SANDBOX} loading="lazy" onLoad={(e) => ask(e.currentTarget)} className="block w-full border-0" style={{ height: `${size.height}px` }} />;
} }
@@ -125,6 +125,33 @@ describe("PageEditor", () => {
expect(mocks.savePage.mock.calls[1][1].blocks[0].eventUuid ?? null).toBeNull(); expect(mocks.savePage.mock.calls[1][1].blocks[0].eventUuid ?? null).toBeNull();
}); });
// add-hero-full-width: Full width, points, and the form card's heading and text (only while the hero has a form).
it("saves a full-width hero with points and a form heading; No form drops the heading and text", async () => {
const user = userEvent.setup();
render(<PageEditor pageId={5} />);
const picker = await screen.findByLabelText("Sign-up form");
expect(screen.queryByLabelText("Form heading")).not.toBeInTheDocument();
await user.click(screen.getByRole("switch", { name: "Full width" }));
await user.click(screen.getByRole("button", { name: "Add point" }));
await user.type(screen.getByRole("textbox", { name: "Point 1" }), "Local support team");
await waitFor(() => expect(within(picker).getByRole("option", { name: "Website enquiries" })).toBeInTheDocument());
await user.selectOptions(picker, "3312726793093644288");
await user.type(screen.getByLabelText("Form heading"), "Get a free consultation");
await user.type(screen.getByLabelText("Form text"), "It takes a minute.");
await user.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(1));
expect(mocks.savePage.mock.calls[0][1].blocks[0]).toMatchObject({
type: "HERO", fullWidth: true, cards: [{ title: "Local support team" }],
formHeading: "Get a free consultation", formText: "It takes a minute.",
});
await user.selectOptions(screen.getByLabelText("Sign-up form"), "");
expect(screen.queryByLabelText("Form heading")).not.toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(2));
const hero = mocks.savePage.mock.calls[1][1].blocks[0];
expect([hero.formHeading, hero.formText]).toEqual([undefined, undefined]);
});
it("a super admin must choose a company for a new page", async () => { it("a super admin must choose a company for a new page", async () => {
mocks.useAdminAuth.mockReturnValue({ isSuper: true, companyCode: null }); mocks.useAdminAuth.mockReturnValue({ isSuper: true, companyCode: null });
const user = userEvent.setup(); const user = userEvent.setup();
@@ -58,6 +58,16 @@ describe("usePageDraft for the on-page editor", () => {
expect(result.current.rows.map((r) => r.block.eventUuid ?? null)).toEqual([null, null, null]); expect(result.current.rows.map((r) => r.block.eventUuid ?? null)).toEqual([null, null, null]);
}); });
// add-hero-full-width: the form card's heading and text go with the form, or the server refuses the save.
it("a company switch also drops a hero's form heading and text", async () => {
mocks.getPage.mockResolvedValueOnce({ ...stored, blocks: [
{ type: "HERO" as const, heading: "Hi", eventUuid: "77", formHeading: "Get a free consultation", formText: "Quick." },
] });
const { result } = await loaded();
act(() => result.current.changeCompany(3));
expect(result.current.rows[0].block).toEqual({ type: "HERO", heading: "Hi", eventUuid: null });
});
it("keeps the company's branding from the loaded page", async () => { it("keeps the company's branding from the loaded page", async () => {
const { result } = await loaded(); const { result } = await loaded();
expect(result.current.branding).toEqual(stored.company); expect(result.current.branding).toEqual(stored.company);
@@ -191,11 +191,18 @@ export function usePageDraft({ pageId, fromId, initialBlocks }: { pageId?: numbe
step("page:title"); step("page:title");
setDraft((d) => withTitle(d, title)); setDraft((d) => withTitle(d, title));
}; };
/** A super admin's new page changes company: FORM blocks and hero sign-up forms lose their event, which belongs to the old one. */ /**
* A super admin's new page changes company: FORM blocks and hero sign-up forms lose their event, which belongs to the old one,
* and a hero's form heading and text go with its form (add-hero-full-width).
*/
const changeCompany = (companyId: number) => { const changeCompany = (companyId: number) => {
step(null); step(null);
setDraft((d) => ({ ...d, companyId })); setDraft((d) => ({ ...d, companyId }));
setRows((rs) => rs.map((r) => (r.block.eventUuid ? { ...r, block: { ...r.block, eventUuid: null } } : r))); setRows((rs) => rs.map((r) => {
if (!r.block.eventUuid) return r;
const { formHeading: _h, formText: _t, ...block } = r.block;
return { ...r, block: { ...block, eventUuid: null } };
}));
}; };
const setBlock = (key: number, update: (block: CmsBlock) => CmsBlock) => const setBlock = (key: number, update: (block: CmsBlock) => CmsBlock) =>
setRows((rs) => rs.map((r) => (r.key === key ? { ...r, block: update(r.block) } : r))); setRows((rs) => rs.map((r) => (r.key === key ? { ...r, block: update(r.block) } : r)));
+5 -1
View File
@@ -30,7 +30,7 @@ export const BLOCK_LABELS: Record<BlockType, string> = {
CTA: "PagesBlockCta", CTA: "PagesBlockCta",
}; };
/** A FEATURES (icon, title, text), STEPS (title, text) or TRUST (title) card. */ /** A FEATURES (icon, title, text), STEPS (title, text) or TRUST (title) card; a HERO's points are title-only cards. */
export interface CmsCard { export interface CmsCard {
icon?: string; icon?: string;
title: string; title: string;
@@ -58,6 +58,10 @@ export interface CmsBlock {
cards?: CmsCard[]; cards?: CmsCard[];
/** The FORM block's event (a Snowflake uuid, kept as a string). */ /** The FORM block's event (a Snowflake uuid, kept as a string). */
eventUuid?: string | null; eventUuid?: string | null;
/** add-hero-full-width: a HERO across the whole window, and its form card's heading (80) and text (200). */
fullWidth?: boolean;
formHeading?: string;
formText?: string;
} }
export type PageStatus = "DRAFT" | "PUBLISHED"; export type PageStatus = "DRAFT" | "PUBLISHED";
@@ -47,4 +47,13 @@ describe("frame script: height report", () => {
runFrameScript("<header>Top bar</header>"); runFrameScript("<header>Top bar</header>");
expect(post).toHaveBeenCalledWith({ type: "colite-frame-height", height: 70 }, "*"); expect(post).toHaveBeenCalledWith({ type: "colite-frame-height", height: 70 }, "*");
}); });
it("reports again when the page asks", () => {
const post = vi.spyOn(window.parent, "postMessage").mockImplementation(() => {});
vi.spyOn(document.documentElement, "getBoundingClientRect").mockReturnValue({ height: 68 } as DOMRect);
runFrameScript("<header>Top bar</header>");
post.mockClear();
window.dispatchEvent(new MessageEvent("message", { data: { type: "colite-frame-ask" } }));
expect(post).toHaveBeenCalledWith({ type: "colite-frame-height", height: 68 }, "*");
});
}); });
@@ -33,11 +33,13 @@ describe("frameHtml", () => {
expect(frameResponse("<p>x</p>", { preview: false }).headers.get("cache-control")).not.toBe("no-store"); expect(frameResponse("<p>x</p>", { preview: false }).headers.get("cache-control")).not.toBe("no-store");
}); });
it("clamps a reported height between 100 and 20000 pixels and ignores junk", () => { // add-hero-full-width: the floor is 20 px, so a 68 px top bar keeps its own height.
it("clamps a reported height between 20 and 20000 pixels and ignores junk", () => {
const start = { height: START_HEIGHT, steps: [] }; const start = { height: START_HEIGHT, steps: [] };
expect(START_HEIGHT).toBe(600); expect(START_HEIGHT).toBe(600);
expect(nextFrameHeight(start, { type: "colite-frame-height", height: 3000 }).height).toBe(3000); expect(nextFrameHeight(start, { type: "colite-frame-height", height: 3000 }).height).toBe(3000);
expect(nextFrameHeight(start, { type: "colite-frame-height", height: 10 }).height).toBe(100); expect(nextFrameHeight(start, { type: "colite-frame-height", height: 68 }).height).toBe(68);
expect(nextFrameHeight(start, { type: "colite-frame-height", height: 10 }).height).toBe(20);
expect(nextFrameHeight(start, { type: "colite-frame-height", height: 99999 }).height).toBe(20000); expect(nextFrameHeight(start, { type: "colite-frame-height", height: 99999 }).height).toBe(20000);
for (const junk of [null, "600", { type: "other", height: 900 }, { type: "colite-frame-height", height: "900" }, { type: "colite-frame-height", height: NaN }]) { for (const junk of [null, "600", { type: "other", height: 900 }, { type: "colite-frame-height", height: "900" }, { type: "colite-frame-height", height: NaN }]) {
expect(nextFrameHeight(start, junk)).toBe(start); expect(nextFrameHeight(start, junk)).toBe(start);
+5 -3
View File
@@ -6,8 +6,10 @@ export const FRAME_SANDBOX = "allow-scripts allow-popups allow-popups-to-escape-
/** The frame document's own policy. next.config sends it too: config headers replace a route's header of the same name. */ /** The frame document's own policy. next.config sends it too: config headers replace a route's header of the same name. */
export const FRAME_CSP = `sandbox ${FRAME_SANDBOX}; frame-ancestors 'self'`; export const FRAME_CSP = `sandbox ${FRAME_SANDBOX}; frame-ancestors 'self'`;
export const FRAME_MESSAGE = "colite-frame-height"; export const FRAME_MESSAGE = "colite-frame-height";
/** The page asks a frame to report its height again: its first report can come before the page listens (add-hero-full-width). */
export const FRAME_ASK_MESSAGE = "colite-frame-ask";
export const START_HEIGHT = 600; export const START_HEIGHT = 600;
const MIN_HEIGHT = 100; const MIN_HEIGHT = 20;
const MAX_HEIGHT = 20000; const MAX_HEIGHT = 20000;
export const FRAME_ANCHOR_MESSAGE = "colite-frame-anchor"; export const FRAME_ANCHOR_MESSAGE = "colite-frame-anchor";
@@ -15,11 +17,11 @@ export const FRAME_ANCHOR_MESSAGE = "colite-frame-anchor";
const ANCHOR_SOURCE = "^(?!reg-)[a-z0-9][a-z0-9-]{0,39}$"; const ANCHOR_SOURCE = "^(?!reg-)[a-z0-9][a-z0-9-]{0,39}$";
const ANCHOR = new RegExp(ANCHOR_SOURCE); const ANCHOR = new RegExp(ANCHOR_SOURCE);
// Posts the content height (not scrollHeight, which never drops below the frame itself) to the parent page on load and whenever it changes. A click on a #name link // Posts the content height (not scrollHeight, which never drops below the frame itself) to the parent page on load, whenever it changes, and when the page asks. A click on a #name link
// (add-page-anchor-links) asks the page to scroll instead: the frame is as tall as its content and never scrolls. // (add-page-anchor-links) asks the page to scroll instead: the frame is as tall as its content and never scrolls.
const FRAME_SCRIPT = const FRAME_SCRIPT =
`<script>(function(){function s(){parent.postMessage({type:"${FRAME_MESSAGE}",height:Math.ceil(document.documentElement.getBoundingClientRect().height)},"*")}` + `<script>(function(){function s(){parent.postMessage({type:"${FRAME_MESSAGE}",height:Math.ceil(document.documentElement.getBoundingClientRect().height)},"*")}` +
`addEventListener("load",s);if(window.ResizeObserver)new ResizeObserver(s).observe(document.documentElement);s();` + `addEventListener("load",s);addEventListener("message",function(e){if(e.data&&e.data.type==="${FRAME_ASK_MESSAGE}")s()});if(window.ResizeObserver)new ResizeObserver(s).observe(document.documentElement);s();` +
`document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;` + `document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;` +
`var n=a.getAttribute("href").slice(1);if(!/${ANCHOR_SOURCE}/.test(n))return;e.preventDefault();var t=document.getElementById(n);` + `var n=a.getAttribute("href").slice(1);if(!/${ANCHOR_SOURCE}/.test(n))return;e.preventDefault();var t=document.getElementById(n);` +
`parent.postMessage({type:"${FRAME_ANCHOR_MESSAGE}",name:n,y:t?Math.round(t.getBoundingClientRect().top+scrollY):null},"*")})})();</script>`; `parent.postMessage({type:"${FRAME_ANCHOR_MESSAGE}",name:n,y:t?Math.round(t.getBoundingClientRect().top+scrollY):null},"*")})})();</script>`;
@@ -870,6 +870,11 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
PagesFormPreview: "The sign-up form shows here on the published page.", PagesFormPreview: "The sign-up form shows here on the published page.",
PagesHeroForm: "Sign-up form", PagesHeroForm: "Sign-up form",
PagesNoForm: "No form", PagesNoForm: "No form",
PagesFullWidth: "Full width",
PagesPointN: "Point {number}",
PagesAddPoint: "Add point",
PagesFormHeading: "Form heading",
PagesFormText: "Form text",
PagesToolbar: "Formatting", PagesToolbar: "Formatting",
PagesTextStyle: "Text style", PagesTextStyle: "Text style",
PagesParagraph: "Paragraph", PagesParagraph: "Paragraph",
@@ -855,6 +855,11 @@
"PagesFormPreview": "发布后的网页会在此显示报名表。", "PagesFormPreview": "发布后的网页会在此显示报名表。",
"PagesHeroForm": "报名表单", "PagesHeroForm": "报名表单",
"PagesNoForm": "不显示表单", "PagesNoForm": "不显示表单",
"PagesFullWidth": "全宽",
"PagesPointN": "要点 {number}",
"PagesAddPoint": "添加要点",
"PagesFormHeading": "表单标题",
"PagesFormText": "表单说明",
"PagesToolbar": "格式", "PagesToolbar": "格式",
"PagesTextStyle": "文字样式", "PagesTextStyle": "文字样式",
"PagesParagraph": "段落", "PagesParagraph": "段落",
@@ -10,7 +10,7 @@ import java.util.List;
/** /**
* One landing-page block. Which fields apply depends on {@code type}: * One landing-page block. Which fields apply depends on {@code type}:
* HERO (imageId, heading, text, button, optional eventUuid for a sign-up form beside the text), RICH_TEXT (html), IMAGE_TEXT (imageId, imagePosition, heading, html, button), * HERO (imageId, heading, text, button, optional eventUuid for a sign-up form beside the text, fullWidth, formHeading and formText, cards as title-only points), RICH_TEXT (html), IMAGE_TEXT (imageId, imagePosition, heading, html, button),
* FAQ (heading, items), FORM (heading, eventUuid), HTML (html), FEATURES (heading, text, cards), STEPS (heading, cards), * FAQ (heading, items), FORM (heading, eventUuid), HTML (html), FEATURES (heading, text, cards), STEPS (heading, cards),
* TRUST (cards), CTA (heading, text, button). Any block may carry anchor and look. * TRUST (cards), CTA (heading, text, button). Any block may carry anchor and look.
*/ */
@@ -35,4 +35,9 @@ public class CmsBlock {
/** A Snowflake value beyond JavaScript number precision: written as a string, read from either. */ /** A Snowflake value beyond JavaScript number precision: written as a string, read from either. */
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long eventUuid; private Long eventUuid;
/** add-hero-full-width: a HERO spanning the whole window. */
private Boolean fullWidth;
/** add-hero-full-width: heading (80) and text (200) at the top of a HERO's form card; only with an event. */
private String formHeading;
private String formText;
} }
@@ -27,7 +27,7 @@ public final class CmsBlockValidator {
/** Section looks and feature icons (add-page-sections). */ /** Section looks and feature icons (add-page-sections). */
private static final Set<String> LOOKS = Set.of("DEFAULT", "MUTED", "DARK", "ACCENT"); private static final Set<String> LOOKS = Set.of("DEFAULT", "MUTED", "DARK", "ACCENT");
static final Set<String> ICONS = Set.of("wifi", "phone", "tv", "monitor", "lock", "shield-check", "cloud", "wrench", "headset", "users", "calendar", "star"); static final Set<String> ICONS = Set.of("wifi", "phone", "tv", "monitor", "lock", "shield-check", "cloud", "wrench", "headset", "users", "calendar", "star");
private static final Set<String> CARD_TYPES = Set.of("FEATURES", "STEPS", "TRUST"); private static final Set<String> CARD_TYPES = Set.of("FEATURES", "STEPS", "TRUST", "HERO");
private static final Pattern SCRIPT = Pattern.compile("(?i)<\\s*script|\\son[a-z]+\\s*=|javascript\\s*:"); private static final Pattern SCRIPT = Pattern.compile("(?i)<\\s*script|\\son[a-z]+\\s*=|javascript\\s*:");
private CmsBlockValidator() { private CmsBlockValidator() {
@@ -75,6 +75,18 @@ public final class CmsBlockValidator {
if (b.getEventUuid() != null && !ownEvent.test(b.getEventUuid())) { if (b.getEventUuid() != null && !ownEvent.test(b.getEventUuid())) {
throw refuse(path + ".eventUuid", "PagesBadEvent"); throw refuse(path + ".eventUuid", "PagesBadEvent");
} }
// add-hero-full-width: up to 6 title-only points, and a form card heading and text only with a form.
if (b.getCards() != null) {
cards(b, path, 0, false, false);
}
max(b.getFormHeading(), path + ".formHeading", 80);
max(b.getFormText(), path + ".formText", 200);
if (b.getEventUuid() == null && b.getFormHeading() != null) {
throw refuse(path + ".formHeading", "PagesUnusedField");
}
if (b.getEventUuid() == null && b.getFormText() != null) {
throw refuse(path + ".formText", "PagesUnusedField");
}
} }
case "RICH_TEXT" -> html(b.getHtml(), path + ".html"); case "RICH_TEXT" -> html(b.getHtml(), path + ".html");
case "HTML" -> { case "HTML" -> {
@@ -102,18 +114,18 @@ public final class CmsBlockValidator {
required(b.getHeading(), path + ".heading"); required(b.getHeading(), path + ".heading");
max(b.getHeading(), path + ".heading", 120); max(b.getHeading(), path + ".heading", 120);
max(b.getText(), path + ".text", 300); max(b.getText(), path + ".text", 300);
cards(b, path, true, true); cards(b, path, 2, true, true);
} }
case "STEPS" -> { case "STEPS" -> {
required(b.getHeading(), path + ".heading"); required(b.getHeading(), path + ".heading");
max(b.getHeading(), path + ".heading", 120); max(b.getHeading(), path + ".heading", 120);
cards(b, path, false, true); cards(b, path, 2, false, true);
} }
case "TRUST" -> { case "TRUST" -> {
if (b.getHeading() != null) { if (b.getHeading() != null) {
throw refuse(path + ".heading", "PagesUnusedField"); throw refuse(path + ".heading", "PagesUnusedField");
} }
cards(b, path, false, false); cards(b, path, 2, false, false);
} }
case "CTA" -> { case "CTA" -> {
required(b.getHeading(), path + ".heading"); required(b.getHeading(), path + ".heading");
@@ -173,10 +185,10 @@ public final class CmsBlockValidator {
} }
} }
/** 2 to 6 cards; an icon from the list where the type uses one, a title (80), a text (300) where used, nothing else. */ /** min to 6 cards; an icon from the list where the type uses one, a title (80), a text (300) where used, nothing else. */
private static void cards(CmsBlock b, String path, boolean icon, boolean text) { private static void cards(CmsBlock b, String path, int min, boolean icon, boolean text) {
List<CmsCard> cards = b.getCards(); List<CmsCard> cards = b.getCards();
if (cards == null || cards.size() < 2 || cards.size() > 6) { if (cards == null || cards.size() < min || cards.size() > 6) {
throw refuse(path + ".cards", "PagesCardCount"); throw refuse(path + ".cards", "PagesCardCount");
} }
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
@@ -1,6 +1,7 @@
package com.solvway.services.counter.service; package com.solvway.services.counter.service;
import com.solvway.services.counter.dto.CmsBlock; import com.solvway.services.counter.dto.CmsBlock;
import com.solvway.services.counter.dto.CmsCard;
import com.solvway.services.counter.dto.CmsFaqItem; import com.solvway.services.counter.dto.CmsFaqItem;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -216,4 +217,59 @@ class CmsBlockValidatorTest {
again.setAnchor("signup"); again.setAnchor("signup");
refused(List.of(named, again), "blocks[1].anchor", "PagesAnchorTaken"); refused(List.of(named, again), "blocks[1].anchor", "PagesAnchorTaken");
} }
// add-hero-full-width: points are title-only cards, 0 to 6 of them.
private static List<CmsCard> points(int n) {
List<CmsCard> out = new ArrayList<>();
for (int i = 0; i < n; i++) out.add(new CmsCard(null, "Local support team in Malaysia", null));
return out;
}
@Test
void aHeroMayCarryUpToSixTitleOnlyPoints() {
CmsBlock one = hero();
one.setCards(points(1));
CmsBlock six = hero();
six.setCards(points(6));
assertThatCode(() -> validate(List.of(one, six))).doesNotThrowAnyException();
CmsBlock seven = hero();
seven.setCards(points(7));
refused(List.of(seven), "blocks[0].cards", "PagesCardCount");
CmsBlock blank = hero();
blank.setCards(List.of(new CmsCard(null, " ", null)));
refused(List.of(blank), "blocks[0].cards[0].title", "PagesRequired");
CmsBlock longPoint = hero();
longPoint.setCards(List.of(new CmsCard(null, "x".repeat(81), null)));
refused(List.of(longPoint), "blocks[0].cards[0].title", "PagesTooLong");
CmsBlock withIcon = hero();
withIcon.setCards(List.of(new CmsCard("wifi", "WiFi", null)));
refused(List.of(withIcon), "blocks[0].cards[0].icon", "PagesUnusedField");
CmsBlock withText = hero();
withText.setCards(List.of(new CmsCard(null, "WiFi", "More")));
refused(List.of(withText), "blocks[0].cards[0].text", "PagesUnusedField");
}
@Test
void aHeroWithAFormMayCarryAFormHeadingAndText() {
CmsBlock ok = hero();
ok.setEventUuid(OWN_EVENT);
ok.setFullWidth(true);
ok.setFormHeading("Get a free consultation");
ok.setFormText("Tell us about your property. It takes under a minute.");
assertThatCode(() -> validate(List.of(ok))).doesNotThrowAnyException();
CmsBlock longHeading = hero();
longHeading.setEventUuid(OWN_EVENT);
longHeading.setFormHeading("x".repeat(81));
refused(List.of(longHeading), "blocks[0].formHeading", "PagesTooLong");
CmsBlock longText = hero();
longText.setEventUuid(OWN_EVENT);
longText.setFormText("x".repeat(201));
refused(List.of(longText), "blocks[0].formText", "PagesTooLong");
CmsBlock noForm = hero();
noForm.setFormHeading("Get a free consultation");
refused(List.of(noForm), "blocks[0].formHeading", "PagesUnusedField");
CmsBlock noFormText = hero();
noFormText.setFormText("Tell us more");
refused(List.of(noFormText), "blocks[0].formText", "PagesUnusedField");
}
} }