diff --git a/app/views/albums/_album.html.erb b/app/views/albums/_album.html.erb index fb89f3dd..da5fab52 100644 --- a/app/views/albums/_album.html.erb +++ b/app/views/albums/_album.html.erb @@ -1,4 +1,4 @@ -
+
<%= link_to album_path(album), class: "c-card__image" do %> <%= cover_image_tag album, class: "u-image-fluid" %> <% end %> diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb index c782ee1c..ce7aa161 100644 --- a/app/views/albums/show.html.erb +++ b/app/views/albums/show.html.erb @@ -2,7 +2,7 @@
- <%= cover_image_tag @album, class: "c-card__image u-image-medium", data: {"test-id" => "album_image"} %> + <%= cover_image_tag @album, class: "c-card__image u-image-medium" %>

<%= @album.name %>

<%= link_to @album.artist.name, artist_path(@album.artist), class: "c-card__body__text" %> @@ -39,7 +39,7 @@ <% end %> <% songs.each do |song| %> -
  • +
  • <%= button_to( current_playlist_album_path(@album, should_play: true, song_id: song.id), @@ -56,7 +56,7 @@ ) do %>
    -
    <%= song.name %>
    +
    <%= song.name %>
    <% if @album.artist.various? %> <% if native_app? %> <%= song.artist.name %> @@ -69,7 +69,7 @@
    <% end %> -
    +
    <%= icon_tag "more-vertical", size: "small", title: t("label.more") %> diff --git a/app/views/artists/_artist.html.erb b/app/views/artists/_artist.html.erb index 1858ca56..f0014252 100644 --- a/app/views/artists/_artist.html.erb +++ b/app/views/artists/_artist.html.erb @@ -1,4 +1,4 @@ -
    +
    <%= link_to artist_path(artist), class: "c-card__image" do %> <%= cover_image_tag artist, class: "u-image-fluid" %> <% end %> diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index fd34ff11..7c1995aa 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -2,7 +2,7 @@
    - <%= cover_image_tag @artist, class: "c-card__image u-image-medium", data: {"test-id" => "artist_image"} %> + <%= cover_image_tag @artist, class: "c-card__image u-image-medium" %>

    <%= @artist.name %>

    diff --git a/app/views/current_playlist/songs/_song.html.erb b/app/views/current_playlist/songs/_song.html.erb index 38e09afb..6f7bd18c 100644 --- a/app/views/current_playlist/songs/_song.html.erb +++ b/app/views/current_playlist/songs/_song.html.erb @@ -4,25 +4,24 @@ data-song-id='<%= song.id %>' data-song-json='<%= song_json_builder(song).target! %>' data-should-play='<%= local_assigns[:should_play] ? should_play : false %>' - draggable='true' - data-test-id='current_playlist_song'> + draggable='true'>
    <% unless mobile? %> - + <% end %> -
    +
    <%= icon_tag "more-vertical", size: "small", title: t("label.more") %>
    <%= link_to t("label.add_to_playlist"), dialog_playlists_path(song_id: song.id, referer_url: current_url), data: {"turbo-frame" => ("turbo-dialog" unless native_app?)}, class: "c-dropdown__item" %> diff --git a/app/views/current_playlist/songs/index.html.erb b/app/views/current_playlist/songs/index.html.erb index 9d62fb99..ac91c86f 100644 --- a/app/views/current_playlist/songs/index.html.erb +++ b/app/views/current_playlist/songs/index.html.erb @@ -1,5 +1,4 @@
    <% if @songs.empty? %> @@ -10,7 +9,7 @@ <%= @playlist.songs.count %> <%= t("label.tracks") %>

    -
    +
    <%= icon_tag "more-vertical", title: t("label.more") %>
    <%= button_to t("button.clear"), current_playlist_songs_path, method: :delete, form_class: "c-dropdown__item" %> diff --git a/app/views/dialog/albums/edit.html.erb b/app/views/dialog/albums/edit.html.erb index 084d417f..1849bf1b 100644 --- a/app/views/dialog/albums/edit.html.erb +++ b/app/views/dialog/albums/edit.html.erb @@ -1,6 +1,6 @@ <% page_title_tag t("label.edit_album") %> -<%= form_with model: @album, data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?), "test-id" => "album_edit_form"}, class: "c-form" do |form| %> +<%= form_with model: @album, data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?)}, class: "c-form" do |form| %>
    <%= form.label :cover_image, t("field.album_cover") %> <%= form.file_field :cover_image, accept: "image/png, image/jpeg", class: "c-input" %> diff --git a/app/views/dialog/artists/edit.html.erb b/app/views/dialog/artists/edit.html.erb index 647ae2bd..92cc5117 100644 --- a/app/views/dialog/artists/edit.html.erb +++ b/app/views/dialog/artists/edit.html.erb @@ -1,6 +1,6 @@ <% page_title_tag t("label.edit_artist") %> -<%= form_with model: @artist, data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?), "test-id" => "artist_edit_form"}, class: "c-form" do |form| %> +<%= form_with model: @artist, data: {"turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?)}, class: "c-form" do |form| %>
    <%= form.label :cover_image, t("field.artist_cover") %> <%= form.file_field :cover_image, accept: "image/png, image/jpeg", class: "c-input" %> diff --git a/app/views/dialog/playlists/_playlist.html.erb b/app/views/dialog/playlists/_playlist.html.erb index 7ae71aea..86a27716 100644 --- a/app/views/dialog/playlists/_playlist.html.erb +++ b/app/views/dialog/playlists/_playlist.html.erb @@ -1,3 +1,3 @@ - diff --git a/app/views/dialog/playlists/edit.html.erb b/app/views/dialog/playlists/edit.html.erb index fc6cb589..eb115beb 100644 --- a/app/views/dialog/playlists/edit.html.erb +++ b/app/views/dialog/playlists/edit.html.erb @@ -5,8 +5,7 @@ class: "c-form", data: { "turbo-frame" => "_top", - "turbo-action" => ("replace" if native_app?), - "test-id" => "playlist_edit_form" + "turbo-action" => ("replace" if native_app?) } ) do |form| %>
    diff --git a/app/views/favorite_playlist/songs/index.html.erb b/app/views/favorite_playlist/songs/index.html.erb index 0fe1fa31..7693dc5e 100644 --- a/app/views/favorite_playlist/songs/index.html.erb +++ b/app/views/favorite_playlist/songs/index.html.erb @@ -1,8 +1,8 @@ -
    +
    -

    <%= @playlist.name %>

    +

    <%= @playlist.name %>

    <%= @playlist.songs.size %> <%= t("label.tracks") %> diff --git a/app/views/media_syncing/_button.html.erb b/app/views/media_syncing/_button.html.erb index 0ab395cf..e107eced 100644 --- a/app/views/media_syncing/_button.html.erb +++ b/app/views/media_syncing/_button.html.erb @@ -4,7 +4,6 @@ t("button.syncing"), false, class: "c-button c-button--secondary", - data: {"test-id" => "media_sync_button"}, disabled: true ) %> <% else %> @@ -13,7 +12,6 @@ media_syncing_path, class: "c-button c-button--secondary", data: { - "test-id" => "media_sync_button", "turbo-submits-with" => t("button.syncing") } ) %> diff --git a/app/views/playlists/_playlist.html.erb b/app/views/playlists/_playlist.html.erb index 4a55bfc3..cc1da2be 100644 --- a/app/views/playlists/_playlist.html.erb +++ b/app/views/playlists/_playlist.html.erb @@ -1,4 +1,4 @@ -
    +
    <%= link_to playlist_songs_path(playlist), class: "o-flex o-flex--align-center" do %> <% if playlist.favorite? %> @@ -6,7 +6,7 @@ <% else %> <%= icon_tag("queue-music") %> <% end %> - <%= playlist.name %> + <%= playlist.name %> <% end %>
    diff --git a/app/views/playlists/songs/_song.html.erb b/app/views/playlists/songs/_song.html.erb index 3cc945d0..8e829088 100644 --- a/app/views/playlists/songs/_song.html.erb +++ b/app/views/playlists/songs/_song.html.erb @@ -1,7 +1,7 @@ -
  • +
  • <% unless mobile? %> - + <% end %> <%= button_to( @@ -19,7 +19,7 @@ ) do %>
    - <%= song.name %> + <%= song.name %> <% if native_app? %> <%= song.artist.name %> <% else %> @@ -29,7 +29,7 @@
    <%= format_duration(song.duration) %>
    <% end %> -
    +
    <%= icon_tag "more-vertical", size: "small", title: t("label.more") %>
    <%= button_to( diff --git a/app/views/playlists/songs/index.html.erb b/app/views/playlists/songs/index.html.erb index 05edc912..bb5743e2 100644 --- a/app/views/playlists/songs/index.html.erb +++ b/app/views/playlists/songs/index.html.erb @@ -4,7 +4,7 @@
    -

    <%= @playlist.name %>

    +

    <%= @playlist.name %>

    <%= @playlist.songs.size %> <%= t("label.tracks") %> @@ -30,7 +30,7 @@ <% end %> <%= link_to t("label.edit"), edit_dialog_playlist_path(@playlist), data: {"turbo-frame" => ("turbo-dialog" unless native_app?)}, class: "c-button c-button--secondary" %> -
    +
    <%= icon_tag "more-horizontal", size: "narrow", title: t("label.more") %> diff --git a/app/views/settings/_form.html.erb b/app/views/settings/_form.html.erb index c112beb6..7e43bf71 100644 --- a/app/views/settings/_form.html.erb +++ b/app/views/settings/_form.html.erb @@ -44,7 +44,7 @@ <%= form.text_field :discogs_token, value: Setting.discogs_token, class: "c-input" %>
    - <%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width", data: {"test-id" => "setting_discogs_token_save_button"} %> + <%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width" %>
    <% end %> diff --git a/app/views/shared/_player.html.erb b/app/views/shared/_player.html.erb index 2939b33b..2543d233 100644 --- a/app/views/shared/_player.html.erb +++ b/app/views/shared/_player.html.erb @@ -1,11 +1,11 @@
    -
    +
    -

    +

    @@ -31,20 +31,20 @@ <%= icon_tag "shuffle", active: true, title: t("label.shuffle_mode"), data: {"player-target" => "modeButton"} %>
    - - - -
    -
    +
    <%= button_to "#", class: "c-button c-button--icon", form_class: "u-visibility-hidden", form: {"data-player-target" => "favoriteButton"} do %> <%= icon_tag "heart", title: t("label.toggle_favorite") %> <% end %> diff --git a/app/views/shared/_search_bar.html.erb b/app/views/shared/_search_bar.html.erb index c73419da..16d72aaa 100644 --- a/app/views/shared/_search_bar.html.erb +++ b/app/views/shared/_search_bar.html.erb @@ -6,7 +6,7 @@ <%= icon_tag "search", size: "large" %>
    - <%= text_field_tag "query", query, class: "c-input", data: {"search-target" => "input", "test-id" => "search_input"}, autocomplete: "on" %> + <%= text_field_tag "query", query, class: "c-input", data: {"search-target" => "input"}, autocomplete: "on" %>
    <%= loader_tag size: "small" %> @@ -14,7 +14,7 @@ <% end %>
    -
    +
    <%= avatar_tag current_user %>
    <%= link_to t("label.settings"), setting_path, class: "c-dropdown__item" %> diff --git a/app/views/songs/_song.html.erb b/app/views/songs/_song.html.erb index 19318879..e9e3bb76 100644 --- a/app/views/songs/_song.html.erb +++ b/app/views/songs/_song.html.erb @@ -3,7 +3,6 @@ <%= button_to( current_playlist_songs_path(song_id: song.id, should_play: true), class: "c-button c-button--link", - data: {"test-id" => "song_item"}, form: { data: { "delegated-action" => "turbo:submit-start-songs#checkBeforePlay click->songs-bridge#playNow", @@ -12,7 +11,7 @@ } } ) do %> - <%= song.name %> + <%= song.name %> <% end %>
    @@ -23,7 +22,7 @@
    <%= format_duration(song.duration) %>
    -
    +
    <%= icon_tag "more-vertical", size: "small", title: t("label.more") %> diff --git a/app/views/users/settings/_form.html.erb b/app/views/users/settings/_form.html.erb index b32cf469..4c890b4a 100644 --- a/app/views/users/settings/_form.html.erb +++ b/app/views/users/settings/_form.html.erb @@ -10,6 +10,6 @@ <% end %>
    - <%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width", data: {"test-id" => "setting_theme_save_button"} %> + <%= form.submit t("button.save"), class: "c-button c-button--primary c-button--full-width" %>
    <% end %> diff --git a/test/system/album_test.rb b/test/system/album_test.rb deleted file mode 100644 index 10377c43..00000000 --- a/test/system/album_test.rb +++ /dev/null @@ -1,107 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class AlbumSystemTest < ApplicationSystemTestCase - setup do - @album = albums(:album1) - end - - test "show album" do - login_as users(:visitor1) - visit album_url(@album) - - assert_text(@album.name) - assert_text(@album.artist.name) - - @album.songs.each do |song| - assert_text(song.name) - end - end - - test "play all songs on album" do - login_as users(:visitor1) - - visit album_url(@album) - click_on "Play" - - # assert current playlist have all songs in album - @album.songs.each do |song| - assert_selector(:test_id, "current_playlist_song_name", text: song.name) - end - - # assert play the first song in album - assert_selector(:test_id, "player_song_name", text: @album.songs.first.name) - end - - test "edit album" do - login_as users(:admin) - - visit album_url(@album) - - album_original_image_url = find(:test_id, "album_image")[:src] - - click_on "Edit" - assert_selector(:test_id, "album_edit_form", visible: true) - - attach_file("album_cover_image", fixtures_file_path("cover_image.jpg")) - click_on "Save" - - assert_text("Updated successfully") - assert_not_equal album_original_image_url, find(:test_id, "album_image")[:src] - end - - test "play song from album" do - login_as users(:visitor1) - - visit album_url(@album) - - first_song_name = first(:test_id, "album_song_name").text - first(:test_id, "album_song").click - - # when click song to play, the current playlist and player sould list current playing song - assert_equal first(:test_id, "current_playlist_song_name").text, first_song_name - assert_selector(:test_id, "player_song_name", text: first_song_name) - end - - test "add song to playlist" do - playlist_name = "test-playlist" - playlist = Playlist.create(name: playlist_name, user_id: users(:visitor1).id) - login_as users(:visitor1) - - visit album_url(@album) - first(:test_id, "album_song_menu").click - click_on "Add to Playlist" - find(:test_id, "dialog_playlist", text: playlist_name).click - - # assert the song added to the playlist - assert_equal playlist.songs.first.name, first(:test_id, "album_song_name").text - end - - test "add song to the next in current playlist" do - login_as users(:visitor1) - visit album_url(@album) - - first(:test_id, "album_song_menu").click - click_on "Play Next" - assert_equal first(:test_id, "current_playlist_song_name").text, first(:test_id, "album_song_name").text - - find("body").click - first(:test_id, "current_playlist_song").click - all(:test_id, "album_song_menu").last.click - click_on "Play Next" - assert_equal all(:test_id, "current_playlist_song_name")[1].text, all(:test_id, "album_song_name").last.text - end - - test "add song to the end in current playlist" do - song_ids = Song.ids - @album.songs.ids - users(:visitor1).current_playlist.replace(song_ids) - login_as users(:visitor1) - visit album_url(@album) - - first(:test_id, "album_song_menu").click - click_on "Play Last" - - assert_equal first(:test_id, "album_song_name").text, all(:test_id, "current_playlist_song_name").last.text - end -end diff --git a/test/system/albums_test.rb b/test/system/albums_test.rb deleted file mode 100644 index e183c523..00000000 --- a/test/system/albums_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class AlbumsSystemTest < ApplicationSystemTestCase - setup do - # create many record to test infinite scroll - (Pagy::DEFAULT[:items] * 2).times do |n| - Album.create(name: "album_test_#{n}", artist_id: artists(:artist1).id) - end - - login_as users(:visitor1) - end - - test "show albums" do - visit albums_url - - assert_selector(:test_id, "album_card", count: Pagy::DEFAULT[:items], visible: :all) - end - - test "show next page albums when scroll to the bottom" do - visit albums_url - scroll_to :bottom - - assert_selector(:test_id, "album_card", count: Pagy::DEFAULT[:items] * 2, visible: :all) - end -end diff --git a/test/system/artist_test.rb b/test/system/artist_test.rb deleted file mode 100644 index bc8dcac7..00000000 --- a/test/system/artist_test.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class ArtistSystemTest < ApplicationSystemTestCase - setup do - @artist = artists(:artist1) - end - - test "show artist" do - login_as users(:visitor1) - visit artist_url(@artist) - - assert_text(@artist.name) - - @artist.albums.each do |album| - assert_text(album.name) - end - end - - test "edit artist" do - login_as users(:admin) - visit artist_url(@artist) - - artist_original_image_url = find(:test_id, "artist_image")[:src] - - click_on "Edit" - assert_selector(:test_id, "artist_edit_form", visible: true) - - attach_file("artist_cover_image", fixtures_file_path("cover_image.jpg")) - click_on "Save" - - assert_text("Updated successfully") - assert_not_equal artist_original_image_url, find(:test_id, "artist_image")[:src] - end -end diff --git a/test/system/artists_test.rb b/test/system/artists_test.rb deleted file mode 100644 index 4a23f98e..00000000 --- a/test/system/artists_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class ArtistsSystemTest < ApplicationSystemTestCase - setup do - # create many record to test infinite scroll - (Pagy::DEFAULT[:items] * 2).times do |n| - Artist.create(name: "artist_test_#{n}") - end - - login_as users(:visitor1) - end - - test "show artists" do - visit artists_url - - assert_selector(:test_id, "artist_card", count: Pagy::DEFAULT[:items], visible: :all) - end - - test "show next page artists when scroll to the bottom" do - visit artists_url - scroll_to :bottom - - assert_selector(:test_id, "artist_card", count: Pagy::DEFAULT[:items] * 2, visible: :all) - end -end diff --git a/test/system/current_playlist_test.rb b/test/system/current_playlist_test.rb deleted file mode 100644 index 5c2d423a..00000000 --- a/test/system/current_playlist_test.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class CurrentPlaylistSystemTest < ApplicationSystemTestCase - setup do - users(:visitor1).current_playlist.replace(Song.ids.sort) - login_as users(:visitor1) - end - - test "show playlist songs" do - assert_selector(:test_id, "current_playlist_song", count: Song.count) - - Song.all.each do |song| - assert_selector(:test_id, "current_playlist_song_name", text: song.name) - end - end - - test "clear playlist songs" do - find(:test_id, "playlist_menu").click - click_on "Clear" - - assert_selector(:test_id, "current_playlist_song", count: 0) - assert_text("No Items") - end - - test "player is stopped after clear current playlist" do - find(:test_id, "playlist_menu").click - click_on "Clear" - - find(:test_id, "player_next_button").click - assert_selector(:test_id, "player_header", visible: false) - end - - test "play song in playlist" do - first(:test_id, "current_playlist_song").click - - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: Song.first.name) - end - - test "delete song in playlist" do - first(:test_id, "current_playlist_song_menu").click - click_on "Delete" - - assert_selector(:test_id, "current_playlist_song", count: Song.count - 1) - end - - # Temporarily disable this test, because cuprite does not support HTML drag and drop event, - # so need to switch to another driver to test this feature. - # test "reorder song in playlist" do - # source_element = first(:test_id, "playlist_song_sortable_handle") - # target_element = all(:test_id, "playlist_song_sortable_handle").last - # source_element.drag_to(target_element) - # - # assert_equal Song.first.name, all(:test_id, "current_playlist_song_name").last.text - # end - - test "add to playlist" do - playlist_name = "test-playlist" - playlist = Playlist.create(name: playlist_name, user_id: users(:visitor1).id) - - assert_difference -> { playlist.songs.count } do - first(:test_id, "current_playlist_song_menu").click - click_on "Add to Playlist" - find(:test_id, "dialog_playlist", text: playlist_name).click - end - end -end diff --git a/test/system/favorite_playlist_test.rb b/test/system/favorite_playlist_test.rb deleted file mode 100644 index 530c1fe8..00000000 --- a/test/system/favorite_playlist_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class FavoritePlaylistSystemTest < ApplicationSystemTestCase - setup do - users(:visitor1).favorite_playlist.replace(Song.ids.sort) - login_as users(:visitor1) - - visit favorite_playlist_songs_url - end - - test "show playlist songs" do - assert_selector(:test_id, "playlist_song", count: Song.count) - - Song.all.each do |song| - assert_selector(:test_id, "playlist_song_name", text: song.name) - end - end - - test "play all songs in playlist" do - click_on "Play" - - # assert current playlist have all songs in playlist - assert_selector(:test_id, "current_playlist", visible: true) - Song.all.each.each do |song| - assert_selector(:test_id, "current_playlist_song_name", text: song.name) - end - - # assert play the first song in playlist - assert_selector(:test_id, "player_song_name", text: Song.first.name) - end - - test "clear playlist songs" do - click_on "Clear" - - assert_selector(:test_id, "playlist_song", count: 0) - assert_text("No Items") - end - - test "play song in playlist" do - first(:test_id, "playlist_song").click - - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: Song.first.name) - end - - test "delete song in playlist" do - first(:test_id, "playlist_song_menu").click - click_on "Delete" - - assert_selector(:test_id, "playlist_song", count: Song.count - 1) - end - - # Temporarily disable this test, because cuprite does not support HTML drag and drop event, - # so need to switch to another driver to test this feature. - # test "reorder song in playlist" do - # source_element = first(:test_id, "playlist_song_sortable_handle") - # target_element = all(:test_id, "playlist_song_sortable_handle").last - # - # source_element.drag_to(target_element) - # - # assert_equal Song.first.name, all(:test_id, "playlist_song_name").last.text - # end - - test "add to playlist" do - playlist_name = "test-playlist" - playlist = Playlist.create(name: playlist_name, user_id: users(:visitor1).id) - - assert_difference -> { playlist.songs.count } do - first(:test_id, "playlist_song_menu").click - click_on "Add to Playlist" - find(:test_id, "dialog_playlist", text: playlist_name).click - end - end -end diff --git a/test/system/player_test.rb b/test/system/player_test.rb deleted file mode 100644 index fc824893..00000000 --- a/test/system/player_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class PlayerSystemTest < ApplicationSystemTestCase - setup do - users(:visitor1).current_playlist.replace(Song.ids.sort) - login_as users(:visitor1) - end - - test "play song" do - find(:test_id, "player_play_button").click - - assert_selector(:test_id, "player_play_button", visible: false) - assert_selector(:test_id, "player_pause_button", visible: true) - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: Song.first.name) - end - - test "play next song" do - find(:test_id, "player_play_button").click - find(:test_id, "player_next_button").click - - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: Song.second.name) - end - - test "play previous song" do - find(:test_id, "player_play_button").click - find(:test_id, "player_previous_button").click - - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: Song.last.name) - end - - test "favorite toggle" do - find(:test_id, "player_play_button").click - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: Song.first.name) - - find(:test_id, "player_favorite_button").click - assert_equal Song.first.name, users(:visitor1).favorite_playlist.songs.first.name - - find(:test_id, "player_favorite_button").click - assert_equal 0, users(:visitor1).favorite_playlist.songs.count - end -end diff --git a/test/system/playlist_test.rb b/test/system/playlist_test.rb deleted file mode 100644 index 3260acae..00000000 --- a/test/system/playlist_test.rb +++ /dev/null @@ -1,109 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class PlaylistSystemTest < ApplicationSystemTestCase - setup do - login_as users(:admin) - - visit playlist_songs_url(playlists(:playlist1)) - end - - test "show playlist songs" do - playlists(:playlist1).songs.each do |song| - assert_selector(:test_id, "playlist_song_name", text: song.name) - end - end - - test "play all songs in playlist" do - click_on "Play" - - # assert current playlist have all songs in playlist - assert_selector(:test_id, "current_playlist", visible: true) - playlists(:playlist1).songs.each do |song| - assert_selector(:test_id, "current_playlist_song_name", text: song.name) - end - - # assert play the first song in playlist - assert_selector(:test_id, "player_song_name", text: Song.first.name) - end - - test "clear playlist songs" do - find(:test_id, "playlist_menu").click - click_on "Clear" - - assert_selector(:test_id, "playlist_song", count: 0) - end - - test "delete playlist" do - playlist_count = users(:admin).playlists_with_favorite.count - - find(:test_id, "playlist_menu").click - click_on "Delete" - - assert_selector(:test_id, "playlist", count: playlist_count - 1) - end - - test "edit playlist" do - click_on "Edit" - - assert_selector(:test_id, "playlist_edit_form", visible: true) - - fill_in "playlist_name", with: "renamed_playlist" - click_on "Save" - - assert_text("Updated successfully") - assert_selector(:test_id, "playlist_name", text: "renamed_playlist") - end - - test "delete song in playlist" do - playlist_songs_count = playlists(:playlist1).songs.count - - first(:test_id, "playlist_song_menu").click - click_on "Delete" - - assert_selector(:test_id, "playlist_song", count: playlist_songs_count - 1) - end - - # Temporarily disable this test, because cuprite does not support HTML drag and drop event, - # so need to switch to another driver to test this feature. - # test "reorder song in playlist" do - # first_playlist_song_name = playlists(:playlist1).songs.first.name - # source_element = first(:test_id, "playlist_song_sortable_handle") - # target_element = all(:test_id, "playlist_song_sortable_handle").last - # - # source_element.drag_to(target_element) - # - # assert_equal first_playlist_song_name, all(:test_id, "playlist_song_name").last.text - # end - - test "play song in playlist" do - first(:test_id, "playlist_song").click - - assert_selector(:test_id, "player_header", visible: true) - assert_selector(:test_id, "player_song_name", text: playlists(:playlist1).songs.first.name) - end - - test "add song to another playlist" do - playlist_name = "test-playlist" - playlist = Playlist.create(name: playlist_name, user_id: users(:admin).id) - - assert_difference -> { playlist.songs.count } do - first(:test_id, "playlist_song_menu").click - click_on "Add to Playlist" - find(:test_id, "dialog_playlist", text: playlist_name).click - end - end - - test "add song to the next in current playlist" do - first(:test_id, "playlist_song_menu").click - click_on "Play Next" - assert_equal first(:test_id, "current_playlist_song_name").text, playlists(:playlist1).songs.first.name - - find("body").click - first(:test_id, "current_playlist_song").click - all(:test_id, "playlist_song_menu").last.click - click_on "Play Next" - assert_equal all(:test_id, "current_playlist_song_name")[1].text, playlists(:playlist1).songs.last.name - end -end diff --git a/test/system/playlists_test.rb b/test/system/playlists_test.rb deleted file mode 100644 index 806f7884..00000000 --- a/test/system/playlists_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class PlaylistsSystemTest < ApplicationSystemTestCase - setup do - login_as users(:admin) - visit playlists_url - end - - test "show playlist" do - users(:admin).playlists_with_favorite.each do |playlist| - assert_selector(:test_id, "playlist_name", text: playlist.name) - end - end - - test "create playlist" do - playlist_name = "test-playlist" - - click_on "Add" - fill_in "playlist_name", with: playlist_name - click_on "Save" - - assert_text("Created successfully") - assert_selector(:test_id, "playlist_name", text: playlist_name) - end -end diff --git a/test/system/search_test.rb b/test/system/search_test.rb deleted file mode 100644 index 0c4d9a21..00000000 --- a/test/system/search_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class SearchSystemTest < ApplicationSystemTestCase - setup do - login_as users(:visitor1) - end - - test "show search results" do - fill_in "query", with: "artist" - find(:test_id, "search_input").send_keys(:enter) - - assert_text('Search results for "artist"') - end - - test "can not request search when query text is empty" do - fill_in "query", with: "" - find(:test_id, "search_input").send_keys(:enter) - - assert_no_text('Search results for "artist"') - assert_no_current_path(search_url) - end -end diff --git a/test/system/session_test.rb b/test/system/session_test.rb deleted file mode 100644 index 1b5de6f2..00000000 --- a/test/system/session_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class SessionSystemTest < ApplicationSystemTestCase - test "login" do - visit new_session_url - - fill_in "Email", with: users(:visitor1).email - fill_in "Password", with: "foobar" - - click_on "Login" - - assert_current_path(root_url) - end - - test "login with wrong credentials" do - visit new_session_url - - fill_in "Email", with: users(:visitor1).email - fill_in "Password", with: "wrong_pass" - - click_on "Login" - - # assert have error flash message - assert_text("Wrong email or password") - - # after login failed, cleanup login form - assert_field "Email", with: "" - assert_field "Password", with: "" - end - - test "logout" do - login_as users(:visitor1) - find(:test_id, "search_bar_menu").click - click_on "Logout" - - assert_current_path(new_session_url) - end -end diff --git a/test/system/setting_test.rb b/test/system/setting_test.rb deleted file mode 100644 index 46782b87..00000000 --- a/test/system/setting_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class SettingSystemTest < ApplicationSystemTestCase - setup do - login_as users(:admin) - end - - test "update theme" do - visit setting_url - - choose("user_theme_light") - click_on("setting_theme_save_button") - - assert_text("Updated successfully") - end - - test "update discogs token" do - visit setting_url - - fill_in("setting_discogs_token", with: "fake_token") - click_on("setting_discogs_token_save_button") - - assert_text("Updated successfully") - assert_equal "fake_token", find_field("setting_discogs_token").value - end -end diff --git a/test/system/songs_test.rb b/test/system/songs_test.rb deleted file mode 100644 index 02d40970..00000000 --- a/test/system/songs_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class SongsSystemTest < ApplicationSystemTestCase - setup do - # create many record to test infinite scroll - (Pagy::DEFAULT[:items] * 2).times do |n| - Song.create( - name: "song_test_#{n}", - file_path: Rails.root.join("test/fixtures/files/artist1_album2.mp3"), - file_path_hash: "fake_path_hash", - md5_hash: "fake_md5_#{n}", - artist_id: artists(:artist1).id, - album_id: albums(:album1).id - ) - end - - @user = users(:visitor1) - login_as @user - end - - test "show songs" do - visit songs_url - - assert_selector(:test_id, "song_item", count: Pagy::DEFAULT[:items], visible: :all) - end - - test "show next page songs when scroll to the bottom" do - visit songs_url - scroll_to :bottom - - assert_selector(:test_id, "song_item", count: Pagy::DEFAULT[:items] * 2, visible: :all) - end - - test "play song from songs list" do - visit songs_url - - first_song_name = first(:test_id, "song_name").text - first(:test_id, "song_item").click - - # when click song to play, the current playlist and player sould list current playing song - assert_equal first_song_name, first(:test_id, "current_playlist_song_name").text - assert_selector(:test_id, "player_song_name", text: first_song_name) - end - - test "add song to playlist" do - playlist_name = "test-playlist" - playlist = Playlist.create(name: playlist_name, user_id: @user.id) - - visit songs_url - - assert_difference -> { playlist.songs.count } do - first(:test_id, "song_menu").click - click_on "Add to Playlist" - find(:test_id, "dialog_playlist", text: playlist_name).click - end - end - - test "add song to the end in current playlist" do - @user.current_playlist.songs << Song.where(name: ["song_test_0", "song_test_1"]) - visit songs_url - - first(:test_id, "song_menu").click - click_on "Play Last" - assert_equal first(:test_id, "song_name").text, all(:test_id, "current_playlist_song_name").last.text - end -end diff --git a/test/system/users_test.rb b/test/system/users_test.rb deleted file mode 100644 index ad6240c5..00000000 --- a/test/system/users_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -require "application_system_test_case" - -class UsersSystemTest < ApplicationSystemTestCase - setup do - login_as users(:admin) - end - - test "show users" do - visit users_url - - User.where.not(id: users(:admin)).each do |user| - assert_text(user.email) - end - end - - test "add user" do - visit users_url - click_on "Add" - - fill_in "Email", with: "system_test@test.com" - fill_in "Password", with: "foobar" - fill_in "Password Confirmation", with: "foobar" - click_on "Save" - - assert_text("Created successfully") - assert_text("system_test@test.com") - end - - test "delete user" do - visit users_url - - delete_user = users(:visitor1) - delete_user_button = find("#user_#{delete_user.id}").find("button") - delete_user_button.click - - assert_text("Deleted successfully") - assert_no_text(delete_user.email) - end - - test "edit user" do - visit edit_user_url(users(:visitor1)) - - fill_in "Email", with: "system_test@test.com" - click_on "Save" - - assert_equal "system_test@test.com", find_field("user_email").value - end -end