Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into DX-235-Cancel-next-day-pickup
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrauskopf committed Oct 8, 2020
2 parents d0d7c19 + 86da40e commit 49b500f
Show file tree
Hide file tree
Showing 11 changed files with 1,267 additions and 20 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions src/core/test-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import {
RateShipment,
CreateShipmentReturn,
TrackShipment,
CancelPickupsNextDay
CancelPickupsNextDay,
TrackShipmentReturn,
SameDayPickup,
NextDayPickup,
CancelPickupsSameDay,
RateShipmentReturn,
CancelShipment,
RateShipmentWithAllServices
} from "./test-app/tests";
import { SdkApp } from "./types";
import { TestResults, useTestResults } from "./test-app/runner/test-results";
import { loadAndValidateConfig, LoadAndValidateConfigError } from "./test-app/runner/load-and-validate-config";
import { logFail, logPass, logStep } from "./utils/log-helpers";
import { logResults } from "./utils/log-helpers";
import { RateShipmentWithAllServices } from './test-app/tests/rate-shipment-with-all-services';
import { CancelShipment } from './test-app/tests/cancel-shipment';
import { SameDayPickup } from './test-app/tests/same-day-pickup';
import { NextDayPickup } from './test-app/tests/next-day-pickup';
import { CancelPickupsSameDay } from './test-app/tests/cancel-pickups-same-day';

export const TestAppErrors = LoadAndValidateConfigError;

Expand Down Expand Up @@ -49,7 +51,6 @@ export default async function testApp(
} catch (error) {
switch (error.code) {
case LoadAndValidateConfigError.SchemaInvalid:
case LoadAndValidateConfigError.Filesystem:
case LoadAndValidateConfigError.Syntax:
throw error;
default:
Expand Down Expand Up @@ -166,10 +167,10 @@ function registerTestSuiteModules(app: SdkApp): RegisteredTestSuiteModules {
schedulePickup: [SameDayPickup, NextDayPickup],
rateShipment: [
RateShipment,
RateShipmentWithAllServices
RateShipmentWithAllServices,
RateShipmentReturn
],
// schedulePickup: [SchedulePickupTestSuite],
trackShipment: [TrackShipment],
trackShipment: [TrackShipment, TrackShipmentReturn],
};

const orderAppMethods = {
Expand Down
8 changes: 7 additions & 1 deletion src/core/test-app/runner/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { RateShipmentWithAllServicesConfigOptions } from './config/rate-shipment
import { CancelShipmentConfigOptions } from './config/cancel-shipment';
import { CreateShipmentReturnConfigOptions } from './config/create-shipment-return';
import { SameDayPickupConfigOptions } from './config/same-day-pickup';
import { RateShipmentReturnConfigOptions } from './config/rate-shipment-return';
import { NextDayPickupConfigOptions } from './config/next-day-pickup';
import { TrackShipmentConfigOptions } from './config/track-shipment';
import { TrackShipmentReturnConfigOptions } from './config/track-shipment-return';
import { CancelPickupsSameDayConfigOptions } from './config/cancel-pickups-same-day';

export interface TestsConfig {
Expand All @@ -26,12 +29,15 @@ export interface TestsConfig {
createShipment_return?: CreateShipmentReturnConfigOptions | [CreateShipmentReturnConfigOptions];
rateShipment?: RateShipmentConfigOptions | [RateShipmentConfigOptions];
rateShipment_with_all_services?: RateShipmentWithAllServicesConfigOptions | [RateShipmentWithAllServicesConfigOptions];
rateShipment_return?: RateShipmentReturnConfigOptions | [RateShipmentReturnConfigOptions];
schedulePickup_same_day?: SameDayPickupConfigOptions | [SameDayPickupConfigOptions];
schedulePickup_next_day?: NextDayPickupConfigOptions | [NextDayPickupConfigOptions];
trackShipment?: TrackShipmentConfigOptions | [TrackShipmentConfigOptions];
trackReturnShipment?: TrackShipmentReturnConfigOptions | [TrackShipmentReturnConfigOptions];

cancelPickups_same_day?: CancelPickupsSameDayConfigOptions | [CancelPickupsSameDayConfigOptions];
// createShipment_multi_package?: TestOptions | [TestOptions];
// rateShipmentWithOneService?: RateShipmentConfigOptions | [RateShipmentConfigOptions];
// trackShipment?: TestOptions | [TestOptions];
}

export default interface Config {
Expand Down
21 changes: 21 additions & 0 deletions src/core/test-app/runner/config/rate-shipment-return.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
DateTimeZonePOJO,
AddressWithContactInfoPOJO,
WeightPOJO,
DimensionsPOJO,
} from "@shipengine/connect-sdk";
import { BaseTestConfigOptions } from "./base-test-config-options";

export interface RateShipmentReturnTestParams {
deliveryServiceName: string;
packagingName: string;
shipDateTime: DateTimeZonePOJO | Date | string;
shipFrom: AddressWithContactInfoPOJO;
shipTo: AddressWithContactInfoPOJO;
weight: WeightPOJO;
dimensions: DimensionsPOJO;
}

export interface RateShipmentReturnConfigOptions
extends RateShipmentReturnTestParams,
BaseTestConfigOptions { }
25 changes: 25 additions & 0 deletions src/core/test-app/runner/config/track-shipment-return.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
DateTimeZonePOJO,
AddressWithContactInfoPOJO,
DimensionsPOJO,
WeightPOJO
} from "@shipengine/connect-sdk";
import { NewLabelPOJO } from "@shipengine/connect-sdk/lib/internal";

import { BaseTestConfigOptions } from "./base-test-config-options";

export interface TrackShipmentReturnTestParams {
deliveryServiceName: string;
label: NewLabelPOJO;
shipFrom?: AddressWithContactInfoPOJO;
shipTo?: AddressWithContactInfoPOJO;
weight: WeightPOJO;
dimensions: DimensionsPOJO;
shipDateTime: DateTimeZonePOJO | Date | string;
deliveryConfirmationName?: string;
rmaNumber?: string;
}

export interface TrackShipmentReturnConfigOptions
extends TrackShipmentReturnTestParams,
BaseTestConfigOptions {}
37 changes: 37 additions & 0 deletions src/core/test-app/runner/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ const RateShipmentTestParamsSchema = Joi.object({
}
});

const RateShipmentReturnTestParamsSchema = Joi.object({
...baseTestParamValidations,
...{
deliveryServiceName: Joi.string().optional(),
packagingName: Joi.string().optional(),
shipDateTime: DateTimeZone[_internal].schema.optional(),
shipFrom: AddressWithContactInfo[_internal].schema.optional(),
shipTo: AddressWithContactInfo[_internal].schema.optional(),
weight: Weight[_internal].schema.optional(),
dimensions: Dimensions[_internal].schema.optional(),
}
});

const RateShipmentWithAllServicesTestParamsSchema = Joi.object({
...baseTestParamValidations,
...{
Expand Down Expand Up @@ -244,6 +257,21 @@ const TrackShipmentSchema = Joi.object({
}
});

const TrackShipmentReturnSchema = Joi.object({
...baseTestParamValidations,
...{
rmaNumber: Joi.string().optional(),
deliveryConfirmationName: Joi.string().optional(),
deliveryServiceName: Joi.string().optional(),
shipDateTime: DateTimeZone[_internal].schema.optional(),
shipFrom: AddressWithContactInfo[_internal].schema.optional(),
shipTo: AddressWithContactInfo[_internal].schema.optional(),
weight: Weight[_internal].schema.optional(),
dimensions: Dimensions[_internal].schema.optional(),
label: NewLabel[_internal].schema.optional(),
}
});

const testsSchema = Joi.object({
createShipment_return: Joi.alternatives().conditional(Joi.array(), {
then: Joi.array().items(createShipmentReturnTestParamsSchema),
Expand Down Expand Up @@ -276,6 +304,11 @@ const testsSchema = Joi.object({
otherwise: RateShipmentTestParamsSchema,
}),

rateShipment_return: Joi.alternatives().conditional(Joi.array(), {
then: Joi.array().items(RateShipmentReturnTestParamsSchema),
otherwise: RateShipmentReturnTestParamsSchema,
}),

rateShipment_with_all_services: Joi.alternatives().conditional(Joi.array(), {
then: Joi.array().items(RateShipmentWithAllServicesTestParamsSchema),
otherwise: RateShipmentWithAllServicesTestParamsSchema,
Expand All @@ -302,6 +335,10 @@ const testsSchema = Joi.object({
trackShipment: Joi.alternatives().conditional(Joi.array(), {
then: Joi.array().items(TrackShipmentSchema),
otherwise: TrackShipmentSchema,
}),
trackShipment_return: Joi.alternatives().conditional(Joi.array(), {
then: Joi.array().items(TrackShipmentReturnSchema),
otherwise: TrackShipmentReturnSchema,
})

}).optional();
Expand Down
13 changes: 7 additions & 6 deletions src/core/test-app/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ export * from "./create-shipment-multipackage";
export * from "./create-shipment-with-insurance";
export * from "./create-shipment-international";
export * from "./create-shipment-return";
// export * from "./get-sales-order-test-suite";
// export * from "./get-sales-orders-by-date-test-suite";
// export * from "./get-seller-test-suite";
export * from "./rate-shipment";
export * from "./track-shipment";
// export * from "./schedule-pickup-test-suite";
// export * from "./shipment-created-test-suite";
// export * from "./track-shipment-test-suite";
export * from "./track-shipment-return"
export * from "./same-day-pickup";
export * from "./next-day-pickup";
export * from "./cancel-pickups-same-day";
export * from "./rate-shipment-return";
export * from "./cancel-shipment";
export * from "./rate-shipment-with-all-services";
Loading

0 comments on commit 49b500f

Please sign in to comment.