Skip to content

Commit

Permalink
enh(tests): upgrade cypress and fix flaky tests (#4170)
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret authored and tuntoja committed Jun 12, 2024
1 parent b1dbfb3 commit 787d36a
Show file tree
Hide file tree
Showing 52 changed files with 3,253 additions and 2,286 deletions.
71 changes: 0 additions & 71 deletions .github/actions/merge-artifacts/action.yml

This file was deleted.

21 changes: 11 additions & 10 deletions .github/workflows/behat-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ jobs:
matrix:
type_of_report: [test-logs, test-reports]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Merging Artifacts
uses: ./.github/actions/merge-artifacts
- name: Merge Artifacts
uses: actions/upload-artifact/merge@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ contains(needs.behat-test-run.result, 'failure') }}
with:
target_name: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}
source_paths: |
${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}/**/*.xml
${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}/**/*.txt
source_name_pattern: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}-
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}
pattern: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}-*
retention-days: 1

- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1 # v5.0.0
with:
name: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}-*
failOnError: false
20 changes: 12 additions & 8 deletions .github/workflows/cypress-component-parallelization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,17 @@ jobs:
matrix:
type_of_report: [test-results, test-reports, test-coverage]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Merging Artifacts
uses: ./.github/actions/merge-artifacts
- name: Merge Artifacts
uses: actions/upload-artifact/merge@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ ( contains(needs.cypress-component-test-run.result, 'failure') && ( matrix.type_of_report == 'test-reports' ) ) || matrix.type_of_report == 'test-coverage' }}
with:
target_name: ${{ inputs.name }}-${{ matrix.type_of_report }}
source_paths: ${{ inputs.name }}-${{ matrix.type_of_report }}/**
source_name_pattern: ${{ inputs.name }}-${{ matrix.type_of_report }}-
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ inputs.name }}-${{ matrix.type_of_report }}
pattern: ${{ inputs.name }}-${{ matrix.type_of_report }}-*
delete-merged: false # cannot be set to true due to random fails: Failed to DeleteArtifact: Unable to make request: ECONNRESET
retention-days: 1

- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1 # v5.0.0
with:
name: ${{ inputs.name }}-${{ matrix.type_of_report }}-*
failOnError: false
20 changes: 12 additions & 8 deletions .github/workflows/cypress-e2e-parallelization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,17 @@ jobs:
matrix:
type_of_report: [test-results, test-reports, xray-reports]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Merging Artifacts
uses: ./.github/actions/merge-artifacts
- name: Merge Artifacts
uses: actions/upload-artifact/merge@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ ( contains(needs.cypress-e2e-test-run.result, 'failure') && ( matrix.type_of_report == 'test-results' || matrix.type_of_report == 'test-reports' ) ) || matrix.type_of_report == 'xray-reports' }}
with:
target_name: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}
source_paths: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}/**
source_name_pattern: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}-
github_token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}
pattern: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}-*
delete-merged: false # cannot be set to true due to random fails: Failed to DeleteArtifact: Unable to make request: ECONNRESET
retention-days: 1

- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1 # v5.0.0
with:
name: ${{ inputs.name }}-${{ inputs.os }}-${{ matrix.type_of_report }}-*
failOnError: false
19 changes: 11 additions & 8 deletions .github/workflows/newman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,16 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Merging Artifacts
uses: ./.github/actions/merge-artifacts
- name: Merge Artifacts
uses: actions/upload-artifact/merge@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: ${{ contains(needs.newman-test-run.result, 'failure') }}
with:
target_name: postman-html-reports
source_paths: postman-html-reports/**/*.html
source_name_pattern: postman-html-reports-
github_token: ${{ secrets.GITHUB_TOKEN }}
name: postman-html-reports
pattern: postman-html-reports-*
retention-days: 1

- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1 # v5.0.0
with:
name: postman-html-reports-*
failOnError: false
2 changes: 1 addition & 1 deletion centreon/config/features.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"notification" : 2,
"notification": 2,
"dashboard": 3,
"map_visx_viewer": 0,
"vault": 0,
Expand Down
6 changes: 5 additions & 1 deletion centreon/packages/js-config/cypress/e2e/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import './commands/monitoring';

import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector';

installLogsCollector({ enableExtendedCollector: true });
installLogsCollector({
commandTimings: 'seconds',
enableExtendedCollector: true
});

const apiBase = '/centreon/api';
const apiActionV1 = `${apiBase}/index.php`;
Expand Down Expand Up @@ -260,6 +263,7 @@ Cypress.Commands.add(
return cy.get('.MuiAlert-message').then(($snackbar) => {
if ($snackbar.text().includes('Login succeeded')) {
cy.wait('@getNavigationList');
cy.get('.MuiAlert-message').should('not.be.visible');
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions centreon/packages/js-config/cypress/e2e/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ export default ({
requestTimeout: 20000,
retries: 0,
screenshotsFolder: `${resultsFolder}/screenshots`,
video: true,
video: isDevelopment,
videoCompression: 0,
videosFolder: `${resultsFolder}/videos`
videosFolder: `${resultsFolder}/videos`,
viewportHeight: 1080,
viewportWidth: 1920
});
};
4 changes: 2 additions & 2 deletions centreon/packages/js-config/cypress/e2e/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export default (

// force screen to be non-retina and just use our given resolution
launchOptions.args.push('--force-device-scale-factor=1');
}

launchOptions.args.push(`--window-size=${width},${height}`);
launchOptions.args.push(`--window-size=${width},${height}`);
}

return launchOptions;
});
Expand Down
12 changes: 6 additions & 6 deletions centreon/packages/js-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"prettier": "^3.0.0"
},
"dependencies": {
"@badeball/cypress-cucumber-preprocessor": "^20.0.1",
"@badeball/cypress-cucumber-preprocessor": "^20.0.5",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
Expand All @@ -30,9 +30,9 @@
"@types/cypress-cucumber-preprocessor": "^4.0.5",
"cypress": "^13.6.4",
"cypress-multi-reporters": "^1.6.4",
"cypress-terminal-report": "^6.0.0",
"cypress-terminal-report": "^6.0.2",
"cypress-wait-until": "^3.0.1",
"dotenv": "^16.4.1",
"dotenv": "^16.4.5",
"esbuild": "^0.20.0",
"eslint": "^8.53.0",
"eslint-config-airbnb": "19.0.4",
Expand All @@ -52,8 +52,8 @@
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"mochawesome": "^7.1.3",
"mysql2": "^3.9.1",
"tar-fs": "^3.0.4",
"testcontainers": "^10.7.1"
"mysql2": "^3.9.7",
"tar-fs": "^3.0.6",
"testcontainers": "^10.9.0"
}
}
Loading

0 comments on commit 787d36a

Please sign in to comment.