Skip to content

Commit 59ef792

Browse files
author
Taras Tyshko
committed
improve URL readability in new UI activity tab tests
1 parent a7e3899 commit 59ef792

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/nerves_hub_web/live/new_ui/devices/activity_tab_test.exs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
1414
device: device
1515
} do
1616
conn
17-
|> visit("/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity")
17+
|> visit(~p"/org/#{org}/#{product}/devices/#{device}/activity")
1818
|> assert_has("span", text: "No audit logs found for the device.")
1919
end
2020

@@ -29,7 +29,7 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
2929
DeviceTemplates.audit_reboot(user, device)
3030

3131
conn
32-
|> visit("/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity")
32+
|> visit(~p"/org/#{org}/#{product}/devices/#{device}/activity")
3333
|> assert_has("div", text: "User #{user.name} rebooted device #{device.identifier}")
3434
end
3535

@@ -48,24 +48,20 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
4848

4949
# Test page 1 with default page_size=25
5050
conn
51-
|> visit("/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity")
51+
|> visit(~p"/org/#{org}/#{product}/devices/#{device}/activity")
5252
|> assert_has("div.flex.items-center.gap-6", count: 25)
5353
|> assert_has("button[phx-value-page=\"2\"]")
5454

5555
# Test page 2 with page_size=25
5656
conn
57-
|> visit(
58-
"/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity?page_number=2&page_size=25"
59-
)
57+
|> visit(~p"/org/#{org}/#{product}/devices/#{device}/activity?page_number=2&page_size=25")
6058
# Remaining 5 entries
6159
|> assert_has("div.flex.items-center.gap-6", count: 5)
6260
|> assert_has("button[phx-value-page=\"1\"]")
6361

6462
# Test custom page_size=10
6563
conn
66-
|> visit(
67-
"/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity?page_number=1&page_size=10"
68-
)
64+
|> visit(~p"/org/#{org}/#{product}/devices/#{device}/activity?page_number=1&page_size=10")
6965
|> assert_has("div.flex.items-center.gap-6", count: 10)
7066
|> assert_has("button[phx-value-page=\"2\"]")
7167
|> assert_has("button[phx-value-page=\"3\"]")
@@ -83,8 +79,7 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
8379
NervesHub.AuditLogs.audit!(user, device, "New UI pagination test entry #{i}")
8480
end)
8581

86-
{:ok, view, _html} =
87-
live(conn, "/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity")
82+
{:ok, view, _html} = live(conn, ~p"/org/#{org}/#{product}/devices/#{device}/activity")
8883

8984
# Test paginate event
9085
view
@@ -94,7 +89,7 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
9489
# Should redirect to page 2 on activity page
9590
assert_patch(
9691
view,
97-
"/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity?page_number=2&page_size=25"
92+
~p"/org/#{org}/#{product}/devices/#{device}/activity?page_number=2&page_size=25"
9893
)
9994
end
10095

@@ -110,8 +105,7 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
110105
NervesHub.AuditLogs.audit!(user, device, "Page size test entry #{i}")
111106
end)
112107

113-
{:ok, view, _html} =
114-
live(conn, "/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity")
108+
{:ok, view, _html} = live(conn, ~p"/org/#{org}/#{product}/devices/#{device}/activity")
115109

116110
# Test changing page size to 50
117111
view
@@ -121,7 +115,7 @@ defmodule NervesHubWeb.Live.NewUI.Devices.ActivityTabTest do
121115
# Should redirect to page 1 with page_size=50
122116
assert_patch(
123117
view,
124-
"/org/#{org.name}/#{product.name}/devices/#{device.identifier}/activity?page_number=1&page_size=50"
118+
~p"/org/#{org}/#{product}/devices/#{device}/activity?page_number=1&page_size=50"
125119
)
126120
end
127121
end

0 commit comments

Comments
 (0)