-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathdeveloper_edits_post_test.exs
46 lines (40 loc) · 1.42 KB
/
developer_edits_post_test.exs
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
defmodule DeveloperEditsPostTest do
use Tilex.IntegrationCase, async: true
alias Tilex.Integration.Pages.PostForm
alias Tilex.Integration.Pages.PostShowPage
test "fills out form and updates post from post show", %{session: session} do
Factory.insert!(:channel, name: "phoenix")
developer = Factory.insert!(:developer)
post =
Factory.insert!(
:post,
title: "Awesome Post!",
developer: developer,
body: "This is how to be *awesome*!"
)
session
|> sign_in(developer)
|> PostShowPage.navigate(post)
|> PostShowPage.click_edit()
session
|> PostForm.ensure_page_loaded()
|> PostForm.expect_preview_content("em", "awesome")
|> PostForm.expect_word_count(6)
|> PostForm.expect_words_left("194 words available")
|> PostForm.expect_title_characters_left("37 characters available")
|> PostForm.expect_title_preview("Awesome Post!")
|> PostForm.fill_in_title("Even Awesomer Post!")
|> PostForm.fill_in_body("This is how to be super awesome!")
|> PostForm.select_channel("phoenix")
|> PostForm.click_submit()
session
|> PostShowPage.ensure_page_loaded("Even Awesomer Post!")
|> PostShowPage.ensure_info_flash("Post Updated")
|> PostShowPage.expect_post_attributes(%{
title: "Even Awesomer Post!",
body: "This is how to be super awesome!",
channel: "#phoenix",
likes_count: 1
})
end
end