diff --git a/lib/fotohaecker_web/live/live_helpers.ex b/lib/fotohaecker_web/live/live_helpers.ex
index 3bcc566..4a87ced 100644
--- a/lib/fotohaecker_web/live/live_helpers.ex
+++ b/lib/fotohaecker_web/live/live_helpers.ex
@@ -164,13 +164,14 @@ defmodule FotohaeckerWeb.LiveHelpers do
)
end
- def photo_route(id),
+ def photo_route(id, params \\ %{}),
do:
Helpers.photo_show_path(
FotohaeckerWeb.Endpoint,
:show,
Gettext.get_locale(FotohaeckerWeb.Gettext),
- id
+ id,
+ params
)
def recipe_route(id),
diff --git a/lib/fotohaecker_web/live/photo_live/show.ex b/lib/fotohaecker_web/live/photo_live/show.ex
index 5320c69..f0bc996 100644
--- a/lib/fotohaecker_web/live/photo_live/show.ex
+++ b/lib/fotohaecker_web/live/photo_live/show.ex
@@ -58,7 +58,6 @@ defmodule FotohaeckerWeb.PhotoLive.Show do
/>
- <.back_button />
<.title
photo={@photo}
editing={@editing}
@@ -159,23 +158,6 @@ defmodule FotohaeckerWeb.PhotoLive.Show do
"""
end
- defp back_button(assigns) do
- ~H"""
- <%!-- #TODO: href should be set --%>
- <.link
- data-testid="back-button"
- phx-click="goto"
- phx-keydown="goto"
- phx-key="Enter"
- phx-value-target="index"
- class="w-max px-2 -mx-2 flex gap-1 items-center text-gray-800 dark:text-gray-100 fill-black"
- >
-
- <%= gettext("back") %>
-
- """
- end
-
attr(:photo, Photo, required: true)
defp upload_date_and_user(assigns) do
@@ -384,10 +366,6 @@ defmodule FotohaeckerWeb.PhotoLive.Show do
"""
end
- def handle_event("goto", %{"target" => "index"}, socket) do
- {:noreply, push_navigate(socket, to: home_route())}
- end
-
def handle_event("activate_edit_mode", %{"field" => field} = _params, socket) do
socket =
assign(socket,
diff --git a/priv/gettext/de_DE/LC_MESSAGES/default.po b/priv/gettext/de_DE/LC_MESSAGES/default.po
index 3d6bcfe..a7fd777 100644
--- a/priv/gettext/de_DE/LC_MESSAGES/default.po
+++ b/priv/gettext/de_DE/LC_MESSAGES/default.po
@@ -38,7 +38,7 @@ msgstr "Älteste"
#: lib/fotohaecker_web/live/index_live/home/photo_component.ex:35
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:47
-#: lib/fotohaecker_web/live/photo_live/show.ex:53
+#: lib/fotohaecker_web/live/photo_live/show.ex:57
#, elixir-autogen, elixir-format
msgid "photo %{title} on Fotohäcker"
msgstr "Foto %{title} auf Fotohäcker"
@@ -63,11 +63,6 @@ msgstr "hochladen"
msgid "uploading.."
msgstr "wird hochgeladen.."
-#: lib/fotohaecker_web/live/photo_live/show.ex:170
-#, elixir-autogen, elixir-format
-msgid "back"
-msgstr "zurück"
-
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:87
#, elixir-autogen, elixir-format
msgid "drag the photo here or use the file button below"
@@ -98,7 +93,7 @@ msgstr "Fototitel"
msgid "change language"
msgstr "Sprache ändern"
-#: lib/fotohaecker_web/live/photo_live/show.ex:150
+#: lib/fotohaecker_web/live/photo_live/show.ex:153
#, elixir-autogen, elixir-format, fuzzy
msgid "download the photo %{title} from Fotohäcker"
msgstr "Foto %{title} auf Fotohäcker"
@@ -143,7 +138,7 @@ msgstr "Erfolgreich angemeldet."
msgid "You have been logged out!"
msgstr "Sie wurden abgemeldet!"
-#: lib/fotohaecker_web/live/photo_live/show.ex:74
+#: lib/fotohaecker_web/live/photo_live/show.ex:77
#, elixir-autogen, elixir-format
msgid "Download"
msgstr "Herunterladen"
@@ -158,8 +153,8 @@ msgstr "Name bzw. E-Mail"
msgid "Your Account"
msgstr "Dein Account"
-#: lib/fotohaecker_web/live/photo_live/show.ex:128
-#: lib/fotohaecker_web/live/photo_live/show.ex:185
+#: lib/fotohaecker_web/live/photo_live/show.ex:131
+#: lib/fotohaecker_web/live/photo_live/show.ex:171
#, elixir-autogen, elixir-format
msgid "uploaded on %{date}"
msgstr "hochgeladen am %{date}"
@@ -199,7 +194,7 @@ msgstr "Tags erfolgreich aktualisiert."
msgid "generate using AI"
msgstr "via KI generieren"
-#: lib/fotohaecker_web/live/photo_live/show.ex:228
+#: lib/fotohaecker_web/live/photo_live/show.ex:214
#, elixir-autogen, elixir-format
msgid "no tags"
msgstr "keine Schlagwörter"
@@ -210,7 +205,7 @@ msgid "photo tags"
msgstr "Schlagwörter des Fotos"
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:52
-#: lib/fotohaecker_web/live/photo_live/show.ex:320
+#: lib/fotohaecker_web/live/photo_live/show.ex:306
#, elixir-autogen, elixir-format
msgid "saving.."
msgstr "Speichern.."
@@ -230,42 +225,42 @@ msgstr "Überspringen und zum Foto gehen"
msgid "submit and go to photo"
msgstr "Absenden und zum Foto gehen"
-#: lib/fotohaecker_web/live/photo_live/show.ex:233
+#: lib/fotohaecker_web/live/photo_live/show.ex:219
#, elixir-autogen, elixir-format
msgid "tags"
msgstr "Schlagwörter"
-#: lib/fotohaecker_web/live/photo_live/show.ex:344
+#: lib/fotohaecker_web/live/photo_live/show.ex:330
#, elixir-autogen, elixir-format
msgid "cancel"
msgstr "Abbrechen"
-#: lib/fotohaecker_web/live/photo_live/show.ex:334
+#: lib/fotohaecker_web/live/photo_live/show.ex:320
#, elixir-autogen, elixir-format
msgid "canceling.."
msgstr "Abbrechen.."
-#: lib/fotohaecker_web/live/photo_live/show.ex:441
+#: lib/fotohaecker_web/live/photo_live/show.ex:423
#, elixir-autogen, elixir-format, fuzzy
msgid "photo updated"
msgstr "Foto aktualisiert"
-#: lib/fotohaecker_web/live/photo_live/show.ex:328
+#: lib/fotohaecker_web/live/photo_live/show.ex:314
#, elixir-autogen, elixir-format
msgid "save"
msgstr "Speichern"
-#: lib/fotohaecker_web/live/photo_live/show.ex:377
+#: lib/fotohaecker_web/live/photo_live/show.ex:363
#, elixir-autogen, elixir-format
msgid "edit field %{field}"
msgstr "Feld %{field} bearbeiten"
-#: lib/fotohaecker_web/live/photo_live/show.ex:302
+#: lib/fotohaecker_web/live/photo_live/show.ex:288
#, elixir-autogen, elixir-format
msgid "enter new %{field}"
msgstr "Feld %{field} bearbeiten"
-#: lib/fotohaecker_web/live/photo_live/show.ex:311
+#: lib/fotohaecker_web/live/photo_live/show.ex:297
#, elixir-autogen, elixir-format
msgid "photo %{field}"
msgstr "Foto %{field}"
@@ -378,13 +373,13 @@ msgstr "Metadaten und EXIF-Daten werden beim Hochladen entfernt, um Deine Privat
msgid "Search…"
msgstr "Suche…"
-#: lib/fotohaecker_web/live/photo_live/show.ex:81
-#: lib/fotohaecker_web/live/photo_live/show.ex:111
+#: lib/fotohaecker_web/live/photo_live/show.ex:84
+#: lib/fotohaecker_web/live/photo_live/show.ex:114
#, elixir-autogen, elixir-format, fuzzy
msgid "Delete"
msgstr "Löschen"
-#: lib/fotohaecker_web/live/photo_live/show.ex:455
+#: lib/fotohaecker_web/live/photo_live/show.ex:437
#, elixir-autogen, elixir-format, fuzzy
msgid "photo deleted"
msgstr "Foto gelöscht"
@@ -409,7 +404,7 @@ msgstr "Stripe-Account erstellen und Spenden einrichten"
msgid "Delete Stripe Account"
msgstr "Account löschen"
-#: lib/fotohaecker_web/live/user_live/show.ex:69
+#: lib/fotohaecker_web/live/user_live/show.ex:70
#, elixir-autogen, elixir-format
msgid "Donate to %{user} to support their work"
msgstr "Spende an %{user}, um ihre Arbeit zu unterstützen"
@@ -454,12 +449,12 @@ msgstr "Du hast noch keinen Stripe-Account erstellt. Bitte erstelle einen, um Sp
msgid "You're ready to receive donations!"
msgstr "Du bist bereit, Spenden zu erhalten!"
-#: lib/fotohaecker_web/live/user_live/show.ex:71
+#: lib/fotohaecker_web/live/user_live/show.ex:73
#, elixir-autogen, elixir-format
msgid "donate"
msgstr "spenden"
-#: lib/fotohaecker_web/live/user_live/show.ex:96
+#: lib/fotohaecker_web/live/user_live/show.ex:98
#, elixir-autogen, elixir-format
msgid "error initializing donation: %{message}"
msgstr "Fehler beim Initialisieren der Spende: %{message}"
@@ -506,17 +501,17 @@ msgstr "Profilbild von %{nickname}"
msgid "title (maximum 32 characters)"
msgstr "Titel (maximal 32 Zeichen)"
-#: lib/fotohaecker_web/live/photo_live/show.ex:104
+#: lib/fotohaecker_web/live/photo_live/show.ex:107
#, elixir-autogen, elixir-format
msgid "Are you sure you want to delete this photo?"
msgstr "Sind Sie sicher, dass Sie dieses Foto löschen möchten?"
-#: lib/fotohaecker_web/live/photo_live/show.ex:118
+#: lib/fotohaecker_web/live/photo_live/show.ex:121
#, elixir-autogen, elixir-format, fuzzy
msgid "Cancel"
msgstr "Abbrechen"
-#: lib/fotohaecker_web/live/photo_live/show.ex:101
+#: lib/fotohaecker_web/live/photo_live/show.ex:104
#, elixir-autogen, elixir-format, fuzzy
msgid "Delete photo"
msgstr "Foto löschen"
@@ -547,7 +542,7 @@ msgstr "Einstellungen"
msgid "Unknown recipe brand, ask a developer to implement component"
msgstr "Unbekannter Hersteller vom Rezept, frage einen Entwickler, diese Komponente zu implementieren"
-#: lib/fotohaecker_web/live/photo_live/show.ex:276
+#: lib/fotohaecker_web/live/photo_live/show.ex:262
#, elixir-autogen, elixir-format
msgid "Brand: %{brand}"
msgstr "Hersteller: %{Brand}"
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index b6fd54b..69386d6 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -62,11 +62,6 @@ msgstr ""
msgid "uploading.."
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:174
-#, elixir-autogen, elixir-format
-msgid "back"
-msgstr ""
-
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:87
#, elixir-autogen, elixir-format
msgid "drag the photo here or use the file button below"
@@ -97,7 +92,7 @@ msgstr ""
msgid "change language"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:154
+#: lib/fotohaecker_web/live/photo_live/show.ex:153
#, elixir-autogen, elixir-format
msgid "download the photo %{title} from Fotohäcker"
msgstr ""
@@ -142,7 +137,7 @@ msgstr ""
msgid "You have been logged out!"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:78
+#: lib/fotohaecker_web/live/photo_live/show.ex:77
#, elixir-autogen, elixir-format
msgid "Download"
msgstr ""
@@ -157,8 +152,8 @@ msgstr ""
msgid "Your Account"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:132
-#: lib/fotohaecker_web/live/photo_live/show.ex:189
+#: lib/fotohaecker_web/live/photo_live/show.ex:131
+#: lib/fotohaecker_web/live/photo_live/show.ex:171
#, elixir-autogen, elixir-format
msgid "uploaded on %{date}"
msgstr ""
@@ -198,7 +193,7 @@ msgstr ""
msgid "generate using AI"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:232
+#: lib/fotohaecker_web/live/photo_live/show.ex:214
#, elixir-autogen, elixir-format
msgid "no tags"
msgstr ""
@@ -209,7 +204,7 @@ msgid "photo tags"
msgstr ""
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:52
-#: lib/fotohaecker_web/live/photo_live/show.ex:324
+#: lib/fotohaecker_web/live/photo_live/show.ex:306
#, elixir-autogen, elixir-format
msgid "saving.."
msgstr ""
@@ -229,42 +224,42 @@ msgstr ""
msgid "submit and go to photo"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:237
+#: lib/fotohaecker_web/live/photo_live/show.ex:219
#, elixir-autogen, elixir-format
msgid "tags"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:348
+#: lib/fotohaecker_web/live/photo_live/show.ex:330
#, elixir-autogen, elixir-format
msgid "cancel"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:338
+#: lib/fotohaecker_web/live/photo_live/show.ex:320
#, elixir-autogen, elixir-format
msgid "canceling.."
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:445
+#: lib/fotohaecker_web/live/photo_live/show.ex:423
#, elixir-autogen, elixir-format
msgid "photo updated"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:332
+#: lib/fotohaecker_web/live/photo_live/show.ex:314
#, elixir-autogen, elixir-format
msgid "save"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:381
+#: lib/fotohaecker_web/live/photo_live/show.ex:363
#, elixir-autogen, elixir-format
msgid "edit field %{field}"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:306
+#: lib/fotohaecker_web/live/photo_live/show.ex:288
#, elixir-autogen, elixir-format
msgid "enter new %{field}"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:315
+#: lib/fotohaecker_web/live/photo_live/show.ex:297
#, elixir-autogen, elixir-format
msgid "photo %{field}"
msgstr ""
@@ -377,13 +372,13 @@ msgstr ""
msgid "Search…"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:85
-#: lib/fotohaecker_web/live/photo_live/show.ex:115
+#: lib/fotohaecker_web/live/photo_live/show.ex:84
+#: lib/fotohaecker_web/live/photo_live/show.ex:114
#, elixir-autogen, elixir-format
msgid "Delete"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:459
+#: lib/fotohaecker_web/live/photo_live/show.ex:437
#, elixir-autogen, elixir-format
msgid "photo deleted"
msgstr ""
@@ -505,17 +500,17 @@ msgstr ""
msgid "title (maximum 32 characters)"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:108
+#: lib/fotohaecker_web/live/photo_live/show.ex:107
#, elixir-autogen, elixir-format
msgid "Are you sure you want to delete this photo?"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:122
+#: lib/fotohaecker_web/live/photo_live/show.ex:121
#, elixir-autogen, elixir-format
msgid "Cancel"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:105
+#: lib/fotohaecker_web/live/photo_live/show.ex:104
#, elixir-autogen, elixir-format
msgid "Delete photo"
msgstr ""
@@ -546,7 +541,7 @@ msgstr ""
msgid "Unknown recipe brand, ask a developer to implement component"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:280
+#: lib/fotohaecker_web/live/photo_live/show.ex:262
#, elixir-autogen, elixir-format
msgid "Brand: %{brand}"
msgstr ""
diff --git a/priv/gettext/en_US/LC_MESSAGES/default.po b/priv/gettext/en_US/LC_MESSAGES/default.po
index 17ff948..2d2c904 100644
--- a/priv/gettext/en_US/LC_MESSAGES/default.po
+++ b/priv/gettext/en_US/LC_MESSAGES/default.po
@@ -63,11 +63,6 @@ msgstr ""
msgid "uploading.."
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:174
-#, elixir-autogen, elixir-format
-msgid "back"
-msgstr ""
-
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:87
#, elixir-autogen, elixir-format
msgid "drag the photo here or use the file button below"
@@ -98,7 +93,7 @@ msgstr ""
msgid "change language"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:154
+#: lib/fotohaecker_web/live/photo_live/show.ex:153
#, elixir-autogen, elixir-format, fuzzy
msgid "download the photo %{title} from Fotohäcker"
msgstr ""
@@ -143,7 +138,7 @@ msgstr ""
msgid "You have been logged out!"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:78
+#: lib/fotohaecker_web/live/photo_live/show.ex:77
#, elixir-autogen, elixir-format
msgid "Download"
msgstr ""
@@ -158,8 +153,8 @@ msgstr ""
msgid "Your Account"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:132
-#: lib/fotohaecker_web/live/photo_live/show.ex:189
+#: lib/fotohaecker_web/live/photo_live/show.ex:131
+#: lib/fotohaecker_web/live/photo_live/show.ex:171
#, elixir-autogen, elixir-format
msgid "uploaded on %{date}"
msgstr ""
@@ -199,7 +194,7 @@ msgstr ""
msgid "generate using AI"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:232
+#: lib/fotohaecker_web/live/photo_live/show.ex:214
#, elixir-autogen, elixir-format
msgid "no tags"
msgstr ""
@@ -210,7 +205,7 @@ msgid "photo tags"
msgstr ""
#: lib/fotohaecker_web/live/index_live/home/upload_form.ex:52
-#: lib/fotohaecker_web/live/photo_live/show.ex:324
+#: lib/fotohaecker_web/live/photo_live/show.ex:306
#, elixir-autogen, elixir-format
msgid "saving.."
msgstr ""
@@ -230,42 +225,42 @@ msgstr ""
msgid "submit and go to photo"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:237
+#: lib/fotohaecker_web/live/photo_live/show.ex:219
#, elixir-autogen, elixir-format
msgid "tags"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:348
+#: lib/fotohaecker_web/live/photo_live/show.ex:330
#, elixir-autogen, elixir-format
msgid "cancel"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:338
+#: lib/fotohaecker_web/live/photo_live/show.ex:320
#, elixir-autogen, elixir-format
msgid "canceling.."
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:445
+#: lib/fotohaecker_web/live/photo_live/show.ex:423
#, elixir-autogen, elixir-format, fuzzy
msgid "photo updated"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:332
+#: lib/fotohaecker_web/live/photo_live/show.ex:314
#, elixir-autogen, elixir-format
msgid "save"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:381
+#: lib/fotohaecker_web/live/photo_live/show.ex:363
#, elixir-autogen, elixir-format
msgid "edit field %{field}"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:306
+#: lib/fotohaecker_web/live/photo_live/show.ex:288
#, elixir-autogen, elixir-format
msgid "enter new %{field}"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:315
+#: lib/fotohaecker_web/live/photo_live/show.ex:297
#, elixir-autogen, elixir-format
msgid "photo %{field}"
msgstr ""
@@ -378,13 +373,13 @@ msgstr ""
msgid "Search…"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:85
-#: lib/fotohaecker_web/live/photo_live/show.ex:115
+#: lib/fotohaecker_web/live/photo_live/show.ex:84
+#: lib/fotohaecker_web/live/photo_live/show.ex:114
#, elixir-autogen, elixir-format, fuzzy
msgid "Delete"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:459
+#: lib/fotohaecker_web/live/photo_live/show.ex:437
#, elixir-autogen, elixir-format, fuzzy
msgid "photo deleted"
msgstr ""
@@ -506,17 +501,17 @@ msgstr ""
msgid "title (maximum 32 characters)"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:108
+#: lib/fotohaecker_web/live/photo_live/show.ex:107
#, elixir-autogen, elixir-format
msgid "Are you sure you want to delete this photo?"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:122
+#: lib/fotohaecker_web/live/photo_live/show.ex:121
#, elixir-autogen, elixir-format, fuzzy
msgid "Cancel"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:105
+#: lib/fotohaecker_web/live/photo_live/show.ex:104
#, elixir-autogen, elixir-format, fuzzy
msgid "Delete photo"
msgstr ""
@@ -547,7 +542,7 @@ msgstr ""
msgid "Unknown recipe brand, ask a developer to implement component"
msgstr ""
-#: lib/fotohaecker_web/live/photo_live/show.ex:280
+#: lib/fotohaecker_web/live/photo_live/show.ex:262
#, elixir-autogen, elixir-format
msgid "Brand: %{brand}"
msgstr ""
diff --git a/test/e2e/tests/helpers.ts b/test/e2e/tests/helpers.ts
index 694dac3..fd10706 100644
--- a/test/e2e/tests/helpers.ts
+++ b/test/e2e/tests/helpers.ts
@@ -69,6 +69,17 @@ export const changeLanguage = async (
await languageButton.click();
};
+/**
+ * On the homepage, selects the first photo in the list
+ * @param page {Page}
+ */
+export const selectFirstPhoto = async (page: Page) => {
+ await page.goto("/fh");
+ const photo = page.locator("ul#photos > li:first-child");
+ await photo.click();
+ await expect(page).toHaveURL(/.*\/photos\/\d+/);
+};
+
/**
* Joins the given path with the directory name.
* @param {string} join - The path to join with the directory name.
diff --git a/test/e2e/tests/photo.spec.ts b/test/e2e/tests/photo.spec.ts
index a92589d..677c7aa 100644
--- a/test/e2e/tests/photo.spec.ts
+++ b/test/e2e/tests/photo.spec.ts
@@ -4,14 +4,12 @@ import {
deletePhoto,
openDeletePhotoModal,
uploadPhoto,
+ selectFirstPhoto,
} from "./helpers";
test.describe("Photo Page: Static", () => {
test.beforeEach(async ({ page }) => {
- await page.goto("/fh");
- const photo = page.locator("ul#photos > li:first-child");
- await photo.click();
- await expect(page).toHaveURL(/.*\/photos\/\d+/);
+ await selectFirstPhoto(page);
});
test("should not have any automatically detectable accessibility issues", async ({
@@ -43,8 +41,27 @@ test.describe("Photo Page: Static", () => {
expect(download.suggestedFilename()).toContain(".jpg");
});
- test("can go back to home page", async ({ page }) => {
- await page.getByTestId("back-button").click();
+ test("can go back to home page and preserve url params and scroll position", async ({
+ page,
+ }) => {
+ await page.goBack();
+
+ // click "show more button" to load more photos
+ await page.getByTestId("show_more_photos_button").click();
+
+ // save current get parameters
+ const expectedParams = new URL(page.url()).searchParams;
+ const expectedScrollY = await page.evaluate(() => window.scrollY);
+
+ await selectFirstPhoto(page);
+ await page.goBack();
+
+ const actualParams = new URL(page.url()).searchParams;
+ const actualScrollY = await page.evaluate(() => window.scrollY);
+
+ expect(actualParams).toEqual(expectedParams);
+ // be close to one pixel
+ expect(actualScrollY - expectedScrollY).toBeLessThanOrEqual(1);
await expect(page).toHaveURL(/.*\/fh/);
});
diff --git a/test/fotohaecker_web/live/index_live_test.exs b/test/fotohaecker_web/live/index_live_test.exs
index 6a45bf3..d587d71 100644
--- a/test/fotohaecker_web/live/index_live_test.exs
+++ b/test/fotohaecker_web/live/index_live_test.exs
@@ -38,6 +38,15 @@ defmodule FotohaeckerWeb.IndexLiveTest do
assert actual =~ expected
end
+
+ test "can handle 'user_display_options' params", %{conn: conn} do
+ photo_fixtures(%{}, 15)
+
+ {:ok, view, _html} =
+ live(conn, "/fh?user_display_options[limit]=10&user_display_options[order]=asc_inserted_at")
+
+ assert render(view) =~ "showing 10 out of 15 photos"
+ end
end
defmodule FotohaeckerWeb.IndexLiveSyncTest do
@@ -49,11 +58,7 @@ defmodule FotohaeckerWeb.IndexLiveSyncTest do
@endpoint FotohaeckerWeb.Endpoint
test "can click on 'more photos' button", %{conn: conn} do
- Enum.each(
- 1..6,
- fn _i -> photo_fixture() end
- )
-
+ photo_fixtures(%{}, 6)
{:ok, view, _html} = live(conn, "/fh")
assert render(view) =~ "showing 5 out of 6 photos"
@@ -71,11 +76,7 @@ defmodule FotohaeckerWeb.IndexLiveSyncTest do
end
test "can click on 'sort by' options", %{conn: conn} do
- Enum.each(
- 1..6,
- fn _i -> photo_fixture() end
- )
-
+ photo_fixtures(%{}, 6)
{:ok, view, _html} = live(conn, "/fh")
actual_before = render(view)
diff --git a/test/fotohaecker_web/live/recipe_live/show_test.exs b/test/fotohaecker_web/live/recipe_live/show_test.exs
index 4dbf80a..3f5a21c 100644
--- a/test/fotohaecker_web/live/recipe_live/show_test.exs
+++ b/test/fotohaecker_web/live/recipe_live/show_test.exs
@@ -86,14 +86,10 @@ defmodule FotohaeckerWeb.RecipeLive.ShowTest do
expected = ["Photos using this recipe", "photo title"]
assert Enum.all?(expected, &(actual =~ &1))
- actual_after_click =
- view
- |> element("a", "photo title")
- |> render_click()
-
- expected_after_click = {:error, {:redirect, %{to: "/fh/en_US/photos/1"}}}
-
- assert actual_after_click == expected_after_click
+ view
+ |> element("a", "photo title")
+ |> render_click()
+ |> follow_redirect(conn, "/fh/en_US/photos/1")
end
test "throws error if recipe not found", %{conn: conn} do
diff --git a/test/support/fixtures/content_fixtures.ex b/test/support/fixtures/content_fixtures.ex
index 9a6aafd..fba82e0 100644
--- a/test/support/fixtures/content_fixtures.ex
+++ b/test/support/fixtures/content_fixtures.ex
@@ -22,6 +22,9 @@ defmodule Fotohaecker.ContentFixtures do
photo
end
+ def photo_fixtures(attrs \\ %{}, amount \\ 1),
+ do: Enum.map(1..amount, fn _i -> photo_fixture(attrs) end)
+
@doc """
Create a changeset for a photo.
"""