Validate grid width bounds and qualify Archiver window and document states in IntelliJ
This commit is contained in:
@@ -7,6 +7,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import de.neitzel.fxdesigner.workflow.DesignerWorkflow.Example;
|
||||
import java.nio.file.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
import javafx.scene.control.*;
|
||||
@@ -24,17 +25,24 @@ public final class DocumentTabsWorkflowProbe extends FormWorkflowProbe {
|
||||
"AutoCompleteTextField #input",
|
||||
"promptText",
|
||||
"Belegtag wählen");
|
||||
build(4);
|
||||
for (String id :
|
||||
new String[] {"details-invoice", "details-delivery", "details-readonly", "details-busy"})
|
||||
preview(id);
|
||||
qualify("details-invoice", "details-delivery", "details-readonly", "details-busy");
|
||||
open(project, "HtmlDocument");
|
||||
build(2);
|
||||
preview("html-invoice");
|
||||
preview("html-delivery");
|
||||
qualify("html-invoice", "html-delivery");
|
||||
open(project, "ArchiveWindow");
|
||||
build(2);
|
||||
preview("archive-window-documents");
|
||||
qualify("archive-window-documents");
|
||||
var ids = fx(this::available);
|
||||
if (!ids.contains("archive-window-media"))
|
||||
throw new AssertionError("Missing media example: " + ids);
|
||||
try {
|
||||
awaitExamples(List.of("missing-required-example"));
|
||||
throw new AssertionError("Missing descriptor was accepted");
|
||||
} catch (IllegalStateException expected) {
|
||||
String diagnostic = expected.getMessage();
|
||||
if (!diagnostic.contains(
|
||||
"ArchiveWindow.fxml · required [missing-required-example] · available " + ids))
|
||||
throw expected;
|
||||
step(diagnostic);
|
||||
}
|
||||
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
|
||||
}
|
||||
|
||||
@@ -65,32 +73,84 @@ public final class DocumentTabsWorkflowProbe extends FormWorkflowProbe {
|
||||
step("Saved and reopened " + control + "." + property + " = " + value);
|
||||
}
|
||||
|
||||
private void build(int examples) throws Exception {
|
||||
private List<String> available() {
|
||||
return ((ComboBox<?>) pane.lookup("#preview-example"))
|
||||
.getItems().stream().map(Example.class::cast).map(Example::id).toList();
|
||||
}
|
||||
|
||||
private String state() {
|
||||
return ((Label) pane.lookup("#preview-state")).getText();
|
||||
}
|
||||
|
||||
private boolean failed() {
|
||||
String state = state();
|
||||
return state.startsWith("Preview failed")
|
||||
|| state.startsWith("Preview blocked")
|
||||
|| state.startsWith("Preview unavailable")
|
||||
|| state.contains("correct the build");
|
||||
}
|
||||
|
||||
private String diagnostic(List<String> required) {
|
||||
return file.getName()
|
||||
+ " · required "
|
||||
+ required
|
||||
+ " · available "
|
||||
+ available()
|
||||
+ " · "
|
||||
+ state();
|
||||
}
|
||||
|
||||
private void awaitExamples(List<String> required) throws Exception {
|
||||
try {
|
||||
// Discovery publishes the complete list at once. Additional providers may extend it.
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
failed()
|
||||
|| state().contains("register an example")
|
||||
|| !state().startsWith("Building") && !available().isEmpty()));
|
||||
} catch (AssertionError timeout) {
|
||||
throw new AssertionError(fx(() -> diagnostic(required)), timeout);
|
||||
}
|
||||
if (!fx(() -> !failed() && available().containsAll(required)))
|
||||
throw new IllegalStateException(fx(() -> diagnostic(required)));
|
||||
}
|
||||
|
||||
private void qualify(String... examples) throws Exception {
|
||||
var required = List.of(examples);
|
||||
click(pane, "Form preview");
|
||||
click(pane, "Build and Refresh");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
((ComboBox<?>) pane.lookup("#preview-example")).getItems().size() == examples));
|
||||
awaitExamples(required);
|
||||
step(file.getName() + " · available " + fx(this::available));
|
||||
for (String id : required) preview(id);
|
||||
}
|
||||
|
||||
private void preview(String id) throws Exception {
|
||||
choose("preview-example", id);
|
||||
String label =
|
||||
fx(() -> ((Example) ((ComboBox<?>) pane.lookup("#preview-example")).getValue()).label());
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() -> {
|
||||
String state = ((Label) pane.lookup("#preview-state")).getText();
|
||||
if (state.startsWith("Preview failed")
|
||||
|| state.startsWith("Preview blocked")
|
||||
|| state.startsWith("Preview unavailable"))
|
||||
throw new AssertionError(id + ": " + state);
|
||||
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
|
||||
&& state.contains(label);
|
||||
}));
|
||||
fx(
|
||||
() -> {
|
||||
var choices = (ComboBox<Example>) pane.lookup("#preview-example");
|
||||
var selected =
|
||||
choices.getItems().stream()
|
||||
.filter(example -> example.id().equals(id))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException(diagnostic(List.of(id))));
|
||||
choices.getSelectionModel().select(selected);
|
||||
return selected.label();
|
||||
});
|
||||
try {
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
failed()
|
||||
|| ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
|
||||
&& state().contains(label)));
|
||||
} catch (AssertionError timeout) {
|
||||
throw new AssertionError(fx(() -> diagnostic(List.of(id))), timeout);
|
||||
}
|
||||
if (fx(this::failed)) throw new AssertionError(fx(() -> diagnostic(List.of(id))));
|
||||
fx(
|
||||
() -> {
|
||||
var frame = ((ImageView) pane.lookup("#full-preview-image")).getImage();
|
||||
|
||||
Reference in New Issue
Block a user