1 | import org.junit.*; |
---|
2 | |
---|
3 | import play.mvc.*; |
---|
4 | import play.test.*; |
---|
5 | import play.libs.F.*; |
---|
6 | |
---|
7 | import static play.test.Helpers.*; |
---|
8 | import static org.fest.assertions.Assertions.*; |
---|
9 | |
---|
10 | import static org.fluentlenium.core.filter.FilterConstructor.*; |
---|
11 | |
---|
12 | public class IntegrationTest { |
---|
13 | |
---|
14 | @Test |
---|
15 | public void test() { |
---|
16 | running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() { |
---|
17 | public void invoke(TestBrowser browser) { |
---|
18 | browser.goTo("http://localhost:3333"); |
---|
19 | |
---|
20 | assertThat(browser.$("header h1").first().getText()).isEqualTo("Play 2.0 sample application â Computer database"); |
---|
21 | assertThat(browser.$("section h1").first().getText()).isEqualTo("574 computers found"); |
---|
22 | |
---|
23 | assertThat(browser.$("#pagination li.current").first().getText()).isEqualTo("Displaying 1 to 10 of 574"); |
---|
24 | |
---|
25 | browser.$("#pagination li.next a").click(); |
---|
26 | |
---|
27 | assertThat(browser.$("#pagination li.current").first().getText()).isEqualTo("Displaying 11 to 20 of 574"); |
---|
28 | browser.$("#searchbox").text("Apple"); |
---|
29 | browser.$("#searchsubmit").click(); |
---|
30 | |
---|
31 | assertThat(browser.$("section h1").first().getText()).isEqualTo("13 computers found"); |
---|
32 | browser.$("a", withText("Apple II")).click(); |
---|
33 | |
---|
34 | assertThat(browser.$("section h1").first().getText()).isEqualTo("Edit computer"); |
---|
35 | |
---|
36 | browser.$("#discontinued").text("xxx"); |
---|
37 | browser.$("input.primary").click(); |
---|
38 | |
---|
39 | assertThat(browser.$("div.error").size()).isEqualTo(1); |
---|
40 | assertThat(browser.$("div.error label").first().getText()).isEqualTo("Discontinued date"); |
---|
41 | |
---|
42 | browser.$("#discontinued").text(""); |
---|
43 | browser.$("input.primary").click(); |
---|
44 | |
---|
45 | assertThat(browser.$("section h1").first().getText()).isEqualTo("574 computers found"); |
---|
46 | assertThat(browser.$(".alert-message").first().getText()).isEqualTo("Done! Computer Apple II has been updated"); |
---|
47 | |
---|
48 | browser.$("#searchbox").text("Apple"); |
---|
49 | browser.$("#searchsubmit").click(); |
---|
50 | |
---|
51 | browser.$("a", withText("Apple II")).click(); |
---|
52 | browser.$("input.danger").click(); |
---|
53 | |
---|
54 | assertThat(browser.$("section h1").first().getText()).isEqualTo("573 computers found"); |
---|
55 | assertThat(browser.$(".alert-message").first().getText()).isEqualTo("Done! Computer has been deleted"); |
---|
56 | |
---|
57 | browser.$("#searchbox").text("Apple"); |
---|
58 | browser.$("#searchsubmit").click(); |
---|
59 | |
---|
60 | assertThat(browser.$("section h1").first().getText()).isEqualTo("12 computers found"); |
---|
61 | |
---|
62 | } |
---|
63 | }); |
---|
64 | } |
---|
65 | |
---|
66 | } |
---|