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:
parent
7bc4bc6696
commit
78ba9f4fe9
8 changed files with 66 additions and 24 deletions
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -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/
|
2
.github/workflows/test-env-deploy.yml
vendored
2
.github/workflows/test-env-deploy.yml
vendored
|
@ -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: |
|
||||
|
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -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
10
cypress/Data/users.js
Normal 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")
|
||||
};
|
|
@ -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']"
|
||||
};
|
||||
|
|
27
cypress/integration/homePage/homePage.js
Normal file
27
cypress/integration/homePage/homePage.js
Normal 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}`);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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", () => {
|
|
@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue