Verify Archiver document tabs and tag popups in IntelliJ

This commit is contained in:
2026-11-24 22:01:56 +01:00
parent 33e8f8f9f0
commit a2952a2490
5 changed files with 286 additions and 5 deletions
+2
View File
@@ -87,6 +87,8 @@ In `ArchiveWindow.fxml`, select a layout branch to split it or an outer side are
Add `--saved-document` to the Archiver launcher or host check to open the designer-profile view `SavedDocument.fxml`. Under **Form controls**, select **HtmlViewer #article** to edit the media button labels and tooltips. Select **AutoCompleteTextField #fixed** and edit **suggestions**, one tag per line. **Build and Refresh** discovers **HTML · Rechnung** and **HTML · Lieferschein**. **Form preview** shows the rendered HTML at the selected dimensions. In **Interactive preview**, use **Dokument wechseln**, edit **HTML-Quelle**, or type **Re** and **Li** into **Dokument-Tags** before and after switching. The form binds `article.html` to `html` and `dynamic.suggestionsSource` to `tags`, both toward the view. To create either binding, open **Bindings → Discover targets**, select **view** and the model path, select the compatible control property, then choose **Use selected target → Apply binding**. **Form controls → Bind property** opens the declaration for an existing target. Add `--saved-document` to the Archiver launcher or host check to open the designer-profile view `SavedDocument.fxml`. Under **Form controls**, select **HtmlViewer #article** to edit the media button labels and tooltips. Select **AutoCompleteTextField #fixed** and edit **suggestions**, one tag per line. **Build and Refresh** discovers **HTML · Rechnung** and **HTML · Lieferschein**. **Form preview** shows the rendered HTML at the selected dimensions. In **Interactive preview**, use **Dokument wechseln**, edit **HTML-Quelle**, or type **Re** and **Li** into **Dokument-Tags** before and after switching. The form binds `article.html` to `html` and `dynamic.suggestionsSource` to `tags`, both toward the view. To create either binding, open **Bindings → Discover targets**, select **view** and the model path, select the compatible control property, then choose **Use selected target → Apply binding**. **Form controls → Bind property** opens the declaration for an existing target.
Use `--document-tabs` with the Archiver host check to open the production archive window and select **Archiver · HTML-Dokumenttabs**. The check switches from the invoice to the delivery note and back, reads each WebView, and checks the actual suggestion popup for the same prefix in both tabs.
For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots. For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots.
The [save/startup reliability follow-up](docs/ide-host-reliability.md) covers queued IntelliJ VFS writes and host-revision/validation races, including repeated registered module-path qualification. Add `--mode modulepath --repeat 3` to the IDE runner to repeat that gate. The [save/startup reliability follow-up](docs/ide-host-reliability.md) covers queued IntelliJ VFS writes and host-revision/validation races, including repeated registered module-path qualification. Add `--mode modulepath --repeat 3` to the IDE runner to repeat that gate.
@@ -0,0 +1,215 @@
package qualification;
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.*;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.image.PixelFormat;
import javafx.stage.*;
import javax.imageio.ImageIO;
import org.w3c.dom.Document;
/**
* Checks the selected product tab, WebKit DOM and actual popup, including a return to the first
* tab.
*/
public final class DocumentTabsTargetProbe {
public static void premain(String dir) {
if (System.getProperty("sun.java.command", "")
.startsWith("de.neitzel.fxdesigner.target.WorkerMain "))
Thread.ofPlatform().daemon().start(() -> Probe.run(Path.of(dir)));
}
private static final class Probe {
private static <T> T fx(Callable<T> task) throws Exception {
var future = new FutureTask<>(task);
Platform.runLater(future);
return future.get(10, TimeUnit.SECONDS);
}
private static void await(String description, Callable<Boolean> check) throws Exception {
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(45);
while (System.nanoTime() < deadline) {
if (fx(check)) return;
Thread.sleep(100);
}
throw new AssertionError(description);
}
private static void run(Path dir) {
try {
Stage stage = null;
while (stage == null) {
Thread.sleep(120);
try {
stage =
fx(
() ->
Window.getWindows().stream()
.filter(Stage.class::isInstance)
.map(Stage.class::cast)
.filter(
s ->
s.getOpacity() > 0
&& s.getTitle() != null
&& s.getTitle().startsWith("Neitzel preview"))
.findFirst()
.orElse(null));
} catch (IllegalStateException starting) {
/* Waiting for FX startup. */
}
}
final Stage window = stage;
TabPane group =
fx(
() ->
window.getScene().getRoot().lookupAll(".tab-pane").stream()
.map(TabPane.class::cast)
.filter(
p ->
p.getTabs().stream()
.anyMatch(t -> "Rechnung.html".equals(t.getText())))
.findFirst()
.orElseThrow());
check(
dir,
group,
"Rechnung.html",
"Rechnung RE-042",
"Büromaterial · 48,00 €",
"Beleg offen",
"Beleg geprüft",
"rechnung-tab");
check(
dir,
group,
"Lieferschein.html",
"Lieferschein LS-018",
"Wareneingang · 3 Archivkartons",
"Beleg geprüft",
"Beleg offen",
"lieferschein-tab");
check(
dir,
group,
"Rechnung.html",
"Rechnung RE-042",
"Büromaterial · 48,00 €",
"Beleg offen",
"Beleg geprüft",
"rechnung-tab");
Files.writeString(
dir.resolve("document-tabs-result"),
"PASS Rechnung → Lieferschein → Rechnung: HTML content, assigned tag and filtered"
+ " suggestion in each production tab.\n");
} catch (Throwable error) {
var trace = new java.io.StringWriter();
error.printStackTrace(new java.io.PrintWriter(trace));
try {
Files.writeString(dir.resolve("target-error.txt"), trace.toString());
} catch (Exception ignored) {
error.printStackTrace();
}
}
}
private static void check(
Path dir,
TabPane group,
String name,
String heading,
String body,
String assigned,
String suggestion,
String image)
throws Exception {
var tab =
fx(
() -> {
var target =
group.getTabs().stream()
.filter(t -> name.equals(t.getText()))
.findFirst()
.orElseThrow();
group.getSelectionModel().select(target);
return target;
});
await(
"HTML in " + name,
() -> {
var content = tab.getContent();
var viewer = content.lookup("#html-document");
if (viewer == null
|| group.getSelectionModel().getSelectedItem() != tab
|| !content.isVisible()) return false;
var browser = viewer.lookup("WebView");
Object engine = browser.getClass().getMethod("getEngine").invoke(browser);
var doc = (Document) engine.getClass().getMethod("getDocument").invoke(engine);
return doc != null
&& doc.getElementsByTagName("h1").getLength() == 1
&& heading.equals(doc.getElementsByTagName("h1").item(0).getTextContent())
&& doc.getDocumentElement().getTextContent().contains(body);
});
var field = fx(() -> (TextField) tab.getContent().lookup("#tag-input"));
await(
"Focus in " + name,
() -> {
var stage = (Stage) group.getScene().getWindow();
if (!field.isFocused()) {
stage.toFront();
stage.requestFocus();
field.requestFocus();
}
return field.isFocused();
});
fx(
() -> {
var chips = tab.getContent().lookupAll(".tag-chip");
if (chips.size() != 1) throw new AssertionError("Expected one assigned tag in " + name);
var chip = chips.iterator().next();
if (!assigned.equals(chip.getClass().getMethod("getText").invoke(chip)))
throw new AssertionError("Wrong assigned tag in " + name);
field.setText("");
field.setText("Be");
return null;
});
await(
"Popup with " + suggestion,
() -> {
for (var window : Window.getWindows()) {
if (window instanceof Popup popup
&& popup.isShowing()
&& popup.getOwnerNode() == field
&& popup.getScene().lookup(".list-view") instanceof ListView<?> list
&& list.getItems().equals(List.of(suggestion))) {
save(list, dir.resolve(image + "-tags.png"));
return true;
}
}
return false;
});
fx(
() -> {
save(tab.getContent(), dir.resolve(image + ".png"));
field.setText("");
return null;
});
}
private static void save(Node node, Path file) throws Exception {
var image = node.snapshot(null, null);
int width = (int) image.getWidth(), height = (int) image.getHeight();
var pixels = new int[width * height];
image
.getPixelReader()
.getPixels(0, 0, width, height, PixelFormat.getIntArgbInstance(), pixels, 0, width);
var png =
new java.awt.image.BufferedImage(
width, height, java.awt.image.BufferedImage.TYPE_INT_ARGB);
png.setRGB(0, 0, width, height, pixels, 0, width);
ImageIO.write(png, "png", file.toFile());
}
}
}
@@ -0,0 +1,60 @@
package qualification;
import static qualification.WorkflowProbe.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import java.nio.file.*;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javax.imageio.ImageIO;
/**
* Opens the production ArchiveWindow in the registered editor and selects its real document tabs.
*/
public final class DocumentTabsWorkflowProbe extends FormWorkflowProbe {
@Override
void verify(Project project) throws Exception {
var path =
Path.of(
project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui/ArchiveWindow.fxml");
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
pane = openDesigner(project, file);
click(pane, "Form preview");
click(pane, "Build and Refresh");
await(
() ->
fx(
() ->
((ComboBox<?>) pane.lookup("#preview-example"))
.getItems().stream()
.anyMatch(
item -> item.toString().contains("archive-window-documents"))));
choose("preview-example", "archive-window-documents");
await(
() ->
fx(
() -> {
var status = ((Label) pane.lookup("#preview-state")).getText();
if (status.startsWith("Preview failed") || status.startsWith("Preview blocked"))
throw new AssertionError(status);
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
&& status.contains("HTML-Dokumenttabs");
}));
step("Production ArchiveWindow rendered the document tabs");
fx(
() -> {
ImageIO.write(
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
"png",
output.resolve("intellij.png").toFile());
return null;
});
click(pane, "Interactive preview");
awaitTarget("document-tabs-result");
click(pane, "Stop preview");
Files.writeString(
output.resolve("SUCCESS.txt"), Files.readString(output.resolve("document-tabs-result")));
}
}
+4 -3
View File
@@ -26,9 +26,10 @@ p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a di
forms = p.add_mutually_exclusive_group() forms = p.add_mutually_exclusive_group()
forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form") forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form")
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example") forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
args = p.parse_args() args = p.parse_args()
if (args.connection_form or args.grid_docking or args.saved_document) and not args.archiver: if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs) and not args.archiver:
p.error("Selecting an Archiver view requires --archiver") p.error("Selecting an Archiver view requires --archiver")
if args.repeat < 1: if args.repeat < 1:
p.error("--repeat must be positive") p.error("--repeat must be positive")
@@ -40,7 +41,7 @@ modes = ("classpath",) if args.archiver else (("classpath", "modulepath") if arg
for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes): for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes):
crashes = NativeCrashGuard(ROOT) crashes = NativeCrashGuard(ROOT)
launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij", launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij",
"--check", *(["--saved-document"] if args.saved_document else []), *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home, "--check", *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home,
"--target-java-home", args.target_java_home, "--idea-home", args.idea_home], "--target-java-home", args.target_java_home, "--idea-home", args.idea_home],
cwd=ROOT, text=True, capture_output=True, timeout=60) cwd=ROOT, text=True, capture_output=True, timeout=60)
if launch.returncode: if launch.returncode:
@@ -84,7 +85,7 @@ for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode i
shutil.copyfile(base / "intellij.png", output / (mode + ".png")) shutil.copyfile(base / "intellij.png", output / (mode + ".png"))
(evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n") (evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n")
finally: finally:
for name in ("SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"): for name in ("SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"):
if (base / name).exists(): if (base / name).exists():
shutil.copyfile(base / name, evidence / name) shutil.copyfile(base / name, evidence / name)
workers = descendant_workers(pid) workers = descendant_workers(pid)
+5 -2
View File
@@ -22,9 +22,10 @@ p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archi
forms = p.add_mutually_exclusive_group() forms = p.add_mutually_exclusive_group()
forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form") forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form")
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example") forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
args = p.parse_args() args = p.parse_args()
if (args.connection_form or args.grid_docking or args.saved_document) and not args.archiver: if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs) and not args.archiver:
p.error("Selecting an Archiver view requires --archiver") p.error("Selecting an Archiver view requires --archiver")
base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve() base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve()
project = base / "project" project = base / "project"
@@ -80,11 +81,13 @@ else:
suite = "Connection" suite = "Connection"
elif args.grid_docking: elif args.grid_docking:
suite = "GridDock" suite = "GridDock"
elif args.document_tabs:
suite = "DocumentTabs"
elif args.saved_document: elif args.saved_document:
suite = "SavedDocument" suite = "SavedDocument"
probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe" probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe"
files = [sources / "WorkflowProbe.java"] files = [sources / "WorkflowProbe.java"]
if args.connection_form or args.saved_document: if args.connection_form or args.saved_document or args.document_tabs:
files.append(sources / "FormWorkflowProbe.java") files.append(sources / "FormWorkflowProbe.java")
if args.archiver: if args.archiver:
files.append(sources / f"{probe}.java") files.append(sources / f"{probe}.java")