File tree Expand file tree Collapse file tree 4 files changed +39
-24
lines changed
app/src/testFixtures/kotlin/pro/qyoga/tests
e2e-tests/src/test/kotlin/pro/qyoga/tests Expand file tree Collapse file tree 4 files changed +39
-24
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import org.springframework.web.util.UriTemplate
1010import pro.qyoga.tests.platform.html.Component
1111import pro.qyoga.tests.platform.html.HtmlPage
1212import pro.qyoga.tests.platform.html.Input
13+ import pro.qyoga.tests.platform.html.elementDescr
1314
1415
1516fun beComponent (component : Component ) = Matcher <Element > { element ->
@@ -189,19 +190,14 @@ fun haveCheckboxChecked(
189190}
190191
191192val Element .descr: String
192- get() {
193- val selector = if (this .id().isNotEmpty()) {
194- " id=\" ${this .id()} \" "
195- } else if (this .classNames().isNotEmpty()) {
196- " class=\" ${this .classNames().first()} \" ..."
197- } else {
198- " "
199- }
200- return " <${this .tag().name} $selector >" +
201- this .text().take(32 ) +
202- (" ..." .takeIf { this .text().length > 32 } ? : " " ) +
203- " </${this .tag().name} >"
204- }
193+ get() =
194+ elementDescr(
195+ this .tag().name,
196+ this .id(),
197+ this .classNames().firstOrNull(),
198+ this .attr(" name" ),
199+ this .text()
200+ )
205201
206202infix fun Element.shouldHaveComponent (component : Component ): Element {
207203 this should haveComponent(component)
Original file line number Diff line number Diff line change 1+ package pro.qyoga.tests.platform.html
2+
3+
4+ fun elementDescr (
5+ tag : String ,
6+ idValue : String? ,
7+ elClassValue : String? ,
8+ nameValue : String? ,
9+ text : String?
10+ ): String {
11+ val id = idValue?.takeIf { it.isNotBlank() }
12+ ?.let { " id=\" $it \" " } ? : " "
13+ val elClass = elClassValue?.takeIf { it.isNotBlank() }
14+ ?.let { " class=\" ${it.split(" " ).first()} ...\" " } ? : " "
15+ val name = nameValue?.takeIf { it.isNotBlank() }
16+ ?.let { " name=\" $it \" " } ? : " "
17+
18+ return " <$tag $id $elClass $name >" +
19+ (text?.take(16 )?.let { " $it ..." } ? : " " ) +
20+ " </$tag >"
21+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package pro.qyoga.tests.assertions
33import com.codeborne.selenide.SelenideElement
44import io.kotest.matchers.Matcher
55import io.kotest.matchers.MatcherResult
6+ import pro.qyoga.tests.platform.html.elementDescr
67import io.kotest.matchers.should as koshould
78import io.kotest.matchers.shouldNot as koshouldNot
89
@@ -32,14 +33,11 @@ fun SelenideElement.shouldNotBeEmptyInput() {
3233}
3334
3435fun SelenideElement.descr (): String {
35- val id = this .getAttribute(" id" )
36- ?.takeIf { it.isNotBlank() }
37- ?.let { " id=\" $it \" " } ? : " "
38- val elClass = this .getAttribute(" class" )
39- ?.takeIf { it.isNotBlank() }
40- ?.let { " class=\" ${it.split(" " ).first()} ...\" " } ? : " "
41- val name = this .getAttribute(" name" )
42- ?.takeIf { it.isNotBlank() }
43- ?.let { " name=\" $it \" " } ? : " "
44- return " <${this .tagName} $id $elClass $name />"
36+ return elementDescr(
37+ this .tagName,
38+ getAttribute(" id" ),
39+ getAttribute(" class" ),
40+ getAttribute(" name" ),
41+ this .text
42+ )
4543}
Original file line number Diff line number Diff line change @@ -49,4 +49,4 @@ class CreateClientScenarioTest : QYogaE2EBaseTest() {
4949 CreateClientForm .shouldBeEmpty()
5050 }
5151
52- }
52+ }
You can’t perform that action at this time.
0 commit comments