Search in sources :

Example 11 with VisitEdit

use of io.jmix.petclinic.screen.visit.VisitEdit 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 12 with VisitEdit

use of io.jmix.petclinic.screen.visit.VisitEdit in project jmix-sneferu by mariodavid.

the class GetValueInteractionTest method when_interactionIsPerformed_then_valueIsReturnedFromTheComponent.

@Test
void when_interactionIsPerformed_then_valueIsReturnedFromTheComponent(UiTestAPI uiTestAPI) {
    // given:
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    visitEdit.interact(enter(VISIT_START_FIELD, VISIT_START_VALUE));
    // when:
    final LocalDateTime actualVisitStart = (LocalDateTime) visitEdit.andThenGet(getValue(VISIT_START_FIELD));
    // then:
    assertThat(actualVisitStart).isEqualTo(VISIT_START_VALUE);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) LocalDateTime(java.time.LocalDateTime) Visit(io.jmix.petclinic.entity.visit.Visit) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest)

Example 13 with VisitEdit

use of io.jmix.petclinic.screen.visit.VisitEdit in project jmix-sneferu by mariodavid.

the class GetLazyOpenedEditorScreenTest method given_screenIsOpenedAfterRetrievingTheLazyReference_when_accessingScreen_then_screenIsReturned.

@Test
void given_screenIsOpenedAfterRetrievingTheLazyReference_when_accessingScreen_then_screenIsReturned(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    final StandardEditorTestAPI<Visit, VisitEdit> lazyOpenedScreen = uiTestAPI.getLazyOpenedEditorScreen(VisitEdit.class);
    // and: screen is opened through the application (or test in this case)
    final VisitEdit screen = showVisitEditor(screens);
    // expect: the previous retrieved lazy reference will return the correct reference to the screen
    assertThat(lazyOpenedScreen.screen()).isEqualTo(screen);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with VisitEdit

use of io.jmix.petclinic.screen.visit.VisitEdit in project jmix-sneferu by mariodavid.

the class GetLazyOpenedEditorScreenTest method given_lazyTestApiIsReturned_when_accessingScreen_then_ScreenNotFoundExceptionIsThrown.

@Test
void given_lazyTestApiIsReturned_when_accessingScreen_then_ScreenNotFoundExceptionIsThrown(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    screens.removeAll();
    // when:
    final StandardEditorTestAPI<Visit, VisitEdit> lazyOpenedScreen = uiTestAPI.getLazyOpenedEditorScreen(VisitEdit.class);
    // then:
    final ScreenNotOpenException exception = Assertions.assertThrows(ScreenNotOpenException.class, lazyOpenedScreen::screen);
    // then:
    assertThat(exception.getMessage()).isEqualTo("No Screen of class VisitEdit found");
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) ScreenNotOpenException(de.diedavids.sneferu.ScreenNotOpenException) Visit(io.jmix.petclinic.entity.visit.Visit) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with VisitEdit

use of io.jmix.petclinic.screen.visit.VisitEdit in project jmix-sneferu by mariodavid.

the class GetLazyOpenedEditorScreenTest method showVisitEditor.

@NotNull
private VisitEdit showVisitEditor(Screens screens) {
    final VisitEdit screen = screens.create(VisitEdit.class);
    screen.setEntityToEdit(dataManager.create(Visit.class));
    screen.show();
    return screen;
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VisitEdit (io.jmix.petclinic.screen.visit.VisitEdit)19 SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)18 Visit (io.jmix.petclinic.entity.visit.Visit)18 Test (org.junit.jupiter.api.Test)18 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 LocalDateTime (java.time.LocalDateTime)5 VisitType (io.jmix.petclinic.entity.visit.VisitType)4 OperationResult (io.jmix.ui.util.OperationResult)3 ScreenNotOpenException (de.diedavids.sneferu.ScreenNotOpenException)2 Interactions.screenOpenMode (de.diedavids.sneferu.Interactions.screenOpenMode)1 Pet (io.jmix.petclinic.entity.pet.Pet)1 VisitBrowse (io.jmix.petclinic.screen.visit.VisitBrowse)1 OpenMode (io.jmix.ui.screen.OpenMode)1 NotNull (org.jetbrains.annotations.NotNull)1