-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.roc
83 lines (77 loc) · 3.15 KB
/
tests.roc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
app [test_cases, config] { r2e: platform "https://github.com/adomurad/r2e-platform/releases/download/0.9.0/18rG0wcljf8EmqFsLkFc8bioPpNZPyH_NJ83oCdmPrQ.tar.br" }
import r2e.Test exposing [test]
import r2e.Config
import r2e.Debug
import r2e.Browser
import r2e.Element
import r2e.Assert
config = Config.default_config
test_cases = [
test1,
test2,
test3,
]
test1 = test(
"fill out a fake form",
|browser|
# open the test page
browser |> Browser.navigate_to!("https://adomurad.github.io/e2e-test-page/")?
# find the framework name input by data-testid
framework_input = browser |> Browser.find_element!(TestId("framework-name"))?
# send text to input
framework_input |> Element.input_text!("R2E Platform")?
# find the test count input by id
test_count_input = browser |> Browser.find_element!(Css("#testCount"))?
# send text to input
test_count_input |> Element.input_text!("55")?
# find the checkbox
is_production_checkbox = browser |> Browser.find_element!(TestId("isProduction"))?
# click the checkbox
is_production_checkbox |> Element.click!()?
# find the submit button
submit_button = browser |> Browser.find_element!(Css("#submit-button"))?
# click the submit button
submit_button |> Element.click!()?
# the page title should have changed
browser |> Assert.title_should_be!("E2E Testing - Summary Page")?
# find the summary page header
summary_header = browser |> Browser.find_element!(TestId("summary-header"))?
# the header should be "Thank You!"
summary_header |> Assert.element_should_have_text!("Thank You!"),
)
test2 = test(
"test form validation",
|browser|
# open the test page
browser |> Browser.navigate_to!("https://adomurad.github.io/e2e-test-page/")?
# find the test count input by id
test_count_input = browser |> Browser.find_element!(Css("#testCount"))?
# send text to input
test_count_input |> Element.input_text!("2")?
# find the submit button
submit_button = browser |> Browser.find_element!(Css("#submit-button"))?
# click the submit button
submit_button |> Element.click!()?
# find the error message
test_count_error = browser |> Browser.find_element!(TestId("testCountError"))?
# check the error message text
test_count_error |> Assert.element_should_have_text!("At least 5 tests are required"),
)
test3 = test(
"use roc repl",
|browser|
# go to roc-lang.org
browser |> Browser.navigate_to!("http://roc-lang.org")?
# find repl input
repl_input = browser |> Browser.find_element!(Css("#source-input"))?
# wait for the repl to initialize
Debug.wait!(200)
# send keys to repl
repl_input |> Element.input_text!("0.1+0.2{enter}")?
# find repl output element
output_el = browser |> Browser.find_element!(Css(".output"))?
# get output text
output_text = output_el |> Element.get_text!()?
# assert text
output_text |> Assert.should_be("0.3 : Frac *"),
)