-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
navigation_test.go
72 lines (60 loc) · 2.2 KB
/
navigation_test.go
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
package biloba_test
import (
"fmt"
"net/http"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Navigation", func() {
Describe("navigating to a new page", func() {
It("succeeds with http.StatusOK if all is well", func() {
b.Navigate(fixtureServer + "/nav-a.html")
Eventually("body a").Should(b.Exist())
})
It("fails with the relevant status code otherwise", func() {
b.Navigate(fixtureServer + "/non-existing")
ExpectFailures(fmt.Sprintf("failed to navigate to %s: expected status code 200, got 404", fixtureServer+"/non-existing"))
})
It("succeeds when given a status", func() {
b.NavigateWithStatus(fixtureServer+"/non-existing", http.StatusNotFound)
})
It("errors when the url is malformed", func() {
b.Navigate("floop")
ExpectFailures(ContainSubstring("Cannot navigate to invalid URL"))
})
It("succeeds when navigating to about:blank", func() {
b.Navigate("about:blank")
})
})
Describe("title", func() {
It("returns the page's title", func() {
b.Navigate(fixtureServer + "/nav-a.html")
Eventually(b.Title).Should(Equal("Nav-A Testpage"))
})
})
Describe("location", func() {
It("returns the page's url", func() {
b.Navigate(fixtureServer + "/nav-a.html")
Eventually(b.Location).Should(Equal(fixtureServer + "/nav-a.html"))
})
})
Describe("navigation flow", func() {
It("allows the user to navigate across urls", func() {
b.Navigate(fixtureServer + "/nav-a.html")
Eventually("#to-b").Should(b.Click())
Eventually(b.Location).Should(Equal(fixtureServer + "/nav-b.html"))
Eventually(b.Title).Should(Equal("Nav-B Testpage"))
Eventually("#to-a").Should(b.Exist())
b.Click("#to-a")
Eventually(b.Location).Should(Equal(fixtureServer + "/nav-a.html"))
Eventually(b.Title).Should(Equal("Nav-A Testpage"))
})
It("allows the user to navigate to new tabs", func() {
b.Navigate(fixtureServer + "/nav-a.html")
Eventually("#to-b-new").Should(b.Click())
Eventually(b).Should(b.HaveSpawnedTab(b.TabWithTitle("Nav-B Testpage")))
Ω(b.Location()).Should(Equal(fixtureServer + "/nav-a.html"))
Ω(b.AllSpawnedTabs().Find(b.TabWithTitle("Nav-B Testpage")).Location()).Should(HaveSuffix("nav-b.html"))
})
})
})