use of io.jmix.ui.util.OperationResult in project jmix-sneferu by mariodavid.
the class GetOpenedInputDialogScreenTest method given_inputDialogIsOpen_when_getOpenedInputDialog_then_inputDialogIsReturned.
@Test
void given_inputDialogIsOpen_when_getOpenedInputDialog_then_inputDialogIsReturned(UiTestAPI uiTestAPI) {
// given:
final String pikachuIdentifier = "025";
final Pet pikachu = storePikachu(pikachuIdentifier);
// and:
openPetByIdInputDialog(uiTestAPI);
// when:
final InputDialogTestAPI openedInputDialog = uiTestAPI.getOpenedInputDialog();
// and:
final OperationResult operationResult = openedInputDialog.interact(enter(textInputField("id"), pikachuIdentifier)).andThenGet(closeInputDialogWith(InputDialog.INPUT_DIALOG_OK_ACTION));
// then:
assertThat(operationResult).isEqualTo(OperationResult.success());
// and: after the input dialog, the Pet editor is opened
final StandardEditorTestAPI<Pet, PetEdit> openedPetEditor = uiTestAPI.getOpenedEditorScreen(PetEdit.class);
final Pet pet = openedPetEditor.get(editedEntity());
assertThat(pet).isEqualTo(pikachu);
}
use of io.jmix.ui.util.OperationResult in project jmix-sneferu by mariodavid.
the class CloseEditorInteractionTest method given_invalidForm_when_interactionIsPerformedWith_then_screenIsClosedAndFailIsReturned.
@Test
void given_invalidForm_when_interactionIsPerformedWith_then_screenIsClosedAndFailIsReturned(UiTestAPI uiTestAPI) {
// given:
StandardEditorTestAPI<Veterinarian, VeterinarianEdit> visitEdit = uiTestAPI.openStandardEditor(Veterinarian.class, VeterinarianEdit.class);
// and:
visitEdit.interact(enter(textInputField("firstNameField"), null));
// when:
final OperationResult operationResult = visitEdit.andThenGet(closeEditor());
// then:
assertThat(operationResult).isEqualTo(OperationResult.fail());
}
use of io.jmix.ui.util.OperationResult in project jmix-sneferu by mariodavid.
the class VisitEditTest method aVisitCanBeCreated_whenAllFieldsAreFilled.
@Test
void aVisitCanBeCreated_whenAllFieldsAreFilled(UiTestAPI uiTestAPI) {
StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
// when:
OperationResult outcome = (OperationResult) visitEdit.interact(enter(dateField("visitStartField"), LocalDateTime.now())).interact(enter(textField("descriptionField"), "Regular Visit")).interact(select(comboBox("typeField"), VisitType.RECHARGE)).interact(select(entityComboBox("petField"), pet)).andThenGet(closeEditor());
// then:
assertThat(outcome).isEqualTo(OperationResult.success());
}
use of io.jmix.ui.util.OperationResult in project jmix-sneferu by mariodavid.
the class VisitEditTest method aVisitCannotBeCreated_whenPetIsMissing.
@Test
void aVisitCannotBeCreated_whenPetIsMissing(UiTestAPI uiTestAPI) {
StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
// when:
visitEdit.interact(enter(entityComboBox("petField"), null));
// and:
OperationResult outcome = (OperationResult) visitEdit.interact(enter(textField("descriptionField"), "Regular Visit")).interact(select(comboBox("typeField"), VisitType.RECHARGE)).andThenGet(closeEditor());
// then:
assertThat(outcome).isEqualTo(OperationResult.fail());
// and:
assertThat(visitEdit.screen().getWindow().validateAll()).isFalse();
}
use of io.jmix.ui.util.OperationResult in project jmix by jmix-framework.
the class AppWorkAreaImpl method closeWindowStack.
protected boolean closeWindowStack(WindowStack windowStack) {
boolean closed = true;
Collection<Screen> tabScreens = windowStack.getBreadcrumbs();
for (Screen screen : tabScreens) {
if (isNotCloseable(screen.getWindow())) {
continue;
}
if (isWindowClosePrevented(screen.getWindow(), CloseOriginType.CLOSE_BUTTON)) {
closed = false;
// focus tab
windowStack.select();
break;
}
OperationResult closeResult = screen.close(FrameOwner.WINDOW_CLOSE_ACTION);
if (closeResult.getStatus() != OperationResult.Status.SUCCESS) {
closed = false;
// focus tab
windowStack.select();
break;
}
}
return closed;
}
Aggregations