Search in sources :

Example 1 with VisitBrowse

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

the class GetOpenedLookupScreenTest method given_noLookupScreenIsOpen_when_getOpenedScreen_then_exceptionIsThrown.

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

Example 2 with VisitBrowse

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

the class GetOpenedLookupScreenTest method given_differentLookupScreenIsOpen_when_getOpenedScreen_then_exceptionIsThrown.

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

Example 3 with VisitBrowse

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

the class GetLazyOpenedLookupScreenTest method given_screenIsOpenedAfterRetrievingTheLazyReference_when_accessingScreen_then_screenIsReturned.

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

Example 4 with VisitBrowse

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

the class OpenTabInteractionTest method when_interactionIsPerformed_then_tabIsSelected.

@Test
void when_interactionIsPerformed_then_tabIsSelected(UiTestAPI uiTestAPI) {
    // given:
    final StandardLookupTestAPI<Visit, VisitBrowse> openedScreen = uiTestAPI.openStandardLookup(Visit.class, VisitBrowse.class);
    final TabsheetComponentDescriptor tabSheet = tabSheet("contentTabSheet");
    assertThat(openedScreen.rawComponent(tabSheet)).isNotNull();
    assertThat(openedScreen.rawComponent(tabSheet).getTab("tableTab")).isNotNull();
    // when:
    openedScreen.interact(openTab(tabSheet, "tableTab"));
    // then:
    final TabSheet.Tab selectedTab = openedScreen.rawComponent(tabSheet).getSelectedTab();
    // and:
    assertThat(selectedTab.getName()).isEqualTo("tableTab");
}
Also used : Visit(io.jmix.petclinic.entity.visit.Visit) TabsheetComponentDescriptor(de.diedavids.sneferu.components.descriptor.TabsheetComponentDescriptor) TabSheet(io.jmix.ui.component.TabSheet) 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)

Example 5 with VisitBrowse

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

the class OpenTabInteractionTest method when_interactionIsPerformedWithInvalidTab_then_exceptionIsThrown.

@Test
void when_interactionIsPerformedWithInvalidTab_then_exceptionIsThrown(UiTestAPI uiTestAPI) {
    // given:
    final StandardLookupTestAPI<Visit, VisitBrowse> openedScreen = uiTestAPI.openStandardLookup(Visit.class, VisitBrowse.class);
    final TabsheetComponentDescriptor tabSheet = tabSheet("contentTabSheet");
    assertThat(openedScreen.rawComponent(tabSheet)).isNotNull();
    // expect:
    assertThrows(IllegalStateException.class, () -> openedScreen.interact(openTab(tabSheet, "notExistingTab")));
}
Also used : Visit(io.jmix.petclinic.entity.visit.Visit) TabsheetComponentDescriptor(de.diedavids.sneferu.components.descriptor.TabsheetComponentDescriptor) 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

SneferuUiTest (de.diedavids.sneferu.SneferuUiTest)11 VisitBrowse (io.jmix.petclinic.screen.visit.VisitBrowse)11 Test (org.junit.jupiter.api.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 Visit (io.jmix.petclinic.entity.visit.Visit)9 ScreenNotOpenException (de.diedavids.sneferu.ScreenNotOpenException)3 TabsheetComponentDescriptor (de.diedavids.sneferu.components.descriptor.TabsheetComponentDescriptor)2 ButtonTestAPI (de.diedavids.sneferu.components.testapi.ButtonTestAPI)1 Pet (io.jmix.petclinic.entity.pet.Pet)1 PetBrowse (io.jmix.petclinic.screen.pet.pet.PetBrowse)1 VisitEdit (io.jmix.petclinic.screen.visit.VisitEdit)1 Button (io.jmix.ui.component.Button)1 TabSheet (io.jmix.ui.component.TabSheet)1 OperationResult (io.jmix.ui.util.OperationResult)1