This repository has been archived on 2023-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
temple/integration_test/temple_demo/test/temple_demo_web/features/temple_feature_test.exs

44 lines
1.5 KiB
Elixir
Raw Normal View History

2020-06-16 19:28:21 +00:00
defmodule TempleDemoWeb.TempleFeatureTest do
use ExUnit.Case, async: false
use Wallaby.Feature
alias TempleDemoWeb.Router.Helpers, as: Routes
2021-01-02 18:21:48 +00:00
@endpoint TempleDemoWeb.Endpoint
2020-06-16 19:28:21 +00:00
feature "renders the homepage", %{session: session} do
session
|> visit("/")
|> assert_text("Welcome to Phoenix!")
2021-01-02 18:21:48 +00:00
|> assert_text("inner content of outer")
2020-06-16 19:28:21 +00:00
end
2020-11-05 00:57:03 +00:00
feature "case statements work", %{session: session} do
2021-01-02 18:21:48 +00:00
session
|> visit("/?text=staging")
|> assert_text("Welcome to Phoenix!")
|> assert_text("Peace-of-mind from prototype to staging")
|> visit("/?text=foobar")
|> assert_text("Welcome to Phoenix!")
|> assert_text("Peace-of-mind from prototype to production")
2020-11-05 00:57:03 +00:00
end
2020-06-16 19:28:21 +00:00
feature "can create a new post", %{session: session} do
session
2021-01-02 18:21:48 +00:00
|> visit(Routes.post_path(@endpoint, :index))
2020-06-16 19:28:21 +00:00
|> click(Query.link("New Post"))
|> fill_in(Query.text_field("Title"), with: "Temple is awesome!")
|> fill_in(Query.text_field("Body"), with: "In this post I will show you how to use Temple")
|> find(Query.select("post_published_at_year"), fn s ->
s |> click(Query.option("2020"))
end)
|> find(Query.select("post_published_at_month"), fn s ->
s |> click(Query.option("May"))
end)
|> find(Query.select("post_published_at_day"), fn s ->
s |> click(Query.option("21"))
end)
|> fill_in(Query.text_field("Author"), with: "Mitchelob Ultra")
|> click(Query.button("Save"))
|> assert_text("Post created successfully.")
end
end