Skip to content

Commit

Permalink
Add datagrid on shipping methods view (#4176)
Browse files Browse the repository at this point in the history
* Strict TS adjustments

* Add datagrid to shipping zones list

* Support for bulk delete

* Extract messages

* Add changeset

* Cleanup

* Fix stories & fixtures

* Fix freeze columns

* Replace params.ids with selectedRowIds

* Implement search & relocate bulk delete button

* Unify margins

* Move default weight unit form to TopNav.Menu

* Add weight configuration modal

* Fix type issue

* Add messages

* Fix strict mode

* Simplify modal closing

* Disable dialog when incorrect unit is selected

* Move outside render

* Disable pricerange column

* e2e fixes

* Replace combobox with select

* shipping method test - remove wait for skeleton

* Update macaw-ui

* Skip cypress cloud when running e2e tests (#4162)

* wip 
* cr fixes

---------

Co-authored-by: Paweł Chyła <pawel.chyla@saleor.io>

* Update vite sentry library and handle legacy uploading (#4169)

* Handle legacy sentry

* Changeset

* Increate memory for vite sourcemaps (sentry) (#4173)

* Increate memory for vite sourcemaps (sentry)

* Changeset

* Remove legacy sentry

* Use sentry cli (#4175)

* use sentry cli

* use sentry cli

* use sentry cli

* Fix rendering of top products on home, when attributes does not have value (#4172)

* Fix top product on home

* Fix top product on home

* Changeset

* Fix attribute creation when we change input type (#4177)

* Fix attribute creation

* Fix attribute creation

* Fix layouts for translation edition pages (#4178)

* Fix translation pages

* Fix translation pages

* Update changesets based deployments (#4167)

* 3.15.3 release cleanup (#4180)

* Fix address form keeps country state from prev address provided (#4188)

* Fixes Dashboard crash on quick-menu escape (#4166)

* crash-fix#3933

* Update changesets based deployments

* Added sk translation (#4144)

* Added sk translation

* add changeset for SK translation

---------

Co-authored-by: Ladislav Hano <524934@mail.muni.cz>

* Migrate product page to new macaw (#4125)

Co-authored-by: timur <timuric@gmail.com>

* Dashboard modal (#4198)

* Datagrid cell improvements (#4091)

* Implement status cell

* Add auto tags cell

* Tighten types

* Redesign money cell

* Add light text color

* Add custom date cell

* Add color difference

* Remove moment

* Make font bolder

* Add range price

* Switch to new date cell

* Made font heavier

* Make image bigger

* Use tag cells

* Fixed lint errors

* Add percentage display

* Fix type errors

* Add safety check

* Add safety check

* Remove duplicate

* Enable darkmode support

* Fix linter issue

* Refactor date cell

* Refactor money cell

* Rename AutoTags cell to PillCell

* TS cleanup

* Add changeset

* Fix strict mode

* Strict TS fixes

* Tune dark mode colors

* Add fallback for oklch

* Fix date cell

* Fix tests after oklch fallback is added

* Add type - strict mode fix

* Reading channel

* Conditionally set selected channel based on feature flag

* Fix currency crash

* Obtain channel

* Cleanup

* Fix test

* Validate date cell

* Fix passing incorrect date in order list

* Fix invisible dates

* Make default width of date column larger on product and order views

---------

Co-authored-by: timur <timuric@gmail.com>
Co-authored-by: andrzejewsky <vox3r69@gmail.com>

* Update release workflow (#4187)

* Update relase workflow

* Workflow update

* Changesets

* Ubuntu version

* Aws actions update

* Add triage status (#4200)

* Bug triage

* Bug triage

* Triage status

* Bump @adobe/css-tools from 4.0.1 to 4.3.1 (#4145)

Bumps [@adobe/css-tools](https://github.com/adobe/css-tools) from 4.0.1 to 4.3.1.
- [Changelog](https://github.com/adobe/css-tools/blob/main/History.md)
- [Commits](https://github.com/adobe/css-tools/commits)

---
updated-dependencies:
- dependency-name: "@adobe/css-tools"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fixed inconsistent capitalization on translation page (#4160)

* add_voucher_used-info#3972 (#4161)

* add_voucher_used-info#3972

* suggested-update_voucher-used

* Epics template (#4202)

* Add epic template

* Add epic template

* Add epic template

* Improve text

* Fix external app crashing (#4205)

* Fix external app crashing

* Fix external app crashing

* Bump tough-cookie and @cypress/request (#4069)

* Bump tough-cookie and @cypress/request

Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) and [@cypress/request](https://github.com/cypress-io/request). These dependencies needed to be updated together.

Updates `tough-cookie` from 2.5.0 to 4.1.3
- [Release notes](https://github.com/salesforce/tough-cookie/releases)
- [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md)
- [Commits](salesforce/tough-cookie@v2.5.0...v4.1.3)

Updates `@cypress/request` from 2.88.11 to 2.88.12
- [Release notes](https://github.com/cypress-io/request/releases)
- [Changelog](https://github.com/cypress-io/request/blob/master/CHANGELOG.md)
- [Commits](cypress-io/request@v2.88.11...v2.88.12)

---
updated-dependencies:
- dependency-name: tough-cookie
  dependency-type: indirect
- dependency-name: "@cypress/request"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Trigger CI

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: andrzejewsky <vox3r69@gmail.com>

* Fix prepare release workflow dependency (#4207)

* Fix workflow

* Fix workflow

* Handle null

* Refactor modal

* Change as to satisfies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: wojteknowacki <wojciech.nowacki@saleor.io>
Co-authored-by: wojteknowacki <124166231+wojteknowacki@users.noreply.github.com>
Co-authored-by: Paweł Chyła <pawel.chyla@saleor.io>
Co-authored-by: Patryk Andrzejewski <vox3r69@gmail.com>
Co-authored-by: Krzysztof Żuraw <9116238+krzysztofzuraw@users.noreply.github.com>
Co-authored-by: Paweł Chyła <chyla1988@gmail.com>
Co-authored-by: Rishi Jain <itsjainrishi@users.noreply.github.com>
Co-authored-by: Djkáťo <radovan.katrencik@gmail.com>
Co-authored-by: Ladislav Hano <524934@mail.muni.cz>
Co-authored-by: timur <timuric@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tushar Rathore <tushh.r1212@gmail.com>
  • Loading branch information
13 people authored Sep 21, 2023
1 parent 03d1798 commit 646e72f
Show file tree
Hide file tree
Showing 37 changed files with 788 additions and 510 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-boats-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Add datagrid on shipping zones view
17 changes: 4 additions & 13 deletions cypress/e2e/catalog/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,18 @@

import faker from "faker";

import {
CATEGORIES_LIST_SELECTORS,
} from "../../elements/catalog/categories/categories-list";
import {
CATEGORY_DETAILS_SELECTORS,
} from "../../elements/catalog/categories/category-details";
import { CATEGORIES_LIST_SELECTORS } from "../../elements/catalog/categories/categories-list";
import { CATEGORY_DETAILS_SELECTORS } from "../../elements/catalog/categories/category-details";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import {
categoryDetailsUrl,
urlList,
} from "../../fixtures/urlList";
import { categoryDetailsUrl, urlList } from "../../fixtures/urlList";
import {
createCategory as createCategoryRequest,
getCategory,
} from "../../support/api/requests/Category";
import * as channelsUtils from "../../support/api/utils/channelsUtils";
import * as productsUtils from "../../support/api/utils/products/productsUtils";
import {
ensureCanvasStatic,
} from "../../support/customCommands/sharedElementsOperations/canvas";
import { ensureCanvasStatic } from "../../support/customCommands/sharedElementsOperations/canvas";
import {
createCategory,
updateCategory,
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/configuration/plugins/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

import faker from "faker";

import {
PLUGINS_DETAILS_SELECTORS,
} from "../../../elements/plugins/pluginDetails";
import { PLUGINS_DETAILS_SELECTORS } from "../../../elements/plugins/pluginDetails";
import { PLUGINS_LIST_SELECTORS } from "../../../elements/plugins/pluginsList";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { urlList } from "../../../fixtures/urlList";
Expand Down
11 changes: 3 additions & 8 deletions cypress/e2e/configuration/shippingMethods/channelsInShipping.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import faker from "faker";

import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import {
SHIPPING_ZONE_DETAILS,
} from "../../../elements/shipping/shipping-zone-details";
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
import { urlList } from "../../../fixtures/urlList";
import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
import { createChannel } from "../../../support/api/requests/Channels";
import {
Expand All @@ -15,10 +14,6 @@ import {
} from "../../../support/api/requests/ShippingMethod";
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
import { selectChannelInHeader } from "../../../support/pages/channelsPage";
import {
enterAndSelectShippings,
enterShippingZone,
} from "../../../support/pages/shippingZones";

describe("As a staff user I want have different shipping method prices for each channel", () => {
const startsWith = "ChannelShippingMethod";
Expand Down Expand Up @@ -74,7 +69,7 @@ describe("As a staff user I want have different shipping method prices for each
"auth",
ONE_PERMISSION_USERS.shipping,
);
enterAndSelectShippings(shippingZone.id, enterShippingZone);
cy.visit(`${urlList.shippingMethods}${shippingZone.id}`);
selectChannelInHeader(defaultChannel.name);
cy.waitForProgressBarToNotBeVisible()
.get(SHARED_ELEMENTS.skeleton)
Expand Down
40 changes: 27 additions & 13 deletions cypress/e2e/configuration/shippingMethods/createShippingMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ import faker from "faker";

import { urlList } from "../../../fixtures/urlList";
import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
import {
updateChannelWarehouses,
} from "../../../support/api/requests/Channels";
import { updateChannelWarehouses } from "../../../support/api/requests/Channels";
import { createCheckout } from "../../../support/api/requests/Checkout";
import { createVariant } from "../../../support/api/requests/Product";
import { createWarehouse } from "../../../support/api/requests/Warehouse";
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
import {
createWaitingForCaptureOrder,
} from "../../../support/api/utils/ordersUtils";
import * as productsUtils
from "../../../support/api/utils/products/productsUtils";
import {
isShippingAvailableInCheckout,
} from "../../../support/api/utils/storeFront/checkoutUtils";
import { createWaitingForCaptureOrder } from "../../../support/api/utils/ordersUtils";
import * as productsUtils from "../../../support/api/utils/products/productsUtils";
import { isShippingAvailableInCheckout } from "../../../support/api/utils/storeFront/checkoutUtils";
import {
createShippingRate,
createShippingZone,
getDifferentDefaultWeight,
openChangeDefaultWeightDialog,
rateOptions,
selectDifferentDefaultWeight,
} from "../../../support/pages/shippingMethodPage";

describe("As a staff user I want to create shipping zone and rate", () => {
Expand Down Expand Up @@ -127,7 +123,7 @@ describe("As a staff user I want to create shipping zone and rate", () => {
"auth",
ONE_PERMISSION_USERS.shipping,
);
cy.visit(urlList.shippingMethods).expectSkeletonIsVisible();
cy.visit(urlList.shippingMethods);
createShippingZone(
shippingName,
warehouse.name,
Expand Down Expand Up @@ -177,7 +173,7 @@ describe("As a staff user I want to create shipping zone and rate", () => {
"auth",
ONE_PERMISSION_USERS.shipping,
);
cy.visit(urlList.shippingMethods).expectSkeletonIsVisible();
cy.visit(urlList.shippingMethods);
createShippingZone(
shippingName,
warehouse.name,
Expand Down Expand Up @@ -217,4 +213,22 @@ describe("As a staff user I want to create shipping zone and rate", () => {
});
},
);
it(
"should be able to change default weight in shipping methods TC: SALEOR_4",
{ tags: ["@shipping", "@allEnv", "@stable"] },
() => {
cy.addAliasToGraphRequest("ShopInfo");
cy.clearSessionData().loginUserViaRequest();
cy.visit(urlList.shippingMethods);
openChangeDefaultWeightDialog();
getDifferentDefaultWeight().then(unit => {
selectDifferentDefaultWeight(unit)
.waitForRequestAndCheckIfNoErrors("@ShopInfo")
.then(resp => {
expect(resp.response.body.data.shop.defaultWeightUnit).equal(unit);
});
});
cy.confirmationMessageShouldAppear();
},
);
});
39 changes: 18 additions & 21 deletions cypress/e2e/configuration/shippingMethods/editShippingZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@

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 { MESSAGES } from "../../../fixtures/";
import { shippingZoneDetailsUrl, urlList } 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 {
fillUpShippingZoneData,
} from "../../../support/pages/shippingMethodPage";
import { enterAndSelectShippings } from "../../../support/pages/shippingZones";
import { fillUpShippingZoneData } from "../../../support/pages/shippingMethodPage";
import { typeShippingNameInSearch } from "../../../support/pages/shippingZones";

describe("As a user I should be able to update and delete shipping zone", () => {
const startsWith = "EditShippingZ-";
Expand Down Expand Up @@ -95,27 +91,28 @@ describe("As a user I should be able to update and delete shipping zone", () =>
);

it(
"should be able to delete several shipping zones on shipping zones list page. TC: SALEOR_0810",
"should be able to delete shipping zones on shipping zones list page. TC: SALEOR_0810",
{ tags: ["@shipping", "@allEnv", "@stable"] },
() => {
const name = `${faker.datatype.number()}`;
let secondShippingZone;

cy.addAliasToGraphRequest("ShippingZones");
cy.addAliasToGraphRequest("BulkDeleteShippingZone");
createShippingZone(
`${startsWith}Second`,
`e2e-shippinig-zone-${name}`,
"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");
cy.visit(urlList.shippingMethods);
typeShippingNameInSearch(shippingZone.name);
cy.deleteFirstRecordFromGridListAndValidate(
shippingZone.name,
"BulkDeleteShippingZone",
"ShippingZones",
);
cy.contains(MESSAGES.noShippingZonesFound).should("be.visible");
});
},
);
Expand Down
4 changes: 4 additions & 0 deletions cypress/elements/shipping/shipping-zones-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export const SHIPPING_ZONES_LIST_SELECTORS = {
addShippingZone: "[data-test-id='add-shipping-zone']",
unitSelect: "[id='mui-component-select-unit']",
saveUnit: '[data-test-id="save-unit"]',
settingsButton: '[data-test-id="show-more-button"]',
changeDefaultWeightUnitButton: '[data-test-id="weight-unit-configuration"]',
weightUnitSelector: '[name="unit"] span',
saveUnitsButton: '[data-test-id="save-unit"]',
};

export const SHIPPING_ZONE_CHECKBOX = shippingId =>
Expand Down
1 change: 1 addition & 0 deletions cypress/fixtures/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const MESSAGES = {
invalidEmailAddress: "Enter a valid email address.",
slugMustBeUnique: "Slug must be unique",
noGiftCardsFound: "No gift cards found",
noShippingZonesFound: "No shipping zones found",
};
1 change: 1 addition & 0 deletions cypress/fixtures/weightsUnits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const WEIGHT_UNITS = ["KG", "G", "LB", "OZ", "TONNE"];
21 changes: 21 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,27 @@ Cypress.Commands.add(
});
},
);
Cypress.Commands.add(
"deleteFirstRecordFromGridListAndValidate",
(expectedName, deleteRequestName, listRequestName) => {
ensureCanvasStatic(SHARED_ELEMENTS.dataGridTable);
cy.get(SHARED_ELEMENTS.firstRowDataGrid)
.invoke("text")
.then(firstOnListName => {
expect(expectedName).to.eq(firstOnListName);
cy.clickGridCell(0, 0);
cy.get(CATEGORY_DETAILS_SELECTORS.deleteCategoriesButton)
.click()
.get(BUTTON_SELECTORS.submit)
.click()
.waitForRequestAndCheckIfNoErrors(`@${deleteRequestName}`)
.waitForRequestAndCheckIfNoErrors(`@${listRequestName}`);
cy.contains(SHARED_ELEMENTS.dataGridTable, firstOnListName).should(
"not.exist",
);
});
},
);

Cypress.on(
"uncaught:exception",
Expand Down
23 changes: 23 additions & 0 deletions cypress/support/pages/shippingMethodPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { SHIPPING_RATE_DETAILS } from "../../elements/shipping/shipping-rate-details";
import { SHIPPING_ZONE_DETAILS } from "../../elements/shipping/shipping-zone-details";
import { SHIPPING_ZONES_LIST_SELECTORS } from "../../elements/shipping/shipping-zones-list";
import { WEIGHT_UNITS } from "../../fixtures/weightsUnits";

export function createShippingZone(
shippingName,
Expand Down Expand Up @@ -200,6 +201,28 @@ export function fillUpDeliveryTime({ min, max }) {
.get(SHIPPING_RATE_DETAILS.maxDeliveryTimeInput)
.clearAndType(max, { force: true });
}
export function openSettings() {
cy.get(SHIPPING_ZONES_LIST_SELECTORS.settingsButton).click();
}
export function openChangeDefaultWeightDialog() {
openSettings();
cy.get(SHIPPING_ZONES_LIST_SELECTORS.changeDefaultWeightUnitButton).click();
}
export function getDifferentDefaultWeight() {
return cy
.get(SHIPPING_ZONES_LIST_SELECTORS.weightUnitSelector)
.invoke("text")
.then(defaultUnit => {
WEIGHT_UNITS.find(unit => {
unit !== defaultUnit;
});
});
}
export function selectDifferentDefaultWeight(unit) {
cy.get(SHIPPING_ZONES_LIST_SELECTORS.weightUnitSelector).click();
cy.contains(unit).click();
return cy.get(SHIPPING_ZONES_LIST_SELECTORS.saveUnitsButton).click();
}

export const rateOptions = {
PRICE_OPTION: SHIPPING_ZONE_DETAILS.addPriceRateButton,
Expand Down
10 changes: 7 additions & 3 deletions cypress/support/pages/shippingZones.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import { SEARCH } from "../../elements/shared/";
import {
SHIPPING_ZONE_CHECKBOX,
SHIPPING_ZONE_NAME
SHIPPING_ZONE_NAME,
} from "../../elements/shipping/shipping-zones-list";
import { urlList } from "../../fixtures/urlList";

export function enterAndSelectShippings(
shippingIds,
actionFunction = selectShippingZone
actionFunction = selectShippingZone,
) {
cy.addAliasToGraphRequest("ShippingZones")
.visit(urlList.shippingMethods)
.findElementsAndMakeActionOnTable({
elementsGraphqlAlias: "ShippingZones",
elementsName: "shippingZones",
elementsIds: shippingIds,
actionFunction
actionFunction,
});
}

export function selectShippingZone(id) {
cy.get(SHIPPING_ZONE_CHECKBOX(id)).click();
}
export function typeShippingNameInSearch(methodName) {
cy.get(SEARCH.searchInput).click().type(methodName);
}

export function enterShippingZone(id) {
cy.get(SHIPPING_ZONE_NAME(id)).click();
Expand Down
Loading

0 comments on commit 646e72f

Please sign in to comment.