You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/10/09 21:49:54 UTC

(juneau) branch master updated: Add Shorts.nm (a null-safe map, via the new ObjectUtils.mapOrNull) and Shorts.any, and remove the unused or(boolean...) overload (J0649); the remaining TableSpec view keys columnConfig, copyLink, cleanAddress and pausePollingWhileEditing (J0650); and defer a columnConfig table's build until juneau-config.js registers, so the View Settings gear and hidden-by-default columns survive the shell-first script order real pages use (J0652).

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new dd9a765668 Add Shorts.nm (a null-safe map, via the new ObjectUtils.mapOrNull) and Shorts.any, and remove the unused or(boolean...) overload (J0649); the remaining TableSpec view keys columnConfig, copyLink, cleanAddress and pausePollingWhileEditing (J0650); and defer a columnConfig table's build until juneau-config.js registers, so the View Settings gear and hidden-by-default columns survive the shell-first script order real pages use (J0652).
dd9a765668 is described below

commit dd9a76566809efce3a249e283ba8935d8cc6eb70
Author: James Bognar <ja...@apache.org>
AuthorDate: Fri Oct 9 17:49:47 2026 -0400

    Add Shorts.nm (a null-safe map, via the new ObjectUtils.mapOrNull) and Shorts.any, and remove the unused or(boolean...) overload (J0649); the remaining TableSpec view keys columnConfig, copyLink, cleanAddress and pausePollingWhileEditing (J0650); and defer a columnConfig table's build until juneau-config.js registers, so the View Settings gear and hidden-by-default columns survive the shell-first script order real pages use (J0652).
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
---
 .../apache/juneau/commons/utils/ObjectUtils.java   |  11 ++
 .../org/apache/juneau/commons/utils/Shorts.java    |  19 +++-
 .../apache/juneau/commons/utils/Shorts_Test.java   |  36 ++++++
 .../apache/juneau/rest/server/views/TableSpec.java |  68 +++++++++++
 .../org/apache/juneau/views/juneau-config.js       |   2 +
 .../org/apache/juneau/views/juneau-views.js        |  33 ++++++
 .../server/views/PageSpecTable_BrowserTest.java    |   2 +-
 .../views/TableSpecColumnConfig_BrowserTest.java   | 126 +++++++++++++++++++++
 .../server/views/TableSpec_ToCardBody_Test.java    |  38 +++++++
 9 files changed, 332 insertions(+), 3 deletions(-)

diff --git a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ObjectUtils.java b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ObjectUtils.java
index 600368d636..6727ad6252 100644
--- a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ObjectUtils.java
+++ b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/ObjectUtils.java
@@ -217,6 +217,17 @@ public class ObjectUtils {
 		return null;
 	}
 
+	/**
+	 * Returns <jk>null</jk> when the value is <jk>null</jk>, else the mapper's result; the mapper is never called on <jk>null</jk>.
+	 *
+	 * @param <T> The value type.
+	 * @param <R> The result type.
+	 * @param value The value to map. Can be <jk>null</jk>.
+	 * @param mapper The mapping function.
+	 * @return The mapped value, or <jk>null</jk> if {@code value} is <jk>null</jk> or the mapper returns <jk>null</jk>.
+	 */
+	public static <T,R> R mapOrNull(T value, Function<? super T,? extends R> mapper) { return value == null ? null : mapper.apply(value); }
+
 	/** Boolean AND-fold (vacuously true when empty). */
 	public static boolean allTrue(boolean...values) {
 		if (values == null || values.length == 0) return true;
diff --git a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Shorts.java b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Shorts.java
index 0a3f7f19a1..513a8c06f6 100644
--- a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Shorts.java
+++ b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Shorts.java
@@ -270,8 +270,23 @@ public class Shorts {
 	 * @return <jk>true</jk> if at least one value is <jk>true</jk>.
 	 * @see ObjectUtils#anyTrue(boolean...)
 	 */
-	@SafeVarargs
-	public static boolean or(boolean...v) { return ObjectUtils.anyTrue(v); }
+	public static boolean any(boolean...v) { return ObjectUtils.anyTrue(v); }
+
+	/**
+	 * Null-safe map: returns <jk>null</jk> when the value is <jk>null</jk>, else the mapper's result.
+	 *
+	 * <p>
+	 * Replaces <c>x == null ? null : f(x)</c>.  This is not {@link #or(Object...)}, which returns its first non-null
+	 * argument (so <c>x</c>, not <c>f(x)</c>) and evaluates <c>f(x)</c> even when <c>x</c> is null.
+	 *
+	 * @param <T> The value type.
+	 * @param <R> The result type.
+	 * @param v The value to map. Can be <jk>null</jk>.
+	 * @param m The mapping function; never called with <jk>null</jk>.
+	 * @return The mapped value, or <jk>null</jk>.
+	 * @see ObjectUtils#mapOrNull(Object, Function)
+	 */
+	public static <T,R> R nm(T v, Function<? super T,? extends R> m) { return ObjectUtils.mapOrNull(v, m); }
 
 	/**
 	 * Returns <jk>true</jk> if all of the specified booleans are <jk>true</jk>.
diff --git a/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/utils/Shorts_Test.java b/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/utils/Shorts_Test.java
index 7093f0de1e..45d5ec576a 100644
--- a/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/utils/Shorts_Test.java
+++ b/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/utils/Shorts_Test.java
@@ -425,4 +425,40 @@ class Shorts_Test extends TestBase {
 	void h001_dtf_getDateTimeFormatter() {
 		assertNotNull(DateUtils.getDateTimeFormatter("yyyy-MM-dd"));
 	}
+
+	//-----------------------------------------------------------------------------------------------------------------
+	// nm / any / or with Boolean
+	//-----------------------------------------------------------------------------------------------------------------
+
+	@Test
+	void i001_nm_nullInputSkipsMapper() {
+		var calls = new int[1];
+		String r = nm((String)null, x -> { calls[0]++; return x + "!"; });
+		assertNull(r);
+		assertEquals(0, calls[0]);
+	}
+
+	@Test
+	void i002_nm_mapsNonNull() {
+		assertEquals(Integer.valueOf(3), nm("abc", String::length));
+	}
+
+	@Test
+	void i003_nm_mapperReturningNullGivesNull() {
+		assertNull(nm("abc", x -> null));
+	}
+
+	@Test
+	void i004_any_trueIfAnyTrue() {
+		assertTrue(any(false, true));
+		assertFalse(any(false, false));
+		assertFalse(any());
+	}
+
+	@Test
+	void i005_or_booleanBoxedCoalesces() {
+		Boolean n = null;
+		assertEquals(Boolean.TRUE, or(n, true));
+		assertEquals(Boolean.FALSE, or(Boolean.FALSE, true));
+	}
 }
diff --git a/juneau-rest/juneau-rest-server-views/src/main/java/org/apache/juneau/rest/server/views/TableSpec.java b/juneau-rest/juneau-rest-server-views/src/main/java/org/apache/juneau/rest/server/views/TableSpec.java
index 93b46b3c3f..cd6fd5f918 100644
--- a/juneau-rest/juneau-rest-server-views/src/main/java/org/apache/juneau/rest/server/views/TableSpec.java
+++ b/juneau-rest/juneau-rest-server-views/src/main/java/org/apache/juneau/rest/server/views/TableSpec.java
@@ -123,6 +123,10 @@ public final class TableSpec {
 	private String quickStatsId;
 	private List<QuickStat> quickStats;
 	private boolean primary;
+	private Object columnConfig;
+	private Boolean copyLink;
+	private Boolean cleanAddress;
+	private Boolean pausePollingWhileEditing;
 	private String cssClass;
 
 	private TableSpec(String id) {
@@ -412,6 +416,62 @@ public final class TableSpec {
 		return this;
 	}
 
+	/**
+	 * Sets whether this table offers the View Settings dialog (column chooser, search and sort settings).
+	 *
+	 * @param v The new value.
+	 * @return This object.
+	 */
+	public TableSpec columnConfig(boolean v) {
+		columnConfig = v;
+		return this;
+	}
+
+	/**
+	 * Sets the View Settings dialog options, serialized as the {@code columnConfig} object (for example
+	 * {@code {"chooser": true}}).
+	 *
+	 * @param options The options, copied at call time. Must not be <jk>null</jk>.
+	 * @return This object.
+	 */
+	public TableSpec columnConfig(Map<String,Object> options) {
+		columnConfig = new LinkedHashMap<>(rnn(options));
+		return this;
+	}
+
+	/**
+	 * Sets whether the table offers a copy-link control for its current view state.
+	 *
+	 * @param v The new value.
+	 * @return This object.
+	 */
+	public TableSpec copyLink(boolean v) {
+		copyLink = v;
+		return this;
+	}
+
+	/**
+	 * Sets whether the browser address bar is cleaned of the table's view-state parameters.
+	 *
+	 * @param v The new value.
+	 * @return This object.
+	 */
+	public TableSpec cleanAddress(boolean v) {
+		cleanAddress = v;
+		return this;
+	}
+
+	/**
+	 * Sets whether polling pauses while an editing surface (an open detail row or action dialog) is bound to this table.
+	 *
+	 * @param v The new value.
+	 * @return This object.
+	 */
+	public TableSpec pausePollingWhileEditing(boolean v) {
+		pausePollingWhileEditing = v;
+		return this;
+	}
+
 	/**
 	 * Sets the CSS class applied to this table's card.  It is carried on the card placement, not in the card body
 	 * returned by {@link #toCardBody()}.
@@ -523,6 +583,14 @@ public final class TableSpec {
 			t.put("pollIntervalMs", pollIntervalMs);
 		if (primary)
 			t.put("primary", true);
+		if (columnConfig != null)
+			t.put("columnConfig", columnConfig);
+		if (copyLink != null)
+			t.put("copyLink", copyLink);
+		if (cleanAddress != null)
+			t.put("cleanAddress", cleanAddress);
+		if (pausePollingWhileEditing != null)
+			t.put("pausePollingWhileEditing", pausePollingWhileEditing);
 		if (! rowClassRules.isEmpty())
 			t.put("rowClassRules", List.copyOf(rowClassRules));
 		if (! rowActions.isEmpty())
diff --git a/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-config.js b/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-config.js
index 3099b3f29b..c5dce99c31 100644
--- a/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-config.js
+++ b/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-config.js
@@ -2430,4 +2430,6 @@
 	NS.config.copyShareLink = copyShareLink;
 	NS.config.selectConfigTab = selectConfigTab;
 	NS.config.resetDraftToDefaults = resetDraftToDefaults;
+	// Tables built before this file registered (a shell-first page) are rebuilt now that the chooser exists.
+	if (typeof NS.init?.flushLateConfigRebuilds === "function") NS.init.flushLateConfigRebuilds();
 })();
diff --git a/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-views.js b/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-views.js
index 00934aa44c..b158e0c7c2 100644
--- a/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-views.js
+++ b/juneau-rest/juneau-rest-server-views/src/main/resources/org/apache/juneau/views/juneau-views.js
@@ -9125,6 +9125,7 @@
 		extras = extras || {};
 		const $ = window.jQuery;
 		if ($?.fn?.dataTable?.isDataTable(table)) return;
+		if (configDeferred.has(table)) return;
 		const id = table.dataset.juneauView;
 		if (viewDef?.contractVersion !== JUNEAU_VIEW_CONTRACT_VERSION) {
 			const m = "Juneau view '" + id + "': contract version mismatch (page='" +
@@ -9223,9 +9224,40 @@
 
 		if (viewDef.columnConfig && typeof NS.config?.resolveActiveView === "function")
 			return NS.config.resolveActiveView(table, viewDef).then(go);
+		if (viewDef.columnConfig && typeof NS.config?.resolveActiveView !== "function")
+			return deferUntilConfig(table, function () { return NS.config.resolveActiveView(table, viewDef).then(go); }, function () { go(null); });
 		go(null);
 	}
 
+	const configDeferred = new Map();
+
+	/**
+	 * Holds a {@code columnConfig} table whose build must wait for juneau-config.js (a shell-first page renders the
+	 * card as soon as this script registers it, before the next script in the pack has run).  {@code withConfig} runs
+	 * once when the config layer registers; {@code withoutConfig} runs if it never does, once the document has finished
+	 * parsing, so a views-only page still renders (every column, no chooser).  Whichever fires first wins.
+	 */
+	function deferUntilConfig(table, withConfig, withoutConfig) {
+		return new Promise(function (resolve, reject) {
+			let fired = false;
+			const fire = function (run) {
+				if (fired) return;
+				fired = true;
+				configDeferred.delete(table);
+				try { resolve(run()); } catch (err) { reject(err); }
+			};
+			configDeferred.set(table, function () { fire(withConfig); });
+			if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", function () { fire(withoutConfig); });
+			else setTimeout(function () { fire(withoutConfig); }, 0);
+		});
+	}
+
+	/** Builds, with the config layer, every table that was waiting for juneau-config.js. */
+	function flushLateConfigRebuilds() {
+		if (typeof NS.config?.resolveActiveView !== "function") return;
+		for (const run of Array.from(configDeferred.values())) run();
+	}
+
 	function beginInitTable(table) {
 		const id = table.dataset.juneauView;
 		const key = viewSidecarKey(table);
@@ -10418,6 +10450,7 @@
 		initTableFromDef: initTableFromDef,
 		mountTableSlot: mountTableSlot,
 		buildTable: buildTable,
+		flushLateConfigRebuilds: flushLateConfigRebuilds,
 		liveDtIndex: liveDtIndex,
 		assembleFullColumnArray: assembleFullColumnArray,
 		restoreHeaderShell: restoreHeaderShell,
diff --git a/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/PageSpecTable_BrowserTest.java b/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/PageSpecTable_BrowserTest.java
index 1721ded8d4..97f2a427c3 100644
--- a/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/PageSpecTable_BrowserTest.java
+++ b/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/PageSpecTable_BrowserTest.java
@@ -70,7 +70,7 @@ class PageSpecTable_BrowserTest extends TestBase {
 		assertNoShellErrors(report.get("table"));
 	}
 
-	// defaultVisible(false) only takes effect with columnConfig on (juneau-config.js); the plain table keeps every column.
+	// defaultVisible(false) only takes effect with columnConfig on (juneau-config.js); corpus 03 has no columnConfig, so the table keeps every column.
 	@Test void a02_headerHasEveryColumn_withLabelsLiftedToTitles() {
 		var ths = probeList("ths");
 		assertTrue(ths.containsAll(List.of("Pod", "Incident", "Root cause")), ths::toString);
diff --git a/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpecColumnConfig_BrowserTest.java b/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpecColumnConfig_BrowserTest.java
new file mode 100644
index 0000000000..07672ae60f
--- /dev/null
+++ b/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpecColumnConfig_BrowserTest.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juneau.rest.server.views;
+
+import static org.apache.juneau.rest.server.views.ConsoleBrowserFixture.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.marshall.marshaller.Json;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.condition.*;
+
+/**
+ * A {@code TableSpec}-built table card mounts the View Settings gear in Chromium when {@code columnConfig(true)} is set
+ * and has no gear when it is unset. {@code PageSpec.table(...)} passes {@link TableSpec#toCardBody()} through unchanged,
+ * so the page contract here is the parity corpus case with its table body replaced by the {@code TableSpec} output.
+ */
+@EnabledIfSystemProperty(named=ConsoleBrowserFixture.GATE, matches="true",
+	disabledReason="JS-execution harness is opt-in; run with `mvn -Pjs-tests -f juneau-rest/juneau-rest-server-views/pom.xml test`")
+class TableSpecColumnConfig_BrowserTest extends TestBase {
+
+	private static final String PROBE = """
+		<script>
+		window.__fetches = 0;
+		(function () {
+		  var open = XMLHttpRequest.prototype.open;
+		  XMLHttpRequest.prototype.open = function (m, u) { if (String(u).indexOf("/rest/slo/data") >= 0) window.__fetches++; return open.apply(this, arguments); };
+		  var f = window.fetch;
+		  window.fetch = function (u) { if (String(u && u.url || u).indexOf("/rest/slo/data") >= 0) window.__fetches++; return f.apply(this, arguments); };
+		})();
+		window.__probe = {
+		  get fetches() { return window.__fetches; },
+		  get gears() { return document.querySelectorAll(".juneau-config-chooser-btn").length; },
+		  get ths() { return Array.from(document.querySelectorAll("#slo-body table thead th")).map(function (e) { return e.textContent.trim(); }); }
+		};
+		</script>
+		""";
+
+	private static final String ROWS = """
+		[{"id":"1","pod":"p1","cause":"disk"}]
+		""";
+
+	private static Map<String,Map<String,Object>> report;
+
+	private static String page(TableSpec table, boolean shellFirst) throws Exception {
+		return page(table, shellFirst, viewsPack());
+	}
+
+	@SuppressWarnings("unchecked")
+	private static String page(TableSpec table, boolean shellFirst, String pack) throws Exception {
+		var corpus = (Map<String,Object>)Json.to(resource("/pagespec-corpus/03-table-every-feature.json"), Map.class);
+		var contract = (Map<String,Object>)corpus.get("contract");
+		var card = (Map<String,Object>)((List<?>)contract.get("cards")).get(0);
+		card.put("table", table.toCardBody());
+		// shellFirst is the order a real page emits (shell, then the toolkit pack); the other loads the pack first.
+		return shellFirst
+			? contractPage(Json.of(contract), "", PROBE, pack)
+			: contractPage(Json.of(contract), "", pack + PROBE, "");
+	}
+
+	@BeforeAll
+	static void probe() throws Exception {
+		var gear = TableSpec.create("slo").dataUrl("/rest/slo/data").columns(Column.create("pod"), Column.create("cause").label("Cause").defaultVisible(false)).columnConfig(true);
+		var plain = TableSpec.create("slo").dataUrl("/rest/slo/data").columns(Column.create("pod"));
+		report = ConsoleBrowserFixture.create("tablespec-column-config")
+			.asset("/rest/slo/data", ROWS, "application/json")
+			.page("gear", ORIGIN + "/gear", page(gear, false))
+			.page("gearShellFirst", ORIGIN + "/gear-sf", page(gear, true))
+			.page("noConfigJs", ORIGIN + "/no-config", page(gear, true, viewsPack().replace("<script>\n" + resource(ViewsMixin.CONFIG_JS_RESOURCE) + "\n</script>\n", "")))
+			.page("plain", ORIGIN + "/plain", page(plain, false))
+			.waitFor("#slo-body tbody tr")
+			.run();
+	}
+
+	@Test void a01_columnConfigSet_mountsGear() {
+		assertNoShellErrors(report.get("gear"));
+		assertEquals(1, ((Number)ConsoleBrowserFixture.probe(report.get("gear")).get("gears")).intValue(), () -> report.get("gear").toString());
+	}
+
+	@Test void a03_columnConfigSet_shellFirst_mountsGearAndHidesDefaultInvisibleColumn() {
+		var r = report.get("gearShellFirst");
+		assertNoShellErrors(r);
+		var probe = ConsoleBrowserFixture.probe(r);
+		assertEquals(1, ((Number)probe.get("gears")).intValue(), r::toString);
+		assertEquals(List.of("pod"), probe.get("ths"), r::toString);
+	}
+
+	@Test void a05_shellFirst_fetchesRowsOnce() {
+		var r = report.get("gearShellFirst");
+		assertEquals(1, ((Number)ConsoleBrowserFixture.probe(r).get("fetches")).intValue(), r::toString);
+	}
+
+	@Test void a06_viewsPackWithoutConfigJs_stillRendersEveryColumn() {
+		var r = report.get("noConfigJs");
+		assertNoShellErrors(r);
+		var probe = ConsoleBrowserFixture.probe(r);
+		assertEquals(0, ((Number)probe.get("gears")).intValue(), r::toString);
+		assertEquals(List.of("pod", "Cause"), probe.get("ths"), r::toString);
+	}
+
+	@Test void a04_columnConfigSet_packFirst_hidesDefaultInvisibleColumn() {
+		var r = report.get("gear");
+		assertEquals(List.of("pod"), ConsoleBrowserFixture.probe(r).get("ths"), r::toString);
+	}
+
+	@Test void a02_columnConfigUnset_hasNoGear() {
+		assertNoShellErrors(report.get("plain"));
+		assertEquals(0, ((Number)ConsoleBrowserFixture.probe(report.get("plain")).get("gears")).intValue(), () -> report.get("plain").toString());
+	}
+}
diff --git a/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpec_ToCardBody_Test.java b/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpec_ToCardBody_Test.java
index f4c2ccbbf9..3956449d15 100644
--- a/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpec_ToCardBody_Test.java
+++ b/juneau-rest/juneau-rest-server-views/src/test/java/org/apache/juneau/rest/server/views/TableSpec_ToCardBody_Test.java
@@ -165,6 +165,44 @@ class TableSpec_ToCardBody_Test extends TestBase {
 		assertEquals(List.of("key", "label", "render", "href"), List.copyOf(col.keySet()).subList(0, 4));
 	}
 
+	private static TableSpec minimal() {
+		return TableSpec.create("slo").dataUrl("/rest/slo/data").columns(Column.create("pod"));
+	}
+
+	@Test void b01_viewKeys_absentWhenUnset() {
+		var body = minimal().toCardBody();
+		for (var key : List.of("columnConfig", "copyLink", "cleanAddress", "pausePollingWhileEditing"))
+			assertFalse(body.containsKey(key), key);
+	}
+
+	@Test void b02_viewKeys_emittedWhenSet() {
+		var body = minimal().columnConfig(true).copyLink(true).cleanAddress(true).pausePollingWhileEditing(true).toCardBody();
+		assertPlain(body);
+		assertEquals(true, body.get("columnConfig"));
+		assertEquals(true, body.get("copyLink"));
+		assertEquals(true, body.get("cleanAddress"));
+		assertEquals(true, body.get("pausePollingWhileEditing"));
+	}
+
+	@Test void b03_viewKeys_falseIsEmitted() {
+		var body = minimal().columnConfig(false).copyLink(false).cleanAddress(false).pausePollingWhileEditing(false).toCardBody();
+		assertEquals(false, body.get("columnConfig"));
+		assertEquals(false, body.get("copyLink"));
+		assertEquals(false, body.get("cleanAddress"));
+		assertEquals(false, body.get("pausePollingWhileEditing"));
+	}
+
+	@Test void b04_columnConfig_objectForm() {
+		var body = minimal().columnConfig(Map.of("chooser", true)).toCardBody();
+		assertPlain(body);
+		assertEquals(Map.of("chooser", true), body.get("columnConfig"));
+	}
+
+	@Test void b05_columnConfig_nullOptionsRejected() {
+		var t = minimal();
+		assertThrows(NullPointerException.class, () -> t.columnConfig((Map<String,Object>)null));
+	}
+
 	private static void assertPlain(Object o) {
 		if (o instanceof Map<?,?> m)
 			m.values().forEach(TableSpec_ToCardBody_Test::assertPlain);