From 7f6f6045c0c1cc9bd8323e3e7de905e0e46fe82d Mon Sep 17 00:00:00 2001 From: Artyom Shalkhakov Date: Mon, 28 May 2018 21:34:07 +0600 Subject: Adding: cradio (support for client-side radio box). --- tests/cradio.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/cradio.py (limited to 'tests/cradio.py') diff --git a/tests/cradio.py b/tests/cradio.py new file mode 100644 index 00000000..b70b2ef1 --- /dev/null +++ b/tests/cradio.py @@ -0,0 +1,27 @@ +import unittest +import base + +# issue: initialization doesn't quite work + +class Suite(base.Base): +# test case: +# initially the source is EMPTY +# then we pick SECOND variant and check the source +# then we pick the FIRST variant and check the source + def test_1(self): + """Test case 1""" + self.start("Cradio/main") + txt = self.body_text() + self.assertEqual("Wilbur Walbur Hello, I'm B. I'll be your waiter for this evening.", txt) + el1 = self.xpath('label[1]/input') + el2 = self.xpath('label[2]/input') + self.assertEqual(False, el1.is_selected()) + self.assertEqual(True, el2.is_selected()) + el1.click() + alert = self.driver.switch_to.alert + self.assertEqual("Now it's A", alert.text) + alert.accept() + self.assertEqual(True, el1.is_selected()) + self.assertEqual(False, el2.is_selected()) + txt = self.body_text() + self.assertEqual("Wilbur Walbur Hello, I'm A. I'll be your waiter for this evening.", txt) -- cgit v1.2.3 From 6fc9746d0cc8f18cc570647b8e571a34c5aeb0fe Mon Sep 17 00:00:00 2001 From: Artyom Shalkhakov Date: Mon, 28 May 2018 21:39:46 +0600 Subject: Formatting --- src/css.sml | 2 +- tests/cradio.py | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'tests/cradio.py') diff --git a/src/css.sml b/src/css.sml index 5bf4ea7b..17ec01d5 100644 --- a/src/css.sml +++ b/src/css.sml @@ -104,7 +104,7 @@ val tags = [("span", inline), ("cpassword", replaced), ("button", replaced), ("ccheckbox", replaced), - ("cradio", replaced), + ("cradio", replaced), ("cselect", replaced), ("ctextarea", replaced), ("tabl", table), diff --git a/tests/cradio.py b/tests/cradio.py index b70b2ef1..acc8dc11 100644 --- a/tests/cradio.py +++ b/tests/cradio.py @@ -1,13 +1,7 @@ import unittest import base -# issue: initialization doesn't quite work - class Suite(base.Base): -# test case: -# initially the source is EMPTY -# then we pick SECOND variant and check the source -# then we pick the FIRST variant and check the source def test_1(self): """Test case 1""" self.start("Cradio/main") -- cgit v1.2.3 From 4bf7bfd52e5e822b05665b1872a2cfd31417486d Mon Sep 17 00:00:00 2001 From: Artyom Shalkhakov Date: Wed, 30 May 2018 20:26:06 +0600 Subject: Multi-group test --- tests/cradio.py | 20 ++++++++++++++++---- tests/cradio.ur | 17 +++++++++++++++-- tests/driver.sh | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-) (limited to 'tests/cradio.py') diff --git a/tests/cradio.py b/tests/cradio.py index acc8dc11..cc075593 100644 --- a/tests/cradio.py +++ b/tests/cradio.py @@ -5,8 +5,10 @@ class Suite(base.Base): def test_1(self): """Test case 1""" self.start("Cradio/main") - txt = self.body_text() - self.assertEqual("Wilbur Walbur Hello, I'm B. I'll be your waiter for this evening.", txt) + txt = self.xpath('div[1]').text + self.assertEqual("Hello, I'm B. I'll be your waiter for this evening.", txt) + txt2 = self.xpath('div[2]').text + self.assertEqual('Value:', txt2) el1 = self.xpath('label[1]/input') el2 = self.xpath('label[2]/input') self.assertEqual(False, el1.is_selected()) @@ -17,5 +19,15 @@ class Suite(base.Base): alert.accept() self.assertEqual(True, el1.is_selected()) self.assertEqual(False, el2.is_selected()) - txt = self.body_text() - self.assertEqual("Wilbur Walbur Hello, I'm A. I'll be your waiter for this evening.", txt) + txt = self.xpath('div[1]').text + self.assertEqual("Hello, I'm A. I'll be your waiter for this evening.", txt) + txt2 = self.xpath('div[2]').text + self.assertEqual('Value:', txt2) + # now check that the second radio group works as well + el3 = self.xpath('label[4]/input') + el3.click() + alert = self.driver.switch_to.alert + alert.accept() + txt2 = self.xpath('div[2]').text + self.assertEqual('Value: Y', txt2) + self.assertEqual("Hello, I'm A. I'll be your waiter for this evening.", txt) diff --git a/tests/cradio.ur b/tests/cradio.ur index 5b6e9d22..48c04f1e 100644 --- a/tests/cradio.ur +++ b/tests/cradio.ur @@ -1,13 +1,26 @@ fun main () = s <- source (Some "B"); +r <- source None; let val onc = v <- get s; alert ("Now it's " ^ show v) + val onc_r = v <- get r; alert ("Changed to " ^ show v) in return +

First group

+ - Hello, I'm {[s]}
}/>. - I'll be your waiter for this evening. +
+ Hello, I'm {[s]}}/>. I'll be your waiter for this evening. +
+ +

Second group

+ + + + + +
Value: {[r]}}/>
end diff --git a/tests/driver.sh b/tests/driver.sh index cc62644b..879c093d 100755 --- a/tests/driver.sh +++ b/tests/driver.sh @@ -21,5 +21,5 @@ fi $TESTSRV -q -a 127.0.0.1 & echo $! >> $TESTPID sleep 1 -python -m unittest $1.py +python3 -m unittest $1.py kill `cat $TESTPID` -- cgit v1.2.3