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:
1 parent
dcad8cb650
commit
9a7b225827
15 files changed
+96
-7
No files matched your search
+8
-1
@@ -5,4 +5,11 @@ import java.util.Map;
|
||||
|
||||
/** A landing page as the editor saves it. Blocks pass through to the counter, which validates them. companyId counts only on create. */
|
||||
public record AdminPageRequest(Long companyId, String slug, String title, String metaDescription, String status,
|
||||
List<Map<String, Object>> blocks) {}
|
||||
boolean hideHeader, List<Map<String, Object>> blocks) {
|
||||
|
||||
/** A page that shows its header (the default). */
|
||||
public AdminPageRequest(Long companyId, String slug, String title, String metaDescription, String status,
|
||||
List<Map<String, Object>> blocks) {
|
||||
this(companyId, slug, title, metaDescription, status, false, blocks);
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,7 @@ public class AdminPageService {
|
||||
page.put("title", r.title());
|
||||
page.put("metaDescription", r.metaDescription());
|
||||
page.put("status", r.status());
|
||||
page.put("hideHeader", r.hideHeader());
|
||||
page.put("blocks", r.blocks() == null ? List.of() : r.blocks());
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
body.put("page", page);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class PublicPageService {
|
||||
page.put("slug", f.page().get("slug"));
|
||||
page.put("title", f.page().get("title"));
|
||||
page.put("metaDescription", f.page().get("metaDescription"));
|
||||
page.put("hideHeader", Boolean.TRUE.equals(f.page().get("hideHeader")));
|
||||
page.put("blocks", blocks);
|
||||
return Map.of("company", f.company(), "page", page);
|
||||
}
|
||||
|
||||
+11
@@ -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);
|
||||
|
||||
+10
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user