all tests for site settings (#1236)
This commit is contained in:
parent
e830d199c2
commit
0ec88cdb1e
5 changed files with 132 additions and 8 deletions
|
@ -1,3 +1,5 @@
|
|||
import { getDefaultAddress } from "./utils/Utils";
|
||||
|
||||
export function updateShopWeightUnit(weightUnit) {
|
||||
const mutation = `mutation{
|
||||
shopSettingsUpdate(input:{
|
||||
|
@ -14,3 +16,42 @@ export function updateShopWeightUnit(weightUnit) {
|
|||
}`;
|
||||
return cy.sendRequestWithQuery(mutation).its("body.data.shopSettingsUpdate");
|
||||
}
|
||||
|
||||
export function updateShopAddress(address) {
|
||||
const input = getDefaultAddress(address, "input");
|
||||
const mutation = `mutation{
|
||||
shopAddressUpdate(${input}){
|
||||
errors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function getShopInfo() {
|
||||
const query = `query{
|
||||
shop{
|
||||
name
|
||||
domain{
|
||||
host
|
||||
}
|
||||
description
|
||||
companyAddress{
|
||||
companyName
|
||||
streetAddress1
|
||||
streetAddress2
|
||||
city
|
||||
cityArea
|
||||
postalCode
|
||||
country{
|
||||
code
|
||||
}
|
||||
countryArea
|
||||
phone
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(query).its("body.data.shop");
|
||||
}
|
||||
|
|
5
cypress/elements/siteSettings/site-settings-details.js
Normal file
5
cypress/elements/siteSettings/site-settings-details.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
export const SITE_SETTINGS_DETAILS = {
|
||||
nameInput: '[name="name"]',
|
||||
urlInput: '[name="domain"]',
|
||||
descriptionInput: '[name="description"]'
|
||||
};
|
78
cypress/integration/allEnv/configuration/siteSettings.js
Normal file
78
cypress/integration/allEnv/configuration/siteSettings.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
import faker from "faker";
|
||||
|
||||
import {
|
||||
getShopInfo,
|
||||
updateShopAddress
|
||||
} from "../../../apiRequests/shopSettings";
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
import { SITE_SETTINGS_DETAILS } from "../../../elements/siteSettings/site-settings-details";
|
||||
import { fillUpBasicAddress } from "../../../steps/shared/addressForm";
|
||||
import { confirmationMessageShouldDisappear } from "../../../steps/shared/confirmationMessage";
|
||||
import { urlList } from "../../../url/urlList";
|
||||
|
||||
describe("Tests for site settings", () => {
|
||||
let address;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
cy.fixture("addresses").then(({ usAddress, plAddress }) => {
|
||||
address = usAddress;
|
||||
updateShopAddress(plAddress);
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest()
|
||||
.visit(urlList.siteSettings);
|
||||
});
|
||||
|
||||
it("should change store name", () => {
|
||||
const name = `Cypress-${faker.datatype.number()}`;
|
||||
|
||||
cy.get(SITE_SETTINGS_DETAILS.nameInput)
|
||||
.clearAndType(name)
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click();
|
||||
confirmationMessageShouldDisappear();
|
||||
getShopInfo().then(shopInfo => {
|
||||
expect(shopInfo.name).to.eq(name);
|
||||
});
|
||||
});
|
||||
|
||||
it("should change site url", () => {
|
||||
const url = `http://cypress${faker.datatype.number()}.saleor.com`;
|
||||
|
||||
cy.get(SITE_SETTINGS_DETAILS.urlInput)
|
||||
.clearAndType(url)
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click();
|
||||
confirmationMessageShouldDisappear();
|
||||
getShopInfo().then(shopInfo => {
|
||||
expect(shopInfo.domain.host).to.eq(url);
|
||||
});
|
||||
});
|
||||
|
||||
it("should change store description", () => {
|
||||
const description = faker.lorem.sentence();
|
||||
|
||||
cy.get(SITE_SETTINGS_DETAILS.descriptionInput)
|
||||
.clearAndType(description)
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click();
|
||||
confirmationMessageShouldDisappear();
|
||||
getShopInfo().then(shopInfo => {
|
||||
expect(shopInfo.description).to.eq(description);
|
||||
});
|
||||
});
|
||||
|
||||
it("should change store address", () => {
|
||||
fillUpBasicAddress(address);
|
||||
cy.get(BUTTON_SELECTORS.confirm).click();
|
||||
confirmationMessageShouldDisappear();
|
||||
getShopInfo().then(({ companyAddress }) => {
|
||||
expect(companyAddress.companyName).to.eq(address.companyName);
|
||||
cy.expectCorrectBasicAddress(companyAddress, address);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -17,17 +17,17 @@ export function fillUpAddressForm(address) {
|
|||
|
||||
export function fillUpBasicAddress(address) {
|
||||
cy.get(ADDRESS_SELECTORS.companyName)
|
||||
.type(address.companyName)
|
||||
.clearAndType(address.companyName)
|
||||
.get(ADDRESS_SELECTORS.phone)
|
||||
.type(address.phone)
|
||||
.clearAndType(address.phone)
|
||||
.get(ADDRESS_SELECTORS.streetAddress1)
|
||||
.type(address.streetAddress1)
|
||||
.clearAndType(address.streetAddress1)
|
||||
.get(ADDRESS_SELECTORS.streetAddress2)
|
||||
.type(address.streetAddress2)
|
||||
.clearAndType(address.streetAddress2)
|
||||
.get(ADDRESS_SELECTORS.city)
|
||||
.type(address.city)
|
||||
.clearAndType(address.city)
|
||||
.get(ADDRESS_SELECTORS.postalCode)
|
||||
.type(address.postalCode);
|
||||
.clearAndType(address.postalCode);
|
||||
fillAutocompleteSelect(ADDRESS_SELECTORS.country, address.countryFullName);
|
||||
cy.get(ADDRESS_SELECTORS.countryArea).type(address.countryArea);
|
||||
cy.get(ADDRESS_SELECTORS.countryArea).clearAndType(address.countryArea);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ export const urlList = {
|
|||
permissionsGroups: "permission-groups/",
|
||||
products: "products/",
|
||||
productTypes: "product-types/",
|
||||
shippingMethods: "shipping/",
|
||||
sales: "discounts/sales/",
|
||||
shippingMethods: "shipping/",
|
||||
siteSettings: "site-settings/",
|
||||
staffMembers: "staff/",
|
||||
vouchers: "discounts/vouchers/",
|
||||
warehouses: "warehouses/",
|
||||
|
|
Loading…
Reference in a new issue