Initial Upload

This commit is contained in:
Matt Batchelder
2025-12-02 10:32:59 -05:00
commit 05ce0da296
2240 changed files with 467811 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Applications', function() {
let testRun = '';
beforeEach(function() {
cy.login();
testRun = Cypress._.random(0, 1e9);
});
it('should add edit an application', function() {
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/application/*',
}).as('putRequest');
cy.visit('/application/view');
// Click on the Add Application button
cy.contains('Add Application').click();
cy.get('.modal input#name')
.type('Cypress Test Application ' + testRun);
// Add first by clicking next
cy.get('.modal .save-button').click();
// Check if application is added in toast message
cy.contains('Edit Application');
cy.get('.modal input#name').clear()
.type('Cypress Test Application Edited ' + testRun);
// edit test application
cy.get('.bootbox .save-button').click();
// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;
// assertion on the "application" value
expect(responseData.name).to.eq('Cypress Test Application Edited ' + testRun);
// Return appKey as a Cypress.Promise to ensure proper scoping
return Cypress.Promise.resolve(responseData.key);
}).then((appKey) => {
if (appKey) {
// TODO cannot be deleted via cypress
// Delete the application and assert success
// cy.deleteApplication(appKey).then((res) => {
// expect(res.status).to.equal(200);
// });
}
});
});
});

View File

@@ -0,0 +1,198 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Folders', function() {
beforeEach(function() {
cy.login();
});
it('creating a new folder and rename it', () => {
cy.visit('/folders/view');
cy.contains('Root Folder').rightclick();
cy.contains('Create').should('be.visible').click();
cy.visit('/folders/view');
cy.contains('New Folder').should('be.visible').rightclick();
cy.contains('Rename').type('Folder123{enter}');
});
it('Moving an image from Root Folder to another folder', () => {
cy.intercept({
url: '/library?*',
query: {media: 'child_folder_media'},
}).as('mediaGridLoadAfterSearch');
// Go to library
cy.visit('/library/view');
cy.get('#media').type('child_folder_media');
// Wait for the search to complete
cy.wait('@mediaGridLoadAfterSearch');
cy.get('#libraryItems tbody tr').should('have.length', 1);
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({force: true});
cy.get('#libraryItems tr:first-child .library_button_selectfolder').click({force: true});
// 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();
});
it('Sharing', () => {
// Create and alias for load user permissions for folders
cy.intercept({
url: '/user/permissions/Folder/*',
query: {name: 'folder_user'},
}).as('permissionsFoldersAfterSearch');
cy.visit('/folders/view');
cy.contains('ShareFolder').should('be.visible').rightclick();
cy.get('ul.jstree-contextmenu >li:nth-child(6) > a').click(); // Click on Share Link
cy.get('#name').type('folder_user');
cy.wait('@permissionsFoldersAfterSearch');
cy.get('#permissionsTable tbody tr').should('have.length', 1);
cy.get('#permissionsTable tbody tr:nth-child(1) td:nth-child(1)').contains('folder_user');
cy.get('#permissionsTable tbody tr:nth-child(1) td:nth-child(2)> input').click();
cy.get('.save-button').click();
});
it('Set Home Folders for a user', () => {
// Create and alias for load users
cy.intercept({
url: '/user*',
query: {userName: 'folder_user'},
}).as('userGridLoadAfterSearch');
cy.visit('/user/view');
cy.get('#userName').type('folder_user');
cy.wait('@userGridLoadAfterSearch');
cy.get('#users tbody tr').should('have.length', 1);
cy.get('#users tr:first-child .dropdown-toggle').click({force: true});
cy.get('#users tr:first-child .user_button_set_home').click({force: true});
cy.get('#home-folder').should('be.visible');
cy.get('.jstree-anchor:contains(\'FolderHome\')').should('be.visible').click();
cy.get('.save-button').click();
// Check
cy.visit('/user/view');
cy.get('#userName').clear();
cy.get('#userName').type('folder_user');
cy.wait('@userGridLoadAfterSearch');
cy.get('#users tbody tr').should('have.length', 1);
cy.get('#users tbody tr:nth-child(1) td:nth-child(1)').contains('folder_user');
cy.get('#users tbody tr:nth-child(1) td:nth-child(3)').contains('FolderHome');
});
it('Remove an empty folder', () => {
cy.visit('/folders/view');
// Find the EmptyFolder element and right-click on it
cy.get('.jstree-anchor:contains(\'EmptyFolder\')')
.rightclick()
.should('have.class', 'jstree-hovered'); // Ensure the right-click effect
// Find the context menu item with "Remove" text and click on it
cy.contains('Remove').click();
// Validate
cy.visit('/folders/view');
cy.get('.jstree-anchor:contains(\'EmptyFolder\')').should('not.exist');
});
it('cannot remove a folder with content', () => {
cy.visit('/folders/view');
cy.get('.jstree-anchor:contains(\'FolderWithContent\')')
.rightclick();
// Find the context menu item with "Remove" text and click on it
cy.contains('Remove').click();
// Check folder still exists
cy.visit('/folders/view');
cy.get('.jstree-anchor:contains(\'FolderWithContent\')').should('exist');
});
it('search a media in a folder', () => {
// Go to library
cy.visit('/library/view');
cy.get('.jstree-anchor:contains(\'Root Folder\')')
.should('be.visible') // Ensure the element is visible
.parent()
.find('.jstree-icon.jstree-ocl')
.click();
cy.get('.jstree-anchor:contains(\'FolderWithImage\')').click();
cy.get('#libraryItems tbody tr').should('have.length', 1);
cy.get('#libraryItems tbody').contains('media_for_search_in_folder')
.should('be.visible');
});
it('Hide Folder tree', () => {
// Go to library
cy.visit('/library/view');
// The Folder tree is open by default on a grid
cy.get('#folder-tree-select-folder-button').click();
// clicking on the folder icon hides it
cy.get('#grid-folder-filter').should('have.css', 'display', 'none');
});
it('Move folders and Merge', () => {
// Go to folders
cy.visit('/folders/view');
cy.get('.jstree-anchor:contains(\'MoveFromFolder\')').rightclick();
cy.contains('Move Folder').click();
cy.get('#container-folder-form-tree').within(() => {
// Find the "MoveToFolder" link and click it
cy.contains('MoveToFolder').click();
});
cy.get('#merge').should('be.visible').check();
cy.get('.save-button').click();
// Validate test34 image exist in MoveToFolder
cy.visit('/folders/view');
cy.get('.jstree-anchor:contains(\'MoveFromFolder\')').should('not.exist');
// Validate test34 image exist in MoveToFolder
// Go to library
cy.visit('/library/view');
cy.get('.jstree-anchor:contains(\'Root Folder\')')
.should('be.visible') // Ensure the element is visible
.parent()
.find('.jstree-icon.jstree-ocl')
.click();
cy.get('.jstree-anchor:contains(\'MoveToFolder\')').click();
cy.get('#libraryItems tbody').contains('test34');
});
});

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
describe('Modules Page', function () {
beforeEach(function () {
cy.login();
});
it.skip('should load the modules page and show a complete table of modules', function () {
cy.visit('/module/view');
cy.contains('Modules');
// Click on the first page of the pagination
cy.get('.pagination > :nth-child(2) > a').click();
cy.contains('Showing 1 to');
});
});

View File

@@ -0,0 +1,157 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Tags', function() {
let testRun = '';
beforeEach(function() {
cy.login();
testRun = Cypress._.random(0, 1e9);
});
it('should add a tag', function() {
cy.visit('/tag/view');
// Click on the Add Tag button
cy.contains('Add Tag').click();
cy.get('.modal input#name')
.type('Cypress Test Tag ' + testRun + '_1');
// Add first by clicking next
cy.get('.modal .save-button').click();
// Check if tag is added in toast message
cy.contains('Added Cypress Test Tag ' + testRun + '_1');
});
it('searches and edit existing tag', function() {
// Create a new tag and then search for it and delete it
cy.createTag('Cypress Test Tag ' + testRun).then((res) => {
cy.intercept({
url: '/tag?*',
query: {tag: 'Cypress Test Tag ' + testRun},
}).as('loadGridAfterSearch');
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/tag/*',
}).as('putRequest');
cy.visit('/tag/view');
// Filter for the created tag
cy.get('#Filter input[name="tag"]')
.type('Cypress Test Tag ' + testRun);
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#tags tbody tr').should('have.length', 1);
// Click on the first row element to open the delete modal
cy.get('#tags tr:first-child .dropdown-toggle').click({force: true});
cy.get('#tags tr:first-child .tag_button_edit').click({force: true});
cy.get('.modal input#name').clear()
.type('Cypress Test Tag Edited ' + testRun);
// edit test tag
cy.get('.bootbox .save-button').click();
// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;
const tag = responseData.tag;
// assertion on the "tag" value
expect(tag).to.eq('Cypress Test Tag Edited ' + testRun);
});
});
});
it('searches and delete existing tag', function() {
// Create a new tag and then search for it and delete it
cy.createTag('Cypress Test Tag ' + testRun).then((res) => {
cy.intercept({
url: '/tag?*',
query: {tag: 'Cypress Test Tag ' + testRun},
}).as('loadGridAfterSearch');
cy.visit('/tag/view');
// Filter for the created tag
cy.get('#Filter input[name="tag"]')
.type('Cypress Test Tag ' + testRun);
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#tags tbody tr').should('have.length', 1);
// Click on the first row element to open the delete modal
cy.get('#tags tr:first-child .dropdown-toggle').click({force: true});
cy.get('#tags tr:first-child .tag_button_delete').click({force: true});
// Delete test tag
cy.get('.bootbox .save-button').click();
// Check if tag is deleted in toast message
cy.get('.toast').contains('Deleted Cypress Test Tag');
});
});
it('selects multiple tags and delete them', function() {
// Create a new tag and then search for it and delete it
cy.createTag('Cypress Test Tag ' + testRun).then((res) => {
cy.intercept({
url: '/tag?*',
query: {tag: 'Cypress Test Tag'},
}).as('loadGridAfterSearch');
// Delete all test tags
cy.visit('/tag/view');
// Clear filter
cy.get('.clear-filter-btn').click();
cy.get('#Filter input[name="tag"]')
.type('Cypress Test Tag');
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
// Select all
cy.get('button[data-toggle="selectAll"]').click();
// Delete all
cy.get('.dataTables_info button[data-toggle="dropdown"]').click();
cy.get('.dataTables_info a[data-button-id="tag_button_delete"]').click();
cy.get('button.save-button').click();
// Modal should contain one successful delete at least
cy.get('.modal-body').contains(': Success');
});
});
});

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Tasks', function() {
beforeEach(function() {
cy.login();
});
it('should edit a task', function() {
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/task/*',
}).as('putRequest');
cy.visit('/task/view');
// Click on the first row element to open the delete modal
cy.get('#tasks tr:first-child .dropdown-toggle').click({force: true});
cy.get('#tasks tr:first-child .task_button_edit').click({force: true});
// Assuming you have an input field with the id 'myInputField'
cy.get('.modal input#name').invoke('val').then((value) => {
return Cypress.Promise.resolve(value);
}).then((value) => {
if (value) {
cy.get('.modal input#name').clear()
.type(value + ' Edited');
// edit test tag
cy.get('.bootbox .save-button').click();
// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;
// assertion on the "task" value
expect(responseData.name).to.eq(value + ' Edited');
});
}
});
});
});

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Transitions', function() {
beforeEach(function() {
cy.login();
});
it('should edit an transition', function() {
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/transition/*',
}).as('putRequest');
cy.visit('/transition/view');
cy.get('#transitions tbody tr').should('have.length', 3);
// Click on the first row element to open the delete modal
cy.get('#transitions tr:first-child .dropdown-toggle').click({force: true});
cy.get('#transitions tr:first-child .transition_button_edit').click({force: true});
cy.get('.modal #availableAsIn').then(($checkbox) => {
const isChecked = $checkbox.prop('checked');
cy.get('#availableAsIn').should('be.visible').click(); // Click to check/uncheck
// edit
cy.get('.bootbox .save-button').click();
// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;
// assertion on the "task" value
if (isChecked) {
expect(responseData.availableAsIn).to.eq(0);
} else {
expect(responseData.availableAsIn).to.eq(1);
}
});
});
});
});

View File

@@ -0,0 +1,128 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Usergroups', function() {
let testRun = '';
beforeEach(function() {
cy.login();
testRun = Cypress._.random(0, 1e9);
});
it('should add a usergroup', function() {
cy.visit('/group/view');
// Click on the Add Usergroup button
cy.contains('Add User Group').click();
cy.get('.modal input#group')
.type('Cypress Test Usergroup ' + testRun + '_1');
// Add first by clicking next
cy.get('.modal .save-button').click();
// Check if usergroup is added in toast message
cy.contains('Added Cypress Test Usergroup');
});
it('searches and edit existing usergroup', function() {
// Create a new usergroup and then search for it and delete it
cy.createUsergroup('Cypress Test Usergroup ' + testRun).then((groupId) => {
cy.intercept({
url: '/group?*',
query: {userGroup: 'Cypress Test Usergroup ' + testRun},
}).as('loadGridAfterSearch');
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/group/*',
}).as('putRequest');
cy.visit('/group/view');
// Filter for the created usergroup
cy.get('#Filter input[name="userGroup"]')
.type('Cypress Test Usergroup ' + testRun);
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#userGroups tbody tr').should('have.length', 1);
// Click on the first row element to open the delete modal
cy.get('#userGroups tr:first-child .dropdown-toggle').click({force: true});
cy.get('#userGroups tr:first-child .usergroup_button_edit').click({force: true});
cy.get('.modal input#group').clear()
.type('Cypress Test Usergroup Edited ' + testRun);
// edit test usergroup
cy.get('.bootbox .save-button').click();
// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;
// assertion on the "usergroup" value
expect(responseData.group).to.eq('Cypress Test Usergroup Edited ' + testRun);
// Delete the usergroup and assert success
cy.deleteUsergroup(groupId).then((response) => {
expect(response.status).to.equal(200);
});
});
});
});
it('searches and delete existing usergroup', function() {
// Create a new usergroup and then search for it and delete it
cy.createUsergroup('Cypress Test Usergroup ' + testRun).then((groupId) => {
cy.intercept({
url: '/group?*',
query: {userGroup: 'Cypress Test Usergroup ' + testRun},
}).as('loadGridAfterSearch');
cy.visit('/group/view');
// Filter for the created usergroup
cy.get('#Filter input[name="userGroup"]')
.type('Cypress Test Usergroup ' + testRun);
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#userGroups tbody tr').should('have.length', 1);
// Click on the first row element to open the delete modal
cy.get('#userGroups tr:first-child .dropdown-toggle').click({force: true});
cy.get('#userGroups tr:first-child .usergroup_button_delete').click({force: true});
// Delete test usergroup
cy.get('.bootbox .save-button').click();
// Check if usergroup is deleted in toast message
cy.get('.toast').contains('Deleted Cypress Test Usergroup');
});
});
});

View File

@@ -0,0 +1,166 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable max-len */
describe('Users', function() {
let testRun = '';
beforeEach(function() {
cy.login();
testRun = Cypress._.random(0, 1e9);
});
it('should add a user', function() {
cy.intercept({
url: '/user/form/homepages?groupId=1&userTypeId=3*',
query: {},
}).as('loadHomepageAfterSearch');
cy.visit('/user/view');
// Click on the Add User button
cy.contains('Add User').click();
cy.get('.radio input[value="manual"]').click();
cy.get('#onboarding-steper-next-button').click();
cy.get('.modal input#userName')
.type('CypressTestUser' + testRun);
cy.get('.modal input#password')
.type('cypress');
// Error checking - for incorrect email format
cy.get('.modal input#email').type('cypress');
cy.get('.select2-container--bootstrap').eq(1).click();
cy.log('Before waiting for Icon Dashboard element');
cy.wait('@loadHomepageAfterSearch');
cy.get('.select2-results__option')
.should('contain', 'Icon Dashboard')
.click();
// Try saving
cy.get('.modal .save-button').click();
cy.contains('Please enter a valid email address.');
cy.get('.modal input#email').clear().type('cypress@test.com');
// Save
cy.get('.modal .save-button').click();
// Check if user is added in toast message
cy.contains('Added CypressTestUser');
});
it('searches and edit existing user', function() {
// Create a new user and then search for it and delete it
cy.createUser('CypressTestUser' + testRun, 'password', 3, 1).then((id) => {
cy.intercept({
url: '/user?*',
query: {userName: 'CypressTestUser' + testRun},
}).as('loadGridAfterSearch');
// Intercept the PUT request
cy.intercept({
method: 'PUT',
url: '/user/*',
}).as('putRequest');
cy.visit('/user/view');
// Filter for the created user
cy.get('#Filter input[name="userName"]')
.type('CypressTestUser' + testRun);
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#users tbody tr').should('have.length', 1);
// Click on the first row element to open the delete modal
cy.get('#users tr:first-child .dropdown-toggle').click({force: true});
cy.get('#users tr:first-child .user_button_edit').click({force: true});
cy.get('.modal input#userName').clear()
.type('CypressTestUserEdited' + testRun);
cy.get('.modal input#newPassword').clear().type('newPassword');
cy.get('.modal input#retypeNewPassword').clear().type('wrongPassword');
// edit test user
cy.get('.bootbox .save-button').click();
cy.wait('@putRequest')
// Error checking - for password mismatch
cy.contains('Passwords do not match');
cy.get('.modal input#retypeNewPassword').clear().type('newPassword');
// edit test user
cy.get('.bootbox .save-button').click();
// Wait for the intercepted PUT request and check the form data
cy.wait('@putRequest').then((interception) => {
// Get the request body (form data)
const response = interception.response;
const responseData = response.body.data;
// assertion on the "user" value
expect(responseData.userName).to.eq('CypressTestUserEdited' + testRun);
});
// Delete the user and assert success
cy.deleteUser(id).then((res) => {
expect(res.status).to.equal(200);
});
});
});
it('searches and delete existing user', function() {
// Create a new user and then search for it and delete it
cy.createUser('CypressTestUser' + testRun, 'password', 3, 1).then((id) => {
cy.intercept({
url: '/user?*',
query: {userName: 'CypressTestUser' + testRun},
}).as('loadGridAfterSearch');
cy.visit('/user/view');
// Filter for the created user
cy.get('#Filter input[name="userName"]')
.type('CypressTestUser' + testRun);
// Wait for the grid reload
cy.wait('@loadGridAfterSearch');
cy.get('#users tbody tr').should('have.length', 1);
// Click on the first row element to open the delete modal
cy.get('#users tr:first-child .dropdown-toggle').click({force: true});
cy.get('#users tr:first-child .user_button_delete').click({force: true});
// Delete test User
cy.get('.bootbox .save-button').click();
// Check if User is deleted in toast message
cy.get('.toast').contains('Deleted CypressTestUser');
});
});
});