diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 56f936bee..b8131fd87 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -29,4 +29,4 @@ greatly reduce the amount of work needed to review your work. --> -API_URI=https://master.staging.saleor.cloud/graphql/ +API_URI=https://qa.staging.saleor.cloud/graphql/ \ No newline at end of file diff --git a/.github/workflows/test-env-deploy.yml b/.github/workflows/test-env-deploy.yml index d7603e822..c9d70388b 100644 --- a/.github/workflows/test-env-deploy.yml +++ b/.github/workflows/test-env-deploy.yml @@ -59,7 +59,7 @@ jobs: - name: Run build env: # Use custom API_URI or the default one - API_URI: ${{ steps.api_uri.outputs.custom_api_uri || 'https://master.staging.saleor.cloud/graphql/' }} + API_URI: ${{ steps.api_uri.outputs.custom_api_uri || 'https://qa.staging.saleor.cloud/graphql/' }} APP_MOUNT_URI: / STATIC_URL: / run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af5f372c5..e21f06193 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,7 +93,9 @@ jobs: APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }} CYPRESS_baseUrl: ${{ secrets.CYPRESS_BASEURL }} 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: build: npm run build start: npx local-web-server --spa index.html diff --git a/cypress/Data/users.js b/cypress/Data/users.js new file mode 100644 index 000000000..7b6cfda6e --- /dev/null +++ b/cypress/Data/users.js @@ -0,0 +1,10 @@ +export const TEST_ADMIN_USER = { + email: Cypress.env("USER_NAME"), + password: Cypress.env("USER_PASSWORD"), + name: "Test", + lastName: "Test" +}; +export const USER_WITHOUT_NAME = { + email: Cypress.env("SECOND_USER_NAME"), + password: Cypress.env("USER_PASSWORD") +}; diff --git a/cypress/elements/homePage/homePage-selectors.js b/cypress/elements/homePage/homePage-selectors.js index 221cb68e8..79afbfe93 100644 --- a/cypress/elements/homePage/homePage-selectors.js +++ b/cypress/elements/homePage/homePage-selectors.js @@ -5,5 +5,6 @@ export const HOMEPAGE_SELECTORS = { topProducts: "[data-test-id='top-products']", ordersReadyToFulfill: "[data-test-id='orders-to-fulfill']", paymentsWaitingForCapture: "[data-test-id='orders-to-capture']", - productsOutOfStock: "[data-test-id='products-out-of-stock']" + productsOutOfStock: "[data-test-id='products-out-of-stock']", + welcomeMessage: "[data-test='welcomeHeader']" }; diff --git a/cypress/integration/homePage/homePage.js b/cypress/integration/homePage/homePage.js new file mode 100644 index 000000000..26fd69ed4 --- /dev/null +++ b/cypress/integration/homePage/homePage.js @@ -0,0 +1,27 @@ +import { TEST_ADMIN_USER, USER_WITHOUT_NAME } from "../../Data/users"; +import { HOMEPAGE_SELECTORS } from "../../elements/homePage/homePage-selectors"; +import { urlList } from "../../url/urlList"; + +describe("Displaying welcome message on home page", () => { + it("should display user name on home page", () => { + cy.loginUserViaRequest(); + cy.visit(urlList.homePage); + cy.get(HOMEPAGE_SELECTORS.welcomeMessage) + .invoke("text") + .then(text => { + expect(text).to.contains( + `${TEST_ADMIN_USER.name} ${TEST_ADMIN_USER.lastName}` + ); + }); + }); + + it("should display user email on home page", () => { + cy.loginUserViaRequest("auth", USER_WITHOUT_NAME); + cy.visit(urlList.homePage); + cy.get(HOMEPAGE_SELECTORS.welcomeMessage) + .invoke("text") + .then(text => { + expect(text).to.contains(`${USER_WITHOUT_NAME.email}`); + }); + }); +}); diff --git a/cypress/integration/homePage.js b/cypress/integration/homePage/homePageAnalitics.js similarity index 93% rename from cypress/integration/homePage.js rename to cypress/integration/homePage/homePageAnalitics.js index 73201d050..c9aca74fd 100644 --- a/cypress/integration/homePage.js +++ b/cypress/integration/homePage/homePageAnalitics.js @@ -3,18 +3,18 @@ import faker from "faker"; import { createCustomer, deleteCustomersStartsWith -} from "../apiRequests/Customer"; -import { HOMEPAGE_SELECTORS } from "../elements/homePage/homePage-selectors"; -import { changeChannel } from "../steps/homePageSteps"; -import { urlList } from "../url/urlList"; -import { getDefaultChannel } from "../utils/channelsUtils"; -import * as homePageUtils from "../utils/homePageUtils"; +} from "../../apiRequests/Customer"; +import { HOMEPAGE_SELECTORS } from "../../elements/homePage/homePage-selectors"; +import { changeChannel } from "../../steps/homePageSteps"; +import { urlList } from "../../url/urlList"; +import { getDefaultChannel } from "../../utils/channelsUtils"; +import * as homePageUtils from "../../utils/homePageUtils"; import { createReadyToFulfillOrder, createWaitingForCaptureOrder -} from "../utils/ordersUtils"; -import * as productsUtils from "../utils/productsUtils"; -import * as shippingUtils from "../utils/shippingUtils"; +} from "../../utils/ordersUtils"; +import * as productsUtils from "../../utils/productsUtils"; +import * as shippingUtils from "../../utils/shippingUtils"; // describe("Homepage analytics", () => { diff --git a/cypress/support/user/index.js b/cypress/support/user/index.js index 33fcc4adc..a87f31502 100644 --- a/cypress/support/user/index.js +++ b/cypress/support/user/index.js @@ -1,3 +1,4 @@ +import { TEST_ADMIN_USER } from "../../Data/users"; import { LOGIN_SELECTORS } from "../../elements/account/login-selectors"; Cypress.Commands.add("loginUser", () => @@ -14,11 +15,11 @@ Cypress.Commands.add("loginInShop", () => { cy.loginUserViaRequest("token"); }); -Cypress.Commands.add("loginUserViaRequest", (authorization = "auth") => { - const mutation = `mutation TokenAuth{ - tokenCreate(email: "${Cypress.env("USER_NAME")}", password: "${Cypress.env( - "USER_PASSWORD" - )}") { +Cypress.Commands.add( + "loginUserViaRequest", + (authorization = "auth", user = TEST_ADMIN_USER) => { + const mutation = `mutation TokenAuth{ + tokenCreate(email: "${user.email}", password: "${user.password}") { token errors: accountErrors { code @@ -30,10 +31,11 @@ Cypress.Commands.add("loginUserViaRequest", (authorization = "auth") => { } } }`; - return cy.sendRequestWithQuery(mutation, authorization).then(resp => { - window.sessionStorage.setItem( - authorization, - resp.body.data.tokenCreate.token - ); - }); -}); + return cy.sendRequestWithQuery(mutation, authorization).then(resp => { + window.sessionStorage.setItem( + authorization, + resp.body.data.tokenCreate.token + ); + }); + } +);