A host should take the CMS whole from this qbit: its tables, its help and its schema. Two things forced a host to write CMS material of its own; both are fixed here. - Help: help/qbit-cms.yaml (643 entries) covers every app, home, table, section, field, child list and value list. The producer registers it when the host uses the default names. CmsHelpTest holds it to the core's coverage gate (HelpBundleAssertions) and to every section. - Schema: the first guard changeset (1.0.0-guard-existing-tables) no longer has runAlways. It rewrote its DATABASECHANGELOG row on every migration, so a second migration was never a no-op and a rollback by count began with it; a host whose migrations must be repeatable had to copy the tables. It runs once now, with validCheckSum: ANY so an install that already ran it migrates on unchanged. This changes a released changeset on purpose; CmsInstallTest.testRerunIsNoop covers a second run and an install the earlier version recorded. - Homes: text sizes in rem (labels 0.875rem instead of 13px), so they follow the reader's text size. Tests: 40, Checkstyle 0, guardrails and coverage checks pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
129 lines
6.2 KiB
Java
129 lines
6.2 KiB
Java
/*
|
|
* Copyright 2026 Kingsrook, LLC
|
|
*
|
|
* Licensed 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 com.kingsrook.qbits.cms;
|
|
|
|
|
|
import java.util.EnumSet;
|
|
import java.util.List;
|
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
|
import com.kingsrook.qqq.backend.core.model.metadata.help.bundles.HelpBundles;
|
|
import com.kingsrook.qqq.backend.core.testing.HelpBundleAssertions;
|
|
import org.junit.jupiter.api.Test;
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
/*******************************************************************************
|
|
** The qbit ships its own help (help/qbit-cms.yaml): a host gets it with the
|
|
** jar and writes none of it. It covers every app, table, field, home, child
|
|
** list and value list of the qbit, names nothing that does not exist, and is
|
|
** registered only under the default names it is written for.
|
|
*******************************************************************************/
|
|
class CmsHelpTest
|
|
{
|
|
|
|
/*******************************************************************************
|
|
** With every feature: registered once as a QBIT layer bundle of this version,
|
|
** complete by the core's own gate, and every home, child list and value list
|
|
** has its text.
|
|
*******************************************************************************/
|
|
@Test
|
|
void testHelpCoversTheQBit() throws Exception
|
|
{
|
|
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
|
|
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)).produce(qInstance);
|
|
|
|
assertThat(HelpBundles.of(qInstance).getBundles()).singleElement().satisfies(bundle ->
|
|
{
|
|
assertThat(bundle.getId()).isEqualTo("qbit-cms");
|
|
assertThat(bundle.getVersion()).isEqualTo(CmsQBitProducer.VERSION);
|
|
assertThat(bundle.getLayer().name()).isEqualTo("QBIT");
|
|
});
|
|
HelpBundleAssertions.forInstance(qInstance)
|
|
.bundles(CmsQBitProducer.HELP_BUNDLE)
|
|
.owning(target -> target.name().equals("cms") || target.name().startsWith("cms"))
|
|
.assertComplete();
|
|
|
|
var entries = HelpBundles.of(qInstance).resolveWinningEntries();
|
|
List<String> widgets = qInstance.getWidgets().keySet().stream().filter(name -> name.startsWith("cms")).sorted().toList();
|
|
assertThat(widgets).hasSizeGreaterThan(30);
|
|
for(String name : widgets)
|
|
{
|
|
assertThat(entries).as("the card " + name).containsKey(new HelpBundles.EntryKey("widget:" + name + ";slot:label", "ALL_SCREENS"));
|
|
}
|
|
List<String> sources = qInstance.getPossibleValueSources().keySet().stream().filter(name -> name.startsWith("cms_")).sorted().toList();
|
|
assertThat(sources).hasSize(36);
|
|
for(String name : sources)
|
|
{
|
|
assertThat(entries).as("the value source " + name).containsKey(new HelpBundles.EntryKey("possibleValueSource:" + name + ";slot:help", "ALL_SCREENS"));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Every section of every table has its text too (the core's gate leaves
|
|
** sections optional).
|
|
*******************************************************************************/
|
|
@Test
|
|
void testEverySectionHasHelp() throws Exception
|
|
{
|
|
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
|
|
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)).produce(qInstance);
|
|
var entries = HelpBundles.of(qInstance).resolveWinningEntries();
|
|
int sections = 0;
|
|
for(var table : qInstance.getTables().values())
|
|
{
|
|
if(!table.getName().startsWith("cms_"))
|
|
{
|
|
continue;
|
|
}
|
|
for(var section : table.getSections())
|
|
{
|
|
sections++;
|
|
assertThat(entries).as(table.getName() + " section " + section.getName())
|
|
.containsKey(new HelpBundles.EntryKey("table:" + table.getName() + ";section:" + section.getName(), "ALL_SCREENS"));
|
|
}
|
|
}
|
|
assertThat(sections).isGreaterThan(100);
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** The text is written for the default names: an install under other
|
|
** prefixes does not register it, and with a feature off the entries of its
|
|
** tables are simply unused (the gate still passes for what is there).
|
|
*******************************************************************************/
|
|
@Test
|
|
void testOtherNamesAndFeatureSubsets() throws Exception
|
|
{
|
|
QInstance renamed = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
|
|
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)
|
|
.withTableNamePrefix("acme_cms_")).produce(renamed);
|
|
assertThat(HelpBundles.of(renamed).getBundles()).isEmpty();
|
|
|
|
QInstance core = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
|
|
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)
|
|
.withFeatures(EnumSet.of(CmsFeature.CORE))).produce(core);
|
|
assertThat(HelpBundles.of(core).getBundles()).hasSize(1);
|
|
assertThat(HelpBundleAssertions.forInstance(core).bundles(CmsQBitProducer.HELP_BUNDLE)
|
|
.owning(target -> target.name().equals("cms") || target.name().startsWith("cms")).report())
|
|
.as("with CORE alone nothing of CORE is missing; entries of the other features have no object and are reported as such")
|
|
.noneMatch(line -> line.toLowerCase(java.util.Locale.ROOT).contains("missing"));
|
|
}
|
|
}
|