Saleor 2705 tests for warehouse (#1143)
* tests for warehouses * tests for warehouses
This commit is contained in:
parent
12e9cf0472
commit
5b3465861f
12 changed files with 196 additions and 29 deletions
|
@ -26,6 +26,7 @@ export function createWarehouse({ name, shippingZone, address, slug = name }) {
|
|||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.createWarehouse.warehouse");
|
||||
}
|
||||
|
||||
export function getWarehouses(first, search) {
|
||||
const query = `query{
|
||||
warehouses(first:${first}, filter:{
|
||||
|
@ -43,6 +44,7 @@ export function getWarehouses(first, search) {
|
|||
.sendRequestWithQuery(query)
|
||||
.then(resp => resp.body.data.warehouses.edges);
|
||||
}
|
||||
|
||||
export function deleteWarehouse(warehouseId) {
|
||||
const mutation = `mutation{
|
||||
deleteWarehouse(id:"${warehouseId}"){
|
||||
|
@ -54,3 +56,29 @@ export function deleteWarehouse(warehouseId) {
|
|||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function getWarehouse(warehouseId) {
|
||||
const query = `query{
|
||||
warehouse(id:"${warehouseId}"){
|
||||
id
|
||||
name
|
||||
address{
|
||||
companyName
|
||||
streetAddress1
|
||||
streetAddress2
|
||||
city
|
||||
postalCode
|
||||
countryArea
|
||||
phone
|
||||
}
|
||||
shippingZones(first:100){
|
||||
edges{
|
||||
node{
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(query).its("body.data.warehouse");
|
||||
}
|
||||
|
|
3
cypress/elements/warehouses/warehouse-details.js
Normal file
3
cypress/elements/warehouses/warehouse-details.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export const WAREHOUSES_DETAILS = {
|
||||
nameInput: '[name="name"]'
|
||||
};
|
3
cypress/elements/warehouses/warehouses-list.js
Normal file
3
cypress/elements/warehouses/warehouses-list.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export const WAREHOUSES_LIST = {
|
||||
createNewButton: '[data-test-id="createWarehouse"]'
|
||||
};
|
|
@ -23,7 +23,7 @@
|
|||
"postalCode": "70957",
|
||||
"country": "US",
|
||||
"countryArea": "LA",
|
||||
"phone": "2025550189",
|
||||
"phone": "+12025550189",
|
||||
"currency": "USD",
|
||||
"countryFullName": "United States of America"
|
||||
}
|
||||
|
|
|
@ -1,25 +1,132 @@
|
|||
// <reference types="cypress" />
|
||||
import { urlList } from "../../../url/urlList";
|
||||
import faker from "faker";
|
||||
|
||||
import { createShippingZone } from "../../../apiRequests/ShippingMethod";
|
||||
import { createWarehouse, getWarehouse } from "../../../apiRequests/Warehouse";
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
|
||||
import { WAREHOUSES_DETAILS } from "../../../elements/warehouses/warehouse-details";
|
||||
import { WAREHOUSES_LIST } from "../../../elements/warehouses/warehouses-list";
|
||||
import { fillUpBasicAddress } from "../../../steps/shared/addressForm";
|
||||
import { fillAutocompleteSelect } from "../../../steps/shared/autocompleteSelect";
|
||||
import {
|
||||
shippingZoneDetailsUrl,
|
||||
urlList,
|
||||
warehouseDetailsUrl
|
||||
} from "../../../url/urlList";
|
||||
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
||||
import { deleteShippingStartsWith } from "../../../utils/shippingUtils";
|
||||
|
||||
describe("Warehouse settings", () => {
|
||||
const startsWith = "CyWarehouse";
|
||||
let usAddress;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteShippingStartsWith(startsWith);
|
||||
cy.fixture("addresses").then(addresses => {
|
||||
usAddress = addresses.usAddress;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData();
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
});
|
||||
|
||||
xit("Warehouse section visible in the configuration", () => {
|
||||
cy.visit(urlList.configuration)
|
||||
.loginUser()
|
||||
.get("[data-test-id=warehouses][data-test=settingsSubsection]")
|
||||
.click();
|
||||
cy.location("pathname").should("eq", "/warehouses/");
|
||||
});
|
||||
|
||||
xit("Editing warehouse is available", () => {
|
||||
it("should create warehouse", () => {
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
cy.visit(urlList.warehouses)
|
||||
.loginUser()
|
||||
.get("[data-test=editButton]")
|
||||
.first()
|
||||
.get(WAREHOUSES_LIST.createNewButton)
|
||||
.click();
|
||||
cy.get(WAREHOUSES_DETAILS.nameInput).type(name);
|
||||
fillUpBasicAddress(usAddress);
|
||||
cy.addAliasToGraphRequest("WarehouseCreate")
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click()
|
||||
.get("[data-test=generalInformationSection]");
|
||||
.wait("@WarehouseCreate")
|
||||
.its("response.body.data.createWarehouse.warehouse")
|
||||
.then(warehouse => {
|
||||
getWarehouse(warehouse.id);
|
||||
})
|
||||
.then(warehouse => {
|
||||
const addressResp = warehouse.address;
|
||||
expect(warehouse.name).to.be.eq(name);
|
||||
expect(addressResp).to.have.property(
|
||||
"city",
|
||||
usAddress.city.toUpperCase()
|
||||
);
|
||||
expect(addressResp).to.have.property(
|
||||
"countryArea",
|
||||
usAddress.countryArea
|
||||
);
|
||||
expect(addressResp).to.have.property("phone", usAddress.phone);
|
||||
expect(addressResp).to.have.property(
|
||||
"postalCode",
|
||||
usAddress.postalCode
|
||||
);
|
||||
expect(addressResp).to.have.property(
|
||||
"streetAddress1",
|
||||
usAddress.streetAddress1
|
||||
);
|
||||
expect(addressResp).to.have.property(
|
||||
"streetAddress2",
|
||||
usAddress.streetAddress2
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("should add warehouse to shipping zone", () => {
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
let defaultChannel;
|
||||
let warehouse;
|
||||
let shippingZone;
|
||||
|
||||
getDefaultChannel()
|
||||
.then(channelResp => {
|
||||
defaultChannel = channelResp;
|
||||
createWarehouse({
|
||||
name,
|
||||
address: usAddress
|
||||
});
|
||||
})
|
||||
.then(warehouseResp => {
|
||||
warehouse = warehouseResp;
|
||||
createShippingZone(name, "US", defaultChannel.id);
|
||||
})
|
||||
.then(shippingZoneResp => {
|
||||
shippingZone = shippingZoneResp;
|
||||
cy.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||
fillAutocompleteSelect(
|
||||
SHIPPING_ZONE_DETAILS.warehouseSelector,
|
||||
warehouse.name
|
||||
);
|
||||
cy.addAliasToGraphRequest("UpdateShippingZone")
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
.click()
|
||||
.wait("@UpdateShippingZone");
|
||||
getWarehouse(warehouse.id);
|
||||
})
|
||||
.then(warehouseResp => {
|
||||
expect(warehouseResp.shippingZones.edges[0].node.id).to.be.eq(
|
||||
shippingZone.id
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("should delete warehouse", () => {
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
createWarehouse({
|
||||
name,
|
||||
address: usAddress
|
||||
}).then(warehouse => {
|
||||
cy.visit(warehouseDetailsUrl(warehouse.id))
|
||||
.get(BUTTON_SELECTORS.deleteButton)
|
||||
.click()
|
||||
.addAliasToGraphRequest("WarehouseDelete")
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.wait("@WarehouseDelete");
|
||||
getWarehouse(warehouse.id).should("be.null");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,8 +6,13 @@ export function fillUpAddressForm(address) {
|
|||
cy.get(ADDRESS_SELECTORS.firstName)
|
||||
.type(address.firstName)
|
||||
.get(ADDRESS_SELECTORS.lastName)
|
||||
.type(address.lastName)
|
||||
.get(ADDRESS_SELECTORS.companyName)
|
||||
.type(address.lastName);
|
||||
fillUpBasicAddress(address);
|
||||
cy.get(BUTTON_SELECTORS.submit).click();
|
||||
}
|
||||
|
||||
export function fillUpBasicAddress(address) {
|
||||
cy.get(ADDRESS_SELECTORS.companyName)
|
||||
.type(address.companyName)
|
||||
.get(ADDRESS_SELECTORS.phone)
|
||||
.type(address.phone)
|
||||
|
@ -20,8 +25,5 @@ export function fillUpAddressForm(address) {
|
|||
.get(ADDRESS_SELECTORS.postalCode)
|
||||
.type(address.postalCode);
|
||||
fillAutocompleteSelect(ADDRESS_SELECTORS.country, address.countryFullName);
|
||||
cy.get(ADDRESS_SELECTORS.countryArea)
|
||||
.type(address.countryArea)
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click();
|
||||
cy.get(ADDRESS_SELECTORS.countryArea).type(address.countryArea);
|
||||
}
|
||||
|
|
|
@ -26,5 +26,11 @@ export const staffMemberDetailsUrl = staffMemberId =>
|
|||
export const permissionGroupDetails = permissionGroupId =>
|
||||
`${urlList.permissionsGroups}${permissionGroupId}`;
|
||||
|
||||
export const shippingZoneDetailsUrl = shippingZoneId =>
|
||||
`${urlList.shippingMethods}${shippingZoneId}`;
|
||||
|
||||
export const warehouseDetailsUrl = warehouseId =>
|
||||
`${urlList.warehouses}${warehouseId}`;
|
||||
|
||||
export const productTypeDetailsUrl = productTypeId =>
|
||||
`${urlList.productTypes}${productTypeId}`;
|
||||
`${urlList.productTypes}${productTypeId}`;
|
|
@ -67,6 +67,7 @@ const DialogButtons: React.FC<DialogButtonsProps> = props => {
|
|||
className={classNames({
|
||||
[classes.deleteButton]: variant === "delete"
|
||||
})}
|
||||
data-test-id="submit"
|
||||
data-test="submit"
|
||||
>
|
||||
{confirmButtonLabel ||
|
||||
|
|
|
@ -147,6 +147,7 @@ const CompanyAddressForm: React.FC<CompanyAddressFormProps> = props => {
|
|||
<FormSpacer />
|
||||
<Grid>
|
||||
<SingleAutocompleteSelectField
|
||||
data-test-id="address-edit-country-select-field"
|
||||
disabled={disabled}
|
||||
displayValue={displayCountry}
|
||||
error={!!formErrors.country}
|
||||
|
|
|
@ -59,6 +59,7 @@ const WarehousesSection: React.FC<WarehousesSectionProps> = ({
|
|||
label: intl.formatMessage(messages.selectFieldAddText),
|
||||
onClick: onAdd
|
||||
}}
|
||||
testId="warehouses"
|
||||
choices={choices}
|
||||
displayValues={displayValues}
|
||||
fetchChoices={onSearchChange}
|
||||
|
|
|
@ -22874,7 +22874,7 @@ exports[`Storyshots Shipping zones details / Settings Card default 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id MultiAutocompleteSelectField-chipClose-id"
|
||||
data-test-id="remove"
|
||||
data-test-id="warehousesRemove"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -22908,7 +22908,7 @@ exports[`Storyshots Shipping zones details / Settings Card default 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id MultiAutocompleteSelectField-chipClose-id"
|
||||
data-test-id="remove"
|
||||
data-test-id="warehousesRemove"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -235335,7 +235335,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details default 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id MultiAutocompleteSelectField-chipClose-id"
|
||||
data-test-id="remove"
|
||||
data-test-id="warehousesRemove"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -235369,7 +235369,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details default 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id MultiAutocompleteSelectField-chipClose-id"
|
||||
data-test-id="remove"
|
||||
data-test-id="warehousesRemove"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -236447,7 +236447,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details form errors 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id MultiAutocompleteSelectField-chipClose-id"
|
||||
data-test-id="remove"
|
||||
data-test-id="warehousesRemove"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -236481,7 +236481,7 @@ exports[`Storyshots Views / Shipping / Shipping zone details form errors 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id MultiAutocompleteSelectField-chipClose-id"
|
||||
data-test-id="remove"
|
||||
data-test-id="warehousesRemove"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -239814,6 +239814,7 @@ exports[`Storyshots Views / Site settings / Page default 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -240359,6 +240360,7 @@ exports[`Storyshots Views / Site settings / Page form errors 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -240908,6 +240910,7 @@ exports[`Storyshots Views / Site settings / Page loading 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -247018,6 +247021,7 @@ exports[`Storyshots Views / Warehouses / Create warehouse default 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -247487,6 +247491,7 @@ exports[`Storyshots Views / Warehouses / Create warehouse form errors 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -247947,6 +247952,7 @@ exports[`Storyshots Views / Warehouses / Create warehouse loading 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -248389,6 +248395,7 @@ exports[`Storyshots Views / Warehouses / Warehouse details default 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -248931,6 +248938,7 @@ exports[`Storyshots Views / Warehouses / Warehouse details form errors 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -249470,6 +249478,7 @@ exports[`Storyshots Views / Warehouses / Warehouse details loading 1`] = `
|
|||
>
|
||||
<div
|
||||
class="SingleAutocompleteSelectField-container-id"
|
||||
data-test-id="address-edit-country-select-field"
|
||||
>
|
||||
<div
|
||||
class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id"
|
||||
|
@ -249670,6 +249679,7 @@ exports[`Storyshots Views / Warehouses / Warehouse list default 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||
data-test-id="createWarehouse"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -250226,6 +250236,7 @@ exports[`Storyshots Views / Warehouses / Warehouse list limits reached 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id MuiButton-disabled-id MuiButtonBase-disabled-id"
|
||||
data-test-id="createWarehouse"
|
||||
disabled=""
|
||||
tabindex="-1"
|
||||
type="button"
|
||||
|
@ -250828,6 +250839,7 @@ exports[`Storyshots Views / Warehouses / Warehouse list loading 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||
data-test-id="createWarehouse"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -251193,6 +251205,7 @@ exports[`Storyshots Views / Warehouses / Warehouse list no data 1`] = `
|
|||
</div>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||
data-test-id="createWarehouse"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
@ -251487,6 +251500,7 @@ exports[`Storyshots Views / Warehouses / Warehouse list no limits 1`] = `
|
|||
>
|
||||
<button
|
||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-contained-id MuiButton-containedPrimary-id"
|
||||
data-test-id="createWarehouse"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
|
|
|
@ -74,6 +74,7 @@ export const WarehouseListPage: React.FC<WarehouseListPageProps> = ({
|
|||
}
|
||||
>
|
||||
<Button
|
||||
data-test-id="createWarehouse"
|
||||
color="primary"
|
||||
disabled={limitReached}
|
||||
variant="contained"
|
||||
|
|
Loading…
Reference in a new issue