Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Shopware v6.5 compatibility #1995

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export interface Customer {
defaultPaymentMethod: PaymentMethod;
defaultBillingAddress: BillingAddress;
defaultShippingAddress: ShippingAddress;
activeBillingAddress: BillingAddress;
activeShippingAddress: ShippingAddress;
addresses: Array<CustomerAddress>;
orderCustomers: Array<OrderCustomer> | null;
autoIncrement: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ import { SeoUrl } from "../navigation/Navigation";
* @public
*/
export type LandingPage = {
active: boolean;
translations: null | unknown;
cmsPage: null | CmsPage;
cmsPageId: string;
name: string;
metaTitle: null | string;
metaDescription: null | string;
keywords: null | string;
url: string;
slotConfig: null | unknown[];
seoUrls: null | SeoUrl[];
_uniqueIdentifier: string;
versionId: string;
translated: {
[key: string]: string;
};
createdAt: string;
updatedAt: null | string;
extensions: unknown;
id: string;
customFields: null | unknown;
cmsPageVersionId: string;
apiAlias: "landing_page";
active: boolean;
translations: null | unknown;
cmsPage: null | CmsPage;
cmsPageId: string;
name: string;
metaTitle: null | string;
metaDescription: null | string;
keywords: null | string;
url: string;
slotConfig: null | unknown[];
seoUrls: null | SeoUrl[];
_uniqueIdentifier: string;
versionId: string;
translated: {
[key: string]: string;
};
createdAt: string;
updatedAt: null | string;
extensions: unknown;
id: string;
customFields: null | unknown;
cmsPageVersionId: string;
apiAlias: "landing_page";
};
4 changes: 2 additions & 2 deletions packages/commons/interfaces/response/SessionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { PaymentMethod } from "../models/checkout/payment/PaymentMethod";
import { ShippingMethod } from "../models/checkout/shipping/ShippingMethod";
import { ShippingAddress } from "../models/checkout/customer/ShippingAddress";
import { Country } from "../models/system/country/Country";
import { User } from "../models/system/user/User";
import { Currency } from "../models/system/currency/Currency";
import { Customer } from "../models/checkout/customer/Customer";

export interface ContextTokenResponse {
contextToken: string;
Expand All @@ -29,7 +29,7 @@ export interface SessionContext {
id: string;
name: string;
}[];
customer?: User;
customer: null | Customer;
paymentMethod: PaymentMethod;
shippingMethod: ShippingMethod;
shippingLocation: {
Expand Down
2 changes: 1 addition & 1 deletion packages/composables/__tests__/useCheckout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe("Composables - useCheckout", () => {
isLoggedIn.value = true;
sessionContextMock.value = {
customer: {
activeBillingAddress: {
defaultBillingAddress: {
street: "some street",
},
},
Expand Down
88 changes: 46 additions & 42 deletions packages/composables/__tests__/useCustomerOrders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("Composables - useCustomerOrders", () => {
id: "12345",
orderNumber: "100123",
},
]
],
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
Expand Down Expand Up @@ -77,7 +77,7 @@ describe("Composables - useCustomerOrders", () => {

it("should return 0 when there is no orders", () => {
const ordersResponse = {
elements: []
elements: [],
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
Expand All @@ -86,29 +86,29 @@ describe("Composables - useCustomerOrders", () => {

expect(getTotal.value).toEqual(0);
});

it("should return total same value with count field", async () => {
const ordersResponse = {
aggregations: {
'count-id': {
count: 20
}
"count-id": {
count: 20,
},
},
elements: Array(20).fill({
id: "11111",
orderNumber: "100120",
})
}),
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
);

const { getTotal, loadOrders } = useCustomerOrders();
await loadOrders();
expect(getTotal.value).toEqual(20);
});
});

describe("getLimit", () => {
it("should return 10 when there is no configuration set", async () => {
const ordersResponse = {
Expand All @@ -127,7 +127,7 @@ describe("Composables - useCustomerOrders", () => {
await loadOrders();
expect(getLimit.value).toEqual(10);
});

it("should return limit from current orders", async () => {
const ordersResponse = {
elements: [
Expand All @@ -136,7 +136,7 @@ describe("Composables - useCustomerOrders", () => {
orderNumber: "100123",
},
],
limit: 11
limit: 11,
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
Expand All @@ -146,42 +146,42 @@ describe("Composables - useCustomerOrders", () => {
expect(getLimit.value).toEqual(11);
});
});

describe("getTotalPagesCount", () => {
it("should return 0 when there is no currentListing", async () => {
const ordersResponse = {
aggregations: {
'count-id': {
count: 0
}
"count-id": {
count: 0,
},
},
elements: []
elements: [],
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
);

const { getTotalPagesCount, loadOrders } = useCustomerOrders();
await loadOrders();
expect(getTotalPagesCount.value).toEqual(0);
});

it("should return ceiled pages count from current listing", async () => {
const ordersResponse = {
aggregations: {
'count-id': {
count: 22
}
"count-id": {
count: 22,
},
},
elements: Array(22).fill({
id: "11111",
orderNumber: "100120",
})
}),
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
);

const { getTotalPagesCount, loadOrders } = useCustomerOrders();
await loadOrders();
expect(getTotalPagesCount.value).toEqual(3);
Expand All @@ -197,27 +197,27 @@ describe("Composables - useCustomerOrders", () => {
it("should return 1 when there is no orders", async () => {
const ordersResponse = {
aggregations: {
'count-id': {
count: 0
}
"count-id": {
count: 0,
},
},
elements: []
elements: [],
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
);

const { getCurrentPage, loadOrders } = useCustomerOrders();
await loadOrders();
expect(getCurrentPage.value).toEqual(1);
});

it("should return page number from current listing", async () => {
const ordersResponse = {
aggregations: {
'count-id': {
count: 3
}
"count-id": {
count: 3,
},
},
page: 3,
limit: 1,
Expand All @@ -229,32 +229,36 @@ describe("Composables - useCustomerOrders", () => {
{
id: "12346",
orderNumber: "100123",
}
]
},
],
};
mockedApiClient.getCustomerOrders.mockResolvedValueOnce(
ordersResponse as any
);

const { getCurrentPage, loadOrders } = useCustomerOrders();
await loadOrders();
expect(getCurrentPage.value).toEqual(3);
});
});

describe("changeCurrentPage", () => {
it("should invoke search with changed page number", async () => {
const ordersResponse = (page: number) : EntityResult<"order", Order[]> => ({
const ordersResponse = (
page: number
): EntityResult<"order", Order[]> => ({
aggregations: [],
page,
limit: 10,
entity: 'order',
entity: "order",
total: 10,
apiAlias: '',
elements: []
apiAlias: "",
elements: [],
});
mockedApiClient.getCustomerOrders.mockImplementationOnce(async (params) => Promise.resolve(ordersResponse(params?.page || 1)));

mockedApiClient.getCustomerOrders.mockImplementationOnce(
async (params) => Promise.resolve(ordersResponse(params?.page || 1))
);

const { changeCurrentPage, getCurrentPage } = useCustomerOrders();
await changeCurrentPage(3);
expect(getCurrentPage.value).toEqual(3);
Expand Down
Loading
Loading