Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
export const TEST_SETUP_TIMEOUT_MS = process.env.E2E_DEBUG ? 1800 * 1000 : 120000;
/**
* For local debugging of the e2e tests, we set a very long timeout value otherwise tests will
* automatically fail for going over the 5 second default timeout.
*/
if (process.env.E2E_DEBUG) {
// tslint:disable-next-line:no-console
console.log('E2E_DEBUG', process.env.E2E_DEBUG, ' - setting long timeout');
jest.setTimeout(1800 * 1000);
}
const packageDir = getPackageDir();
export const testConfig = mergeConfig(defaultTestConfig, {
importExportOptions: {
importAssetsDir: path.join(packageDir, 'fixtures/assets'),
},
});
export function getLoadTestConfig(tokenMethod: 'cookie' | 'bearer'): Required {
const count = getProductCount();
return mergeConfig(defaultConfig, {
paymentOptions: {
paymentMethodHandlers: [examplePaymentHandler],
},
orderOptions: {
orderItemsLimit: 99999,
},
logger: new DefaultLogger({ level: LogLevel.Info }),
dbConnectionOptions: getMysqlConnectionOptions(count),
authOptions: {
tokenMethod,
requireVerification: false,
},
importExportOptions: {
importAssetsDir: path.join(__dirname, './data-sources'),
},
workerOptions: {
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('Shop orders', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig, {
paymentOptions: {
paymentMethodHandlers: [
testSuccessfulPaymentMethod,
testFailingPaymentMethod,
testErrorPaymentMethod,
],
},
orderOptions: {
orderItemsLimit: 99,
},
}),
);
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
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('Registration without email verification', () => {
const { server, shopClient } = createTestEnvironment(
mergeConfig(testConfig, {
plugins: [TestEmailPlugin as any],
authOptions: {
requireVerification: false,
},
}),
);
const userEmailAddress = 'glen.beardsley@test.com';
beforeAll(async () => {
await server.init({
dataDir: path.join(__dirname, '__data__'),
initialData,
productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
customerCount: 1,
});
}, TEST_SETUP_TIMEOUT_MS);
describe('Default search plugin', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig, { plugins: [DefaultSearchPlugin] }),
);
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('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__'),
initialData,