Search in sources :

Example 1 with InputDialogTestAPI

use of de.diedavids.sneferu.screen.InputDialogTestAPI in project jmix-sneferu by mariodavid.

the class GetOpenedInputDialogScreenTest method given_inputDialogIsOpen_when_incorrectlyInteractingWithInputDialog_then_operationResultIsFail.

@Test
void given_inputDialogIsOpen_when_incorrectlyInteractingWithInputDialog_then_operationResultIsFail(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    storePikachu("025");
    // and:
    openPetByIdInputDialog(uiTestAPI);
    // when:
    final InputDialogTestAPI openedInputDialog = uiTestAPI.getOpenedInputDialog();
    // and:
    openedInputDialog.interact(enter(textInputField("id"), null)).andThenGet(closeInputDialogWith(InputDialog.INPUT_DIALOG_OK_ACTION));
    // then:
    assertThrows(ScreenNotOpenException.class, () -> uiTestAPI.getOpenedEditorScreen(PetEdit.class));
}
Also used : PetEdit(io.jmix.petclinic.screen.pet.pet.PetEdit) InputDialogTestAPI(de.diedavids.sneferu.screen.InputDialogTestAPI) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with InputDialogTestAPI

use of de.diedavids.sneferu.screen.InputDialogTestAPI 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 3 with InputDialogTestAPI

use of de.diedavids.sneferu.screen.InputDialogTestAPI in project jmix-sneferu by mariodavid.

the class CloseInputDialogInteractionTest method when_interactionIsPerformed_then_inputDialogIsClosedAndSuccessIsReturned.

@Test
void when_interactionIsPerformed_then_inputDialogIsClosedAndSuccessIsReturned(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 4 with InputDialogTestAPI

use of de.diedavids.sneferu.screen.InputDialogTestAPI in project jmix-sneferu by mariodavid.

the class CloseInputDialogInteractionTest method when_interactionIsPerformedWithCloseAction_then_inputDialogIsClosedAndSuccessIsReturned.

@Test
void when_interactionIsPerformedWithCloseAction_then_inputDialogIsClosedAndSuccessIsReturned(UiTestAPI uiTestAPI) {
    // given:
    storePikachu("025");
    // and:
    openPetByIdInputDialog(uiTestAPI);
    // when:
    final InputDialogTestAPI openedInputDialog = uiTestAPI.getOpenedInputDialog();
    // and:
    openedInputDialog.interact(enter(textInputField("id"), null)).andThenGet(closeInputDialogWith(InputDialog.INPUT_DIALOG_OK_ACTION));
    // then:
    assertThrows(ScreenNotOpenException.class, () -> uiTestAPI.getOpenedEditorScreen(PetEdit.class));
}
Also used : PetEdit(io.jmix.petclinic.screen.pet.pet.PetEdit) InputDialogTestAPI(de.diedavids.sneferu.screen.InputDialogTestAPI) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)4 InputDialogTestAPI (de.diedavids.sneferu.screen.InputDialogTestAPI)4 PetEdit (io.jmix.petclinic.screen.pet.pet.PetEdit)4 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Pet (io.jmix.petclinic.entity.pet.Pet)2 OperationResult (io.jmix.ui.util.OperationResult)2