Leon4gr45 commited on
Commit
2d356dd
·
verified ·
1 Parent(s): 4262149

Delete test/plausible_web/plugins/api/controllers/capabilities_test.exs with huggingface_hub

Browse files
test/plausible_web/plugins/api/controllers/capabilities_test.exs DELETED
@@ -1,177 +0,0 @@
1
- defmodule PlausibleWeb.Plugins.API.Controllers.CapabilitiesTest do
2
- use PlausibleWeb.PluginsAPICase, async: true
3
- alias PlausibleWeb.Plugins.API.Schemas
4
-
5
- describe "examples" do
6
- test "Capabilities" do
7
- assert_schema(
8
- Schemas.Capabilities.schema().example,
9
- "Capabilities",
10
- spec()
11
- )
12
- end
13
- end
14
-
15
- describe "unauthorized" do
16
- test "no token", %{conn: conn} do
17
- resp =
18
- conn
19
- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))
20
- |> json_response(200)
21
-
22
- assert resp ==
23
- %{
24
- "authorized" => false,
25
- "data_domain" => nil,
26
- "features" => %{
27
- "Funnels" => false,
28
- "Goals" => false,
29
- "Props" => false,
30
- "RevenueGoals" => false,
31
- "StatsAPI" => false,
32
- "SitesAPI" => false,
33
- "SiteSegments" => false,
34
- "SiteAnnotations" => false,
35
- "SharedLinks" => false,
36
- "SSO" => false,
37
- "ConsolidatedView" => false
38
- }
39
- }
40
-
41
- assert_schema(resp, "Capabilities", spec())
42
- end
43
-
44
- test "bad token", %{conn: conn} do
45
- resp =
46
- conn
47
- |> put_req_header("content-type", "application/json")
48
- |> authenticate("foo", "bad token")
49
- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))
50
- |> json_response(200)
51
-
52
- assert resp ==
53
- %{
54
- "authorized" => false,
55
- "data_domain" => nil,
56
- "features" => %{
57
- "Funnels" => false,
58
- "Goals" => false,
59
- "Props" => false,
60
- "RevenueGoals" => false,
61
- "StatsAPI" => false,
62
- "SitesAPI" => false,
63
- "SiteSegments" => false,
64
- "SiteAnnotations" => false,
65
- "SharedLinks" => false,
66
- "SSO" => false,
67
- "ConsolidatedView" => false
68
- }
69
- }
70
-
71
- assert_schema(resp, "Capabilities", spec())
72
- end
73
- end
74
-
75
- describe "authorized" do
76
- test "trial", %{conn: conn, site: site, token: token} do
77
- resp =
78
- conn
79
- |> put_req_header("content-type", "application/json")
80
- |> authenticate(site.domain, token)
81
- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))
82
- |> json_response(200)
83
-
84
- assert resp ==
85
- %{
86
- "authorized" => true,
87
- "data_domain" => site.domain,
88
- "features" => %{
89
- "Funnels" => true,
90
- "Goals" => true,
91
- "Props" => true,
92
- "RevenueGoals" => true,
93
- "StatsAPI" => true,
94
- "SitesAPI" => false,
95
- "SiteSegments" => true,
96
- "SiteAnnotations" => true,
97
- "SharedLinks" => true,
98
- "SSO" => false,
99
- "ConsolidatedView" => true
100
- }
101
- }
102
-
103
- assert_schema(resp, "Capabilities", spec())
104
- end
105
-
106
- @tag :ee_only
107
- test "growth", %{conn: conn, site: site, token: token} do
108
- [owner | _] = Plausible.Repo.preload(site, :owners).owners
109
- subscribe_to_growth_plan(owner)
110
-
111
- resp =
112
- conn
113
- |> put_req_header("content-type", "application/json")
114
- |> authenticate(site.domain, token)
115
- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))
116
- |> json_response(200)
117
-
118
- assert resp ==
119
- %{
120
- "authorized" => true,
121
- "data_domain" => site.domain,
122
- "features" => %{
123
- "Funnels" => false,
124
- "Goals" => true,
125
- "Props" => false,
126
- "RevenueGoals" => false,
127
- "StatsAPI" => false,
128
- "SitesAPI" => false,
129
- "SiteSegments" => false,
130
- "SiteAnnotations" => false,
131
- "SharedLinks" => true,
132
- "SSO" => false,
133
- "ConsolidatedView" => false
134
- }
135
- }
136
-
137
- assert_schema(resp, "Capabilities", spec())
138
- end
139
-
140
- @tag :ee_only
141
- test "enterprise with SitesAPI", %{conn: conn, site: site, token: token} do
142
- [owner | _] = Plausible.Repo.preload(site, :owners).owners
143
-
144
- subscribe_to_enterprise_plan(owner,
145
- features: [Plausible.Billing.Feature.StatsAPI, Plausible.Billing.Feature.SitesAPI]
146
- )
147
-
148
- resp =
149
- conn
150
- |> put_req_header("content-type", "application/json")
151
- |> authenticate(site.domain, token)
152
- |> get(Routes.plugins_api_capabilities_url(PlausibleWeb.Endpoint, :index))
153
- |> json_response(200)
154
-
155
- assert resp ==
156
- %{
157
- "authorized" => true,
158
- "data_domain" => site.domain,
159
- "features" => %{
160
- "Funnels" => false,
161
- "Goals" => true,
162
- "Props" => false,
163
- "RevenueGoals" => false,
164
- "StatsAPI" => true,
165
- "SitesAPI" => true,
166
- "SiteSegments" => false,
167
- "SiteAnnotations" => false,
168
- "SharedLinks" => false,
169
- "SSO" => false,
170
- "ConsolidatedView" => false
171
- }
172
- }
173
-
174
- assert_schema(resp, "Capabilities", spec())
175
- end
176
- end
177
- end