I found this code for cypress which is ideal for storing cookies and not delegating the test after the first function.
Link from article: https://dzone.com/articles/cypress-preserve-cookies-and-keep-login-session-active-in-tests
Unfortunately, during the execution of the fifth function in my code, the application is logged out.
afterEach(() => {
//Code to Handle the Sesssions in cypress.
//Keep the Session alive when you jump to another test
let str = [];
cy.getCookies().then((cook) => {
cy.log(cook);
for (let l = 0; l < cook.length; l++) {
if (cook.length > 0 && l == 0) {
str[l] = cook[l].name;
Cypress.Cookies.preserveOnce(str[l]);
} else if (cook.length > 1 && l > 1) {
str[l] = cook[l].name;
Cypress.Cookies.preserveOnce(str[l]);
}
}
})
The last function looks like this:
it('Start Creating New Appointment ',function () {
cy.get('.user-box__input .dx-dropdowneditor-icon').first().click()
cy.get('.dx-calendar-contoured-date').click()
cy.get('.user-box__input .dx-dropdowneditor-icon').eq(1).click()
cy.contains('01:30 AM').click()
cy.get('.dx-dropdowneditor-button .dx-button-content').eq(2).click()
cy.wait(1000)
cy.get('.dx-item-content dx-list-item-content').eq(2).click()
cy.get('.dx-dropdowneditor-button .dx-button-content').eq(3).click()
cy.wait(1000)
cy.get('.dx-list-item-content').eq(2).click()
cy.contains('Save').click()
cy.wait(2000)
})