mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
input tests
commit_hash:d42795bc88ec14b77fcf0b54389926f04c9f5ce7
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"description": "Currency input mask",
|
||||
"platforms": [
|
||||
"android",
|
||||
"web"
|
||||
],
|
||||
"div_data": {
|
||||
"card": {
|
||||
"log_id": "ui_test_card",
|
||||
"variables": [
|
||||
{
|
||||
"name": "input",
|
||||
"type": "string",
|
||||
"value": "1234567"
|
||||
},
|
||||
{
|
||||
"name": "raw_input",
|
||||
"type": "string",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"name": "locale",
|
||||
"type": "string",
|
||||
"value": "en-US"
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#ffffff"
|
||||
}
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Locale: @{locale}; raw text: @{raw_input}"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"text_variable": "input",
|
||||
"paddings": {
|
||||
"start": 10,
|
||||
"end": 10,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"margins": {
|
||||
"start": 5,
|
||||
"end": 5,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type":"solid",
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
],
|
||||
"mask": {
|
||||
"type": "currency",
|
||||
"raw_text_variable": "raw_input",
|
||||
"locale": "@{locale}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"expected_screenshot": "step0.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=locale&value=ru-RU",
|
||||
"log_id": "change locale"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step1.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=raw_input&value=1234567890",
|
||||
"log_id": "set bigger number"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step2.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=locale&value=en-US",
|
||||
"log_id": "change locale back"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step3.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"description": "Expression input validator",
|
||||
"platforms": [
|
||||
"android",
|
||||
"web"
|
||||
],
|
||||
"div_data": {
|
||||
"card": {
|
||||
"log_id": "ui_test_card",
|
||||
"variables": [
|
||||
{
|
||||
"name": "input",
|
||||
"type": "string",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"name": "allow_empty",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "check_fail",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "minimum_value",
|
||||
"type": "string",
|
||||
"value": "100"
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#ffffff"
|
||||
}
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Condition: value >= @{minimum_value}"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Allow empty: @{allow_empty}"
|
||||
},
|
||||
{
|
||||
"id": "input",
|
||||
"type": "input",
|
||||
"text_variable": "input",
|
||||
"paddings": {
|
||||
"start": 10,
|
||||
"end": 10,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"margins": {
|
||||
"start": 5,
|
||||
"end": 5,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
],
|
||||
"validators": [
|
||||
{
|
||||
"type": "expression",
|
||||
"condition": "@{(toNumber(input) !: 0) >= toNumber(minimum_value)}",
|
||||
"allow_empty": "@{allow_empty}",
|
||||
"label_id": "error_text",
|
||||
"variable": "check_fail"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "error_text",
|
||||
"type": "text",
|
||||
"text": "Validation failed",
|
||||
"text_color": "#ff0000",
|
||||
"font_size": 14,
|
||||
"visibility": "@{check_fail ? 'invisible' : 'visible'}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"expected_screenshot": "step0.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"log_id": "bigger",
|
||||
"url": "div-action://set_variable?name=input&value=200"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step1.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"log_id": "change minimum",
|
||||
"url": "div-action://set_variable?name=minimum_value&value=300"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step2.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"log_id": "empty",
|
||||
"url": "div-action://set_variable?name=input&value="
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step3.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"log_id": "allow empty",
|
||||
"url": "div-action://set_variable?name=allow_empty&value=1"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step4.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
{
|
||||
"description": "Fixed length input mask",
|
||||
"platforms": [
|
||||
"android",
|
||||
"web"
|
||||
],
|
||||
"div_data": {
|
||||
"card": {
|
||||
"log_id": "ui_test_card",
|
||||
"variables": [
|
||||
{
|
||||
"name": "input",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "raw_input",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "mask",
|
||||
"type": "string",
|
||||
"value": "$#### $####"
|
||||
},
|
||||
{
|
||||
"name": "key_1",
|
||||
"type": "string",
|
||||
"value": "#"
|
||||
},
|
||||
{
|
||||
"name": "filter_1",
|
||||
"type": "string",
|
||||
"value": "[a-z]"
|
||||
},
|
||||
{
|
||||
"name": "placeholder",
|
||||
"type": "string",
|
||||
"value": "_"
|
||||
},
|
||||
{
|
||||
"name": "key_2",
|
||||
"type": "string",
|
||||
"value": "$"
|
||||
},
|
||||
{
|
||||
"name": "filter_2",
|
||||
"type": "string",
|
||||
"value": "[A-Z]"
|
||||
},
|
||||
{
|
||||
"name": "always_visible",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#ffffff"
|
||||
}
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Value in input: '@{input}'"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"text_variable": "input",
|
||||
"paddings": {
|
||||
"start": 10,
|
||||
"end": 10,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"margins": {
|
||||
"start": 5,
|
||||
"end": 5,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
],
|
||||
"mask": {
|
||||
"type": "fixed_length",
|
||||
"pattern": "@{mask}",
|
||||
"raw_text_variable": "raw_input",
|
||||
"pattern_elements": [
|
||||
{
|
||||
"key": "@{key_1}",
|
||||
"regex": "@{filter_1}",
|
||||
"placeholder": "@{placeholder}"
|
||||
},
|
||||
{
|
||||
"key": "@{key_2}",
|
||||
"regex": "@{filter_2}",
|
||||
"placeholder": "@{placeholder}"
|
||||
}
|
||||
],
|
||||
"always_visible": "@{always_visible}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "mask: @{mask}; @{key_1}=@{filter_1}, @{key_2}=@{filter_2}"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Show placeholders: @{always_visible}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"expected_screenshot": "step0.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=raw_input&value=Test",
|
||||
"log_id": "changing_text_to_capitalized"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step1.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"log_id": "show_placeholders",
|
||||
"url": "div-action://set_variable?name=always_visible&value=true"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step2.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"log_id": "hide_placeholders",
|
||||
"url": "div-action://set_variable?name=always_visible&value=false"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step3.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=raw_input&value=ALotSymbolsToOverflow",
|
||||
"log_id": "changing_text_to_overflow"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step4.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"description": "Phone input mask",
|
||||
"platforms": [
|
||||
"android"
|
||||
],
|
||||
"div_data": {
|
||||
"card": {
|
||||
"log_id": "ui_test_card",
|
||||
"variables": [
|
||||
{
|
||||
"name": "input",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "raw_input",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#ffffff"
|
||||
}
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Raw value: '@{raw_input}'"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"text_variable": "input",
|
||||
"keyboard_type": "phone",
|
||||
"paddings": {
|
||||
"start": 10,
|
||||
"end": 10,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"margins": {
|
||||
"start": 5,
|
||||
"end": 5,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
],
|
||||
"mask": {
|
||||
"type": "phone",
|
||||
"raw_text_variable": "raw_input"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"expected_screenshot": "step0.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=raw_input&value=aabb",
|
||||
"log_id": "change_text_to_invalid"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step1.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=raw_input&value=78005553535",
|
||||
"log_id": "change_text_to_valid"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step2.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
{
|
||||
"description": "Regex Input",
|
||||
"platforms": [
|
||||
"android",
|
||||
"web"
|
||||
],
|
||||
"div_data": {
|
||||
"card": {
|
||||
"log_id": "ui_test_card",
|
||||
"variables": [
|
||||
{
|
||||
"name": "input",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "regex",
|
||||
"type": "string",
|
||||
"value": "[a-zA-Z0-9]+"
|
||||
},
|
||||
{
|
||||
"name": "allow_empty",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "length_check",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "content_check",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#ffffff"
|
||||
}
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Conditions: length >= 8; regex = @{regex}"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Allow empty: @{allow_empty}"
|
||||
},
|
||||
{
|
||||
"id": "input",
|
||||
"type": "input",
|
||||
"text_variable": "input",
|
||||
"paddings": {
|
||||
"start": 10,
|
||||
"end": 10,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"margins": {
|
||||
"start": 5,
|
||||
"end": 5,
|
||||
"top": 5,
|
||||
"bottom": 5
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
],
|
||||
"validators": [
|
||||
{
|
||||
"type": "regex",
|
||||
"pattern": ".{8,}",
|
||||
"allow_empty": "@{allow_empty}",
|
||||
"label_id": "length_warning",
|
||||
"variable": "length_check"
|
||||
},
|
||||
{
|
||||
"type": "regex",
|
||||
"pattern": "@{regex}",
|
||||
"allow_empty": "@{allow_empty}",
|
||||
"label_id": "content_warning",
|
||||
"variable": "content_check"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "length_warning",
|
||||
"type": "text",
|
||||
"text": "Length validation failed",
|
||||
"text_color": "#ff0000",
|
||||
"visibility": "@{length_check ? 'invisible' : 'visible'}"
|
||||
},
|
||||
{
|
||||
"id": "content_warning",
|
||||
"type": "text",
|
||||
"text": "Content validation failed",
|
||||
"text_color": "#ff0000",
|
||||
"visibility": "@{content_check ? 'invisible' : 'visible'}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"expected_screenshot": "step0.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=input&value=12345678",
|
||||
"log_id": "change text to digits"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step1.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=regex&value=[a-zA-Z]%2B",
|
||||
"log_id": "change regex"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step2.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=input&value=aAbBcC",
|
||||
"log_id": "change text to 6 letters"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step3.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=input&value=aAbBcCdD",
|
||||
"log_id": "change text to 8 letters"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step4.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=input&value=",
|
||||
"log_id": "change text to blank"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step5.png"
|
||||
},
|
||||
{
|
||||
"div_actions": [
|
||||
{
|
||||
"url": "div-action://set_variable?name=allow_empty&value=1",
|
||||
"log_id": "allow empty"
|
||||
}
|
||||
],
|
||||
"expected_screenshot": "step6.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user