Skip to content

Commit 49c9cab

Browse files
authored
Minor crm fixes (#5863)
* Bump `accept_traffic_until` on `trial_expiry_date` change * Fix domain escaping in CRM * Format
1 parent 839aebd commit 49c9cab

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

extra/lib/plausible_web/live/customer_support/site/components/overview.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ defmodule PlausibleWeb.CustomerSupport.Site.Components.Overview do
1818
<div class="flex justify-center items-center gap-x-8 pb-8 mb-8 border-b border-gray-200 dark:border-gray-700 w-full text-sm text-center">
1919
<span>Quick links:</span>
2020
21-
<.styled_link new_tab={true} href={"/#{@site.domain}"}>
21+
<.styled_link
22+
new_tab={true}
23+
href={Routes.stats_path(PlausibleWeb.Endpoint, :stats, @site.domain, [])}
24+
>
2225
Dashboard
2326
</.styled_link>
2427
25-
<.styled_link new_tab={true} href={"/#{@site.domain}/settings/general"}>
28+
<.styled_link
29+
new_tab={true}
30+
href={Routes.site_path(PlausibleWeb.Endpoint, :settings_general, @site.domain, [])}
31+
>
2632
Settings
2733
</.styled_link>
2834

lib/plausible/teams/team.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ defmodule Plausible.Teams.Team do
9393
:allow_next_upgrade_override,
9494
:accept_traffic_until
9595
])
96+
|> maybe_bump_accept_traffic_until()
9697
end
9798

9899
def changeset(team \\ %__MODULE__{}, attrs \\ %{}, today \\ Date.utc_today()) do

test/plausible_web/live/customer_support/sites_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ defmodule PlausibleWeb.Live.CustomerSupport.SitesTest do
2828

2929
assert element_exists?(
3030
html,
31-
~s|a[href$="#{site.domain}/settings/general"]|
31+
~s|a[href$="#{URI.encode_www_form(site.domain)}/settings/general"]|
3232
)
3333

34-
assert element_exists?(html, ~s|a[href="/#{site.domain}"]|)
34+
assert element_exists?(html, ~s|a[href="/#{URI.encode_www_form(site.domain)}/"]|)
3535
end
3636

3737
test "404", %{conn: conn} do

test/plausible_web/live/customer_support/teams_test.exs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do
141141
assert team.locked
142142
end
143143

144+
test "trial expiry date update, updates accept traffic until too", %{conn: conn, user: user} do
145+
team = team_of(user)
146+
{:ok, lv, _html} = live(conn, open_team(team.id))
147+
148+
lv
149+
|> element("form")
150+
|> render_submit(%{
151+
"team" => %{"trial_expiry_date" => "2029-01-01"}
152+
})
153+
154+
html = render(lv)
155+
156+
assert text_of_attr(html, "#team_trial_expiry_date", "value") == "2029-01-01"
157+
assert text_of_attr(html, "#team_accept_traffic_until", "value") == "2029-01-15"
158+
end
159+
144160
test "404", %{conn: conn} do
145161
assert_raise Ecto.NoResultsError, fn ->
146162
{:ok, _lv, _html} = live(conn, open_team(9999))
@@ -157,7 +173,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do
157173

158174
test "lists sites belonging to a team", %{conn: conn, user: user} do
159175
team = team_of(user)
160-
new_site(owner: user, domain: "primary.example.com")
176+
new_site(owner: user, domain: "primary.example.com/test")
161177
new_site(owner: user, domain: "consolidated.example.com", consolidated: true)
162178
new_site(owner: user, domain: "secondary.example.com")
163179
# other
@@ -167,7 +183,10 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest do
167183
html = render(lv)
168184
text = text(html)
169185

170-
assert text =~ "primary.example.com"
186+
assert element_exists?(html, ~s|a[href="/primary.example.com%2Ftest/"]|)
187+
assert element_exists?(html, ~s|a[href="/primary.example.com%2Ftest/settings/general"]|)
188+
189+
assert text =~ "primary.example.com/test"
171190
assert text =~ "secondary.example.com"
172191
refute text =~ "condolidated.example.com"
173192
refute text =~ "other.example.com"

0 commit comments

Comments
 (0)