Search in sources :

Example 16 with VisitEdit

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

the class GetLazyOpenedEditorScreenTest method given_screenIsAlreadyOpened_when_getLazyOpenedEditorScreen_then_lazyTestApiIsReturned.

@Test
void given_screenIsAlreadyOpened_when_getLazyOpenedEditorScreen_then_lazyTestApiIsReturned(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    final VisitEdit screen = showVisitEditor(screens);
    // when:
    final StandardEditorTestAPI<Visit, VisitEdit> lazyOpenedScreen = uiTestAPI.getLazyOpenedEditorScreen(VisitEdit.class);
    // then:
    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 17 with VisitEdit

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

the class InteractionsTest method when_interactIsPerformedMultipleTimes_then_allInteractionsArePerformed.

@Test
void when_interactIsPerformedMultipleTimes_then_allInteractionsArePerformed(UiTestAPI uiTestAPI) {
    // given:
    final StandardEditorTestAPI<Visit, VisitEdit> openedScreen = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    assertThat(openedScreen.component(dateField("visitStartField"))).isNotNull();
    assertThat(openedScreen.component(comboBox("typeField"))).isNotNull();
    // and:
    final LocalDateTime startDate = LocalDateTime.of(2022, 1, 15, 6, 0);
    final VisitType recharge = VisitType.RECHARGE;
    // when:
    openedScreen.interact(enter(dateField("visitStartField"), startDate)).andThen(select(comboBox("typeField"), recharge));
    // then:
    assertThat(openedScreen.verify(entityValue("visitStart", LocalDateTime.class))).isEqualTo(startDate);
    // and:
    assertThat(openedScreen.verify(entityValue("type", VisitType.class))).isEqualTo(recharge);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) LocalDateTime(java.time.LocalDateTime) Visit(io.jmix.petclinic.entity.visit.Visit) VisitType(io.jmix.petclinic.entity.visit.VisitType) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 18 with VisitEdit

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

the class EntityValueInteractionTest method when_interactionIsPerformed_then_valueIsReturnedFromTheEntity.

@Test
void when_interactionIsPerformed_then_valueIsReturnedFromTheEntity(UiTestAPI uiTestAPI) {
    // given:
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    final LocalDateTime visitStart = LocalDateTime.now();
    visitEdit.interact(enter(dateField("visitStartField"), visitStart));
    // when:
    final LocalDateTime actualVisitStart = (LocalDateTime) visitEdit.andThenGet(entityValue("visitStart", LocalDateTime.class));
    // then:
    assertThat(actualVisitStart).isEqualTo(visitStart);
}
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 19 with VisitEdit

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

the class CreateVisitTest method aVisitCanBeCreated_whenAllFieldsAreFilled.

@Test
void aVisitCanBeCreated_whenAllFieldsAreFilled(UiTestAPI uiTestAPI) {
    // given:
    final Pet pikachu = dataManager.create(Pet.class);
    pikachu.setName("Pikachu");
    pikachu.setIdentificationNumber("025");
    final Pet savedPikachu = dataManager.save(pikachu);
    // and:
    final StandardLookupTestAPI<Visit, VisitBrowse> visitBrowse = uiTestAPI.openStandardLookup(Visit.class, VisitBrowse.class);
    visitBrowse.interact(click(button("createBtn")));
    // when:
    final StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.getOpenedEditorScreen(VisitEdit.class);
    OperationResult outcome = (OperationResult) visitEdit.interact(enter(dateField("visitStartField"), LocalDateTime.now())).interact(enter(textField("descriptionField"), "Regular Visit")).interact(select(comboBox("typeField"), VisitType.REGULAR_CHECKUP)).interact(select(entityComboBox("petField"), savedPikachu)).andThenGet(closeEditor());
    // then:
    assertThat(outcome).isEqualTo(OperationResult.success());
    // and:
    assertThat(uiTestAPI.isActive(visitEdit)).isFalse();
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) Visit(io.jmix.petclinic.entity.visit.Visit) OperationResult(io.jmix.ui.util.OperationResult) Pet(io.jmix.petclinic.entity.pet.Pet) VisitBrowse(io.jmix.petclinic.screen.visit.VisitBrowse) SneferuUiTest(de.diedavids.sneferu.SneferuUiTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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