2016-11-15 07:54:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace E2E;
|
|
|
|
|
|
|
|
use Facebook\WebDriver\WebDriverBy;
|
|
|
|
use Facebook\WebDriver\WebDriverElement;
|
|
|
|
use Facebook\WebDriver\WebDriverKeys;
|
|
|
|
|
|
|
|
class SongListTest extends TestCase
|
|
|
|
{
|
2016-11-18 07:56:18 +00:00
|
|
|
use SongListActions;
|
|
|
|
|
2016-11-15 07:54:41 +00:00
|
|
|
public function testSelection()
|
|
|
|
{
|
|
|
|
$this->loginAndWait()->repopulateList();
|
|
|
|
|
|
|
|
// Single song selection
|
2016-11-18 07:56:18 +00:00
|
|
|
static::assertContains('selected', $this->selectSong()->getAttribute('class'));
|
2016-11-15 07:54:41 +00:00
|
|
|
|
2016-11-18 07:56:18 +00:00
|
|
|
// Shift+Click
|
|
|
|
$this->selectRange();
|
2016-11-15 07:54:41 +00:00
|
|
|
// should have 5 selected rows
|
|
|
|
static::assertCount(5, $this->els('#queueWrapper tr.song-item.selected'));
|
|
|
|
|
|
|
|
// Cmd+Click
|
2016-11-18 07:56:18 +00:00
|
|
|
$this->cmdSelectSongs(2, 3);
|
2016-11-15 07:54:41 +00:00
|
|
|
// should have only 3 selected rows remaining
|
|
|
|
static::assertCount(3, $this->els('#queueWrapper tr.song-item.selected'));
|
|
|
|
// 2nd and 3rd rows must not be selected
|
|
|
|
static::assertNotContains(
|
|
|
|
'selected',
|
|
|
|
$this->el('#queueWrapper tr.song-item:nth-child(2)')->getAttribute('class')
|
|
|
|
);
|
|
|
|
static::assertNotContains(
|
|
|
|
'selected',
|
|
|
|
$this->el('#queueWrapper tr.song-item:nth-child(3)')->getAttribute('class')
|
|
|
|
);
|
|
|
|
|
|
|
|
// Delete key should remove selected songs
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->press(WebDriverKeys::DELETE)->waitUntil(function () {
|
2016-11-15 07:54:41 +00:00
|
|
|
return count($this->els('#queueWrapper tr.song-item.selected')) === 0
|
|
|
|
&& count($this->els('#queueWrapper tr.song-item')) === 7;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Ctrl+A/Cmd+A should select all songs
|
2016-11-18 07:56:18 +00:00
|
|
|
$this->selectAllSongs();
|
2016-11-15 07:54:41 +00:00
|
|
|
static::assertCount(7, $this->els('#queueWrapper tr.song-item.selected'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testActionButtons()
|
|
|
|
{
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->loginAndWait()
|
|
|
|
->repopulateList()
|
|
|
|
// Since no songs are selected, the "Shuffle All" button must be shown
|
|
|
|
->see('#queueWrapper button.btn-shuffle-all')
|
|
|
|
// Now we selected all songs for the "Shuffle Selected" button to be shown
|
|
|
|
->selectAllSongs()
|
|
|
|
->see('#queueWrapper button.btn-shuffle-selected');
|
2016-11-15 07:54:41 +00:00
|
|
|
|
|
|
|
// Add to favorites
|
2016-11-18 07:56:18 +00:00
|
|
|
$this->selectSong();
|
2016-11-17 09:25:58 +00:00
|
|
|
$this->click('#queueWrapper .buttons button.btn-add-to');
|
|
|
|
$this->click('#queueWrapper .buttons .add-to li.favorites');
|
2016-11-15 07:54:41 +00:00
|
|
|
$this->goto('favorites');
|
|
|
|
static::assertCount(1, $this->els('#favoritesWrapper tr.song-item'));
|
|
|
|
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->goto('queue')
|
|
|
|
->selectSong();
|
2016-11-15 07:54:41 +00:00
|
|
|
// Try adding a song into a new playlist
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->createPlaylist('Foo')
|
|
|
|
->seeText('Foo', '#playlists > ul');
|
2016-11-15 07:54:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSorting()
|
|
|
|
{
|
|
|
|
$this->loginAndWait()->repopulateList();
|
|
|
|
|
|
|
|
// Confirm that we can't sort in Queue screen
|
|
|
|
/** @var WebDriverElement $th */
|
|
|
|
foreach ($this->els('#queueWrapper div.song-list-wrap th') as $th) {
|
|
|
|
if (!$th->isDisplayed()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($th->findElements(WebDriverBy::tagName('i')) as $sortDirectionIcon) {
|
|
|
|
static::assertFalse($sortDirectionIcon->isDisplayed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now go to All Songs screen and sort there
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->goto('songs')
|
|
|
|
->click('#songsWrapper div.song-list-wrap th:nth-child(2)');
|
2016-11-15 07:54:41 +00:00
|
|
|
$last = null;
|
|
|
|
$results = [];
|
|
|
|
/** @var WebDriverElement $td */
|
|
|
|
foreach ($this->els('#songsWrapper div.song-list-wrap td.title') as $td) {
|
|
|
|
$current = $td->getText();
|
|
|
|
$results[] = $last === null ? true : $current <= $last;
|
|
|
|
$last = $current;
|
|
|
|
}
|
|
|
|
static::assertNotContains(false, $results);
|
|
|
|
|
|
|
|
// Second click will reverse the sort
|
|
|
|
$this->click('#songsWrapper div.song-list-wrap th:nth-child(2)');
|
|
|
|
$last = null;
|
|
|
|
$results = [];
|
|
|
|
/** @var WebDriverElement $td */
|
|
|
|
foreach ($this->els('#songsWrapper div.song-list-wrap td.title') as $td) {
|
|
|
|
$current = $td->getText();
|
|
|
|
$results[] = $last === null ? true : $current >= $last;
|
|
|
|
$last = $current;
|
|
|
|
}
|
|
|
|
static::assertNotContains(false, $results);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testContextMenu()
|
|
|
|
{
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->loginAndGoTo('songs')
|
|
|
|
->rightClickOnSong()
|
|
|
|
->see('#songsWrapper .song-menu');
|
2016-11-15 07:54:41 +00:00
|
|
|
|
|
|
|
// 7 sub menu items
|
|
|
|
static::assertCount(7, $this->els('#songsWrapper .song-menu > li'));
|
|
|
|
|
|
|
|
// Clicking the "Go to Album" menu item
|
|
|
|
$this->click('#songsWrapper .song-menu > li:nth-child(2)');
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->see('#albumWrapper');
|
2016-11-15 07:54:41 +00:00
|
|
|
|
|
|
|
// Clicking the "Go to Artist" menu item
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->back()
|
|
|
|
->rightClickOnSong()
|
|
|
|
->click('#songsWrapper .song-menu > li:nth-child(3)');
|
|
|
|
$this->see('#artistWrapper');
|
2016-11-15 07:54:41 +00:00
|
|
|
|
|
|
|
// Clicking "Edit"
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->back()
|
|
|
|
->rightClickOnSong()
|
|
|
|
->click('#songsWrapper .song-menu > li:nth-child(5)');
|
|
|
|
$this->see('#editSongsOverlay form');
|
|
|
|
|
2016-11-15 07:54:41 +00:00
|
|
|
// Updating song
|
2016-11-24 03:56:00 +00:00
|
|
|
$this->typeIn('#editSongsOverlay form input[name="title"]', 'Foo')
|
|
|
|
->typeIn('#editSongsOverlay form input[name="track"]', 99)
|
|
|
|
->enter()
|
|
|
|
->notSee('#editSongsOverlay form');
|
2016-11-15 07:54:41 +00:00
|
|
|
static::assertEquals('99', $this->el('#songsWrapper tr.song-item:nth-child(1) .track-number')->getText());
|
|
|
|
static::assertEquals('Foo', $this->el('#songsWrapper tr.song-item:nth-child(1) .title')->getText());
|
|
|
|
}
|
|
|
|
|
|
|
|
private function repopulateList()
|
|
|
|
{
|
|
|
|
// Go back to Albums and queue an album of 10 songs
|
|
|
|
$this->goto('albums');
|
2016-11-17 09:25:58 +00:00
|
|
|
$this->click('#albumsWrapper > div > article:nth-child(1) .meta a.shuffle-album');
|
2016-11-15 07:54:41 +00:00
|
|
|
$this->goto('queue');
|
2016-11-24 03:56:00 +00:00
|
|
|
|
|
|
|
return $this;
|
2016-11-15 07:54:41 +00:00
|
|
|
}
|
|
|
|
}
|