-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyst_test.exs
More file actions
91 lines (65 loc) · 2.54 KB
/
Copy pathyst_test.exs
File metadata and controls
91 lines (65 loc) · 2.54 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
defmodule YstTest do
use ExUnit.Case
use Hound.Helpers
require Logger
alias Hound.Browser.PhantomJS
doctest Yst
doctest Scenarios
doctest ScenesList
hound_session()
test "user_agent capabilities check and driver details" do
in_browser_session "#{UUID.uuid4}", fn ->
for user_agent <- [:iphone, :chrome, :firefox, :android] do
ua = Hound.Browser.user_agent user_agent
assert (PhantomJS.user_agent_capabilities ua) == %{"phantomjs.page.settings.userAgent" => ua}
end
{:ok, driver_info} = Hound.driver_info
assert driver_info[:driver] == "phantomjs"
assert driver_info[:browser] == "phantomjs"
end
end
test "each checked page has to pass content validations" do
scenes = HeadlessScene.script()
res = scenes |> Scenarios.play()
assert res == {:ok, scenes}
assert (length scenes) == 2
end
test "test if results queue is filled" do
case Results.start_link() do
{:ok, pid} ->
Logger.info "Results queue started (#{inspect pid})"
{:error, {:already_started, pid}} ->
Logger.warn "Results queue already started for pid: #{inspect pid}"
{:error, er} ->
Logger.error "Error caught: #{inspect er}"
end
scenes = HeadlessScene.script ++ BasicLoginLogoutScene.script
res = scenes |> Scenarios.play()
assert res == {:ok, scenes}
assert (length scenes) >= 5
assert (length Results.show) >= 5
end
test "Director results after run may not be empty!" do
_ = Results.start_link()
scenes = BasicLoginLogoutScene.script()
res = scenes |> Scenarios.play()
assert res == {:ok, scenes}, "Response with :ok and scenes"
for {result, scene, message} <- Results.show() do
Logger.info "REZULT: #{inspect result}"
assert result == :success, "Each test result has to be successful!"
case message do
"" ->
assert false, "Results message can't be empty!"
any ->
assert (String.length any) > 0, "Results message can't have zero length!"
end
at_least_same_name = Enum.find(scenes, fn scn -> scn[:name] == scene[:name] end)
assert at_least_same_name, "Each processed scene should be present in Results"
# NOTE: Initial actions_ms => 0. We fill that value to time spent on "clicking actions"
# non_zero_action_time = Enum.find(scenes, fn scn ->
# scene[:actions_ms] > 50 and scn[:actions_ms] == 0
# end)
# assert non_zero_action_time, "Each processed scene should always have :actions_ms field set > 0"
end
end
end