update tax configuration before creating vouchers (#2939)

This commit is contained in:
Karolina Rakoczy 2023-01-25 13:32:30 +01:00 committed by GitHub
parent ee00b27795
commit d413c8e852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 144 additions and 168 deletions

View file

@ -142,7 +142,7 @@ async function getTestsStatusAndId(dashboardUrl) {
buildNumber: dashboardUrl.match(getRunRegex)[1],
};
const throwErrorAfterTimeout = setTimeout(function() {
const throwErrorAfterTimeout = setTimeout(function () {
throw new Error("Run have still running status, after all tests executed");
}, 1200000);
@ -166,7 +166,7 @@ async function waitForTestsToFinish(requestVariables) {
)
.then(response => {
if (response.runByBuildNumber.status === "RUNNING") {
setTimeout(async function() {
setTimeout(async function () {
resolve(await waitForTestsToFinish(requestVariables));
}, 10000);
} else {

View file

@ -30,11 +30,11 @@ describe("As an admin I want to use attributes in variant selection", () => {
cy.clearSessionData().loginUserViaRequest();
deleteProductsStartsWith(startsWith);
getDefaultChannel().then(defaultChannel => (channel = defaultChannel));
createCategory({ name: startsWith }).then(
categoryResp => (category = categoryResp),
);
createCategory({ name: startsWith }).then(categoryResp => {
category = categoryResp;
cy.checkIfDataAreNotNull({ channel, category });
});
});
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();

View file

@ -53,6 +53,15 @@ describe("As an admin I want to create voucher", () => {
shippingMethodName: shippingMethodResp.name,
auth: "token",
};
updateTaxConfigurationForChannel({
channelSlug: defaultChannel.slug,
});
cy.checkIfDataAreNotNull({
createdChannel,
dataForCheckout,
defaultChannel,
});
},
);
cy.checkIfDataAreNotNull({
@ -162,9 +171,7 @@ describe("As an admin I want to create voucher", () => {
() => {
const voucherCode = `${startsWith}${faker.datatype.number()}`;
cy.clearSessionData()
.loginUserViaRequest()
.visit(urlList.vouchers);
cy.clearSessionData().loginUserViaRequest().visit(urlList.vouchers);
cy.expectSkeletonIsVisible();
createChannel({ name }).then(channel => {
createdChannel = channel;

View file

@ -52,8 +52,8 @@ describe("As an admin I want to update vouchers", () => {
auth: "token",
};
},
cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product }),
);
cy.checkIfDataAreNotNull({ dataForCheckout, defaultChannel, product });
});
beforeEach(() => {

View file

@ -174,9 +174,7 @@ describe("Creating variants", () => {
const name = `${startsWith}${faker.datatype.number()}`;
const prices = { sellingPrice: 10, costPrice: 6 };
cy.visit(urlList.products)
.get(PRODUCTS_LIST.createProductBtn)
.click();
cy.visit(urlList.products).get(PRODUCTS_LIST.createProductBtn).click();
fillUpProductTypeDialog({ productType: simpleProductType.name });
cy.get(BUTTON_SELECTORS.submit)
.click()

View file

@ -201,9 +201,7 @@ describe("Staff members", () => {
.get(SHARED_ELEMENTS.searchInput)
.type(`${email} {enter}`);
cy.waitForProgressBarToNotExist();
cy.get(STAFF_MEMBERS_LIST.staffAvatar)
.first()
.should("be.visible");
cy.get(STAFF_MEMBERS_LIST.staffAvatar).first().should("be.visible");
cy.waitForProgressBarToNotExist()
.get(STAFF_MEMBERS_LIST.staffStatusText)
.first()
@ -245,19 +243,11 @@ describe("Staff members", () => {
password: Cypress.env("USER_PASSWORD"),
});
cy.visit(urlList.staffMembers)
.get(LOGIN_SELECTORS.userMenu)
.click();
cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
cy.get(LOGIN_SELECTORS.accountSettings).click();
cy.get(STAFF_MEMBER_DETAILS.staffFirstName)
.clear()
.type("สมชาย");
cy.get(STAFF_MEMBER_DETAILS.staffLastName)
.clear()
.type(newLastName);
cy.get(STAFF_MEMBER_DETAILS.staffEmail)
.clear()
.type(changedEmail);
cy.get(STAFF_MEMBER_DETAILS.staffFirstName).clear().type("สมชาย");
cy.get(STAFF_MEMBER_DETAILS.staffLastName).clear().type(newLastName);
cy.get(STAFF_MEMBER_DETAILS.staffEmail).clear().type(changedEmail);
// Test blocked from this point by https://github.com/saleor/saleor-dashboard/issues/2847
cy.get(BUTTON_SELECTORS.confirm).confirmationMessageShouldAppear();
@ -295,9 +285,7 @@ describe("Staff members", () => {
password: Cypress.env("USER_PASSWORD"),
});
cy.visit(urlList.staffMembers)
.get(LOGIN_SELECTORS.userMenu)
.click();
cy.visit(urlList.staffMembers).get(LOGIN_SELECTORS.userMenu).click();
cy.get(LOGIN_SELECTORS.accountSettings).click();
cy.get(STAFF_MEMBER_DETAILS.changePasswordBtn).click();
cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.oldPassword).type(
@ -306,9 +294,7 @@ describe("Staff members", () => {
cy.get(STAFF_MEMBER_DETAILS.changePasswordModal.newPassword).type(
newPass,
);
cy.get(BUTTON_SELECTORS.submit)
.click()
.confirmationMessageShouldAppear();
cy.get(BUTTON_SELECTORS.submit).click().confirmationMessageShouldAppear();
cy.clearSessionData().loginUserViaRequest("auth", {
email: newEmail,

View file

@ -6,7 +6,7 @@ import {
export function updateTaxConfigurationForChannel({
channelSlug = "default-channel",
chargeTaxes = true,
chargeTaxes = false,
taxCalculationStrategy = "FLAT_RATES",
pricesEnteredWithTax = "false",
}) {

View file

@ -33,12 +33,8 @@ const AppLayout: React.FC<AppLayoutProps> = ({
const [appState] = useAppState();
const [isNavigatorVisible, setNavigatorVisibility] = React.useState(false);
const {
availableChannels,
channel,
isPickerActive,
setChannel,
} = useAppChannel(false);
const { availableChannels, channel, isPickerActive, setChannel } =
useAppChannel(false);
const toggleTheme = () => setTheme(isDarkTheme(themeType) ? "light" : "dark");

View file

@ -20,9 +20,9 @@ export interface CustomAppWebhookDetailsProps {
id: string;
}
export const CustomAppWebhookDetails: React.FC<CustomAppWebhookDetailsProps> = ({
id,
}) => {
export const CustomAppWebhookDetails: React.FC<
CustomAppWebhookDetailsProps
> = ({ id }) => {
const notify = useNotifier();
const intl = useIntl();

View file

@ -246,7 +246,7 @@ type InferPromiseResult<T> = T extends Promise<infer V> ? V : never;
export const extractMutationErrors = async <
TData extends InferPromiseResult<TPromise>,
TPromise extends Promise<FetchResult<TData>>,
TErrors extends ReturnType<typeof getMutationErrors>
TErrors extends ReturnType<typeof getMutationErrors>,
>(
submitPromise: TPromise,
): Promise<TErrors> => {
@ -269,7 +269,7 @@ export const hasMutationErrors = (result: FetchResult): boolean => {
export const getMutationErrors = <
T extends FetchResult<any>,
TData extends T["data"],
TErrors extends TData[keyof TData]["errors"]
TErrors extends TData[keyof TData]["errors"],
>(
result: T,
): TErrors[] => {
@ -283,7 +283,7 @@ export const getMutationErrors = <
};
export function getMutationStatus<
TData extends Record<string, SaleorMutationResult | any>
TData extends Record<string, SaleorMutationResult | any>,
>(opts: MutationResult<TData>): ConfirmButtonTransitionState {
const errors = getMutationErrors(opts);
@ -389,9 +389,7 @@ export function splitDateTime(dateTime: string) {
};
}
// Default html input format YYYY-MM-DD HH:mm
const splitDateTime = moment(dateTime)
.format("YYYY-MM-DD HH:mm")
.split(" ");
const splitDateTime = moment(dateTime).format("YYYY-MM-DD HH:mm").split(" ");
return {
date: splitDateTime[0],
time: splitDateTime[1],
@ -430,7 +428,7 @@ export function findValueInEnum<TEnum extends {}>(
throw new Error(`Value ${needle} not found in enum`);
}
return (needle as unknown) as TEnum[keyof TEnum];
return needle as unknown as TEnum[keyof TEnum];
}
export function parseBoolean(a: string, defaultValue: boolean): boolean {
@ -521,10 +519,7 @@ export function PromiseQueue() {
function add<T>(operation: (value: T | void) => PromiseLike<T>) {
return new Promise((resolve, reject) => {
queue = queue
.then(operation)
.then(resolve)
.catch(reject);
queue = queue.then(operation).then(resolve).catch(reject);
});
}
@ -545,9 +540,9 @@ export const getBySlug = (slugToCompare: string) => (obj: SlugNode) =>
export const getById = (idToCompare: string) => (obj: Node) =>
obj.id === idToCompare;
export const getByUnmatchingId = (idToCompare: string) => (obj: {
id: string;
}) => obj.id !== idToCompare;
export const getByUnmatchingId =
(idToCompare: string) => (obj: { id: string }) =>
obj.id !== idToCompare;
export const findById = <T extends Node>(id: string, list?: T[]) =>
list?.find(getById(id));

View file

@ -49,7 +49,8 @@ export const AppListPage: React.FC<AppListPageProps> = props => {
appsInstallations,
installableMarketplaceApps,
);
const verifiedInstallableMarketplaceApps = getVerifiedInstallableMarketplaceApps(
const verifiedInstallableMarketplaceApps =
getVerifiedInstallableMarketplaceApps(
installedApps,
installableMarketplaceApps,
);

View file

@ -341,7 +341,8 @@ describe("App List verified installable marketplace apps util", () => {
];
// Act
const verifiedInstallableMarketplaceApps = getVerifiedInstallableMarketplaceApps(
const verifiedInstallableMarketplaceApps =
getVerifiedInstallableMarketplaceApps(
installedApps,
installableMarketplaceApps,
);

View file

@ -68,10 +68,8 @@ function useActiveAppsInstallations({
const handleAppInstallRetry = (id: string) =>
retryInstallApp({ variables: { id } });
const [
deleteInProgressApp,
deleteInProgressAppOpts,
] = useAppDeleteFailedInstallationMutation({
const [deleteInProgressApp, deleteInProgressAppOpts] =
useAppDeleteFailedInstallationMutation({
onCompleted: data => {
if (!data?.appDeleteFailedInstallation?.errors?.length) {
removeInProgressAppNotify();

View file

@ -56,9 +56,8 @@ export const getMarketplaceAppsLists = (
}
return {
installableMarketplaceApps: getInstallableMarketplaceApps(
marketplaceAppList,
),
installableMarketplaceApps:
getInstallableMarketplaceApps(marketplaceAppList),
comingSoonMarketplaceApps: getComingSoonMarketplaceApps(marketplaceAppList),
};
};

View file

@ -86,10 +86,8 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
paginationState,
);
const {
data: appsInProgressData,
refetch: appsInProgressRefetch,
} = useAppsInstallationsQuery({
const { data: appsInProgressData, refetch: appsInProgressRefetch } =
useAppsInstallationsQuery({
displayLoader: false,
});
@ -149,13 +147,8 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
AppsConfig.marketplaceApiUri,
);
const {
installableMarketplaceApps,
comingSoonMarketplaceApps,
} = getMarketplaceAppsLists(
!!AppsConfig.marketplaceApiUri,
marketplaceAppList,
);
const { installableMarketplaceApps, comingSoonMarketplaceApps } =
getMarketplaceAppsLists(!!AppsConfig.marketplaceApiUri, marketplaceAppList);
const appsInstallations = appsInProgressData?.appsInstallations;
const installedApps = mapEdgesToItems(installedAppsData?.apps);

View file

@ -91,10 +91,8 @@ export const StaffDetails: React.FC<OrderListProps> = ({ id, params }) => {
skip: !hasManageStaffPermission,
});
const [
updateStaffMember,
updateStaffMemberOpts,
] = useStaffMemberUpdateMutation({
const [updateStaffMember, updateStaffMemberOpts] =
useStaffMemberUpdateMutation({
onCompleted: data => {
if (!maybe(() => data.staffUpdate.errors.length !== 0)) {
notify({

View file

@ -109,9 +109,11 @@ export const TaxClassesPage: React.FC<TaxClassesPageProps> = props => {
rate => rate.label.search(new RegExp(parseQuery(query), "i")) >= 0,
);
const { data: paginatedRates, hasNextPage, hasPreviousPage } = paginate(
filteredRates,
);
const {
data: paginatedRates,
hasNextPage,
hasPreviousPage,
} = paginate(filteredRates);
const formErrors = getFormErrors(["name"], validationErrors);

View file

@ -22,7 +22,8 @@ export const CommonErrorCode = {
REQUIRED: "REQUIRED",
} as const;
export type CommonErrorCode = typeof CommonErrorCode[keyof typeof CommonErrorCode];
export type CommonErrorCode =
(typeof CommonErrorCode)[keyof typeof CommonErrorCode];
export interface CommonError<ErrorCode> {
code: ErrorCode | CommonErrorCode;

View file

@ -9,7 +9,7 @@ export function getFieldError<T extends UserError>(
export type FormErrors<
TField extends string,
TError extends UserError
TError extends UserError,
> = Record<TField, TError | undefined>;
export function getFormErrors<TField extends string, TError extends UserError>(
@ -19,7 +19,7 @@ export function getFormErrors<TField extends string, TError extends UserError>(
return fields.reduce((errs, field) => {
errs[field] = getFieldError(errors, field);
return errs;
}, ({} as unknown) as Record<TField, TError | undefined>);
}, {} as unknown as Record<TField, TError | undefined>);
}
export interface ChannelError {
@ -36,7 +36,7 @@ export function getFieldChannelError<T extends ChannelError>(
export function getFormChannelErrors<
TField extends string,
TError extends ChannelError
TError extends ChannelError,
>(fields: TField[], errors: TError[]) {
return fields.reduce((errs, field) => {
errs[field] = [

View file

@ -10,7 +10,7 @@ import isArray from "lodash/isArray";
function createFilterUtils<
TQueryParams extends {},
TFilters extends {}
TFilters extends {},
>(filters: {}) {
function getActiveFilters(params: TQueryParams): TFilters {
return Object.keys(params)
@ -30,7 +30,7 @@ function createFilterUtils<
tabs: unknown[],
) {
return params.activeTab === undefined
? areFiltersApplied((params as unknown) as TQueryParams)
? areFiltersApplied(params as unknown as TQueryParams)
? tabs.length + 1
: 0
: parseInt(params.activeTab, 10);
@ -53,11 +53,11 @@ export function dedupeFilter<T>(array: T[]): T[] {
export type GetFilterQueryParam<
TFilterKeys extends string,
TFilters extends {}
TFilters extends {},
> = (filter: FilterElement<TFilterKeys>, params?: {}) => TFilters;
export function getFilterQueryParams<
TFilterKeys extends string,
TUrlFilters extends {}
TUrlFilters extends {},
>(
filters: IFilter<TFilterKeys>,
getFilterQueryParam: GetFilterQueryParam<TFilterKeys, TUrlFilters>,
@ -87,7 +87,7 @@ export function getGteLteVariables<T>(variables: GteLte<T>): GteLte<T> | null {
export function getSingleValueQueryParam<
TKey extends string,
TUrlKey extends string
TUrlKey extends string,
>(param: FilterElement<TKey>, key: TUrlKey) {
const { active, value } = param;
@ -105,7 +105,7 @@ export function getSingleValueQueryParam<
export function getSingleEnumValueQueryParam<
TKey extends string,
TUrlKey extends string,
TEnum extends {}
TEnum extends {},
>(param: FilterElementRegular<TKey>, key: TUrlKey, haystack: TEnum) {
const { active, value } = param;
@ -123,7 +123,7 @@ export function getSingleEnumValueQueryParam<
export function getMultipleEnumValueQueryParam<
TKey extends string,
TUrlKey extends string,
TEnum extends {}
TEnum extends {},
>(param: FilterElementRegular<TKey>, key: TUrlKey, haystack: TEnum) {
const { active, value } = param;
@ -140,7 +140,7 @@ export function getMultipleEnumValueQueryParam<
export function getMultipleValueQueryParam<
TKey extends string,
TUrlKey extends string
TUrlKey extends string,
>(param: FilterElement<TKey>, key: TUrlKey) {
const { active, value } = param;
@ -157,7 +157,7 @@ export function getMultipleValueQueryParam<
export function getMinMaxQueryParam<
TKey extends string,
TUrlKey extends string
TUrlKey extends string,
>(param: FilterElement<TKey>, keyFrom: TUrlKey, keyTo: TUrlKey) {
const { active, multiple, value } = param;
@ -183,7 +183,7 @@ export function getMinMaxQueryParam<
export function getKeyValueQueryParam<
TKey extends string,
TUrlKey extends string
TUrlKey extends string,
>(param: FilterElementKeyValue<TKey>, key: TUrlKey) {
const { active, value } = param;

View file

@ -14,7 +14,7 @@ type CreateFilterHandlers<TFilterKeys extends string> = [
function createFilterHandlers<
TFilterKeys extends string,
TFilters extends {}
TFilters extends {},
>(opts: {
getFilterQueryParam: GetFilterQueryParam<TFilterKeys, TFilters>;
navigate: UseNavigatorResult;

View file

@ -56,7 +56,7 @@ export function mapNodeToChoice<T extends ExtendedNode>(
): Array<SingleAutocompleteChoiceType<string>>;
export function mapNodeToChoice<
T extends ExtendedNode | Node,
K extends ChoiceValue
K extends ChoiceValue,
>(nodes: T[], getterFn: (node: T) => K): Array<SingleAutocompleteChoiceType<K>>;
export function mapNodeToChoice<T extends ExtendedNode>(

View file

@ -58,9 +58,8 @@ export function getMenuItemByValue<TMenuData = {}, TValue = string>(
value: TValue,
): IMenuItem<TMenuData, TValue> {
const flatMenu = toFlat(menu);
const flatMenuItem:
| IFlatMenuItem<TMenuData, TValue>
| undefined = flatMenu.find(menuItem => menuItem.value === value);
const flatMenuItem: IFlatMenuItem<TMenuData, TValue> | undefined =
flatMenu.find(menuItem => menuItem.value === value);
if (flatMenuItem === undefined) {
throw new Error(`Value ${value} does not exist in menu`);
@ -117,7 +116,8 @@ export function walkToRoot<TMenuData = {}, TValue = string>(
throw new Error(`Value ${value} does not exist in menu`);
}
return (menuItem.parent === null
return (
menuItem.parent === null
? [menuItem]
: [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)]
).map(flatMenuItem => _fromFlat(flatMenu, flatMenuItem));

View file

@ -32,7 +32,7 @@ export function getArrowDirection(asc: boolean): TableCellHeaderArrowDirection {
// Extracts Sort object from the querystring
export function getSortParams<
TParams extends Sort<TFields>,
TFields extends string
TFields extends string,
>(params: TParams): Sort<TFields> {
return {
asc: params.asc,
@ -43,7 +43,7 @@ export function getSortParams<
// Appends Sort object to the querystring params
export function asSortParams<
TParams extends Record<any, string>,
TFields extends Record<any, string>
TFields extends Record<any, string>,
>(
params: TParams,
fields: TFields,
@ -71,12 +71,12 @@ type GetSortQueryField<TUrlField extends string, TSortField extends string> = (
) => TSortField;
type GetSortQueryVariables<
TSortField extends string,
TParams extends Record<any, any>
TParams extends Record<any, any>,
> = (params: TParams) => SortingInput<TSortField> | undefined;
export function createGetSortQueryVariables<
TUrlField extends string,
TSortField extends string,
TParams extends Record<any, any>
TParams extends Record<any, any>,
>(
getSortQueryField: GetSortQueryField<TUrlField, TSortField>,
): GetSortQueryVariables<TSortField, TParams> {

View file

@ -27,7 +27,8 @@ storiesOf("Warehouses / Create warehouse", module)
.add("form errors", () => (
<WarehouseCreatePage
{...props}
errors={([
errors={(
[
"name",
"city",
"cityArea",
@ -38,7 +39,8 @@ storiesOf("Warehouses / Create warehouse", module)
"postalCode",
"streetAddress1",
"streetAddress2",
] as Array<keyof WarehouseCreatePageFormData>).map(field => ({
] as Array<keyof WarehouseCreatePageFormData>
).map(field => ({
__typename: "WarehouseError",
code: WarehouseErrorCode.INVALID,
field,

View file

@ -32,7 +32,8 @@ storiesOf("Warehouses / Warehouse details", module)
.add("form errors", () => (
<WarehouseDetailsPage
{...props}
errors={([
errors={(
[
"name",
"city",
"cityArea",
@ -43,7 +44,8 @@ storiesOf("Warehouses / Warehouse details", module)
"postalCode",
"streetAddress1",
"streetAddress2",
] as Array<keyof WarehouseDetailsPageFormData>).map(field => ({
] as Array<keyof WarehouseDetailsPageFormData>
).map(field => ({
__typename: "WarehouseError",
code: WarehouseErrorCode.INVALID,
field,

View file

@ -60,10 +60,8 @@ const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
warehouse?.address?.country.country || "",
);
const {
errors: validationErrors,
submit: handleSubmit,
} = useAddressValidation(onSubmit);
const { errors: validationErrors, submit: handleSubmit } =
useAddressValidation(onSubmit);
const initialForm: WarehouseDetailsPageFormData = {
city: warehouse?.address.city ?? "",

View file

@ -13,6 +13,5 @@ export function getSortQueryField(
}
}
export const getSortQueryVariables = createGetSortQueryVariables(
getSortQueryField,
);
export const getSortQueryVariables =
createGetSortQueryVariables(getSortQueryField);

View file

@ -1,3 +1,3 @@
module.exports = async function() {
module.exports = async function () {
process.env.TZ = "UTC";
};