Search in sources :

Example 6 with VisitEdit

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

the class GetOpenedEditorScreenTest method given_editorScreenIsOpen_when_getOpenedScreen_then_screenIsReturned.

@Test
void given_editorScreenIsOpen_when_getOpenedScreen_then_screenIsReturned(Screens screens, UiTestAPI uiTestAPI) {
    // given:
    final VisitEdit screen = screens.create(VisitEdit.class);
    screen.setEntityToEdit(dataManager.create(Visit.class));
    // and:
    screen.show();
    // when:
    final StandardEditorTestAPI<Visit, VisitEdit> openedScreen = uiTestAPI.getOpenedEditorScreen(VisitEdit.class);
    // then:
    assertThat(openedScreen.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 7 with VisitEdit

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

the class GetOpenedEditorScreenTest method given_noEditorScreenIsOpen_when_getOpenedScreen_then_exceptionIsThrown.

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

Example 8 with VisitEdit

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

the class InteractionsTest method when_verifyIsPerformed_then_resultOfTheInteractionIsReturned.

@Test
void when_verifyIsPerformed_then_resultOfTheInteractionIsReturned(UiTestAPI uiTestAPI) {
    // given:
    final StandardEditorTestAPI<Visit, VisitEdit> openedScreen = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class);
    // and:
    assertThat(openedScreen.component(dateField("visitStartField"))).isNotNull();
    // and:
    final LocalDateTime startDate = LocalDateTime.of(2022, 1, 15, 6, 0);
    // and:
    openedScreen.interact(enter(dateField("visitStartField"), startDate));
    // when:
    final LocalDateTime enteredVisitStart = openedScreen.verify(entityValue("visitStart", LocalDateTime.class));
    // then:
    assertThat(enteredVisitStart).isEqualTo(startDate);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) LocalDateTime(java.time.LocalDateTime) 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 9 with VisitEdit

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

the class EditedEntityInteractionTest method when_interactionIsPerformed_then_editedEntityIsReturned.

@Test
void when_interactionIsPerformed_then_editedEntityIsReturned(UiTestAPI uiTestAPI) {
    // given:
    final Visit expectedVisit = dataManager.create(Visit.class);
    // and:
    StandardEditorTestAPI<Visit, VisitEdit> visitEdit = uiTestAPI.openStandardEditor(Visit.class, VisitEdit.class, expectedVisit);
    // when:
    final Visit actualVisitEntity = visitEdit.andThenGet(editedEntity());
    // then:
    assertThat(actualVisitEntity).isEqualTo(expectedVisit);
}
Also used : VisitEdit(io.jmix.petclinic.screen.visit.VisitEdit) 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 10 with VisitEdit

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

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