Run critical tests in ever PR (#1945)

* run critical tests after test env deployment

* add cache

* add all branches

* change workflow name

* add run on pull request for testing

* change type

* add run on deployment

* run on copleted

* test critical

* add quote

* change baseUrl

* fix base url

* fix base url

* upload reports

* run in parallel

* save build folder

* remove build from gitignore

* remove build

* update nide version

* last try with parallel

* save build

* save build

* Run critical

* change cypress API url

* run critical in parallel

* check which workflow has lower duration time

* save all reports with container in name

* add reports on failure

* remove reporters

* fix jobs

* merge

* add group name

* run critical

* Refactor critical tests (#1906)

* refactored tag added to purchaseWithProductsTypes, navigation, stocksInCheckout

* homePageAnalitics - refactor

* refactor home page

* refactor creating variants

* refactor adding product without sku to order

* add script to run critical locally

* change tests cases names

* fix names, remove comments, add script to run refactored tests

* remove workflow for parallel

* remove key

* run critical in deploy workflow

* remove workflow

* remove workflow
This commit is contained in:
Karolina Rakoczy 2022-03-23 13:36:30 +04:00 committed by GitHub
parent a5ac6bb92e
commit 74848922dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 5 deletions

View file

@ -110,3 +110,64 @@ jobs:
status: ${{ job.status }}
env_url: https://${{ steps.set-domain.outputs.domain }}/storybook/index.html
deployment_id: ${{ steps.storybook-deployment.outputs.deployment_id }}
cypress-run-critical:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Get API_URI
id: api_uri
# Search for API_URI in PR description and use default if not defined
env:
pull_request_body: ${{ github.event.pull_request.body }}
prefix: API_URI=
pattern: (http|https)://[a-zA-Z0-9.-]+/graphql/?
fallback_uri: ${{ secrets.CYPRESS_API_URI }}
run: |
echo "::set-output name=custom_api_uri::$(echo $pull_request_body | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1 | { read custom_uri; if [ -z "$custom_uri" ]; then echo "$fallback_uri"; else echo "$custom_uri"; fi })"
- name: Get base_URL
id: base_URL
run: |
echo "::set-output name=base_URL::https://$(echo ${GITHUB_HEAD_REF}).dashboard.saleor.rocks"
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm install
- name: Cypress run critical
uses: cypress-io/github-action@v2
env:
API_URI: ${{ steps.api_uri.outputs.custom_api_uri }}
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: ${{ steps.base_URL.outputs.base_URL }}
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
with:
command: npm run cy:run:critical
wait-on: ${{ steps.base_URL.outputs.base_URL }}
- uses: actions/upload-artifact@v1
with:
name: cypress-videos
path: cypress/videos

View file

@ -81,8 +81,13 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
.get("@ProductDetails")
.its("response.body")
.then(resp => {
const productResp = resp.find(element => element.data.product).data
.product;
let productResp;
if (Array.isArray(resp)) {
productResp = resp.find(element => element.data.product).data
.product;
} else {
productResp = resp.data.product;
}
expectCorrectProductInformation(productResp, productData);
});
});
@ -114,8 +119,13 @@ filterTests({ definedTags: ["all", "critical"] }, () => {
.get("@ProductDetails")
.its("response.body")
.then(resp => {
const productResp = resp.find(element => element.data.product).data
.product;
let productResp;
if (Array.isArray(resp)) {
productResp = resp.find(element => element.data.product).data
.product;
} else {
productResp = resp.data.product;
}
expectCorrectProductInformation(productResp, productData);
expectCorrectProductVariantInformation(
productResp.variants,

View file

@ -274,7 +274,7 @@
"cy:open": "cypress open",
"cy:run:critical:locally": "cypress run --env tags=critical --spec 'cypress/integration/navigation.js','cypress/integration/products/createProduct.js', 'cypress/integration/products/productsVariants.js','cypress/integration/checkout/purchaseWithProductTypes.js','cypress/integration/checkout/stocksInCheckout.js' --reporter cypress-mochawesome-reporter --reporter-options reportDir='cypress/reports',overwrite=true,charts=true",
"cy:run:refactored:locally": "cypress run --env tags=refactored --spec 'cypress/integration/navigation.js','cypress/integration/products/createProduct.js', 'cypress/integration/products/productsVariants.js','cypress/integration/checkout/purchaseWithProductTypes.js','cypress/integration/checkout/stocksInCheckout.js' --reporter cypress-mochawesome-reporter --reporter-options reportDir='cypress/reports',overwrite=true,charts=true",
"cy:run:critical": "cypress run --env tags=critical --spec 'cypress/integration/navigation.js','cypress/integration/products/*.js','cypress/integration/checkout/*.js'",
"cy:run:critical": "cypress run --env tags=critical --spec 'cypress/integration/navigation.js','cypress/integration/products/createProduct.js', 'cypress/integration/products/productsVariants.js','cypress/integration/checkout/purchaseWithProductTypes.js','cypress/integration/checkout/stocksInCheckout.js'",
"cy:run:allEnv": "cypress run --env tags=all --record --key 1fe833f5-fca4-4454-ac55-943815b91c6c",
"test:e2e:run": "start-server-and-test start http://localhost:9000 cy:run",
"test:e2e:run:record": "start-server-and-test start http://localhost:9000 cy:run:record",