Skip to content

Commit

Permalink
[QA] [E2E] Backporting Playwright tests to 3.19 (#4947)
Browse files Browse the repository at this point in the history
* cherry-pick c14402c

* cherry-pick b415834

* cherry-pick c956f35

* cherry pick 621c368

* cherry-pick 7c7c73c

* cherry pick 6f6e5ef

* cherry pick 465aa7b

* cherry-pick 8d30330

* cherry pick 1dcb956

* cherry pick f845150

* cherry pick 563b865

* cherry-pick dbfe9b7

* [E2E] Add tests for translations (#4723)

* add changeset

* add ttest for add and edit translation

* add test for celaring translation

* cherry pick 202b18f

* adding tests for promotion rules (#4722)

* cherry pick a47581e

* [E2E] Fixing flaky e2e tests (#4751)

* adding extra assertion to translation tests

* updating assertion in attribute tests

* modifying assertions for gift card tests

* [E2E] Fixing another batch of flaky tests (#4756)

* updating tests for extra assertions and adding skip to App test

* updating tests for extra assertions

* updating tests for extra assertions and temporarily commenting not working assertions

* adding PW test for readonly Apps access (#4755)

* cherry pick bde2fe8

* add siteSettings basic test (#4759)

* cherry pick ec21ae3

* cherry pick f25bf71

* cherry pick 08b55d4

* cherry pick 5f1ac2a

* cherry pick ae560bf

* cherry pick 024f2d0

* [E2E] Tests for product types (#4757)

* initial commit with changelog

* add test for update product type

* add test to delete several product types

* add test to remove product type with asigned product

* fix numering and assertion after removing types

* typo

* update test data

* add assertions

* [E2E] Use dummy app in delete app test (#4789)

* replace app

* update test data

* fixing flaky gift cards tests (#4785)

* cherry pick 2b0f760

* updating and removing gh workflows and actions (#4823)

* adding back tests-nightly workflow (#4827)

* cherry pick cb5988f

* cherry pick 7b7f222

* cherry pick a6ed457

* cherry pick 6c5be66

* Fix flaky test - TC: SALEOR_205 Bulk delete customers (#4845)

* cherry pick be40ffd

* cherry pick f6d44a9

* cherry pick 06678d0

* cherry pick 618bb01

* cherry pick dd8d60a

* cherry pick 70b2c40

* cherry pick c956f35

* cherry pick b415834

* cherry pick c14402c

* updating test data

* changeset

* updating gh action

* testing snapshot data

---------

Co-authored-by: wojteknowacki <124166231+wojteknowacki@users.noreply.github.com>
Co-authored-by: Karolina Rakoczy <karolina.rakoczy@saleor.io>
Co-authored-by: Anna Szczęch <30683248+szczecha@users.noreply.github.com>
Co-authored-by: M.Graczyk <michalina.graczyk@saleor.io>
  • Loading branch information
5 people committed Jun 26, 2024
1 parent 585c495 commit 6f91338
Show file tree
Hide file tree
Showing 192 changed files with 5,181 additions and 1,222 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-moons-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now run Playwright tests on the 3.19 version
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ CYPRESS_USER_PASSWORD=xxxx
CYPRESS_SECOND_USER_NAME=xxxx
CYPRESS_PERMISSIONS_USERS_PASSWORD=xxxx
CYPRESS_baseUrl=http://localhost:9000/
CYPRESS_MAILPITURL=xxxx
CYPRESS_MAILPITURL=xxxx
MAILPITURL=xxxx #For playwright

E2E_USER_NAME=xxxx
E2E_USER_PASSWORD=xxxx
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/prepare-instance/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ runs:
--domain="$INSTANCE_NAME" \
--skip-restrict \
--skip-webhooks-update
- name: Add client origins
shell: bash
if: ${{!contains(inputs.BASE_URL, inputs.POOL_INSTANCE) && !steps.instance_check.outputs.INSTANCE_KEY }} # Add base url as a trusted origins if we're using deployed dashboard in repo (saleor.rocks)
env:
POOL_NAME: ${{ inputs.POOL_NAME }}
BASE_URL: ${{ inputs.BASE_URL }}
run: |
npx saleor env origins "$POOL_NAME" --origins="$BASE_URL"
6 changes: 3 additions & 3 deletions .github/actions/prepare-tests-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ runs:
uses: ./.github/actions/prepare-api-variables
with:
MODE: ${{ inputs.MODE }}
VERSION: ${{ inputs.VERSION || ''}}
VERSION: ${{ inputs.VERSION || ''}}

- name: Generate backup
id: backup
uses: ./.github/actions/prepare-backups-variables
Expand All @@ -79,4 +79,4 @@ runs:
echo "::notice title=POOL_INSTANCE::${POOL_INSTANCE}"
echo "::notice title=BACKUP_NAMESPACE::${BACKUP_NAMESPACE}"
echo "::notice title=SNAPSHOT::backup_id=${BACKUP_ID}, version=${BACKUP_VER}, name=${BACKUP_NAME}"
echo "::notice title=SALEOR_CLOUD_SERVICE::${SALEOR_CLOUD_SERVICE}"
echo "::notice title=SALEOR_CLOUD_SERVICE::${SALEOR_CLOUD_SERVICE}"
17 changes: 14 additions & 3 deletions .github/actions/run-pw-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ inputs:
MAILPITURL:
description: "mailpit uri"
required: true
URL_TO_RUN:
URL_TO_RUN:
description: "Url which will be passed to testmo where can be found artifacts of the run"
required: false
PW_WORKERS:
description: "Playwright workers"
required: true
PW_RETRIES:
description: "Playwright retries"
required: true

runs:
using: "composite"
Expand All @@ -44,14 +50,19 @@ runs:
- name: Run tests
shell: bash
env:
## backward compatibility for older versions
API_URI: ${{ inputs.API_URL }}

API_URL: ${{ inputs.API_URL }}
BASE_URL: ${{ inputs.BASE_URL }}
E2E_USER_NAME: ${{ inputs.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ inputs.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ inputs.E2E_PERMISSIONS_USERS_PASSWORD }}
SHARD_NUMBER: ${{ inputs.SHARD }}
MAILPITURL: ${{ inputs.MAILPITURL }}
URL_TO_RUN: ${{ inputs.URL_TO_RUN }}
MAILPITURL: ${{ inputs.MAILPITURL }}
URL_TO_RUN: ${{ inputs.URL_TO_RUN }}
WORKERS: ${{ inputs.PW_WORKERS }}
RETRIES: ${{ inputs.PW_RETRIES }}
run: npm run qa:pw-e2e -- --shard "$SHARD_NUMBER"

- name: Upload blob report to GitHub Actions Artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependency-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
current_state:
runs-on: ubuntu-latest
name: "Calculate current state"
outputs:
outputs:
main_statistics: ${{ steps.store_import_stats.outputs.MAIN_STATISTICS }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -55,4 +55,4 @@ jobs:
if: ${{ env.IMPORT_DIFFERENCE <= 0 }}
run: |
echo "Progress by: ${{ env.IMPORT_DIFFERENCE }} imports"
exit 0
exit 0
8 changes: 1 addition & 7 deletions .github/workflows/postTestsResults.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { Command } = require("commander");
const program = new Command();
const core = require("@actions/core");
const { Octokit } = require("@octokit/core");

program
Expand Down Expand Up @@ -30,10 +29,6 @@ program
options.ref_name,
);

core.setOutput("status", testsStatus.status.toLowerCase());
core.setOutput("message", testsStatus.message.replaceAll(/\n/g, ""));
core.setOutput("linkToResults", testsStatus.linkToResults);

await sendMessageOnSlack(
testsStatus,
options.slack_webhook_url,
Expand All @@ -56,8 +51,7 @@ async function getTestsStatus(runId, testmoToken) {

function convertResults(results, environment, refName) {
let status = results?.result?.status === 2 ? "SUCCESS" : "FAILURE";
let message = `Tests run on environment: \n${environment} \n`;

let message = `Tests run on environment: \n${environment}\n`;
const linkToResults = `https:\/\/saleor.testmo.net\/automation\/runs\/view\/${results.result.id}`;
const threads = results.result.threads;

Expand Down
45 changes: 39 additions & 6 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: PR automation

on: [pull_request]
on:
pull_request:
workflow_dispatch:
inputs:
shards:
type: number
description: 'Number of shards to use for parallel testing'
required: false
default: 2 # This is the default only for manually (re-)triggered runs. Default for runs triggered by pull requests is configured via `jobs.initialize-cloud.generate-shard-matrix.env.CONCURRENCY`.

concurrency:
group: ${{ github.ref }}
Expand All @@ -18,6 +26,7 @@ jobs:
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}
BACKUP_VER: ${{ steps.cloud_variables.outputs.BACKUP_VER }}
BACKUP_NAME: ${{ steps.cloud_variables.outputs.BACKUP_NAME }}
SHARD_MATRIX: ${{ steps.generate-shard-matrix.outputs.SHARD_MATRIX }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -42,6 +51,23 @@ jobs:
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}
SALEOR_CLOUD_SERVICE: ${{ steps.cloud_variables.outputs.SALEOR_CLOUD_SERVICE }}

- name: Generate shard matrix
id: generate-shard-matrix
env:
CONCURRENCY: ${{ inputs.shards || 2 }}
run: |
MAX_CONCURRENCY=4
if [ "$CONCURRENCY" -gt "$MAX_CONCURRENCY" ]; then
echo "[WARN] The requested number of shards ($CONCURRENCY) exceeds maximum allowed value ($MAX_CONCURRENCY). Using $MAX_CONCURRENCY shards instead." >&2
CONCURRENCY=$MAX_CONCURRENCY
fi
shard_matrix=() # Initialize an empty array to store the shard values.
for i in $(seq 1 "$CONCURRENCY"); do # Loop through the numbers from 1 to $CONCURRENCY.
shard_matrix+=("\"$i/$CONCURRENCY\"") # For each number i, append a string in the format "${i}/${CONCURRENCY}" to the shard_matrix array.
done
shard_matrix=( $(IFS=,; echo "[${shard_matrix[*]}]") ) # Join the elements of the shard_matrix array with commas and wrap the result in square brackets to create a valid JSON array string.
echo "SHARD_MATRIX=${shard_matrix[0]}" >> "$GITHUB_OUTPUT"
deploy-dashboard:
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -82,7 +108,10 @@ jobs:

- name: Build dashboard
env:
## backward compatibility for older versions
API_URI: ${{ needs.initialize-cloud.outputs.API_URL }}

API_URL: ${{ needs.initialize-cloud.outputs.API_URL }}
APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps"
APP_MOUNT_URI: /
STATIC_URL: /
Expand Down Expand Up @@ -119,13 +148,14 @@ jobs:
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ needs.initialize-cloud.outputs.POOL_NAME }}


run-tests:
runs-on: ubuntu-22.04
needs: [initialize-cloud, deploy-dashboard]
strategy:
fail-fast: false
matrix:
shard: [1/2, 2/2]
shard: ${{ fromJson(needs.initialize-cloud.outputs.SHARD_MATRIX) }}
steps:
- uses: actions/checkout@v4

Expand All @@ -135,9 +165,12 @@ jobs:
SHARD: ${{ matrix.shard }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
API_URL: ${{ needs.initialize-cloud.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
PW_RETRIES: ${{ vars.PW_RETRIES }}

merge-reports:
if: "!cancelled()"
Expand All @@ -147,4 +180,4 @@ jobs:
- uses: actions/checkout@v4

- name: Merge playwright reports
uses: ./.github/actions/merge-pw-reports
uses: ./.github/actions/merge-pw-reports
16 changes: 9 additions & 7 deletions .github/workflows/run-test-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ jobs:
SHARD: ${{ matrix.shard }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
API_URL: ${{ needs.initialize-cloud.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
PW_RETRIES: ${{ vars.PW_RETRIES }}
URL_TO_RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

- name: submit-results-to-testmo
Expand All @@ -97,7 +99,7 @@ jobs:

- name: Merge playwright reports
uses: ./.github/actions/merge-pw-reports

- name: complete testmo report
uses: ./.github/actions/testmo/testmo-finish
with:
Expand All @@ -122,6 +124,6 @@ jobs:
--slack_webhook_url "$slack_webhook_url" \
--environment "$environment" \
--url_to_action "$url_to_action" \
--ref_name "$ref_name"
--ref_name "$ref_name"
16 changes: 9 additions & 7 deletions .github/workflows/run-test-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4
with:
sparse-checkout: ./.github/actions

- name: Set variables mode
id: set_variables_mode
shell: bash
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
testmoToken: ${{ secrets.TESTMO_TOKEN }}
testmoRunName: "Playwright run ${{github.ref_name}}"
id: init-testmo

run-tests:
runs-on: ubuntu-22.04
needs: ["initialize-cloud", "create-run-on-testmo"]
Expand All @@ -81,10 +81,12 @@ jobs:
SHARD: ${{ matrix.shard }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
API_URL: ${{ needs.initialize-cloud.outputs.API_URL }}
E2E_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
E2E_USER_NAME: ${{ secrets.E2E_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.E2E_PERMISSIONS_USERS_PASSWORD }}
MAILPITURL: ${{ secrets.MAILPITURL }}
PW_WORKERS: ${{ vars.PW_WORKERS }}
PW_RETRIES: ${{ vars.PW_RETRIES }}
URL_TO_RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

- name: submit-results-to-testmo
Expand Down Expand Up @@ -129,4 +131,4 @@ jobs:
--slack_webhook_url "$slack_webhook_url" \
--environment "$environment" \
--url_to_action "$url_to_action" \
--ref_name "$ref_name"
--ref_name "$ref_name"
22 changes: 2 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6f91338

Please sign in to comment.