From 6e778e64355d4fa0ccffa5b79f591bfccc51f6e7 Mon Sep 17 00:00:00 2001 From: Shane McLaughlin Date: Tue, 7 Jun 2022 10:50:37 -0500 Subject: [PATCH] Sm/mdapi-fault-handler (#642) * feat: handle transient mdapi error * chore: auto-update metadata coverage in METADATA_SUPPORT.md * test: mdapi error handling --- METADATA_SUPPORT.md | 2 ++ src/client/metadataTransfer.ts | 7 +++++++ test/client/metadataTransfer.test.ts | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/METADATA_SUPPORT.md b/METADATA_SUPPORT.md index c677e1b045..38f625ace6 100644 --- a/METADATA_SUPPORT.md +++ b/METADATA_SUPPORT.md @@ -511,7 +511,9 @@ v56 introduces the following new types. Here's their current level of support |:---|:---|:---| |AccountingSettings|✅|| |CollectionsDashboardSettings|✅|| +|CustomizablePropensityScoringSettings|✅|| |MfgServiceConsoleSettings|✅|| +|OauthOidcSettings|✅|| ## Additional Types diff --git a/src/client/metadataTransfer.ts b/src/client/metadataTransfer.ts index 5ee4965f76..409565a058 100644 --- a/src/client/metadataTransfer.ts +++ b/src/client/metadataTransfer.ts @@ -217,6 +217,13 @@ export abstract class MetadataTransfer diff --git a/test/client/metadataTransfer.test.ts b/test/client/metadataTransfer.test.ts index 5b74c2b11d..dbcc38af07 100644 --- a/test/client/metadataTransfer.test.ts +++ b/test/client/metadataTransfer.test.ts @@ -300,6 +300,18 @@ describe('MetadataTransfer', () => { expect(checkStatus.callCount).to.equal(3); }); + it('should tolerate known mdapi error', async () => { + const { checkStatus } = operation.lifecycle; + const networkError1 = new Error('foo'); + networkError1.name = 'JsonParseError'; + checkStatus.onFirstCall().throws(networkError1); + checkStatus.onSecondCall().throws(networkError1); + checkStatus.onThirdCall().resolves({ done: true }); + + await operation.pollStatus(); + expect(checkStatus.callCount).to.equal(3); + }); + it('should throw wrapped error if there are no error listeners', async () => { const { checkStatus } = operation.lifecycle; const originalError = new Error('whoops');