testingautomationcypresse2e-testing

Cypress - Office365 Redirect causes the test to hang on 'Tests are loading'


I am writing a test where user goes to the Settings page of our application, then clicks on 'Connect Calendar'. This opens a new tab and user is on a Cronofy connection page, then I click on 'Office 365', accept the T&C and then the test ends as if it passed and right after that shows 'Your tests are loading...' and waits for "login.live.com"Test run hanging on 'Your tests are loading...'

Here's my code:

describe('Enhanced Interviews: Calendar Connection', () => {
    beforeEach(() => {
        cy.recruitingLogin();
        settingsNav.navigateToSettingsInterviewScheduling();
    });

    it('Recruiter can connect their Calendar', () => {        
        cy.getByAutomationId('calendar-connect-hidden-link').invoke('removeAttr', 'target');
        interviewSchedulingSettings.clickConnectCalendar();
        urlShouldInclude('app.cronofy.com/oauth/');
        cy.get('body').should('contain.text', 'Company Test is using Cronofy to securely access your calendar');
        cy.get('.office365').click();
        cy.get('#account_profile_accept_terms').check();
        cy.contains('input', 'Link Office 365 Account').click();
    });
});

I tried using a Google account instead of using O365 and got a 403 instead of the test hanging. I tried chaining .then() and that didn't help either:

        cy.contains('input', 'Link Office 365 Account').click().then(() => {
            cy.log('hey from .then()');
            cy.get('body').should('contain.text', `Can’t access your account?`)
            urlShouldInclude('login.microsoftonline.com/');
        });

I tried using Chrome and Electron and the same issue occurs.

The issue is similar to Handling "Your tests are loading..." Issue with Cypress After PayPal Login Redirection but it did not have an answer.

Changing the origin didn't help:

cy.origin('https://app.cronofy.com', () => {
    cy.get('.office365').click();
    cy.get('#account_profile_accept_terms').check();
    //This command causes the test to hang on "Your tests are loading..." like before
    cy.contains('input', 'Link Office 365 Account').click();
});

Solution

  • Adding experimentalModifyObstructiveThirdPartyCode: true to the config file fixed the problem. https://docs.cypress.io/guides/references/experiments#Configuration