|
|
@@ -1,13 +1,7 @@
|
|
|
/* tslint:disable:no-non-null-assertion no-console */
|
|
|
-import { SortOrder } from '@vendure/common/lib/generated-types';
|
|
|
+import { CurrencyCode, SortOrder } from '@vendure/common/lib/generated-types';
|
|
|
import { pick } from '@vendure/common/lib/pick';
|
|
|
-import {
|
|
|
- DefaultJobQueuePlugin,
|
|
|
- DefaultLogger,
|
|
|
- facetValueCollectionFilter,
|
|
|
- LogLevel,
|
|
|
- mergeConfig,
|
|
|
-} from '@vendure/core';
|
|
|
+import { DefaultJobQueuePlugin, facetValueCollectionFilter, LanguageCode, mergeConfig } from '@vendure/core';
|
|
|
import { createTestEnvironment, E2E_DEFAULT_CHANNEL_TOKEN } from '@vendure/testing';
|
|
|
import { fail } from 'assert';
|
|
|
import gql from 'graphql-tag';
|
|
|
@@ -15,33 +9,11 @@ import path from 'path';
|
|
|
|
|
|
import { initialData } from '../../../e2e-common/e2e-initial-data';
|
|
|
import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
|
|
|
+import * as Codegen from '../../core/e2e/graphql/generated-e2e-admin-types';
|
|
|
import {
|
|
|
- AssignProductsToChannel,
|
|
|
- AssignProductVariantsToChannel,
|
|
|
- ChannelFragment,
|
|
|
- CreateChannel,
|
|
|
- CreateCollection,
|
|
|
- CreateFacet,
|
|
|
- CreateProduct,
|
|
|
- CreateProductVariants,
|
|
|
- CurrencyCode,
|
|
|
- DeleteAsset,
|
|
|
- DeleteProduct,
|
|
|
- DeleteProductVariant,
|
|
|
- LanguageCode,
|
|
|
- RemoveProductsFromChannel,
|
|
|
- RemoveProductVariantsFromChannel,
|
|
|
- SearchCollections,
|
|
|
- SearchFacetValues,
|
|
|
- SearchGetPrices,
|
|
|
- SearchInput,
|
|
|
- UpdateAsset,
|
|
|
- UpdateCollection,
|
|
|
- UpdateProduct,
|
|
|
- UpdateProductVariants,
|
|
|
- UpdateTaxRate,
|
|
|
-} from '../../core/e2e/graphql/generated-e2e-admin-types';
|
|
|
-import { SearchProductsShop } from '../../core/e2e/graphql/generated-e2e-shop-types';
|
|
|
+ SearchProductsShopQuery,
|
|
|
+ SearchProductsShopQueryVariables,
|
|
|
+} from '../../core/e2e/graphql/generated-e2e-shop-types';
|
|
|
import {
|
|
|
ASSIGN_PRODUCTVARIANT_TO_CHANNEL,
|
|
|
ASSIGN_PRODUCT_TO_CHANNEL,
|
|
|
@@ -84,10 +56,9 @@ import {
|
|
|
testSinglePrices,
|
|
|
} from './e2e-helpers';
|
|
|
import {
|
|
|
- GetJobInfo,
|
|
|
+ GetJobInfoQuery,
|
|
|
+ GetJobInfoQueryVariables,
|
|
|
JobState,
|
|
|
- Reindex,
|
|
|
- SearchProductsAdmin,
|
|
|
} from './graphql/generated-e2e-elasticsearch-plugin-types';
|
|
|
|
|
|
// tslint:disable-next-line:no-var-requires
|
|
|
@@ -101,8 +72,8 @@ if (process.env.CI) {
|
|
|
jest.setTimeout(10 * 3000);
|
|
|
}
|
|
|
|
|
|
-interface SearchProductShopVariables extends SearchProductsShop.Variables {
|
|
|
- input: SearchProductsShop.Variables['input'] & {
|
|
|
+interface SearchProductShopVariables extends SearchProductsShopQueryVariables {
|
|
|
+ input: SearchProductsShopQueryVariables['input'] & {
|
|
|
// This input field is dynamically added only when the `indexStockStatus` init option
|
|
|
// of DefaultSearchPlugin is set to `true`, and therefore not included in the generated type. Therefore
|
|
|
// we need to manually patch it here.
|
|
|
@@ -234,14 +205,14 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('price ranges', () => testPriceRanges(shopClient));
|
|
|
|
|
|
it('returns correct facetValues when not grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
|
|
|
- SEARCH_GET_FACET_VALUES,
|
|
|
- {
|
|
|
- input: {
|
|
|
- groupByProduct: false,
|
|
|
- },
|
|
|
+ const result = await shopClient.query<
|
|
|
+ Codegen.SearchFacetValuesQuery,
|
|
|
+ Codegen.SearchFacetValuesQueryVariables
|
|
|
+ >(SEARCH_GET_FACET_VALUES, {
|
|
|
+ input: {
|
|
|
+ groupByProduct: false,
|
|
|
},
|
|
|
- );
|
|
|
+ });
|
|
|
expect(result.search.facetValues).toEqual([
|
|
|
{ count: 21, facetValue: { id: 'T_1', name: 'electronics' } },
|
|
|
{ count: 17, facetValue: { id: 'T_2', name: 'computers' } },
|
|
|
@@ -253,14 +224,14 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('returns correct facetValues when grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
|
|
|
- SEARCH_GET_FACET_VALUES,
|
|
|
- {
|
|
|
- input: {
|
|
|
- groupByProduct: true,
|
|
|
- },
|
|
|
+ const result = await shopClient.query<
|
|
|
+ Codegen.SearchFacetValuesQuery,
|
|
|
+ Codegen.SearchFacetValuesQueryVariables
|
|
|
+ >(SEARCH_GET_FACET_VALUES, {
|
|
|
+ input: {
|
|
|
+ groupByProduct: true,
|
|
|
},
|
|
|
- );
|
|
|
+ });
|
|
|
expect(result.search.facetValues).toEqual([
|
|
|
{ count: 10, facetValue: { id: 'T_1', name: 'electronics' } },
|
|
|
{ count: 6, facetValue: { id: 'T_2', name: 'computers' } },
|
|
|
@@ -272,40 +243,43 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('omits facetValues of private facets', async () => {
|
|
|
- const { createFacet } = await adminClient.query<CreateFacet.Mutation, CreateFacet.Variables>(
|
|
|
- CREATE_FACET,
|
|
|
+ const { createFacet } = await adminClient.query<
|
|
|
+ Codegen.CreateFacetMutation,
|
|
|
+ Codegen.CreateFacetMutationVariables
|
|
|
+ >(CREATE_FACET, {
|
|
|
+ input: {
|
|
|
+ code: 'profit-margin',
|
|
|
+ isPrivate: true,
|
|
|
+ translations: [{ languageCode: LanguageCode.en, name: 'Profit Margin' }],
|
|
|
+ values: [
|
|
|
+ {
|
|
|
+ code: 'massive',
|
|
|
+ translations: [{ languageCode: LanguageCode.en, name: 'massive' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ });
|
|
|
+ await adminClient.query<Codegen.UpdateProductMutation, Codegen.UpdateProductMutationVariables>(
|
|
|
+ UPDATE_PRODUCT,
|
|
|
{
|
|
|
input: {
|
|
|
- code: 'profit-margin',
|
|
|
- isPrivate: true,
|
|
|
- translations: [{ languageCode: LanguageCode.en, name: 'Profit Margin' }],
|
|
|
- values: [
|
|
|
- {
|
|
|
- code: 'massive',
|
|
|
- translations: [{ languageCode: LanguageCode.en, name: 'massive' }],
|
|
|
- },
|
|
|
- ],
|
|
|
+ id: 'T_2',
|
|
|
+ // T_1 & T_2 are the existing facetValues (electronics & photo)
|
|
|
+ facetValueIds: ['T_1', 'T_2', createFacet.values[0].id],
|
|
|
},
|
|
|
},
|
|
|
);
|
|
|
- await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
|
|
|
- input: {
|
|
|
- id: 'T_2',
|
|
|
- // T_1 & T_2 are the existing facetValues (electronics & photo)
|
|
|
- facetValueIds: ['T_1', 'T_2', createFacet.values[0].id],
|
|
|
- },
|
|
|
- });
|
|
|
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
|
|
|
- const result = await shopClient.query<SearchFacetValues.Query, SearchFacetValues.Variables>(
|
|
|
- SEARCH_GET_FACET_VALUES,
|
|
|
- {
|
|
|
- input: {
|
|
|
- groupByProduct: true,
|
|
|
- },
|
|
|
+ const result = await shopClient.query<
|
|
|
+ Codegen.SearchFacetValuesQuery,
|
|
|
+ Codegen.SearchFacetValuesQueryVariables
|
|
|
+ >(SEARCH_GET_FACET_VALUES, {
|
|
|
+ input: {
|
|
|
+ groupByProduct: true,
|
|
|
},
|
|
|
- );
|
|
|
+ });
|
|
|
expect(result.search.facetValues).toEqual([
|
|
|
{ count: 10, facetValue: { id: 'T_1', name: 'electronics' } },
|
|
|
{ count: 6, facetValue: { id: 'T_2', name: 'computers' } },
|
|
|
@@ -317,35 +291,35 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('returns correct collections when not grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchCollections.Query, SearchCollections.Variables>(
|
|
|
- SEARCH_GET_COLLECTIONS,
|
|
|
- {
|
|
|
- input: {
|
|
|
- groupByProduct: false,
|
|
|
- },
|
|
|
+ const result = await shopClient.query<
|
|
|
+ Codegen.SearchCollectionsQuery,
|
|
|
+ Codegen.SearchCollectionsQueryVariables
|
|
|
+ >(SEARCH_GET_COLLECTIONS, {
|
|
|
+ input: {
|
|
|
+ groupByProduct: false,
|
|
|
},
|
|
|
- );
|
|
|
+ });
|
|
|
expect(result.search.collections).toEqual([
|
|
|
{ collection: { id: 'T_2', name: 'Plants' }, count: 3 },
|
|
|
]);
|
|
|
});
|
|
|
|
|
|
it('returns correct collections when grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchCollections.Query, SearchCollections.Variables>(
|
|
|
- SEARCH_GET_COLLECTIONS,
|
|
|
- {
|
|
|
- input: {
|
|
|
- groupByProduct: true,
|
|
|
- },
|
|
|
+ const result = await shopClient.query<
|
|
|
+ Codegen.SearchCollectionsQuery,
|
|
|
+ Codegen.SearchCollectionsQueryVariables
|
|
|
+ >(SEARCH_GET_COLLECTIONS, {
|
|
|
+ input: {
|
|
|
+ groupByProduct: true,
|
|
|
},
|
|
|
- );
|
|
|
+ });
|
|
|
expect(result.search.collections).toEqual([
|
|
|
{ collection: { id: 'T_2', name: 'Plants' }, count: 3 },
|
|
|
]);
|
|
|
});
|
|
|
|
|
|
it('encodes the productId and productVariantId', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -362,14 +336,14 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('omits results for disabled ProductVariants', async () => {
|
|
|
- await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
- UPDATE_PRODUCT_VARIANTS,
|
|
|
- {
|
|
|
- input: [{ id: 'T_3', enabled: false }],
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductVariantsMutation,
|
|
|
+ Codegen.UpdateProductVariantsMutationVariables
|
|
|
+ >(UPDATE_PRODUCT_VARIANTS, {
|
|
|
+ input: [{ id: 'T_3', enabled: false }],
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -382,7 +356,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('encodes collectionIds', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -397,7 +371,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('inStock is false and not grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -410,7 +384,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('inStock is false and grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -423,7 +397,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('inStock is true and not grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -436,7 +410,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('inStock is true and grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -449,7 +423,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('inStock is undefined and not grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -462,7 +436,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('inStock is undefined and grouped by product', async () => {
|
|
|
- const result = await shopClient.query<SearchProductsShop.Query, SearchProductShopVariables>(
|
|
|
+ const result = await shopClient.query<SearchProductsShopQuery, SearchProductShopVariables>(
|
|
|
SEARCH_PRODUCTS_SHOP,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -521,15 +495,15 @@ describe('Elasticsearch plugin', () => {
|
|
|
'IHD455T6',
|
|
|
]);
|
|
|
|
|
|
- await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
- UPDATE_PRODUCT_VARIANTS,
|
|
|
- {
|
|
|
- input: search.items.map(i => ({
|
|
|
- id: i.productVariantId,
|
|
|
- sku: i.sku + '_updated',
|
|
|
- })),
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductVariantsMutation,
|
|
|
+ Codegen.UpdateProductVariantsMutationVariables
|
|
|
+ >(UPDATE_PRODUCT_VARIANTS, {
|
|
|
+ input: search.items.map(i => ({
|
|
|
+ id: i.productVariantId,
|
|
|
+ sku: i.sku + '_updated',
|
|
|
+ })),
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
const { search: search2 } = await doAdminSearchQuery(adminClient, {
|
|
|
term: 'drive',
|
|
|
@@ -552,12 +526,12 @@ describe('Elasticsearch plugin', () => {
|
|
|
groupByProduct: false,
|
|
|
});
|
|
|
|
|
|
- await adminClient.query<DeleteProductVariant.Mutation, DeleteProductVariant.Variables>(
|
|
|
- DELETE_PRODUCT_VARIANT,
|
|
|
- {
|
|
|
- id: search.items[0].productVariantId,
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.DeleteProductVariantMutation,
|
|
|
+ Codegen.DeleteProductVariantMutationVariables
|
|
|
+ >(DELETE_PRODUCT_VARIANT, {
|
|
|
+ id: search.items[0].productVariantId,
|
|
|
+ });
|
|
|
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
@@ -575,7 +549,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('updates index when a Product is changed', async () => {
|
|
|
- await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductMutation,
|
|
|
+ Codegen.UpdateProductMutationVariables
|
|
|
+ >(UPDATE_PRODUCT, {
|
|
|
input: {
|
|
|
id: 'T_1',
|
|
|
facetValueIds: [],
|
|
|
@@ -607,7 +584,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
'T_5',
|
|
|
'T_6',
|
|
|
]);
|
|
|
- await adminClient.query<DeleteProduct.Mutation, DeleteProduct.Variables>(DELETE_PRODUCT, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.DeleteProductMutation,
|
|
|
+ Codegen.DeleteProductMutationVariables
|
|
|
+ >(DELETE_PRODUCT, {
|
|
|
id: 'T_5',
|
|
|
});
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
@@ -619,29 +599,29 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('updates index when a Collection is changed', async () => {
|
|
|
- await adminClient.query<UpdateCollection.Mutation, UpdateCollection.Variables>(
|
|
|
- UPDATE_COLLECTION,
|
|
|
- {
|
|
|
- input: {
|
|
|
- id: 'T_2',
|
|
|
- filters: [
|
|
|
- {
|
|
|
- code: facetValueCollectionFilter.code,
|
|
|
- arguments: [
|
|
|
- {
|
|
|
- name: 'facetValueIds',
|
|
|
- value: `["T_4"]`,
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'containsAny',
|
|
|
- value: `false`,
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateCollectionMutation,
|
|
|
+ Codegen.UpdateCollectionMutationVariables
|
|
|
+ >(UPDATE_COLLECTION, {
|
|
|
+ input: {
|
|
|
+ id: 'T_2',
|
|
|
+ filters: [
|
|
|
+ {
|
|
|
+ code: facetValueCollectionFilter.code,
|
|
|
+ arguments: [
|
|
|
+ {
|
|
|
+ name: 'facetValueIds',
|
|
|
+ value: `["T_4"]`,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'containsAny',
|
|
|
+ value: `false`,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- );
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
// add an additional check for the collection filters to update
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
@@ -678,8 +658,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
it('updates index when a Collection created', async () => {
|
|
|
const { createCollection } = await adminClient.query<
|
|
|
- CreateCollection.Mutation,
|
|
|
- CreateCollection.Variables
|
|
|
+ Codegen.CreateCollectionMutation,
|
|
|
+ Codegen.CreateCollectionMutationVariables
|
|
|
>(CREATE_COLLECTION, {
|
|
|
input: {
|
|
|
translations: [
|
|
|
@@ -723,7 +703,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('updates index when a taxRate is changed', async () => {
|
|
|
- await adminClient.query<UpdateTaxRate.Mutation, UpdateTaxRate.Variables>(UPDATE_TAX_RATE, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateTaxRateMutation,
|
|
|
+ Codegen.UpdateTaxRateMutationVariables
|
|
|
+ >(UPDATE_TAX_RATE, {
|
|
|
input: {
|
|
|
// Default Channel's defaultTaxZone is Europe (id 2) and the id of the standard TaxRate
|
|
|
// to Europe is 2.
|
|
|
@@ -732,15 +715,15 @@ describe('Elasticsearch plugin', () => {
|
|
|
},
|
|
|
});
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
- const result = await adminClient.query<SearchGetPrices.Query, SearchGetPrices.Variables>(
|
|
|
- SEARCH_GET_PRICES,
|
|
|
- {
|
|
|
- input: {
|
|
|
- groupByProduct: true,
|
|
|
- term: 'laptop',
|
|
|
- } as SearchInput,
|
|
|
- },
|
|
|
- );
|
|
|
+ const result = await adminClient.query<
|
|
|
+ Codegen.SearchGetPricesQuery,
|
|
|
+ Codegen.SearchGetPricesQueryVariables
|
|
|
+ >(SEARCH_GET_PRICES, {
|
|
|
+ input: {
|
|
|
+ groupByProduct: true,
|
|
|
+ term: 'laptop',
|
|
|
+ } as Codegen.SearchInput,
|
|
|
+ });
|
|
|
expect(result.search.items).toEqual([
|
|
|
{
|
|
|
price: { min: 129900, max: 229900 },
|
|
|
@@ -767,7 +750,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
expect(search1.items[0].productAsset!.id).toBe('T_1');
|
|
|
expect(search1.items[0].productAsset!.focalPoint).toBeNull();
|
|
|
|
|
|
- await adminClient.query<UpdateAsset.Mutation, UpdateAsset.Variables>(UPDATE_ASSET, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateAssetMutation,
|
|
|
+ Codegen.UpdateAssetMutationVariables
|
|
|
+ >(UPDATE_ASSET, {
|
|
|
input: {
|
|
|
id: 'T_1',
|
|
|
focalPoint: {
|
|
|
@@ -791,7 +777,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
const assetId = search1.items[0].productAsset?.id;
|
|
|
expect(assetId).toBeTruthy();
|
|
|
|
|
|
- await adminClient.query<DeleteAsset.Mutation, DeleteAsset.Variables>(DELETE_ASSET, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.DeleteAssetMutation,
|
|
|
+ Codegen.DeleteAssetMutationVariables
|
|
|
+ >(DELETE_ASSET, {
|
|
|
input: {
|
|
|
assetId: assetId!,
|
|
|
force: true,
|
|
|
@@ -815,16 +804,16 @@ describe('Elasticsearch plugin', () => {
|
|
|
const variantToDelete = s1.items.find(i => i.sku === 'IHD455T2_updated')!;
|
|
|
|
|
|
const { deleteProductVariant } = await adminClient.query<
|
|
|
- DeleteProductVariant.Mutation,
|
|
|
- DeleteProductVariant.Variables
|
|
|
+ Codegen.DeleteProductVariantMutation,
|
|
|
+ Codegen.DeleteProductVariantMutationVariables
|
|
|
>(DELETE_PRODUCT_VARIANT, { id: variantToDelete.productVariantId });
|
|
|
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
|
|
|
- const { search } = await adminClient.query<SearchGetPrices.Query, SearchGetPrices.Variables>(
|
|
|
- SEARCH_GET_PRICES,
|
|
|
- { input: { term: 'hard drive', groupByProduct: true } },
|
|
|
- );
|
|
|
+ const { search } = await adminClient.query<
|
|
|
+ Codegen.SearchGetPricesQuery,
|
|
|
+ Codegen.SearchGetPricesQueryVariables
|
|
|
+ >(SEARCH_GET_PRICES, { input: { term: 'hard drive', groupByProduct: true } });
|
|
|
expect(search.items[0].price).toEqual({
|
|
|
min: 7896,
|
|
|
max: 13435,
|
|
|
@@ -845,15 +834,15 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('when grouped, disabled is false if at least one variant is enabled', async () => {
|
|
|
- await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
- UPDATE_PRODUCT_VARIANTS,
|
|
|
- {
|
|
|
- input: [
|
|
|
- { id: 'T_1', enabled: false },
|
|
|
- { id: 'T_2', enabled: false },
|
|
|
- ],
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductVariantsMutation,
|
|
|
+ Codegen.UpdateProductVariantsMutationVariables
|
|
|
+ >(UPDATE_PRODUCT_VARIANTS, {
|
|
|
+ input: [
|
|
|
+ { id: 'T_1', enabled: false },
|
|
|
+ { id: 'T_2', enabled: false },
|
|
|
+ ],
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
const result = await doAdminSearchQuery(adminClient, {
|
|
|
groupByProduct: true,
|
|
|
@@ -865,12 +854,12 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('when grouped, disabled is true if all variants are disabled', async () => {
|
|
|
- await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
- UPDATE_PRODUCT_VARIANTS,
|
|
|
- {
|
|
|
- input: [{ id: 'T_4', enabled: false }],
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductVariantsMutation,
|
|
|
+ Codegen.UpdateProductVariantsMutationVariables
|
|
|
+ >(UPDATE_PRODUCT_VARIANTS, {
|
|
|
+ input: [{ id: 'T_4', enabled: false }],
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
const result = await doAdminSearchQuery(adminClient, {
|
|
|
groupByProduct: true,
|
|
|
@@ -883,7 +872,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
});
|
|
|
|
|
|
it('when grouped, disabled is true product is disabled', async () => {
|
|
|
- await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductMutation,
|
|
|
+ Codegen.UpdateProductMutationVariables
|
|
|
+ >(UPDATE_PRODUCT, {
|
|
|
input: {
|
|
|
id: 'T_3',
|
|
|
enabled: false,
|
|
|
@@ -901,7 +893,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
// https://github.com/vendure-ecommerce/vendure/issues/295
|
|
|
it('enabled status survives reindex', async () => {
|
|
|
- await adminClient.query<Reindex.Mutation>(REINDEX);
|
|
|
+ await adminClient.query<Codegen.ReindexMutation>(REINDEX);
|
|
|
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
const result = await doAdminSearchQuery(adminClient, {
|
|
|
@@ -921,8 +913,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
it('creates synthetic index item for Product with no variants', async () => {
|
|
|
const { createProduct } = await adminClient.query<
|
|
|
- CreateProduct.Mutation,
|
|
|
- CreateProduct.Variables
|
|
|
+ Codegen.CreateProductMutation,
|
|
|
+ Codegen.CreateProductMutationVariables
|
|
|
>(CREATE_PRODUCT, {
|
|
|
input: {
|
|
|
facetValueIds: ['T_1'],
|
|
|
@@ -968,8 +960,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
it('removes synthetic index item once a variant is created', async () => {
|
|
|
const { createProductVariants } = await adminClient.query<
|
|
|
- CreateProductVariants.Mutation,
|
|
|
- CreateProductVariants.Variables
|
|
|
+ Codegen.CreateProductVariantsMutation,
|
|
|
+ Codegen.CreateProductVariantsMutationVariables
|
|
|
>(CREATE_PRODUCT_VARIANTS, {
|
|
|
input: [
|
|
|
{
|
|
|
@@ -997,12 +989,12 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
describe('channel handling', () => {
|
|
|
const SECOND_CHANNEL_TOKEN = 'second-channel-token';
|
|
|
- let secondChannel: ChannelFragment;
|
|
|
+ let secondChannel: Codegen.ChannelFragment;
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
const { createChannel } = await adminClient.query<
|
|
|
- CreateChannel.Mutation,
|
|
|
- CreateChannel.Variables
|
|
|
+ Codegen.CreateChannelMutation,
|
|
|
+ Codegen.CreateChannelMutationVariables
|
|
|
>(CREATE_CHANNEL, {
|
|
|
input: {
|
|
|
code: 'second-channel',
|
|
|
@@ -1014,10 +1006,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
defaultShippingZoneId: 'T_1',
|
|
|
},
|
|
|
});
|
|
|
- secondChannel = createChannel as ChannelFragment;
|
|
|
+ secondChannel = createChannel as Codegen.ChannelFragment;
|
|
|
|
|
|
adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
|
|
|
- await adminClient.query<Reindex.Mutation>(REINDEX);
|
|
|
+ await adminClient.query<Codegen.ReindexMutation>(REINDEX);
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
});
|
|
|
|
|
|
@@ -1034,12 +1026,12 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
it('adding product to channel', async () => {
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
- await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
|
|
|
- ASSIGN_PRODUCT_TO_CHANNEL,
|
|
|
- {
|
|
|
- input: { channelId: secondChannel.id, productIds: ['T_1', 'T_2'] },
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.AssignProductsToChannelMutation,
|
|
|
+ Codegen.AssignProductsToChannelMutationVariables
|
|
|
+ >(ASSIGN_PRODUCT_TO_CHANNEL, {
|
|
|
+ input: { channelId: secondChannel.id, productIds: ['T_1', 'T_2'] },
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
|
|
|
adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
|
|
|
@@ -1050,8 +1042,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('removing product from channel', async () => {
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
const { removeProductsFromChannel } = await adminClient.query<
|
|
|
- RemoveProductsFromChannel.Mutation,
|
|
|
- RemoveProductsFromChannel.Variables
|
|
|
+ Codegen.RemoveProductsFromChannelMutation,
|
|
|
+ Codegen.RemoveProductsFromChannelMutationVariables
|
|
|
>(REMOVE_PRODUCT_FROM_CHANNEL, {
|
|
|
input: {
|
|
|
productIds: ['T_2'],
|
|
|
@@ -1068,10 +1060,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('reindexes in channel', async () => {
|
|
|
adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
|
|
|
|
|
|
- const { reindex } = await adminClient.query<Reindex.Mutation>(REINDEX);
|
|
|
+ const { reindex } = await adminClient.query<Codegen.ReindexMutation>(REINDEX);
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
|
|
|
- const { job } = await adminClient.query<GetJobInfo.Query, GetJobInfo.Variables>(
|
|
|
+ const { job } = await adminClient.query<GetJobInfoQuery, GetJobInfoQueryVariables>(
|
|
|
GET_JOB_INFO,
|
|
|
{ id: reindex.id },
|
|
|
);
|
|
|
@@ -1084,8 +1076,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('adding product variant to channel', async () => {
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
await adminClient.query<
|
|
|
- AssignProductVariantsToChannel.Mutation,
|
|
|
- AssignProductVariantsToChannel.Variables
|
|
|
+ Codegen.AssignProductVariantsToChannelMutation,
|
|
|
+ Codegen.AssignProductVariantsToChannelMutationVariables
|
|
|
>(ASSIGN_PRODUCTVARIANT_TO_CHANNEL, {
|
|
|
input: { channelId: secondChannel.id, productVariantIds: ['T_10', 'T_15'] },
|
|
|
});
|
|
|
@@ -1114,8 +1106,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('removing product variant from channel', async () => {
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
await adminClient.query<
|
|
|
- RemoveProductVariantsFromChannel.Mutation,
|
|
|
- RemoveProductVariantsFromChannel.Variables
|
|
|
+ Codegen.RemoveProductVariantsFromChannelMutation,
|
|
|
+ Codegen.RemoveProductVariantsFromChannelMutationVariables
|
|
|
>(REMOVE_PRODUCTVARIANT_FROM_CHANNEL, {
|
|
|
input: { channelId: secondChannel.id, productVariantIds: ['T_1', 'T_15'] },
|
|
|
});
|
|
|
@@ -1142,8 +1134,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('updating product affects current channel', async () => {
|
|
|
adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
|
|
|
const { updateProduct } = await adminClient.query<
|
|
|
- UpdateProduct.Mutation,
|
|
|
- UpdateProduct.Variables
|
|
|
+ Codegen.UpdateProductMutation,
|
|
|
+ Codegen.UpdateProductMutationVariables
|
|
|
>(UPDATE_PRODUCT, {
|
|
|
input: {
|
|
|
id: 'T_3',
|
|
|
@@ -1174,7 +1166,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
it('removing from channel with multiple languages', async () => {
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
|
|
|
- await adminClient.query<UpdateProduct.Mutation, UpdateProduct.Variables>(UPDATE_PRODUCT, {
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductMutation,
|
|
|
+ Codegen.UpdateProductMutationVariables
|
|
|
+ >(UPDATE_PRODUCT, {
|
|
|
input: {
|
|
|
id: 'T_4',
|
|
|
translations: [
|
|
|
@@ -1194,18 +1189,18 @@ describe('Elasticsearch plugin', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- await adminClient.query<AssignProductsToChannel.Mutation, AssignProductsToChannel.Variables>(
|
|
|
- ASSIGN_PRODUCT_TO_CHANNEL,
|
|
|
- {
|
|
|
- input: { channelId: secondChannel.id, productIds: ['T_4'] },
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.AssignProductsToChannelMutation,
|
|
|
+ Codegen.AssignProductsToChannelMutationVariables
|
|
|
+ >(ASSIGN_PRODUCT_TO_CHANNEL, {
|
|
|
+ input: { channelId: secondChannel.id, productIds: ['T_4'] },
|
|
|
+ });
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
|
|
|
async function searchSecondChannelForDEProduct() {
|
|
|
adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
|
|
|
const { search } = await adminClient.query<
|
|
|
- SearchProductsShop.Query,
|
|
|
+ SearchProductsShopQuery,
|
|
|
SearchProductShopVariables
|
|
|
>(
|
|
|
SEARCH_PRODUCTS,
|
|
|
@@ -1222,8 +1217,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
const { removeProductsFromChannel } = await adminClient.query<
|
|
|
- RemoveProductsFromChannel.Mutation,
|
|
|
- RemoveProductsFromChannel.Variables
|
|
|
+ Codegen.RemoveProductsFromChannelMutation,
|
|
|
+ Codegen.RemoveProductsFromChannelMutationVariables
|
|
|
>(REMOVE_PRODUCT_FROM_CHANNEL, {
|
|
|
input: {
|
|
|
productIds: ['T_4'],
|
|
|
@@ -1239,7 +1234,10 @@ describe('Elasticsearch plugin', () => {
|
|
|
|
|
|
describe('multiple language handling', () => {
|
|
|
function searchInLanguage(languageCode: LanguageCode, groupByProduct: boolean) {
|
|
|
- return adminClient.query<SearchProductsAdmin.Query, SearchProductsAdmin.Variables>(
|
|
|
+ return adminClient.query<
|
|
|
+ Codegen.SearchProductsAdminQuery,
|
|
|
+ Codegen.SearchProductsAdminQueryVariables
|
|
|
+ >(
|
|
|
SEARCH_PRODUCTS,
|
|
|
{
|
|
|
input: {
|
|
|
@@ -1257,8 +1255,8 @@ describe('Elasticsearch plugin', () => {
|
|
|
beforeAll(async () => {
|
|
|
adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
|
|
|
const { updateProduct } = await adminClient.query<
|
|
|
- UpdateProduct.Mutation,
|
|
|
- UpdateProduct.Variables
|
|
|
+ Codegen.UpdateProductMutation,
|
|
|
+ Codegen.UpdateProductMutationVariables
|
|
|
>(UPDATE_PRODUCT, {
|
|
|
input: {
|
|
|
id: 'T_1',
|
|
|
@@ -1279,22 +1277,22 @@ describe('Elasticsearch plugin', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
- UPDATE_PRODUCT_VARIANTS,
|
|
|
- {
|
|
|
- input: [
|
|
|
- {
|
|
|
- id: updateProduct.variants[0].id,
|
|
|
- translations: [
|
|
|
- {
|
|
|
- languageCode: LanguageCode.fr,
|
|
|
- name: 'laptop variant fr',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- );
|
|
|
+ await adminClient.query<
|
|
|
+ Codegen.UpdateProductVariantsMutation,
|
|
|
+ Codegen.UpdateProductVariantsMutationVariables
|
|
|
+ >(UPDATE_PRODUCT_VARIANTS, {
|
|
|
+ input: [
|
|
|
+ {
|
|
|
+ id: updateProduct.variants[0].id,
|
|
|
+ translations: [
|
|
|
+ {
|
|
|
+ languageCode: LanguageCode.fr,
|
|
|
+ name: 'laptop variant fr',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
|
|
|
await awaitRunningJobs(adminClient);
|
|
|
});
|
|
|
@@ -1385,7 +1383,7 @@ describe('Elasticsearch plugin', () => {
|
|
|
}`;
|
|
|
try {
|
|
|
await shopClient.query(gql(query));
|
|
|
- } catch (error) {
|
|
|
+ } catch (error: any) {
|
|
|
expect(error).toBeDefined();
|
|
|
expect(error.message).toContain('Cannot query field "hello"');
|
|
|
return;
|