Fix broken Alerts tests
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/e59b5e46 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/e59b5e46 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/e59b5e46 Branch: refs/heads/5.4-js-rewrite Commit: e59b5e465cd383259b1590e02a7a857fa2413fd2 Parents: 3dd5c8e Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Nov 26 09:24:04 2012 -0800 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Nov 26 09:24:04 2012 -0800 ---------------------------------------------------------------------- .../tapestry5/integration/app1/AlertsTests.groovy | 62 +++++++-------- .../integration/app1/components/Border.tml | 3 +- .../integration/app1/pages/AlertsDemo.tml | 6 +- 3 files changed, 31 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e59b5e46/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy index 4936cee..b174b03 100644 --- a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy +++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy @@ -15,7 +15,7 @@ package org.apache.tapestry5.integration.app1; -import org.apache.tapestry5.test.SeleniumTestCase +import org.apache.tapestry5.integration.TapestryCoreTestCase import org.testng.annotations.Test /** @@ -23,12 +23,13 @@ import org.testng.annotations.Test * * @since 5.3 */ -class AlertsTests extends SeleniumTestCase -{ +class AlertsTests extends TapestryCoreTestCase { + + def CONTAINER = "[data-container-type=alerts]" + @Test - void traditional_update_and_remove() - { - openLinks "Alerts Demo", "reset" + void traditional_update_and_remove() { + openLinks "Alerts Demo", "Reset Alerts Storage" select "id=severity", "Warn" select "id=duration", "Until Dismissed" @@ -36,25 +37,30 @@ class AlertsTests extends SeleniumTestCase clickAndWait "//input[@value='Traditional Update']" + waitForCSSSelectedElementToAppear "$CONTAINER .alert" + assertTextPresent "trad warn until" - clickAndWait "link=Back to index" + clickAndWait BACK_TO_INDEX + + waitForCSSSelectedElementToAppear "$CONTAINER .alert" assertTextPresent "trad warn until" // Click the first and only dismiss icon - click "css=.t-dismiss" + click "css=$CONTAINER button.close" + + sleep 50 // Check that the alert container is now empty - assertText "css=.t-alert-container", "" + assertText "css=$CONTAINER", "" } @Test - void ajax_update_and_remove() - { - openLinks "Alerts Demo", "reset" + void ajax_update_and_remove() { + openLinks "Alerts Demo", "Reset Alerts Storage" select "css=#ajax select[name=\"severity\"]", "Error" select "css=#ajax select[name=\"duration\"]", "Until Dismissed" @@ -62,23 +68,24 @@ class AlertsTests extends SeleniumTestCase click "//input[@value='Ajax Update']" - sleep 200 + sleep 50 // Give page time to fully initialize + + waitForCSSSelectedElementToAppear "$CONTAINER .alert" assertTextPresent "ajax error until" - click "link=Dismiss all" + click "css=$CONTAINER .btn.btn-mini" // Check that the alert container is now empty - assertText "css=.t-alert-container", "" + assertText "css=$CONTAINER", "" } /** Disabled by HLS 7-oct-2011; there's a timing issue that makes it very fragile. */ @Test(enabled = false) - void ajax_update_with_redirect() - { + void ajax_update_with_redirect() { - openLinks "Alerts Demo", "reset" + openLinks "Alerts Demo", "Reset Alerts Storage" select "css=#ajax select[name=\"severity\"]", "Error" select "css=#ajax select[name=\"duration\"]", "Single" @@ -96,24 +103,11 @@ class AlertsTests extends SeleniumTestCase click "link=Dismiss all" } - /** #1633 - alerts shouldn't hard-code the 'Dismiss all' label... */ @Test - void dismiss_label_is_parameter() - { - openLinks "Alerts Demo", "reset" - select "id=severity", "Warn" - select "id=duration", "Until Dismissed" - type "id=message", "I'm sorry, Hal, I can't do that." - clickAndWait "//input[@value='Traditional Update']" - assertTextPresent "I'm sorry, Hal, I can't do that." - assertTrue isElementPresent("link=Zenbu Kesu") - } - - @Test - void check_informal_parameters() - { + void check_informal_parameters() { openLinks "Alerts Demo" - assertTrue isElementPresent("//div[@class='alert-class']") + + assertTrue isElementPresent("css=${CONTAINER}.alert-class") } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e59b5e46/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/Border.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/Border.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/Border.tml index c33413e..473eecc 100644 --- a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/Border.tml +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/Border.tml @@ -39,7 +39,8 @@ <div class="container"> <div class="main"> - <t:alerts/> + <t:remove>alert-class is for the AlertsTest.check_informal_parameters test</t:remove> + <t:alerts class="alert-class"/> <t:body/> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e59b5e46/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml index 0f2445f..3ba44b0 100644 --- a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml @@ -20,10 +20,6 @@ </t:zone> </div> -<p> - [ - <t:actionlink t:id="reset">reset</t:actionlink> - ] -</p> +<t:actionlink class="btn btn-warning" t:id="reset">Reset Alerts Storage</t:actionlink> </html>
