saleor-dashboard/cypress/e2e/configuration/shippingMethods/editShippingZone.js
poulch d5ed6fb202
Feature flags (#2961)
* [Feature Flags] Abstraction over flags provider (#2928)

* Remove useFlag hook

* [Feature Flags] GraphQL build multiple schemas (#2937)

* Build script

* Refactor build types script

* Remove old codegen.yml

* Clean feature flags in script

* Refactor schema path

* Restore useAuthProvider

* Update configuration file

* encapsulate details for feature flags provider

* Add proper env to flagsmith provider

* Remove flagsmith mocks

* Vite config define global variables

* Render flagmisth provider only when is used

* Keep name service agnostic

* Test with mocked flagsmith

* Use global FLAGS varaible for env flags

* Fix type issue with FLAGS

* Fix build issue

* Remove duplicate translations

* Fix typo

* Prepare for QA tests

* Remove test feature flag
2023-01-16 14:55:38 +01:00

121 lines
3.9 KiB
JavaScript

// / <reference types="cypress"/>
// / <reference types="../../../support"/>
import faker from "faker";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { shippingZoneDetailsUrl } from "../../../fixtures/urlList";
import { updateChannelWarehouses } from "../../../support/api/requests/Channels";
import {
createShippingZone,
getShippingZone,
} from "../../../support/api/requests/ShippingMethod";
import { createWarehouse } from "../../../support/api/requests/Warehouse";
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
import { fillUpShippingZoneData } from "../../../support/pages/shippingMethodPage";
import { enterAndSelectShippings } from "../../../support/pages/shippingZones";
describe("As a user I should be able to update and delete shipping zone", () => {
const startsWith = "EditShippingZ-";
const name = `${startsWith}${faker.datatype.number()}`;
let defaultChannel;
let shippingZone;
let plAddress;
let warehouse;
before(() => {
cy.clearSessionData().loginUserViaRequest();
deleteShippingStartsWith(startsWith);
getDefaultChannel()
.then(channel => {
defaultChannel = channel;
cy.fixture("addresses");
})
.then(addresses => {
plAddress = addresses.plAddress;
createWarehouse({ name, address: plAddress }).then(warehouseResp => {
warehouse = warehouseResp;
updateChannelWarehouses(defaultChannel.id, warehouse.id);
cy.checkIfDataAreNotNull({
defaultChannel,
shippingZone,
plAddress,
warehouse,
});
});
});
});
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();
createShippingZone(name, "US", defaultChannel.id, warehouse.id).then(
shippingZoneResp => {
shippingZone = shippingZoneResp;
},
);
});
it(
"should be able to update shipping zone. TC: SALEOR_0808",
{ tags: ["@shipping", "@allEnv", "@stable"] },
() => {
const updatedName = `${startsWith}Updated`;
cy.visit(shippingZoneDetailsUrl(shippingZone.id));
fillUpShippingZoneData({
channelName: defaultChannel.name,
country: "Poland",
shippingName: updatedName,
warehouseName: name,
});
getShippingZone(shippingZone.id).then(shippingZone => {
expect(shippingZone.channels).to.have.length(0);
expect(shippingZone.name).to.eq(updatedName);
expect(shippingZone.description).to.eq(updatedName);
expect(shippingZone.warehouses).to.have.length(0);
expect(shippingZone.countries.find(el => el.code === "PL")).to.be.ok;
});
},
);
it(
"should be able to delete shipping zone. TC: SALEOR_0809",
{ tags: ["@shipping", "@allEnv", "@stable"] },
() => {
cy.visit(
shippingZoneDetailsUrl(shippingZone.id),
).deleteElementWithReqAlias("DeleteShippingZone");
getShippingZone(shippingZone.id).should("be.null");
},
);
it(
"should be able to delete several shipping zones on shipping zones list page. TC: SALEOR_0810",
{ tags: ["@shipping", "@allEnv", "@stable"] },
() => {
let secondShippingZone;
createShippingZone(
`${startsWith}Second`,
"US",
defaultChannel.id,
warehouse.id,
).then(shippingZoneResp => {
secondShippingZone = shippingZoneResp;
enterAndSelectShippings([shippingZone.id, secondShippingZone.id]);
cy.get(BUTTON_SELECTORS.deleteSelectedElementsButton)
.click()
.addAliasToGraphRequest("BulkDeleteShippingZone")
.get(BUTTON_SELECTORS.submit)
.click()
.wait("@BulkDeleteShippingZone");
getShippingZone(shippingZone.id).should("be.null");
getShippingZone(secondShippingZone.id).should("be.null");
});
},
);
});