Skip to content

Commit

Permalink
Cypress Folder Test (#1994)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifarzana authored Aug 18, 2023
1 parent 8757569 commit 4deb0c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
17 changes: 13 additions & 4 deletions cypress/e2e/folder.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

/* eslint-disable max-len */
describe('Folders', function() {
beforeEach(function() {
cy.login();
Expand All @@ -35,26 +36,34 @@ describe('Folders', function() {
});

it('Moving an image from Root Folder to another folder', () => {
// Create and alias for load folders
// Create an alias for load folders
cy.intercept('/library?*').as('mediaLoad');
cy.intercept('/user/pref').as('userPref');

// Go to library
cy.visit('/library/view');

cy.wait('@mediaLoad');
cy.wait('@userPref');

cy.get('#media').type('child_folder_media');

// Wait for the search to complete
cy.wait('@mediaLoad');

cy.get('#libraryItems tbody tr').should('have.length', 1);
cy.wait('@mediaLoad');
cy.wait('@userPref');
cy.get('#datatable-container').should('contain', 'child_folder_media');

// Click the dropdown menu and choose a folder to move the image to
cy.get('#libraryItems tr:first-child .dropdown-toggle').click();
cy.get('#libraryItems tr:first-child .library_button_selectfolder').click();

// Expand the folder tree and select ChildFolder
cy.get('#container-folder-form-tree>ul>li>i').click();
cy.get('#container-folder-form-tree>ul>li:not(.jstree-loading)>i').click();
cy.contains('ChildFolder').click();

// Click the save button
cy.get('.save-button').click();
});

Expand Down Expand Up @@ -203,4 +212,4 @@ describe('Folders', function() {
cy.wait('@mediaLoad');
cy.get('#libraryItems tbody').contains('test34');
});
});
});
31 changes: 15 additions & 16 deletions lib/Factory/MediaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function query($sortOrder = null, $filterBy = [])
`media`.height,
`user`.UserName AS owner,
';
$select .= " (SELECT GROUP_CONCAT(DISTINCT `group`.group)
$select .= ' (SELECT GROUP_CONCAT(DISTINCT `group`.group)
FROM `permission`
INNER JOIN `permissionentity`
ON `permissionentity`.entityId = permission.entityId
Expand All @@ -571,17 +571,17 @@ public function query($sortOrder = null, $filterBy = [])
WHERE entity = :entity
AND objectId = media.mediaId
AND view = 1
) AS groupsWithPermissions, ";
) AS groupsWithPermissions, ';
$params['entity'] = 'Xibo\\Entity\\Media';

$select .= " media.originalFileName AS fileName ";
$select .= ' media.originalFileName AS fileName ';

$body = " FROM media ";
$body .= " LEFT OUTER JOIN media parentmedia ";
$body .= " ON parentmedia.editedMediaId = media.mediaId ";
$body = ' FROM media ';
$body .= ' LEFT OUTER JOIN media parentmedia ';
$body .= ' ON parentmedia.editedMediaId = media.mediaId ';

// Media might be linked to the system user (userId 0)
$body .= " LEFT OUTER JOIN `user` ON `user`.userId = `media`.userId ";
$body .= ' LEFT OUTER JOIN `user` ON `user`.userId = `media`.userId ';

if ($sanitizedFilter->getInt('displayGroupId') !== null) {
$body .= '
Expand All @@ -593,7 +593,7 @@ public function query($sortOrder = null, $filterBy = [])
$params['displayGroupId'] = $sanitizedFilter->getInt('displayGroupId');
}

$body .= " WHERE 1 = 1 ";
$body .= ' WHERE 1 = 1 ';

if ($sanitizedFilter->getInt('allModules') == 0) {
$body .= ' AND media.type <> \'module\' ';
Expand All @@ -618,8 +618,7 @@ public function query($sortOrder = null, $filterBy = [])
}

// Unused only?
if ($sanitizedFilter->getInt('unusedOnly') !== null) {

if ($sanitizedFilter->getInt('unusedOnly') === 1) {
$body .= '
AND media.mediaId NOT IN (SELECT mediaId FROM `lkwidgetmedia`)
AND media.mediaId NOT IN (SELECT mediaId FROM `lkmediadisplaygroup`)
Expand Down Expand Up @@ -686,7 +685,7 @@ public function query($sortOrder = null, $filterBy = [])
}

if ($sanitizedFilter->getInt('mediaId', ['default'=> -1]) != -1) {
$body .= " AND media.mediaId = :mediaId ";
$body .= ' AND media.mediaId = :mediaId ';
$params['mediaId'] = $sanitizedFilter->getInt('mediaId');
} else if ($sanitizedFilter->getInt('parentMediaId') !== null) {
$body .= ' AND media.editedMediaId = :mediaId ';
Expand Down Expand Up @@ -726,7 +725,7 @@ public function query($sortOrder = null, $filterBy = [])
}

if ($sanitizedFilter->getInt('ownerId') !== null) {
$body .= " AND media.userid = :ownerId ";
$body .= ' AND media.userid = :ownerId ';
$params['ownerId'] = $sanitizedFilter->getInt('ownerId');
}

Expand All @@ -737,7 +736,7 @@ public function query($sortOrder = null, $filterBy = [])
}

if ($sanitizedFilter->getInt('released') !== null) {
$body .= " AND media.released = :released ";
$body .= ' AND media.released = :released ';
$params['released'] = $sanitizedFilter->getInt('released');
}

Expand All @@ -746,10 +745,10 @@ public function query($sortOrder = null, $filterBy = [])
}

if ($sanitizedFilter->getInt('retired', ['default'=> -1]) == 1)
$body .= " AND media.retired = 1 ";
$body .= ' AND media.retired = 1 ';

if ($sanitizedFilter->getInt('retired', ['default'=> -1]) == 0)
$body .= " AND media.retired = 0 ";
$body .= ' AND media.retired = 0 ';

// Expired files?
if ($sanitizedFilter->getInt('expires') != 0) {
Expand Down Expand Up @@ -862,7 +861,7 @@ public function query($sortOrder = null, $filterBy = [])
}

if ($sanitizedFilter->getInt('folderId') !== null) {
$body .= " AND media.folderId = :folderId ";
$body .= ' AND media.folderId = :folderId ';
$params['folderId'] = $sanitizedFilter->getInt('folderId');
}

Expand Down

0 comments on commit 4deb0c1

Please sign in to comment.