From 4d1e41517d13d9e5007957e0ca72ca6d3327b0e1 Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Tue, 25 Oct 2022 19:27:26 +0200 Subject: [PATCH] In old release versions run small package of most important tests (#2379) * In old version release run small package of most important tests * add to releases tests for stocks, warehouses and orders * Update .github/workflows/tests-nightly.yml Co-authored-by: Mika <6186720+NyanKiyoshi@users.noreply.github.com> * remove set-output command Co-authored-by: Mika <6186720+NyanKiyoshi@users.noreply.github.com> --- ...aseTests.js => getEnvironmentVariables.js} | 28 ++++++++++++- .github/workflows/tests-nightly.yml | 42 +++++++++++++------ cypress/e2e/apps.js | 2 +- cypress/e2e/catalog/categories.js | 2 +- cypress/e2e/catalog/collections.js | 2 +- .../e2e/checkout/purchaseWithProductTypes.js | 4 +- cypress/e2e/checkout/stocksInCheckout.js | 6 +-- cypress/e2e/checkout/warehouses.js | 2 +- .../attributes/createProductAttributes.js | 2 +- cypress/e2e/configuration/customer.js | 2 +- .../productTypes/createProductType.js | 2 +- .../shippingMethods/createShippingMethod.js | 6 +-- .../e2e/configuration/warehouses/warehouse.js | 2 +- cypress/e2e/homePage/homePage.js | 6 +-- cypress/e2e/login.js | 2 +- cypress/e2e/navigation.js | 4 +- cypress/e2e/orders/orders.js | 8 ++-- cypress/e2e/products/createProduct.js | 4 +- cypress/e2e/products/productsVariants.js | 4 +- 19 files changed, 83 insertions(+), 47 deletions(-) rename .github/workflows/{getUrlForReleaseTests.js => getEnvironmentVariables.js} (80%) diff --git a/.github/workflows/getUrlForReleaseTests.js b/.github/workflows/getEnvironmentVariables.js similarity index 80% rename from .github/workflows/getUrlForReleaseTests.js rename to .github/workflows/getEnvironmentVariables.js index 23a1ad8b2..a55068264 100644 --- a/.github/workflows/getUrlForReleaseTests.js +++ b/.github/workflows/getEnvironmentVariables.js @@ -1,6 +1,7 @@ const { Command } = require("commander"); const core = require("@actions/core"); const fetch = require("node-fetch"); +const { Octokit } = require("@octokit/core"); const program = new Command(); @@ -10,8 +11,10 @@ program .option("--version ", "version of a project") .option("--token ", "token fo login to cloud") .action(async options => { + const isOldVersion = await checkIfOldVersion(options.version); + core.setOutput("IS_OLD_VERSION", isOldVersion); + if (!isPatchRelease(options.version)) { - const environmentId = "2dPjdMTU"; const taskId = await updateEnvironment( environmentId, options.version, @@ -63,7 +66,7 @@ async function updateEnvironment(environmentId, version, token) { return responseInJson.task_id; } -async function waitUntilTaskInProgress(taskId, token, throwErrorAfterTimeout) { +async function waitUntilTaskInProgress(taskId, token) { const response = await fetch( `https://staging-cloud.saleor.io/api/service/task-status/${taskId}/`, { @@ -119,3 +122,24 @@ async function getDomainForUpdatedEnvironment(environmentId, token) { const responseInJson = await response.json(); return responseInJson.domain; } + +async function checkIfOldVersion(version) { + const newestVersion = await getTheNewestVersion(); + const howManyVersionsBehind = + getFormattedVersion(newestVersion) - getFormattedVersion(version); + //All versions besides last three are old versions + return howManyVersionsBehind > 2 ? "true" : "false"; +} + +async function getTheNewestVersion() { + const octokit = new Octokit(); + + const response = await octokit.request( + "GET /repos/{owner}/{repo}/releases/latest", + { + owner: "saleor", + repo: "saleor-dashboard", + }, + ); + return response.data["tag_name"]; +} diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index 7a9a66c7d..4b428cb6f 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -12,6 +12,7 @@ on: - '@allEnv' - '@critical' - '@stable' + - '@oldRelease' environment: required: true description: 'Environment to run tests against' @@ -97,7 +98,7 @@ jobs: fail-fast: false matrix: # run copies of the current job in parallel - containers: [1, 2, 3, 4] + containers: [1, 2, 3, 4, 5, 6, 7, 8, 9] steps: - name: Checkout uses: actions/checkout@v3 @@ -145,12 +146,13 @@ jobs: record: true tag: ${{ steps.get-env-uri.outputs.ENV_URI }},${{ github.event.inputs.tags }} - get-url: + get-environment-variables: if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}} runs-on: ubuntu-latest timeout-minutes: 30 outputs: - url: ${{ steps.get-url.outputs.url }} + url: ${{ steps.get-environment-variables.outputs.url }} + is_old_version: ${{ steps.get-environment-variables.outputs.IS_OLD_VERSION }} env: TOKEN: ${{ secrets.CLOUD_ACCESS_TOKEN }} VERSION: ${{github.event.client_payload.version}} @@ -168,16 +170,16 @@ jobs: cd .github/workflows npm ci - - name: get-url - id: get-url + - name: get environment variables + id: get-environment-variables run: | - node .github/workflows/getUrlForReleaseTests.js \ + node .github/workflows/getEnvironmentVariables.js \ --version $VERSION \ --token "$TOKEN" run-tests-on-release: if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}} - needs: get-url + needs: get-environment-variables runs-on: ubuntu-latest outputs: status: ${{ steps.cypress.outcome }} @@ -187,7 +189,7 @@ jobs: fail-fast: false matrix: # run copies of the current job in parallel - containers: [1, 2, 3, 4, 5, 6] + containers: [1, 2, 3, 4, 5, 6, 7, 8, 9] steps: - name: Get branch @@ -201,15 +203,28 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ steps.branch.outputs.ref }} + + - name: Set tag for tests + id: set-tag-for-tests + env: + is_old_version: ${{ needs.get-environment-variables.outputs.is_old_version }} + old_version_test_tag: "@oldRelease" + new_version_test_tag: "@stable" + run: | + if [[ $is_old_version == "true" ]]; then + echo "TEST_TAG=$old_version_test_tag" >> $GITHUB_OUTPUT + else + echo "TEST_TAG=$new_version_test_tag" >> $GITHUB_OUTPUT + fi - name: Cypress run - automatically id: cypress continue-on-error: true uses: cypress-io/github-action@v4 env: - API_URI: ${{ needs.get-url.outputs.url }}graphql/ + API_URI: ${{ needs.get-environment-variables.outputs.url }}graphql/ APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} - CYPRESS_baseUrl: ${{ needs.get-url.outputs.url }}dashboard/ + CYPRESS_baseUrl: ${{ needs.get-environment-variables.outputs.url }}dashboard/ CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }} CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} @@ -219,13 +234,14 @@ jobs: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }} - COMMIT_INFO_MESSAGE: Critical triggered via release - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}, ${{github.event.client_payload.pullRequestUrl}} - CYPRESS_grepTags: '@stable' + COMMIT_INFO_MESSAGE: Triggered via release - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}, ${{github.event.client_payload.pullRequestUrl}} + CYPRESS_grepTags: ${{steps.set-tag-for-tests.outputs.TEST_TAG}} with: parallel: true group: 'UI - Chrome' record: true - tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, Critical, ${{ needs.get-url.outputs.url }} + tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, ${{ needs.get-environment-variables.outputs.url }} + add-review-and-merge-patch: if: ${{ always() && (needs.run-tests-on-release.outputs.status == 'success' || needs.run-tests-on-release.outputs.status == 'failure') }} diff --git a/cypress/e2e/apps.js b/cypress/e2e/apps.js index c269f70ad..6f81efae2 100644 --- a/cypress/e2e/apps.js +++ b/cypress/e2e/apps.js @@ -93,7 +93,7 @@ describe("As a staff user I want to manage apps", () => { it( "should be able to create app. TC: SALEOR_3001", - { tags: ["@app", "@allEnv", "@stable"] }, + { tags: ["@app", "@allEnv", "@stable", "@oldRelease"] }, () => { const randomAppName = `${startsWith}${faker.datatype.number()}`; diff --git a/cypress/e2e/catalog/categories.js b/cypress/e2e/catalog/categories.js index 8e00d7ac0..b35a3ad32 100644 --- a/cypress/e2e/catalog/categories.js +++ b/cypress/e2e/catalog/categories.js @@ -75,7 +75,7 @@ describe("As an admin I want to manage categories", () => { it( "should be able to create category. TC: SALEOR_0201", - { tags: ["@category", "@allEnv"] }, + { tags: ["@category", "@allEnv", "@oldRelease"] }, () => { const categoryName = `${startsWith}${faker.datatype.number()}`; diff --git a/cypress/e2e/catalog/collections.js b/cypress/e2e/catalog/collections.js index a22350750..6e2f2103d 100644 --- a/cypress/e2e/catalog/collections.js +++ b/cypress/e2e/catalog/collections.js @@ -103,7 +103,7 @@ describe("As an admin I want to manage collections.", () => { it( "should create published collection. TC: SALEOR_0302", - { tags: ["@collection", "@allEnv", "@stable"] }, + { tags: ["@collection", "@allEnv", "@stable", "@oldRelease"] }, () => { const collectionName = `${startsWith}${faker.datatype.number()}`; let collection; diff --git a/cypress/e2e/checkout/purchaseWithProductTypes.js b/cypress/e2e/checkout/purchaseWithProductTypes.js index dc76a67e0..52285e6f2 100644 --- a/cypress/e2e/checkout/purchaseWithProductTypes.js +++ b/cypress/e2e/checkout/purchaseWithProductTypes.js @@ -49,7 +49,7 @@ describe("As an unlogged customer I want to order physical and digital products" it( "should purchase digital product as unlogged customer. TC: SALEOR_0402", - { tags: ["@checkout", "@allEnv", "@stable"] }, + { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, () => { createAndCompleteCheckoutWithoutShipping({ channelSlug: defaultChannel.slug, @@ -73,7 +73,7 @@ describe("As an unlogged customer I want to order physical and digital products" it( "should purchase physical product as unlogged customer. TC: SALEOR_0403", - { tags: ["@checkout", "@allEnv", "@stable"] }, + { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, () => { createWaitingForCaptureOrder({ channelSlug: defaultChannel.slug, diff --git a/cypress/e2e/checkout/stocksInCheckout.js b/cypress/e2e/checkout/stocksInCheckout.js index 91dc9bc78..caaefc76d 100644 --- a/cypress/e2e/checkout/stocksInCheckout.js +++ b/cypress/e2e/checkout/stocksInCheckout.js @@ -61,7 +61,7 @@ describe("Manage products stocks in checkout", () => { it( "should not be possible to add product with quantity greater than stock to checkout. TC: SALEOR_0405", - { tags: ["@checkout", "@allEnv", "@stable"] }, + { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, () => { createCheckout({ channelSlug: defaultChannel.slug, @@ -85,7 +85,7 @@ describe("Manage products stocks in checkout", () => { it( "should buy product with no quantity if tracking is not set. TC: SALEOR_0406", - { tags: ["@checkout", "@allEnv", "@stable"] }, + { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, () => { createWaitingForCaptureOrder({ address, @@ -101,7 +101,7 @@ describe("Manage products stocks in checkout", () => { it( "should create checkout with last product in stock. TC: SALEOR_0419", - { tags: ["@checkout", "@allEnv", "@stable"] }, + { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, () => { createWaitingForCaptureOrder({ address, diff --git a/cypress/e2e/checkout/warehouses.js b/cypress/e2e/checkout/warehouses.js index eda43e7c3..209abffc4 100644 --- a/cypress/e2e/checkout/warehouses.js +++ b/cypress/e2e/checkout/warehouses.js @@ -24,7 +24,7 @@ describe("Warehouses in checkout", () => { it( "should not be possible to buy product for country not listed in warehouse", - { tags: ["@checkout", "@allEnv", "@stable"] }, + { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, () => { cy.clearSessionData().loginUserViaRequest(); deleteShippingStartsWith(startsWith); diff --git a/cypress/e2e/configuration/attributes/createProductAttributes.js b/cypress/e2e/configuration/attributes/createProductAttributes.js index 8e92ae439..90a670d8e 100644 --- a/cypress/e2e/configuration/attributes/createProductAttributes.js +++ b/cypress/e2e/configuration/attributes/createProductAttributes.js @@ -66,7 +66,7 @@ describe("As an admin I want to create product attribute", () => { attributesTypes.forEach(attributeType => { it( `should be able to create ${attributeType.type} attribute. TC:${attributeType.testCase}`, - { tags: ["@attribute", "@allEnv", "@stable"] }, + { tags: ["@attribute", "@allEnv", "@stable", "@oldRelease"] }, () => { const attributeName = `${startsWith}${faker.datatype.number()}`; diff --git a/cypress/e2e/configuration/customer.js b/cypress/e2e/configuration/customer.js index 0f3992938..6949e8f36 100644 --- a/cypress/e2e/configuration/customer.js +++ b/cypress/e2e/configuration/customer.js @@ -35,7 +35,7 @@ describe("Tests for customer", () => { it( "should create customer. TC: SALEOR_1201", - { tags: ["@customer", "@allEnv", "@stable"] }, + { tags: ["@customer", "@allEnv", "@stable", "@oldRelease"] }, () => { const randomName = `${startsWith}${faker.datatype.number()}`; const email = `${randomName}@example.com`; diff --git a/cypress/e2e/configuration/productTypes/createProductType.js b/cypress/e2e/configuration/productTypes/createProductType.js index 68c7faf9d..ce5ba249d 100644 --- a/cypress/e2e/configuration/productTypes/createProductType.js +++ b/cypress/e2e/configuration/productTypes/createProductType.js @@ -25,7 +25,7 @@ describe("As an admin I want to create product types", () => { it( "should be able to create product type without shipping required. TC: SALEOR_1501", - { tags: ["@productType", "@allEnv", "@stable"] }, + { tags: ["@productType", "@allEnv", "@stable", "@oldRelease"] }, () => { const name = `${startsWith}${faker.datatype.number()}`; diff --git a/cypress/e2e/configuration/shippingMethods/createShippingMethod.js b/cypress/e2e/configuration/shippingMethods/createShippingMethod.js index 86505620b..7c7fc5cde 100644 --- a/cypress/e2e/configuration/shippingMethods/createShippingMethod.js +++ b/cypress/e2e/configuration/shippingMethods/createShippingMethod.js @@ -33,8 +33,6 @@ describe("As a staff user I want to create shipping zone and rate", () => { let secondVariantsList; let warehouse; let attribute; - let category; - let productType; before(() => { cy.clearSessionData().loginUserViaRequest(); @@ -68,8 +66,6 @@ describe("As a staff user I want to create shipping zone and rate", () => { attribute: attributeResp, }) => { attribute = attributeResp; - category = categoryResp; - productType = productTypeResp; productsUtils.createProductInChannel({ name, @@ -108,7 +104,7 @@ describe("As a staff user I want to create shipping zone and rate", () => { it( "should be able to create price based shipping method. TC: SALEOR_0803", - { tags: ["@shipping", "@allEnv", "@stable"] }, + { tags: ["@shipping", "@allEnv", "@stable", "@oldRelease"] }, () => { const shippingName = `${startsWith}${faker.datatype.number()}`; cy.clearSessionData().loginUserViaRequest( diff --git a/cypress/e2e/configuration/warehouses/warehouse.js b/cypress/e2e/configuration/warehouses/warehouse.js index 6707ddeed..ae443572c 100644 --- a/cypress/e2e/configuration/warehouses/warehouse.js +++ b/cypress/e2e/configuration/warehouses/warehouse.js @@ -44,7 +44,7 @@ describe("As an admin I want to manage warehouses", () => { it( "should be able to create warehouse. TC: SALEOR_1101", - { tags: ["@warehouse", "@allEnv", "@stable"] }, + { tags: ["@warehouse", "@allEnv", "@stable", "@oldRelease"] }, () => { const name = `${startsWith}${faker.datatype.number()}`; cy.visit(urlList.warehouses) diff --git a/cypress/e2e/homePage/homePage.js b/cypress/e2e/homePage/homePage.js index 09e5945bc..dfb005467 100644 --- a/cypress/e2e/homePage/homePage.js +++ b/cypress/e2e/homePage/homePage.js @@ -8,7 +8,7 @@ import { expectWelcomeMessageIncludes } from "../../support/pages/homePage"; describe("Displaying welcome message on home page", () => { it( "should display user name on home page", - { tags: ["@homePage", "@allEnv", "@stable"] }, + { tags: ["@homePage", "@allEnv", "@stable", "@oldRelease"] }, () => { cy.loginUserViaRequest().visit(urlList.homePage); expectWelcomeMessageIncludes( @@ -19,7 +19,7 @@ describe("Displaying welcome message on home page", () => { it( "should display user email on home page", - { tags: ["@homePage", "@allEnv", "@stable"] }, + { tags: ["@homePage", "@allEnv", "@stable", "@oldRelease"] }, () => { cy.loginUserViaRequest("auth", USER_WITHOUT_NAME).visit(urlList.homePage); expectWelcomeMessageIncludes(`${USER_WITHOUT_NAME.email}`); @@ -28,7 +28,7 @@ describe("Displaying welcome message on home page", () => { it( "should refresh page without errors", - { tags: ["@homePage", "@allEnv", "@stable"] }, + { tags: ["@homePage", "@allEnv", "@stable", "@oldRelease"] }, () => { cy.loginUserViaRequest() .visit(urlList.homePage) diff --git a/cypress/e2e/login.js b/cypress/e2e/login.js index 56e6e9bdd..ccd4f5fe2 100644 --- a/cypress/e2e/login.js +++ b/cypress/e2e/login.js @@ -11,7 +11,7 @@ describe("User authorization", () => { it( "should successfully log in an user", - { tags: ["@login", "@allEnv", "@stable"] }, + { tags: ["@login", "@allEnv", "@stable", "@oldRelease"] }, () => { cy.visit(urlList.homePage); cy.loginUser(); diff --git a/cypress/e2e/navigation.js b/cypress/e2e/navigation.js index 8d464d9f7..a1771d9f8 100644 --- a/cypress/e2e/navigation.js +++ b/cypress/e2e/navigation.js @@ -47,7 +47,7 @@ describe("As a staff user I want to navigate through shop using different permis if (key !== "all") { it( `should be able to navigate through shop as a staff member using ${key} permission. ${permissionsOptions[key].testCase}`, - { tags: ["@allEnv", "@navigation", "@stable"] }, + { tags: ["@allEnv", "@navigation", "@stable", "@oldRelease"] }, () => { const permissionOption = permissionsOptions[key]; const permissions = permissionOption.permissions; @@ -85,7 +85,7 @@ describe("As a staff user I want to navigate through shop using different permis it( `should be able to navigate through shop as a staff member using all permissions. ${permissionsOptions.all.testCase}`, - { tags: ["@critical", "@allEnv", "@navigation", "@stable"] }, + { tags: ["@critical", "@allEnv", "@navigation", "@stable", "@oldRelease"] }, () => { const permissionOption = permissionsOptions.all; diff --git a/cypress/e2e/orders/orders.js b/cypress/e2e/orders/orders.js index 18f5c8279..65e13c334 100644 --- a/cypress/e2e/orders/orders.js +++ b/cypress/e2e/orders/orders.js @@ -107,7 +107,7 @@ describe("Orders", () => { it( "should create order with selected channel. TC: SALEOR_2104", - { tags: ["@orders", "@allEnv", "@stable"] }, + { tags: ["@orders", "@allEnv", "@stable", "@oldRelease"] }, () => { cy.visit(urlList.orders) .get(ORDERS_SELECTORS.createOrder) @@ -125,7 +125,7 @@ describe("Orders", () => { it( "should not be possible to change channel in order. TC: SALEOR_2105", - { tags: ["@orders", "@allEnv", "@stable"] }, + { tags: ["@orders", "@allEnv", "@stable", "@oldRelease"] }, () => { createOrder({ customerId: customer.id, @@ -145,7 +145,7 @@ describe("Orders", () => { it( "should cancel fulfillment. TC: SALEOR_2106", - { tags: ["@orders", "@allEnv", "@stable"] }, + { tags: ["@orders", "@allEnv", "@stable", "@oldRelease"] }, () => { let order; createFulfilledOrder({ @@ -184,7 +184,7 @@ describe("Orders", () => { it( "should make a refund. TC: 2107", - { tags: ["@orders", "@allEnv", "@stable"] }, + { tags: ["@orders", "@allEnv", "@stable", "@oldRelease"] }, () => { let order; createReadyToFulfillOrder({ diff --git a/cypress/e2e/products/createProduct.js b/cypress/e2e/products/createProduct.js index 97952df35..e2259586b 100644 --- a/cypress/e2e/products/createProduct.js +++ b/cypress/e2e/products/createProduct.js @@ -63,7 +63,7 @@ describe("As an admin I should be able to create product", () => { it( "should be able to create product with variants as an admin. SALEOR_2701", - { tags: ["@products", "@allEnv", "@critical", "@stable"] }, + { tags: ["@products", "@allEnv", "@critical", "@stable", "@oldRelease"] }, () => { const randomName = `${startsWith}${faker.datatype.number()}`; seo.slug = randomName; @@ -99,7 +99,7 @@ describe("As an admin I should be able to create product", () => { it( "should be able to create product without variants as an admin. SALEOR_2702", - { tags: ["@products", "@allEnv", "@critical", "@stable"] }, + { tags: ["@products", "@allEnv", "@critical", "@stable", "@oldRelease"] }, () => { const prices = { sellingPrice: 6, costPrice: 3 }; const randomName = `${startsWith}${faker.datatype.number()}`; diff --git a/cypress/e2e/products/productsVariants.js b/cypress/e2e/products/productsVariants.js index 8c802d803..1b364ad65 100644 --- a/cypress/e2e/products/productsVariants.js +++ b/cypress/e2e/products/productsVariants.js @@ -60,7 +60,7 @@ describe("As an admin I should be able to create variant", () => { it( "should be able to create variant visible for the customers in all channels. TC: SALEOR_2901", - { tags: ["@variants", "@allEnv", "@critical", "@stable"] }, + { tags: ["@variants", "@allEnv", "@critical", "@stable", "@oldRelease"] }, () => { const name = `${startsWith}${faker.datatype.number()}`; const price = 10; @@ -113,7 +113,7 @@ describe("As an admin I should be able to create variant", () => { it( "should be able to create several variants visible for the customers. TC: SALEOR_2902", - { tags: ["@variants", "@allEnv", "@critical", "@stable"] }, + { tags: ["@variants", "@allEnv", "@critical", "@stable", "@oldRelease"] }, () => { const name = `${startsWith}${faker.datatype.number()}`; const secondVariantSku = `${startsWith}${faker.datatype.number()}`;