var _ = Describe("ListJobs", func() {
	var page *agouti.Page

	BeforeEach(func() {
		var err error
		page, err = agoutiDriver.NewPage()
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		Expect(page.Destroy()).To(Succeed())
	})

	It("shows a list of jobs", func() {
		By("root url redirects to jobs page", func() {
			Expect(page.Navigate("http://localhost:3001")).To(Succeed())
			Eventually(page.Find("a#newJob")).Should(BeFound())
		})

		By("creating a new job", func() {
			pageobjects.NewListJobsPage(page).GoToCreateNewJob().CreateJob("Jerb", "echo hello", "busybox", "")
		})

		By("list includes the job on jobs page", func() {
			Expect(page.Navigate("http://localhost:3001/jobs")).To(Succeed())
			Eventually(page.Find(".job:first-of-type")).Should(MatchText(".*Jerb.*"))
		})
	})
})
		var err error
		page, err = agoutiDriver.NewPage()
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		Expect(page.Destroy()).To(Succeed())
	})

	PContext("when there is no docker image specified", func() {
		It("runs the job on the host OS", func() {})
	})

	It("creates and runs the new job", func() {
		By("creating the new job using the specified docker image", func() {
			pageobjects.NewListJobsPage(page).Visit().
				GoToCreateNewJob().
				CreateJob("Bob", "cat /etc/lsb-release", "ubuntu:14.04.3", "")
		})

		By("streaming the output from the job", func() {
			expected := `.*DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS".*`
			Eventually(page.Find("#jobOutput")).Should(MatchText(expected))
		})

		By("indicating that the job ran successfully", func() {
			Eventually(page.Find("#jobResult")).Should(HaveText("Success"))
		})