Codecept + Playwright

Hi
We are having Azure AD Authentication in an app. So an user is presented with login.microsoft page and after that the user is redirected to the application home page.

How do we go about automating this with Codecept using Playwright as the helper?

I’ve did this with autoLogin plugin. Facing some issues with clicking in the Sign In button, which ends up failing in the first time and only working on the second attempt. Overall it seems to be fine.

    async loginUser(username: string, pass: string, authPartialUri: string) {
      const currentUrl = await this.grabCurrentUrl();
      const isLoginPage = currentUrl.includes(authPartialUri);
      if (isLoginPage) {
          await this.fillField('Email, phone, or Skype', username);
          await this.click('Next');
          await this.waitForText('Enter password', 5);
          await this.fillField(locate('//*[@name="passwd"]'), pass);
          await this.click('Sign in');
      }
    }