Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('Shop customers', () => {
const { server, adminClient, shopClient } = createTestEnvironment(testConfig);
let customer: GetCustomer.Customer;
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
customerCount: 2,
});
await adminClient.asSuperAdmin();
// Fetch the first Customer and store it as the `customer` variable.
const { customers } = await adminClient.query(gql`
query GetCustomerIds {
customers {
items {
describe('Stock control', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig, {
paymentOptions: {
paymentMethodHandlers: [testSuccessfulPaymentMethod],
},
}),
);
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-stock-control.csv'),
customerCount: 2,
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
describe('Shop orders', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig, {
paymentOptions: {
paymentMethodHandlers: [
testSuccessfulPaymentMethod,
testFailingPaymentMethod,
testErrorPaymentMethod,
],
},
orderOptions: {
orderItemsLimit: 99,
},
}),
);
beforeAll(async () => {
await server.init({
describe('Customer resolver', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig, { plugins: [TestEmailPlugin] }),
);
let firstCustomer: GetCustomerList.Items;
let secondCustomer: GetCustomerList.Items;
let thirdCustomer: GetCustomerList.Items;
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
customerCount: 5,
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
describe('Role resolver', () => {
const { server, adminClient } = createTestEnvironment(testConfig);
let createdRole: Role.Fragment;
let defaultRoles: Role.Fragment[];
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
customerCount: 1,
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
afterAll(async () => {
await server.destroy();
});
describe('Authorization & permissions', () => {
const { server, adminClient } = createTestEnvironment(testConfig);
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
customerCount: 1,
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
afterAll(async () => {
await server.destroy();
});
describe('admin permissions', () => {
describe('Facet resolver', () => {
const { server, adminClient } = createTestEnvironment(testConfig);
let countries: GetCountryList.Items[];
let GB: GetCountryList.Items;
let AT: GetCountryList.Items;
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
customerCount: 1,
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
afterAll(async () => {
await server.destroy();
describe('Product resolver', () => {
const { server, adminClient, shopClient } = createTestEnvironment(testConfig);
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
customerCount: 1,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
afterAll(async () => {
await server.destroy();
});
describe('products list query', () => {
describe('Shop catalog', () => {
const { server, adminClient, shopClient } = createTestEnvironment(testConfig);
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-full.csv'),
customerCount: 1,
});
await adminClient.asSuperAdmin();
}, TEST_SETUP_TIMEOUT_MS);
afterAll(async () => {
await server.destroy();
});
describe('products', () => {
describe('Elasticsearch plugin', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig, {
plugins: [
ElasticsearchPlugin.init({
indexPrefix: 'e2e-tests',
port: process.env.CI ? +(process.env.ELASTICSEARCH_PORT || 9200) : 9200,
host: process.env.CI
? process.env.ELASTICSEARCH_HOST || 'elasticsearch'
: 'http://192.168.99.100',
}),
],
}),
);
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),