-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...v23/kt23-tests/src/main/kotlin/com/github/mvysny/kaributesting/v10/AbstractLayoutTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.github.mvysny.kaributesting.v10 | ||
|
||
import com.github.mvysny.kaributools.navigateTo | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.myapp.MainLayout | ||
import org.myapp.MyRoute | ||
|
||
abstract class AbstractLayoutTests { | ||
companion object { | ||
lateinit var routes: Routes | ||
@BeforeAll @JvmStatic fun discoverRoutes() { | ||
routes = Routes().autoDiscoverViews("org.myapp") | ||
} | ||
} | ||
@BeforeEach fun fakeVaadin() { MockVaadin.setup(routes) } | ||
@AfterEach fun tearDownVaadin() { MockVaadin.tearDown() } | ||
|
||
@Test fun automaticLayouting() { | ||
navigateTo<MyRoute>() | ||
_expectOne<MyRoute>() | ||
_expectOne<MainLayout>() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 15 additions & 2 deletions
17
karibu-testing-v23/kt23-tests/src/main/kotlin/org/myapp/Views.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
package org.myapp | ||
|
||
import com.github.mvysny.kaributesting.v10.Routes | ||
import com.vaadin.flow.component.html.Div | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout | ||
import com.vaadin.flow.router.Layout | ||
import com.vaadin.flow.router.Route | ||
import com.vaadin.flow.router.RouterLayout | ||
import jakarta.annotation.security.RolesAllowed | ||
|
||
val routes = Routes().autoDiscoverViews("org.myapp") | ||
|
||
@Route | ||
@Route(autoLayout = false) | ||
internal class LoginView : VerticalLayout() | ||
@Route("admin") | ||
@Route("admin", autoLayout = false) | ||
@RolesAllowed("admin") | ||
internal class AdminView : VerticalLayout() | ||
|
||
@Layout | ||
class MainLayout : Div(), RouterLayout | ||
|
||
/** | ||
* Should automatically include [MainLayout] as its layout: | ||
* https://vaadin.com/docs/latest/flow/routing/layout#automatic-layout-using-layout | ||
*/ | ||
@Route("myroute") | ||
internal class MyRoute : Div() |