-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5860 from avalonmediasystem/cypress_charumitra_2
Added more cypress tests, env files
- Loading branch information
Showing
10 changed files
with
460 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,3 +211,5 @@ services: | |
volumes: | ||
- ./:/e2e | ||
- npms:/e2e/node_modules | ||
environment: | ||
- CYPRESS_ENV=${CYPRESS_ENV:-local} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,53 @@ | ||
const { defineConfig } = require("cypress"); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
module.exports = defineConfig({ | ||
env: { | ||
"USERS_ADMINISTRATOR_EMAIL": "[email protected]", | ||
"USERS_ADMINISTRATOR_PASSWORD": "password", | ||
"USERS_USER_EMAIL": "[email protected]", | ||
"USERS_USER_PASSWORD": "password", | ||
"MEDIA_OBJECT_ID": "123456789" | ||
}, | ||
|
||
downloadsFolder: "spec/cypress/downloads", | ||
fixturesFolder: "spec/cypress/fixtures", | ||
screenshotsFolder: "spec/cypress/screenshots", | ||
videosFolder: "spec/cypress/videos", | ||
browser: process.env.BROWSER || 'electron', // | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
|
||
// implement node event listeners here | ||
const environmentName = process.env.CYPRESS_ENV || 'local'; | ||
const environmentFilename = `cypress.env.${environmentName}.json`; | ||
const environmentPath = path.resolve(__dirname, environmentFilename); | ||
|
||
console.log('Environment name: %s', environmentName); | ||
console.log('Environment path: %s', environmentPath); | ||
|
||
if (fs.existsSync(environmentPath)) { | ||
console.log('Loading %s', environmentFilename); | ||
const settings = require(environmentPath); | ||
|
||
// Set baseUrl if defined in the environment settings | ||
if (settings.baseUrl) { | ||
config.baseUrl = settings.baseUrl; | ||
console.log('Loading the baseURL.... %s', config.baseUrl); | ||
} | ||
|
||
// Merge environment variables | ||
if (settings.env) { | ||
config.env = { | ||
...config.env, | ||
...settings.env, | ||
}; | ||
} | ||
|
||
console.log('Loaded settings for environment %s', environmentName); | ||
} else { | ||
console.error(`Environment config file ${environmentFilename} not found`); | ||
} | ||
return config; | ||
}, | ||
baseUrl: "http://localhost:3000", | ||
|
||
supportFile: "spec/cypress/support/e2e.js", | ||
specPattern: "spec/cypress/integration/**/*.js" | ||
}, | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
{ | ||
"baseUrl": "https://avalon-dev.dlib.indiana.edu/", | ||
"env": { | ||
"MEDIA_OBJECT_ID": "fj236208t", | ||
"MEDIA_OBJECT_TITLE":"Beginning Responsibility: Lunchroom Manners", | ||
"SEARCH_COLLECTION":"7.7 regression test", | ||
"USERS_ADMINISTRATOR_EMAIL": "admin_email", | ||
"USERS_ADMINISTRATOR_PASSWORD": "placeholder_password", | ||
"USERS_USER_EMAIL":"user_email", | ||
"USERS_USER_PASSWORD": "placeholder_password", | ||
"USER_MANAGER": "userstudy" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
{ | ||
"baseUrl": "http://localhost:3000", | ||
"env": { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"baseUrl": "https://avalon-staging.dlib.indiana.edu/", | ||
"env": { | ||
"MEDIA_OBJECT_TITLE":"Beginning Responsibility: Lunchroom Manners", | ||
"USERS_ADMINISTRATOR_EMAIL": "admin_email", | ||
"USERS_ADMINISTRATOR_PASSWORD": "placeholder_password", | ||
"USERS_USER_EMAIL":"user_email", | ||
"USERS_USER_PASSWORD": "placeholder_password" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2011-2024, The Trustees of Indiana University and Northwestern | ||
* University. Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed | ||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* --- END LICENSE_HEADER BLOCK --- | ||
*/ | ||
|
||
context('Browse', () => { | ||
it('should use the base URL', () => { | ||
cy.visit('/'); // This will navigate to CYPRESS_BASE_URL | ||
cy.screenshot() | ||
}); | ||
|
||
// checks navigation to Browse | ||
it('.browse_navigation()', () => { | ||
cy.login('administrator') | ||
cy.visit('/') | ||
cy.contains('Browse').click() | ||
}) | ||
|
||
it('Verify searching for an item by keyword - @T9c1158fb', () => { | ||
cy.visit('/') | ||
cy.get("li[class='nav-item'] a[class='nav-link']").click() | ||
//create a dynamic item here and use a portion of it as a search keyword | ||
const media_object_title = Cypress.env('MEDIA_OBJECT_TITLE') | ||
cy.get("input.global-search-input[placeholder='Search this site']").first().type(media_object_title).should('have.value', media_object_title) // Only yield inputs within form | ||
cy.get('button.global-search-submit').first().click() | ||
cy.contains('a', media_object_title) | ||
.should('exist') | ||
.and('be.visible'); | ||
}) | ||
|
||
it('Verify browsing items by a format - @Tb477685f', () => { | ||
cy.visit('/') | ||
cy.get("li[class='nav-item'] a[class='nav-link']").click() | ||
cy.contains('button', 'Format').click() | ||
cy.contains('a', 'Moving Image').click() | ||
cy.get('.constraint-value').within(() => { | ||
cy.get('.filter-value[title="Moving Image"]') | ||
.should('contain.text', 'Moving Image') | ||
.and('be.visible'); | ||
}); | ||
//can assert the filtered items here | ||
}) | ||
|
||
|
||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,15 @@ | |
|
||
context('Collections', () => { | ||
//Since it takes a while for a newly created collection to reflect in search, we are using static search data | ||
const search_collection = Cypress.env('SEARCH_COLLECTION') | ||
const collection_title = `Automation collection title ${Math.floor(Math.random() * 10000) + 1}` | ||
|
||
var search_collection = Cypress.env('SEARCH_COLLECTION') | ||
var collection_title = `Automation collection title ${Math.floor(Math.random() * 10000) + 1}` | ||
|
||
Cypress.on('uncaught:exception', (err, runnable) => { | ||
// Prevents Cypress from failing the test due to uncaught exceptions in the application code - TypeError: Cannot read properties of undefined (reading 'scrollDown') | ||
if (err.message.includes('Cannot read properties of undefined (reading \'success\')')) { | ||
return false; | ||
} | ||
}); | ||
// checks navigation to Browse | ||
it('Verify whether an admin user is able to create a collection - @T553cda51', () => { | ||
cy.login('administrator') | ||
|
@@ -60,12 +65,121 @@ context('Collections', () => { | |
//slice a random portion of the collection title as the search keyword to ensure variablitity in testing | ||
const search_keyword = search_collection.slice(startIndex, startIndex + sliceLength) | ||
cy.get('input[placeholder="Search collections..."]').type(search_keyword).should('have.value', search_keyword) | ||
cy.screenshot('search'); | ||
cy.get('.card-body').contains('a', search_collection); | ||
}) | ||
|
||
|
||
it('Verify whether an admin/manager is able assign other users as managers to the collection - @T3c428871', () => { | ||
cy.login('administrator') | ||
cy.visit('/') | ||
cy.get('#manageDropdown').click() | ||
cy.contains('Manage Content').click() | ||
cy.contains('a', collection_title).click(); | ||
const user_manager = Cypress.env('USER_MANAGER') | ||
cy.get("#add_manager_display").type(user_manager).should('have.value', user_manager) | ||
// Verify that the correct suggestions appear in the dropdown and click it | ||
cy.get('.tt-menu .tt-suggestion') | ||
.should('be.visible') | ||
.and('contain', user_manager).click(); | ||
cy.get('button[name="submit_add_manager"]') | ||
.click(); | ||
|
||
//reload the page to ensure that the data is updated in the backend | ||
cy.reload(true); | ||
|
||
cy.get('table.table-hover') | ||
.find('td.access_list_label') | ||
.contains('label', user_manager) | ||
.should('be.visible'); | ||
|
||
//Additional assertions to add :Login as user_manager and validate that the collection is visible in the "Manage page" and/or API validation | ||
}) | ||
|
||
|
||
|
||
it('Verify changing item access - Collection staff only (New items) - @T9978b4f7', () => { | ||
cy.login('administrator') | ||
cy.visit('/') | ||
cy.get('#manageDropdown').click() | ||
cy.contains('Manage Content').click() | ||
cy.contains('a', collection_title).click(); | ||
cy.get('.item-access').within(() => { | ||
cy.contains('label', 'Collection staff only') | ||
.find('input[type="radio"]').click().should('be.checked'); | ||
cy.get('input[value = "Save Setting"]').click() | ||
}); | ||
//reload the page to ensure that the data is updated in the backend | ||
cy.reload() | ||
cy.contains('label', 'Collection staff only') | ||
.find('input[type="radio"]').should('be.checked'); | ||
|
||
//Add UI and/or API assertions here............Assert via UI by opening the create item page and verifying the default access control | ||
}) | ||
|
||
it('Verify changing item access - Collection staff only (Existing items) - @Tdcf756bd', () => { | ||
cy.login('administrator') | ||
cy.visit('/') | ||
cy.get('#manageDropdown').click() | ||
cy.contains('Manage Content').click() | ||
cy.contains('a', collection_title).click(); | ||
cy.get('.item-access').within(() => { | ||
cy.contains('label', 'Collection staff only') | ||
.find('input[type="radio"]').click().should('be.checked'); | ||
cy.get('input[name = "apply_to_existing"]').click() | ||
}); | ||
|
||
//reload the page to ensure that the data is updated in the backend | ||
cy.reload() | ||
cy.contains('label', 'Collection staff only') | ||
.find('input[type="radio"]').should('be.checked'); | ||
|
||
//Add UI and API assertions here............Assert via UI by opening the an ecisting item within the collection and verifying the default access control | ||
|
||
}) | ||
|
||
it('Verify whether a user is able to update Collection information - @Ta1b2fef8', () => { | ||
cy.login('administrator') | ||
cy.visit('/') | ||
cy.get('#manageDropdown').click() | ||
cy.contains('Manage Content').click() | ||
cy.contains('a', collection_title).click(); | ||
cy.get('.admin-collection-details') | ||
.contains('button', 'Edit Collection Info') | ||
.click(); | ||
|
||
//update description | ||
var updatedDescription = ' Adding more details to collection description' | ||
cy.get('#admin_collection_description').invoke('val').then((existingText) => { | ||
updatedDescription = existingText + updatedDescription; | ||
cy.get('#admin_collection_description').type(updatedDescription); | ||
}); | ||
//update title | ||
var new_title = `Updated automation title ${Math.floor(Math.random() * 10000) + 1}` | ||
cy.get('#admin_collection_name').clear().type(new_title); | ||
|
||
//update contact email | ||
cy.get('#admin_collection_contact_email').clear().type('[email protected]'); | ||
|
||
cy.get('input[value="Update Collection"]').click(); | ||
|
||
// Validate updated collection title and update the collection_title global variable | ||
cy.get('.admin-collection-details h2').should('contain.text', new_title).then(() => { | ||
// Update the global variable collection_title with new_title if the assertion passes | ||
collection_title = new_title; | ||
}); | ||
|
||
// Validate updated contact email | ||
cy.get('.admin-collection-details').within(() => { | ||
cy.get('a[href="mailto:[email protected]"]') | ||
.should('have.text', '[email protected]') | ||
}); | ||
//validate updated description | ||
cy.get('.admin-collection-details .collection-description').should('contain.text', updatedDescription); | ||
|
||
}) | ||
|
||
|
||
//Teardown code : delete the created collection | ||
it('Verify deleting a collection - @T959a56df', () => { | ||
cy.login('administrator') | ||
cy.visit('/') | ||
|
@@ -75,7 +189,7 @@ context('Collections', () => { | |
//May require adding steps to select a collection to move the existing items, when dealing with non empty collections | ||
cy.get('input[value="Yes, I am sure"]').click() | ||
cy.contains('h1', 'My Collections') | ||
//May need to update this assertion to ensire that this is valid during pagination of collections. Another alternative would be to check via API or search My collections | ||
//May need to update this assertion to ensure that this is valid during pagination of collections. Another alternative would be to check via API or search My collections | ||
cy.contains('a', collection_title).should('not.exist'); | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.