cypress-io / github-action

GitHub Action for running Cypress end-to-end & component tests
https://on.cypress.io/guides/continuous-integration/github-actions
MIT License
1.35k stars 357 forks source link

Unable to redirect to microsoft sso login page from app url when running cypress feature file using github action #1214

Closed asagarelse closed 1 month ago

asagarelse commented 1 month ago

Unable to redirect to company's microsoft sso login page from app url when running cypress feature file using github action however it works fine locally.

Screenshot 2024-07-11 at 11 19 17 AM

Error log snippet: 1) User Profile Screen Validation Validate User Profile Popup Screen appears for a registered sso user:@ssoUser1 **CypressError: Timed out after waiting 120000ms for your remote page to load.

Your page did not fire its load event within 120000ms.

You can try increasing the pageLoadTimeout value in __w/app/app/cypress.config.js to wait longer.

Browsers will not fire the load event until all stylesheets and scripts are done downloading.

When this load event occurs, Cypress will continue running commands.**

Redirect url: https://login.microsoftonline.com/<>.onmicrosoft.com/oauth2/v2.0/authorize?login_hint=&prompt=select_account&response_type=code&client_id=<>&redirect_uri=https%3A%2F%2Fsso-dev.<>.com%2Flogin%2Fcallback&nonce=<>&scope=openid%20profile%20email%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20https%3A%2F%2Fgraph.microsoft.com%2FDirectory.Read.All&state=<>&sso_reload=true

Screenshot 2024-07-11 at 11 07 04 AM

Please do let us know if you need additional inputs. Thank you

MikeMcC399 commented 1 month ago

@asagarelse

Please post your GitHub Actions workflow.

asagarelse commented 1 month ago

Hello @MikeMcC399 , Thanks for the response, much appreciable! Here is the GitHub Actions workflow *.yaml file

name: Run Feature Test
on:
  workflow_dispatch:
    inputs:
      ENV:
        type: choice
        description: 'Environment'
        required: true
        default: DEV
        options:
          - DEV
      RUNNER:
        type: choice
        description: runner
        required: true
        default: deploy-eks
        options:
          - self-hosted
          - ephemeral
          - deploy-eks
      FEATURE:
        type: choice
        description: feature to be run
        required: true
        options:
          - UserProfile
          - Users
      BROWSER:
        type: choice
        description: browser
        required: true
        headed: true
        default: chrome
        options:
          - chrome
          - electron
          - firefox
      StartAPP:
        type: choice
        description: Starting Application
        required: true
        default: app
        options:
          - app

jobs:
  cypress-test-run:
    name: Execute Test-${{ inputs.FEATURE }}
    runs-on: [self-hosted, ephemeral, '${{ inputs.RUNNER }}']
    container:
      image: cypress/included:13.10.0
      options: -u root -e AWS_STS_REGIONAL_ENDPOINTS -e AWS_DEFAULT_REGION -e AWS_REGION -e AWS_ROLE_ARN -e AWS_WEB_IDENTITY_TOKEN_FILE
      volumes:
        - /var/run//test/123/secrets/eks.amazonaws.com/serviceaccount:/var/run/test/123/secrets/eks.amazonaws.com/serviceaccount

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Get AWS Secrets
        id: secrets
        uses: ./.github/actions/fetchAWS-Secrets

      - name: Build and Run Tests
        shell: bash
        run: |
          export $SECRETS_ENV

          npm ci
          npx cypress run --spec 'cypress/e2e/features/${{ inputs.FEATURE }}.feature' --browser ${{ inputs.BROWSER }} -e StartAPP='${{ inputs.StartAPP }}',ENV='${{ inputs.ENV }}',RunFrom='CI'

      - name: Upload json
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: json-report-${{ inputs.FEATURE }}
          path: |
            cypress/cucumber-json/${{ inputs.FEATURE }}.cucumber.json
            cypress/screenshots/

  generateReport:
    name: Generate HTML Report
    needs: cypress-test-run
    if: always()
    runs-on: ${{ inputs.RUNNER }}
    container:
      image: cypress/included:13.6.0
      options: -u root -e AWS_STS_REGIONAL_ENDPOINTS -e AWS_DEFAULT_REGION -e AWS_REGION -e AWS_ROLE_ARN -e AWS_WEB_IDENTITY_TOKEN_FILE
      volumes:
        - /var/run/secrets/eks.amazonaws.com/serviceaccount:/var/run/secrets/eks.amazonaws.com/serviceaccount

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setting Permissions
        run: |
          chmod -R a+rwx /__w/app/app
          npm ci

      - uses: actions/download-artifact@v4
        with:
          path: /__w/app/app/cypress/cucumber-json

      - name: Display structure of downloaded files
        run: ls -R

      - name: Generate Report
        uses: ./.github/actions/generate-Report
MikeMcC399 commented 1 month ago

@asagarelse

Thank you for providing your GitHub Actions workflow, which shows that you are running Cypress on a self-hosted runner using a shell command. You are not using the Cypress JavaScript GitHub Action cypress-io/github-action:

runs-on: [self-hosted, ephemeral, '${{ inputs.RUNNER }}']
...
steps:
npx cypress run --spec 'cypress/e2e/features/${{ inputs.FEATURE }}.feature' --browser ${{ inputs.BROWSER }} -e StartAPP='${{ inputs.StartAPP }}',ENV='${{ inputs.ENV }}',RunFrom='CI'

This issue list is for reporting bugs in cypress-io/github-action or for enhancement requests to the action. It is not for general issues regarding using Cypress under GitHub Actions. Your problem belongs into the second category and so this issue needs to be closed.

I hope you can find somebody on Discord to help you. You might need to share the test code which is failing. Good luck!