feat(pages): HTML block type and hide-header option in the services

The counter accepts an HTML block (required, at most 200,000 characters, no
script check because it only runs sealed) and stores a hide-header flag on the
page. mobile-api passes the flag through on save and in the public page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-02 17:46:32 +08:00
1 parent dcad8cb650
commit 9a7b225827
15 files changed
+96 -7

No files matched your search

@@ -115,6 +115,17 @@ class AdminPageServiceTest {
assertThat((Map<String, Object>) sent.get("page")).containsEntry("companyId", 2L).containsEntry("slug", "hotel").containsEntry("id", null);
}
@Test
void theHideHeaderOptionIsSentToTheCounter() {
caller(2L, false);
service.create(new AdminPageRequest(null, "designed", "Designed", null, "DRAFT", true, List.of(Map.<String, Object>of("type", "HTML", "html", "<script>x()</script>"))));
ArgumentCaptor<Object> body = ArgumentCaptor.forClass(Object.class);
verify(rest).postForEntity(eq(SAVE), any(ParameterizedTypeReference.class), body.capture());
Map<String, Object> page = (Map<String, Object>) ((Map<String, Object>) body.getValue()).get("page");
assertThat(page).containsEntry("hideHeader", true);
assertThat((List<Map<String, Object>>) page.get("blocks")).first().isEqualTo(Map.of("type", "HTML", "html", "<script>x()</script>"));
}
@Test
void updateKeepsTheIdAndStoredCompany() {
caller(2L, false);
@@ -123,6 +123,16 @@ class PublicPageServiceTest {
assertThat(blocks.get(1)).doesNotContainKey("closed");
}
@Test
void thePageCarriesItsHideHeaderOptionDefaultingToOff() {
assertThat((Map<String, Object>) service.page("INS", "hotel-technology").get("page")).containsEntry("hideHeader", false);
Map<String, Object> designed = page();
designed.put("hideHeader", true);
when(rest.getForEntity(eq(PUBLISHED), any(ParameterizedTypeReference.class), eq(COMPANY), eq("hotel-technology")))
.thenReturn(ResponseEntity.ok(designed));
assertThat((Map<String, Object>) service.page("INS", "hotel-technology").get("page")).containsEntry("hideHeader", true);
}
@Test
void aFormWhoseEventEndedIsClosedButThePageStillShows() {
stubEvent(LocalDateTime.of(2027, 1, 15, 23, 59));