Saleor 2699 tests for home page (#1019)

* tests for home page

* tests for home page

* tests for home page

* change master to qa API_URL

* add user to env

* remove empty file
This commit is contained in:
Karolina 2021-03-23 11:14:18 +01:00 committed by GitHub
parent 7bc4bc6696
commit 78ba9f4fe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 24 deletions

View file

@ -29,4 +29,4 @@ greatly reduce the amount of work needed to review your work. -->
<!-- Do not remove this section. It is required to properly setup test instance.
Modify API_URI if you want test instance to use custom backend. -->
API_URI=https://master.staging.saleor.cloud/graphql/
API_URI=https://qa.staging.saleor.cloud/graphql/

View file

@ -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: |

View file

@ -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

10
cypress/Data/users.js Normal file
View file

@ -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")
};

View file

@ -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']"
};

View file

@ -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}`);
});
});
});

View file

@ -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";
// <reference types="cypress" />
describe("Homepage analytics", () => {

View file

@ -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") => {
Cypress.Commands.add(
"loginUserViaRequest",
(authorization = "auth", user = TEST_ADMIN_USER) => {
const mutation = `mutation TokenAuth{
tokenCreate(email: "${Cypress.env("USER_NAME")}", password: "${Cypress.env(
"USER_PASSWORD"
)}") {
tokenCreate(email: "${user.email}", password: "${user.password}") {
token
errors: accountErrors {
code
@ -36,4 +37,5 @@ Cypress.Commands.add("loginUserViaRequest", (authorization = "auth") => {
resp.body.data.tokenCreate.token
);
});
});
}
);