Skip to content

Commit

Permalink
chore: test coverage and build types
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus committed Jun 27, 2022
1 parent f3f538a commit fd1f532
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 32 deletions.
2 changes: 1 addition & 1 deletion api/composables.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function createShopware(app: App, options: {
}): {
install(app: App, options?: {
enableDevtools: boolean;
}): void;
} | undefined): void;
_a: App<any>;
_e: EffectScope;
apiInstance: ShopwareApiInstance;
Expand Down
8 changes: 6 additions & 2 deletions api/shopware-6-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ProductListingResult } from '@shopware-pwa/commons';
import { ProductResponse } from '@shopware-pwa/commons';
import { ProductReview } from '@shopware-pwa/commons';
import { Salutation } from '@shopware-pwa/commons';
import { SeoUrl } from '@shopware-pwa/commons';
import { SessionContext } from '@shopware-pwa/commons';
import { ShippingMethod } from '@shopware-pwa/commons';
import { ShopwareSearchParams } from '@shopware-pwa/commons';
Expand Down Expand Up @@ -239,7 +240,7 @@ export const getCheckoutCartLineItemEndpoint: () => string;
// @beta (undocumented)
export const getCheckoutOrderEndpoint: () => string;

// @public (undocumented)
// @public @deprecated (undocumented)
export function getCmsPage(path: string, criteria?: ShopwareSearchParams, contextInstance?: ShopwareApiInstance): Promise<CmsPageResponse>;

// @beta (undocumented)
Expand Down Expand Up @@ -282,7 +283,7 @@ export const getCustomerAddAddressEndpoint: () => string;
export function getCustomerAddress(addressId: string, contextInstance?: ShopwareApiInstance): Promise<CustomerAddress>;

// @beta (undocumented)
export const getCustomerAddressEndpoint: (addressId?: string) => string;
export const getCustomerAddressEndpoint: (addressId?: string | undefined) => string;

// @public
export function getCustomerAddresses(parameters?: ShopwareSearchParams, contextInstance?: ShopwareApiInstance): Promise<EntityResult<"customer_address", CustomerAddress[]>>;
Expand Down Expand Up @@ -374,6 +375,9 @@ export const getRemoveWishlistProductEndpoint: (productId: string) => string;
// @beta (undocumented)
export const getSearchEndpoint: () => string;

// @public (undocumented)
export function getSeoUrl(params: ShopwareSearchParams, contextInstance?: ShopwareApiInstance): Promise<EntityResult<"seo_url", SeoUrl[]>>;

// @beta (undocumented)
export const getSeoUrlEndpoint: () => string;

Expand Down
4 changes: 2 additions & 2 deletions docs/landing/resources/api/composables.createshopware.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export declare function createShopware(app: App, options: {
}): {
install(app: App, options?: {
enableDevtools: boolean;
}): void;
} | undefined): void;
_a: App<any>;
_e: EffectScope;
apiInstance: ShopwareApiInstance;
Expand Down Expand Up @@ -225,5 +225,5 @@ export declare function createShopware(app: App, options: {

<b>Returns:</b>

{ install(app: App, options?: { enableDevtools: boolean; }): void; \_a: App&lt;any&gt;; \_e: EffectScope; apiInstance: ShopwareApiInstance; state: { interceptors: {}; sharedStore: any; shopwareDefaults: { \[x: string\]: { p?: number \| undefined; page?: number \| undefined; limit?: number \| undefined; filter?: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| { operator: string; queries: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| any \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; })\[\]; type: import("@shopware-pwa/commons").SearchFilterType; })\[\] \| undefined; sort?: { field: string; order: string; naturalSorting?: boolean \| undefined; }\[\] \| undefined; postFilter?: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| { operator: string; queries: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| any \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; })\[\]; type: import("@shopware-pwa/commons").SearchFilterType; })\[\] \| undefined; associations?: { \[x: string\]: { associations?: any \| undefined; sort?: string \| { field: string; order: string; naturalSorting: boolean; }\[\] \| undefined; }; } \| undefined; aggregations?: { name: string; type: string; field: string; }\[\] \| undefined; grouping?: { field: string; }\[\] \| undefined; order?: string \| undefined; term?: string \| undefined; ids?: string\[\] \| undefined; properties?: string \| never\[\] \| undefined; manufacturer?: string \| never\[\] \| undefined; includes?: { \[x: string\]: string\[\]; } \| undefined; query?: string \| undefined; }; }; } \| undefined; }
{ install(app: App, options?: { enableDevtools: boolean; } \| undefined): void; \_a: App&lt;any&gt;; \_e: EffectScope; apiInstance: ShopwareApiInstance; state: { interceptors: {}; sharedStore: any; shopwareDefaults: { \[x: string\]: { p?: number \| undefined; page?: number \| undefined; limit?: number \| undefined; filter?: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| { operator: string; queries: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| any \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; })\[\]; type: import("@shopware-pwa/commons").SearchFilterType; })\[\] \| undefined; sort?: { field: string; order: string; naturalSorting?: boolean \| undefined; }\[\] \| undefined; postFilter?: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| { operator: string; queries: ({ value: string \| null; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; } \| { field: string; parameters: { lt: string \| number; } \| { gt: string \| number; } \| { lte: string \| number; } \| { gte: string \| number; } \| { lt: string \| number; gt: string \| number; } \| { lt: string \| number; gte: string \| number; } \| { lte: string \| number; gt: string \| number; } \| { lte: string \| number; gte: string \| number; }; type: import("@shopware-pwa/commons").SearchFilterType; } \| any \| { value: string\[\]; field: string; type: import("@shopware-pwa/commons").SearchFilterType; })\[\]; type: import("@shopware-pwa/commons").SearchFilterType; })\[\] \| undefined; associations?: { \[x: string\]: { associations?: any \| undefined; sort?: string \| { field: string; order: string; naturalSorting: boolean; }\[\] \| undefined; }; } \| undefined; aggregations?: { name: string; type: string; field: string; }\[\] \| undefined; grouping?: { field: string; }\[\] \| undefined; order?: string \| undefined; term?: string \| undefined; ids?: string\[\] \| undefined; properties?: string \| never\[\] \| undefined; manufacturer?: string \| never\[\] \| undefined; includes?: { \[x: string\]: string\[\]; } \| undefined; query?: string \| undefined; }; }; } \| undefined; }

52 changes: 26 additions & 26 deletions docs/landing/resources/api/helpers.getproductreviews.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@shopware-pwa/helpers](./helpers.md) &gt; [getProductReviews](./helpers.getproductreviews.md)

## getProductReviews() function

Format product reviews to ui-interfaces

<b>Signature:</b>

```typescript
export declare function getProductReviews({ product, }?: {
product?: Product;
}): UiProductReview[];
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { product, } | { product?: Product; } | |

<b>Returns:</b>

[UiProductReview](./helpers.uiproductreview.md)<!-- -->\[\]

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@shopware-pwa/helpers](./helpers.md) &gt; [getProductReviews](./helpers.getproductreviews.md)

## getProductReviews() function

Format product reviews to ui-interfaces

<b>Signature:</b>

```typescript
export declare function getProductReviews({ product, }?: {
product?: Product;
}): UiProductReview[];
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { product, } | { product?: Product; } | |

<b>Returns:</b>

[UiProductReview](./helpers.uiproductreview.md)<!-- -->\[\]

5 changes: 5 additions & 0 deletions docs/landing/resources/api/shopware-6-client.getcmspage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

## getCmsPage() function

> Warning: This API is now obsolete.
>
> the method is becoming obsolete and will be removed in the future
>
<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
<b>Signature:</b>

```typescript
getCustomerAddressEndpoint: (addressId?: string) => string
getCustomerAddressEndpoint: (addressId?: string | undefined) => string
```
27 changes: 27 additions & 0 deletions docs/landing/resources/api/shopware-6-client.getseourl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@shopware-pwa/shopware-6-client](./shopware-6-client.md) &gt; [getSeoUrl](./shopware-6-client.getseourl.md)

## getSeoUrl() function

<b>Signature:</b>

```typescript
export declare function getSeoUrl(params: ShopwareSearchParams, contextInstance?: ShopwareApiInstance): Promise<EntityResult<"seo_url", SeoUrl[]>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| params | ShopwareSearchParams | |
| contextInstance | [ShopwareApiInstance](./shopware-6-client.shopwareapiinstance.md) | |

<b>Returns:</b>

Promise&lt;EntityResult&lt;"seo\_url", SeoUrl\[\]&gt;&gt;

## Exceptions

ClientApiError

1 change: 1 addition & 0 deletions docs/landing/resources/api/shopware-6-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
| [getProduct(productId, params, contextInstance)](./shopware-6-client.getproduct.md) | Get the product with passed productId |
| [getProductReviews(productId, criteria, contextInstance)](./shopware-6-client.getproductreviews.md) | Get product reviews |
| [getProducts(criteria, contextInstance)](./shopware-6-client.getproducts.md) | Get default amount of products |
| [getSeoUrl(params, contextInstance)](./shopware-6-client.getseourl.md) | |
| [getSeoUrls(entityId, languageId, contextInstance)](./shopware-6-client.getseourls.md) | Returns an array of SEO URLs for given entity Can be used for other languages as well by providing the languageId |
| [getSessionContext(contextInstance)](./shopware-6-client.getsessioncontext.md) | Loads session context, containing all session-related data. |
| [getShippingMethodDetails(shippingId, contextInstance)](./shopware-6-client.getshippingmethoddetails.md) | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { getSeoUrl } from "@shopware-pwa/shopware-6-client";
import { defaultInstance } from "../../../src/apiService";

jest.mock("../../../src/apiService");
const mockedApiInstance = defaultInstance as jest.Mocked<
typeof defaultInstance
>;

describe("PageService - getSeoUrl", () => {
const mockedPost = jest.fn();
beforeEach(() => {
jest.resetAllMocks();
mockedApiInstance.invoke = {
post: mockedPost,
} as any;
});
it("should return seo url entities for given criteria", async () => {
mockedPost.mockResolvedValueOnce({
data: { elements: [{ id: "b218f861361042f3a58a2a9d1b3575b5" }] },
});
const result = await getSeoUrl({
limit: 3,
});
expect(mockedPost).toBeCalledTimes(1);
expect(mockedPost).toBeCalledWith("/store-api/seo-url", {
limit: 3,
});
expect(result).toHaveProperty("elements");
});
});
1 change: 1 addition & 0 deletions packages/shopware-6-client/src/services/pageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { invokePost } from "./pluginService";
/**
* @throws ClientApiError
* @public
* @deprecated the method is becoming obsolete and will be removed in the future as the SwagShopwarePwa plugin won't be needed.
*/
export async function getCmsPage(
path: string,
Expand Down

0 comments on commit fd1f532

Please sign in to comment.