Search in sources :

Example 1 with OperationResult

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);
}
Also used : PetEdit(io.jmix.petclinic.screen.pet.pet.PetEdit) InputDialogTestAPI(de.diedavids.sneferu.screen.InputDialogTestAPI) OperationResult(io.jmix.ui.util.OperationResult) Pet(io.jmix.petclinic.entity.pet.Pet) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with OperationResult

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());
}
Also used : VeterinarianEdit(io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianEdit) Veterinarian(io.jmix.petclinic.entity.veterinarian.Veterinarian) OperationResult(io.jmix.ui.util.OperationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 3 with OperationResult

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());
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OperationResult(io.jmix.ui.util.OperationResult) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with OperationResult

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();
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OperationResult(io.jmix.ui.util.OperationResult) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with OperationResult

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;
}
Also used : Screen(io.jmix.ui.screen.Screen) OperationResult(io.jmix.ui.util.OperationResult)

Aggregations

OperationResult (io.jmix.ui.util.OperationResult)12 SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)8 Test (org.junit.jupiter.api.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Pet (io.jmix.petclinic.entity.pet.Pet)3 Veterinarian (io.jmix.petclinic.entity.veterinarian.Veterinarian)3 Visit (io.jmix.petclinic.entity.visit.Visit)3 VeterinarianEdit (io.jmix.petclinic.screen.veterinarian.veterinarian.VeterinarianEdit)3 VisitEdit (io.jmix.petclinic.screen.visit.VisitEdit)3 Screen (io.jmix.ui.screen.Screen)3 InputDialogTestAPI (de.diedavids.sneferu.screen.InputDialogTestAPI)2 PetEdit (io.jmix.petclinic.screen.pet.pet.PetEdit)2 NotificationType (io.jmix.ui.Notifications.NotificationType)2 Action (io.jmix.ui.action.Action)2 BaseAction (io.jmix.ui.action.BaseAction)2 Icons (io.jmix.ui.icon.Icons)2 Strings (com.google.common.base.Strings)1 UIScope (com.vaadin.spring.annotation.UIScope)1 CssLayout (com.vaadin.ui.CssLayout)1 Layout (com.vaadin.ui.Layout)1