|
|
@@ -10,7 +10,7 @@ import gql from 'graphql-tag';
|
|
|
import path from 'path';
|
|
|
|
|
|
import { initialData } from '../../../e2e-common/e2e-initial-data';
|
|
|
-import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
|
|
|
+import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
|
|
|
import { pick } from '../../common/lib/pick';
|
|
|
|
|
|
import { COLLECTION_FRAGMENT, FACET_VALUE_FRAGMENT } from './graphql/fragments';
|
|
|
@@ -231,7 +231,7 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(updateCollection.assets.map((a) => a.id)).toEqual([assets[3].id, assets[0].id]);
|
|
|
+ expect(updateCollection.assets.map(a => a.id)).toEqual([assets[3].id, assets[0].id]);
|
|
|
});
|
|
|
|
|
|
it('removes all assets', async () => {
|
|
|
@@ -349,7 +349,7 @@ describe('Collection resolver', () => {
|
|
|
expect(result.moveCollection.parent!.id).toBe(electronicsCollection.id);
|
|
|
|
|
|
const positions = await getChildrenOf(electronicsCollection.id);
|
|
|
- expect(positions.map((i) => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
+ expect(positions.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
});
|
|
|
|
|
|
it('re-evaluates Collection contents on move', async () => {
|
|
|
@@ -359,7 +359,7 @@ describe('Collection resolver', () => {
|
|
|
GetCollectionProducts.Query,
|
|
|
GetCollectionProducts.Variables
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -378,7 +378,7 @@ describe('Collection resolver', () => {
|
|
|
});
|
|
|
|
|
|
const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
- expect(afterResult.map((i) => i.id)).toEqual([computersCollection.id, pearCollection.id]);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([computersCollection.id, pearCollection.id]);
|
|
|
});
|
|
|
|
|
|
it('alters the position in the current parent 2', async () => {
|
|
|
@@ -391,7 +391,7 @@ describe('Collection resolver', () => {
|
|
|
});
|
|
|
|
|
|
const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
- expect(afterResult.map((i) => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
});
|
|
|
|
|
|
it('corrects an out-of-bounds negative index value', async () => {
|
|
|
@@ -404,7 +404,7 @@ describe('Collection resolver', () => {
|
|
|
});
|
|
|
|
|
|
const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
- expect(afterResult.map((i) => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([pearCollection.id, computersCollection.id]);
|
|
|
});
|
|
|
|
|
|
it('corrects an out-of-bounds positive index value', async () => {
|
|
|
@@ -417,7 +417,7 @@ describe('Collection resolver', () => {
|
|
|
});
|
|
|
|
|
|
const afterResult = await getChildrenOf(electronicsCollection.id);
|
|
|
- expect(afterResult.map((i) => i.id)).toEqual([computersCollection.id, pearCollection.id]);
|
|
|
+ expect(afterResult.map(i => i.id)).toEqual([computersCollection.id, pearCollection.id]);
|
|
|
});
|
|
|
|
|
|
it(
|
|
|
@@ -452,7 +452,7 @@ describe('Collection resolver', () => {
|
|
|
|
|
|
async function getChildrenOf(parentId: string): Promise<Array<{ name: string; id: string }>> {
|
|
|
const result = await adminClient.query<GetCollections.Query>(GET_COLLECTIONS);
|
|
|
- return result.collections.items.filter((i) => i.parent!.id === parentId);
|
|
|
+ return result.collections.items.filter(i => i.parent!.id === parentId);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -622,7 +622,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: electronicsCollection.id,
|
|
|
});
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -654,7 +654,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: computersCollection.id,
|
|
|
});
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -714,7 +714,7 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- expect(collection!.productVariants.items.map((i) => i.name)).toEqual(['Instant Camera']);
|
|
|
+ expect(collection!.productVariants.items.map(i => i.name)).toEqual(['Instant Camera']);
|
|
|
});
|
|
|
|
|
|
it('photo OR pear', async () => {
|
|
|
@@ -756,7 +756,7 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- expect(collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -811,7 +811,7 @@ describe('Collection resolver', () => {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- expect(collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -867,7 +867,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: collection.id,
|
|
|
});
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Instant Camera',
|
|
|
'Camera Lens',
|
|
|
'SLR Camera',
|
|
|
@@ -883,7 +883,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: collection.id,
|
|
|
});
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual(['Camera Lens']);
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual(['Camera Lens']);
|
|
|
});
|
|
|
|
|
|
it('endsWith operator', async () => {
|
|
|
@@ -895,7 +895,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: collection.id,
|
|
|
});
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Instant Camera',
|
|
|
'SLR Camera',
|
|
|
]);
|
|
|
@@ -910,7 +910,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: collection.id,
|
|
|
});
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -973,7 +973,7 @@ describe('Collection resolver', () => {
|
|
|
GetCollectionProducts.Query,
|
|
|
GetCollectionProducts.Variables
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -986,8 +986,8 @@ describe('Collection resolver', () => {
|
|
|
|
|
|
it('updates contents when ProductVariant is updated', async () => {
|
|
|
const gamingPc240GB = products
|
|
|
- .find((p) => p.name === 'Gaming PC')!
|
|
|
- .variants.find((v) => v.name.includes('240GB'))!;
|
|
|
+ .find(p => p.name === 'Gaming PC')!
|
|
|
+ .variants.find(v => v.name.includes('240GB'))!;
|
|
|
await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
UPDATE_PRODUCT_VARIANTS,
|
|
|
{
|
|
|
@@ -1006,7 +1006,7 @@ describe('Collection resolver', () => {
|
|
|
GetCollectionProducts.Query,
|
|
|
GetCollectionProducts.Variables
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -1020,8 +1020,8 @@ describe('Collection resolver', () => {
|
|
|
|
|
|
it('correctly filters when ProductVariant and Product both have matching FacetValue', async () => {
|
|
|
const gamingPc240GB = products
|
|
|
- .find((p) => p.name === 'Gaming PC')!
|
|
|
- .variants.find((v) => v.name.includes('240GB'))!;
|
|
|
+ .find(p => p.name === 'Gaming PC')!
|
|
|
+ .variants.find(v => v.name.includes('240GB'))!;
|
|
|
await adminClient.query<UpdateProductVariants.Mutation, UpdateProductVariants.Variables>(
|
|
|
UPDATE_PRODUCT_VARIANTS,
|
|
|
{
|
|
|
@@ -1040,7 +1040,7 @@ describe('Collection resolver', () => {
|
|
|
GetCollectionProducts.Query,
|
|
|
GetCollectionProducts.Variables
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearCollection.id });
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -1090,7 +1090,7 @@ describe('Collection resolver', () => {
|
|
|
GetCollectionProducts.Query,
|
|
|
GetCollectionProducts.Variables
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, { id: pearElectronics.id });
|
|
|
- expect(result.collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(result.collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -1132,7 +1132,7 @@ describe('Collection resolver', () => {
|
|
|
>(GET_COLLECTION_PRODUCT_VARIANTS, {
|
|
|
id: pearCollection.id,
|
|
|
});
|
|
|
- expect(collection!.productVariants.items.map((i) => i.name)).toEqual([
|
|
|
+ expect(collection!.productVariants.items.map(i => i.name)).toEqual([
|
|
|
'Laptop 13 inch 8GB',
|
|
|
'Laptop 15 inch 8GB',
|
|
|
'Laptop 13 inch 16GB',
|
|
|
@@ -1143,7 +1143,7 @@ describe('Collection resolver', () => {
|
|
|
});
|
|
|
|
|
|
function getFacetValueId(code: string): string {
|
|
|
- const match = facetValues.find((fv) => fv.code === code);
|
|
|
+ const match = facetValues.find(fv => fv.code === code);
|
|
|
if (!match) {
|
|
|
throw new Error(`Could not find a FacetValue with the code "${code}"`);
|
|
|
}
|