@ -4,7 +4,7 @@ Cypress.on("uncaught:exception", () => {
// ACCOUNTS & USERS
Cypress . Commands . add ( "login" , ( email , password ) => {
cy . visit ( ` ${ Cypress . config ( ) . baseUrl } /builder ` , { timeout : 5 000 } )
cy . visit ( ` ${ Cypress . config ( ) . baseUrl } /builder ` , { timeout : 10 000 } )
cy . wait ( 2000 )
cy . url ( ) . then ( url => {
if ( url . includes ( "builder/admin" ) ) {
@ -210,7 +210,7 @@ Cypress.Commands.add("deleteApp", name => {
cy . get ( ".app-overview-actions-icon" ) . within ( ( ) => {
cy . get ( ".spectrum-Icon" ) . click ( { force : true } )
} )
cy . get ( ".spectrum-Menu" ) . contains ( "Delete" ) . click ( )
cy . get ( ".spectrum-Menu" ) . contains ( "Delete" ) . click ( { force : true } )
cy . get ( ".spectrum-Dialog-grid" ) . within ( ( ) => {
cy . get ( "input" ) . type ( name )
} )
@ -491,26 +491,44 @@ Cypress.Commands.add("selectTable", tableName => {
} )
Cypress . Commands . add ( "addCustomSourceOptions" , totalOptions => {
cy . get ( ".spectrum-ActionButton" )
. contains ( "Define Options" )
. click ( )
. then ( ( ) => {
for ( let i = 0 ; i < totalOptions ; i ++ ) {
// Add radio button options
cy . get ( ".spectrum-Button" )
. contains ( "Add Option" )
. click ( { force : true } )
. then ( ( ) => {
cy . get ( "[placeholder='Label']" , { timeout : 500 } ) . eq ( i ) . type ( i )
cy . get ( "[placeholder='Value']" ) . eq ( i ) . type ( i )
} )
}
// Save options
cy . get ( ".spectrum-Button" ) . contains ( "Save" ) . click ( { force : true } )
} )
cy . get ( '[data-cy="customOptions-prop-control"]' ) . within ( ( ) => {
cy . get ( ".spectrum-ActionButton-label" ) . click ( { force : true } )
} )
for ( let i = 0 ; i < totalOptions ; i ++ ) {
// Add radio button options
cy . get ( ".spectrum-Button-label" , { timeout : 1000 } )
. contains ( "Add Option" )
. click ( { force : true } )
. then ( ( ) => {
cy . get ( "[placeholder='Label']" , { timeout : 500 } ) . eq ( i ) . type ( i )
cy . get ( "[placeholder='Value']" ) . eq ( i ) . type ( i )
} )
}
// Save options
cy . get ( ".spectrum-Button" ) . contains ( "Save" ) . click ( { force : true } )
} )
// DESIGN SECTION
Cypress . Commands . add ( "searchAndAddComponent" , component => {
// Open component menu
cy . get ( ".spectrum-Button" ) . contains ( "Component" ) . click ( { force : true } )
// Search and add component
cy . get ( ".spectrum-Textfield-input" ) . wait ( 500 ) . clear ( ) . type ( component )
cy . get ( ".body" ) . within ( ( ) => {
cy . get ( ".component" )
. contains ( new RegExp ( "^" + component + "$" ) , { timeout : 3000 } )
. click ( { force : true } )
} )
cy . wait ( 1000 )
cy . location ( ) . then ( loc => {
const params = loc . pathname . split ( "/" )
const componentId = params [ params . length - 1 ]
cy . getComponent ( componentId , { timeout : 3000 } ) . should ( "exist" )
return cy . wrap ( componentId )
} )
} )
// DESIGN AREA
Cypress . Commands . add ( "addComponent" , ( category , component ) => {
if ( category ) {
cy . get ( ` [data-cy="category- ${ category } "] ` , { timeout : 3000 } ) . click ( {
@ -546,7 +564,7 @@ Cypress.Commands.add("getComponent", componentId => {
Cypress . Commands . add ( "createScreen" , ( route , accessLevelLabel ) => {
// Blank Screen
cy . contains ( "Design" ) . click ( )
cy . get ( "[aria-label=AddCircle] " ) . click ( )
cy . get ( ".header > .add-button " ) . click ( )
cy . get ( ".spectrum-Modal" ) . within ( ( ) => {
cy . get ( "[data-cy='blank-screen']" ) . click ( )
cy . get ( ".spectrum-Button" ) . contains ( "Continue" ) . click ( { force : true } )
@ -571,7 +589,7 @@ Cypress.Commands.add(
"createDatasourceScreen" ,
( datasourceNames , accessLevelLabel ) => {
cy . contains ( "Design" ) . click ( )
cy . get ( "[aria-label=AddCircle] " ) . click ( )
cy . get ( ".header > .add-button " ) . click ( )
cy . get ( ".spectrum-Modal" ) . within ( ( ) => {
cy . get ( ".item" ) . contains ( "Autogenerated screens" ) . click ( )
cy . get ( ".spectrum-Button" ) . contains ( "Continue" ) . click ( { force : true } )
@ -626,13 +644,60 @@ Cypress.Commands.add(
}
)
Cypress . Commands . add ( "filterScreensAccessLevel" , accessLevel => {
// Filters screens by access level dropdown
cy . get ( ".body" ) . within ( ( ) => {
cy . get ( ".spectrum-Form-item" ) . eq ( 1 ) . click ( )
} )
cy . get ( ".spectrum-Menu" ) . within ( ( ) => {
cy . contains ( accessLevel ) . click ( )
} )
} )
Cypress . Commands . add ( "deleteScreen" , screen => {
// Navigates to Design section and deletes specified screen
cy . contains ( "Design" ) . click ( )
cy . get ( ".body" ) . within ( ( ) => {
cy . contains ( screen )
. siblings ( ".actions" )
. within ( ( ) => {
cy . get ( ".spectrum-Icon" ) . click ( { force : true } )
} )
} )
cy . get ( ".spectrum-Menu > .spectrum-Menu-item > .spectrum-Menu-itemLabel" )
. contains ( "Delete" )
. click ( )
cy . get (
".spectrum-Dialog-grid > .spectrum-ButtonGroup > .confirm-wrap > .spectrum-Button"
) . click ( { force : true } )
cy . get ( ".spectrum-Dialog-grid" , { timeout : 10000 } ) . should ( "not.exist" )
} )
Cypress . Commands . add ( "deleteAllScreens" , ( ) => {
// Deletes all screens
cy . get ( ".body" )
. find ( ".nav-item" )
. its ( "length" )
. then ( len => {
for ( let i = 0 ; i < len ; i ++ ) {
cy . get ( ".body > .nav-item" )
. eq ( 0 )
. invoke ( "text" )
. then ( text => {
cy . deleteScreen ( text . trim ( ) )
} )
}
} )
} )
// NAVIGATION
Cypress . Commands . add ( "navigateToFrontend" , ( ) => {
// Clicks on Design tab and then the Home nav item
cy . wait ( 500 )
cy . contains ( "Design" ) . click ( )
cy . get ( ".spectrum-Search" , { timeout : 2000 } ) . type ( "/" )
cy . get ( ".nav-item" , { timeout : 2000 } ) . contains ( "home" ) . click ( )
cy . get ( ".nav-item" , { timeout : 2000 } ) . contains ( "home" ) . click ( { force : true } )
} )
Cypress . Commands . add ( "navigateToDataSection" , ( ) => {
@ -644,9 +709,11 @@ Cypress.Commands.add("navigateToDataSection", () => {
Cypress . Commands . add ( "navigateToAutogeneratedModal" , ( ) => {
// Screen name must already exist within data source
cy . contains ( "Design" ) . click ( )
cy . get ( "[aria-label=AddCircle] " ) . click ( )
cy . get ( ".header > .add-button " ) . click ( )
cy . get ( ".spectrum-Modal" ) . within ( ( ) => {
cy . get ( ".item" ) . contains ( "Autogenerated screens" ) . click ( )
cy . get ( ".item" , { timeout : 2000 } )
. contains ( "Autogenerated screens" )
. click ( { force : true } )
cy . get ( ".spectrum-Button" ) . contains ( "Continue" ) . click ( { force : true } )
cy . wait ( 500 )
} )