2021-09-27 10:04:21 +00:00
|
|
|
/// <reference types="cypress"/>
|
2021-10-21 10:45:38 +00:00
|
|
|
/// <reference types="../../../support"/>
|
2021-09-27 10:04:21 +00:00
|
|
|
|
2021-07-23 09:46:44 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
2021-10-21 10:45:38 +00:00
|
|
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
2023-07-28 07:48:41 +00:00
|
|
|
import {
|
|
|
|
SHIPPING_ZONE_DETAILS,
|
|
|
|
} from "../../../elements/shipping/shipping-zone-details";
|
|
|
|
import {
|
|
|
|
WAREHOUSES_DETAILS,
|
|
|
|
} from "../../../elements/warehouses/warehouse-details";
|
2021-10-21 10:45:38 +00:00
|
|
|
import { WAREHOUSES_LIST } from "../../../elements/warehouses/warehouses-list";
|
2021-07-23 09:46:44 +00:00
|
|
|
import {
|
|
|
|
shippingZoneDetailsUrl,
|
|
|
|
urlList,
|
2022-06-27 16:49:35 +00:00
|
|
|
warehouseDetailsUrl,
|
2021-10-21 10:45:38 +00:00
|
|
|
} from "../../../fixtures/urlList";
|
2023-07-28 07:48:41 +00:00
|
|
|
import {
|
|
|
|
updateChannelWarehouses,
|
|
|
|
} from "../../../support/api/requests/Channels";
|
2022-07-29 06:35:55 +00:00
|
|
|
import {
|
|
|
|
createShippingZone,
|
|
|
|
createShippingZoneWithoutWarehouse,
|
|
|
|
} from "../../../support/api/requests/ShippingMethod";
|
2021-09-27 10:04:21 +00:00
|
|
|
import {
|
2021-10-05 11:46:58 +00:00
|
|
|
createWarehouse as createWarehouseViaApi,
|
2022-06-27 16:49:35 +00:00
|
|
|
getWarehouse,
|
2021-10-21 10:45:38 +00:00
|
|
|
} from "../../../support/api/requests/Warehouse";
|
|
|
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-07-29 06:35:55 +00:00
|
|
|
describe("As an admin I want to manage warehouses", () => {
|
2022-06-27 09:30:51 +00:00
|
|
|
const startsWith = "CyWarehouse";
|
|
|
|
let usAddress;
|
|
|
|
let secondUsAddress;
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
before(() => {
|
2023-07-28 07:48:41 +00:00
|
|
|
cy.loginUserViaRequest();
|
2022-06-27 09:30:51 +00:00
|
|
|
cy.fixture("addresses").then(addresses => {
|
|
|
|
usAddress = addresses.usAddress;
|
|
|
|
secondUsAddress = addresses.secondUsAddress;
|
2023-01-16 13:55:38 +00:00
|
|
|
cy.checkIfDataAreNotNull({ usAddress, secondUsAddress });
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
beforeEach(() => {
|
2023-07-28 07:48:41 +00:00
|
|
|
cy.loginUserViaRequest();
|
2022-06-27 09:30:51 +00:00
|
|
|
});
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-07-29 06:35:55 +00:00
|
|
|
it(
|
|
|
|
"should be able to create warehouse. TC: SALEOR_1101",
|
2023-05-24 14:27:01 +00:00
|
|
|
{ tags: ["@warehouse", "@allEnv", "@stable", "@oldRelease", "@critical"] },
|
2022-07-29 06:35:55 +00:00
|
|
|
() => {
|
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
cy.visit(urlList.warehouses)
|
|
|
|
.get(WAREHOUSES_LIST.createNewButton)
|
|
|
|
.click()
|
|
|
|
.get(WAREHOUSES_DETAILS.nameInput)
|
|
|
|
.type(name)
|
|
|
|
.fillUpBasicAddress(usAddress)
|
|
|
|
.addAliasToGraphRequest("WarehouseCreate")
|
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@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);
|
|
|
|
cy.expectCorrectBasicAddress(addressResp, usAddress);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
2022-07-29 06:35:55 +00:00
|
|
|
"should be able to add warehouse to shipping zone. TC: SALEOR_1102",
|
|
|
|
{ tags: ["@warehouse", "@allEnv", "@stable"] },
|
2022-06-27 09:30:51 +00:00
|
|
|
() => {
|
2021-07-23 09:46:44 +00:00
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let defaultChannel;
|
|
|
|
let warehouse;
|
|
|
|
let shippingZone;
|
|
|
|
|
|
|
|
getDefaultChannel()
|
|
|
|
.then(channelResp => {
|
|
|
|
defaultChannel = channelResp;
|
2022-07-29 06:35:55 +00:00
|
|
|
|
2021-10-05 11:46:58 +00:00
|
|
|
createWarehouseViaApi({
|
2021-07-23 09:46:44 +00:00
|
|
|
name,
|
2022-06-27 16:49:35 +00:00
|
|
|
address: usAddress,
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(warehouseResp => {
|
|
|
|
warehouse = warehouseResp;
|
2022-07-29 06:35:55 +00:00
|
|
|
|
|
|
|
updateChannelWarehouses(defaultChannel.id, warehouse.id);
|
|
|
|
createShippingZoneWithoutWarehouse(name, "US", defaultChannel.id);
|
2021-07-23 09:46:44 +00:00
|
|
|
})
|
|
|
|
.then(shippingZoneResp => {
|
|
|
|
shippingZone = shippingZoneResp;
|
2022-07-29 06:35:55 +00:00
|
|
|
|
2021-09-27 10:04:21 +00:00
|
|
|
cy.visit(shippingZoneDetailsUrl(shippingZone.id))
|
|
|
|
.fillAutocompleteSelect(
|
|
|
|
SHIPPING_ZONE_DETAILS.warehouseSelector,
|
2022-06-27 16:49:35 +00:00
|
|
|
warehouse.name,
|
2021-09-27 10:04:21 +00:00
|
|
|
)
|
|
|
|
.addAliasToGraphRequest("UpdateShippingZone")
|
2021-07-23 09:46:44 +00:00
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
|
|
|
.click()
|
2021-09-27 10:04:21 +00:00
|
|
|
.waitForRequestAndCheckIfNoErrors("@UpdateShippingZone");
|
2021-07-23 09:46:44 +00:00
|
|
|
getWarehouse(warehouse.id);
|
|
|
|
})
|
|
|
|
.then(warehouseResp => {
|
|
|
|
expect(warehouseResp.shippingZones.edges[0].node.id).to.be.eq(
|
2022-06-27 16:49:35 +00:00
|
|
|
shippingZone.id,
|
2021-07-23 09:46:44 +00:00
|
|
|
);
|
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
|
2022-07-29 06:35:55 +00:00
|
|
|
it(
|
|
|
|
"should be able to delete warehouse. TC: SALEOR_1103",
|
|
|
|
{ tags: ["@warehouse", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
createWarehouseViaApi({
|
|
|
|
name,
|
|
|
|
address: usAddress,
|
|
|
|
}).then(warehouse => {
|
|
|
|
cy.visit(warehouseDetailsUrl(warehouse.id))
|
|
|
|
.get(BUTTON_SELECTORS.deleteButton)
|
|
|
|
.click()
|
|
|
|
.addAliasToGraphRequest("WarehouseDelete")
|
|
|
|
.get(BUTTON_SELECTORS.submit)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@WarehouseDelete");
|
|
|
|
getWarehouse(warehouse.id).should("be.null");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
2021-12-22 13:54:09 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
it(
|
2022-07-29 06:35:55 +00:00
|
|
|
"should be able to remove warehouse from shipping zone. TC: SALEOR_1104",
|
|
|
|
{ tags: ["@warehouse", "@allEnv", "@stable"] },
|
2022-06-27 09:30:51 +00:00
|
|
|
() => {
|
2021-12-22 13:54:09 +00:00
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let defaultChannel;
|
|
|
|
let warehouse;
|
|
|
|
let shippingZone;
|
|
|
|
|
|
|
|
getDefaultChannel()
|
|
|
|
.then(channelResp => {
|
|
|
|
defaultChannel = channelResp;
|
2022-07-29 06:35:55 +00:00
|
|
|
|
2021-12-22 13:54:09 +00:00
|
|
|
createWarehouseViaApi({
|
|
|
|
name,
|
2022-06-27 16:49:35 +00:00
|
|
|
address: usAddress,
|
2022-07-29 06:35:55 +00:00
|
|
|
}).then(warehouseResp => {
|
|
|
|
warehouse = warehouseResp;
|
|
|
|
|
|
|
|
updateChannelWarehouses(defaultChannel.id, warehouse.id);
|
|
|
|
createShippingZone(name, "US", defaultChannel.id, warehouse.id);
|
2021-12-22 13:54:09 +00:00
|
|
|
});
|
|
|
|
})
|
2022-07-29 06:35:55 +00:00
|
|
|
.then(shippingZoneResp => {
|
|
|
|
shippingZone = shippingZoneResp;
|
|
|
|
|
2021-12-22 13:54:09 +00:00
|
|
|
cy.visit(shippingZoneDetailsUrl(shippingZone.id))
|
|
|
|
.get(SHIPPING_ZONE_DETAILS.removeWarehouseButton)
|
|
|
|
.click()
|
|
|
|
.addAliasToGraphRequest("UpdateShippingZone")
|
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@UpdateShippingZone");
|
2022-07-29 06:35:55 +00:00
|
|
|
getWarehouse(warehouse.id).then(warehouseResp => {
|
|
|
|
expect(warehouseResp.shippingZones.edges).to.be.empty;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should be able to update warehouse. TC: SALEOR_1105",
|
|
|
|
{ tags: ["@warehouse", "@allEnv", "@stable"] },
|
|
|
|
() => {
|
|
|
|
const name = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
const updatedName = `${startsWith}${faker.datatype.number()}`;
|
|
|
|
let warehouse;
|
|
|
|
|
|
|
|
createWarehouseViaApi({
|
|
|
|
name,
|
|
|
|
address: usAddress,
|
|
|
|
})
|
|
|
|
.then(warehouseResp => {
|
|
|
|
warehouse = warehouseResp;
|
|
|
|
cy.visit(warehouseDetailsUrl(warehouse.id))
|
|
|
|
.get(WAREHOUSES_DETAILS.nameInput)
|
2023-05-04 08:57:18 +00:00
|
|
|
.clear()
|
|
|
|
.type(updatedName)
|
|
|
|
// .clearAndType(updatedName)
|
2022-07-29 06:35:55 +00:00
|
|
|
.fillUpBasicAddress(secondUsAddress)
|
|
|
|
.addAliasToGraphRequest("WarehouseUpdate")
|
|
|
|
.get(BUTTON_SELECTORS.confirm)
|
|
|
|
.click()
|
|
|
|
.waitForRequestAndCheckIfNoErrors("@WarehouseUpdate");
|
2021-12-22 13:54:09 +00:00
|
|
|
getWarehouse(warehouse.id);
|
|
|
|
})
|
|
|
|
.then(warehouseResp => {
|
2022-07-29 06:35:55 +00:00
|
|
|
const addressResp = warehouseResp.address;
|
|
|
|
expect(warehouseResp.name).to.be.eq(updatedName);
|
|
|
|
cy.expectCorrectBasicAddress(addressResp, secondUsAddress);
|
2021-12-22 13:54:09 +00:00
|
|
|
});
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-23 09:46:44 +00:00
|
|
|
});
|