diff --git a/src/schema/__tests__/partner.test.js b/src/schema/__tests__/partner.test.js index 8340780999..abbc3ac83e 100644 --- a/src/schema/__tests__/partner.test.js +++ b/src/schema/__tests__/partner.test.js @@ -127,5 +127,35 @@ describe("Partner type", () => { }) }) }) + + it("returns false if partner_product_merchant_account call to lewitt returns errors", () => { + const typeDefs = fs.readFileSync( + path.resolve(__dirname, "../../data/lewitt.graphql"), + "utf8" + ) + + const resolvers = { + RootQuery: { + partner_product_merchant_account: () => { + throw new Error("Lewitt error") + }, + }, + } + + const lewittSchema = makeExecutableSchema({ + typeDefs, + resolvers, + }) + + rootValue.lewittSchema = lewittSchema + + return runQuery(query, rootValue).then(data => { + expect(data).toEqual({ + partner: { + acceptsCardPayments: false, + }, + }) + }) + }) }) }) diff --git a/src/schema/partner.js b/src/schema/partner.js index ed5e8f3daf..186059a01c 100644 --- a/src/schema/partner.js +++ b/src/schema/partner.js @@ -247,9 +247,8 @@ const PartnerType = new GraphQLObjectType({ partner_id: _id, }).then(response => { if (response.errors) { - throw new Error( - `Lewitt errors: ${JSON.stringify(response.errors)}` - ) + // Something is off in Lewitt so cards are not accepted at the moment + return false } const { data: { partner_product_merchant_account } } = response return partner_product_merchant_account.credit_card_enabled