From a272c378440a6e4902a24c38b2f0b49f6f34ae0a Mon Sep 17 00:00:00 2001 From: Gerard Soldevila Date: Thu, 2 Jun 2022 09:33:10 +0200 Subject: [PATCH] Update Jest snapshot --- .../7_13_0_transform_failures.test.ts | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/core/server/saved_objects/migrations/integration_tests/7_13_0_transform_failures.test.ts b/src/core/server/saved_objects/migrations/integration_tests/7_13_0_transform_failures.test.ts index 95a3223f5fb9a6..8d7980aca805c9 100644 --- a/src/core/server/saved_objects/migrations/integration_tests/7_13_0_transform_failures.test.ts +++ b/src/core/server/saved_objects/migrations/integration_tests/7_13_0_transform_failures.test.ts @@ -54,33 +54,40 @@ describe('migration v2', () => { await root.start(); } catch (err) { const errorMessage = err.message; - - expect( - errorMessage.startsWith( - 'Unable to complete saved object migrations for the [.kibana] index: Migrations failed. Reason: 7 corrupt saved object documents were found: ' - ) - ).toBeTruthy(); - expect(errorMessage).toMatchInlineSnapshot(''); - - const expectedCorruptDocIds = [ - 'P2SQfHkBs3dBRGh--No5', - 'QGSZfHkBs3dBRGh-ANoD', - 'QWSZfHkBs3dBRGh-hNob', - 'QmSZfHkBs3dBRGh-w9qH', - 'one', - 'two', - 'Q2SZfHkBs3dBRGh-9dp2', - ]; - for (const corruptDocId of expectedCorruptDocIds) { - expect(errorMessage.includes(corruptDocId)).toBeTruthy(); - } - - expect(errorMessage.includes('7 transformation errors were encountered:')).toBeTruthy(); - expect(errorMessage).toEqual( - expect.stringContaining( - 'space:sixth: Error: Migration function for version 7.14.0 threw an error' - ) - ); + const errorLines = errorMessage.split('\n'); + const errorMessageWithoutStack = errorLines + .filter((line: string) => !line.includes(' at ')) + .join('\n'); + + expect(errorMessageWithoutStack).toMatchInlineSnapshot(` + "Unable to complete saved object migrations for the [.kibana] index: Migrations failed. Reason: 7 corrupt saved object documents were found: P2SQfHkBs3dBRGh--No5, QGSZfHkBs3dBRGh-ANoD, QWSZfHkBs3dBRGh-hNob, QmSZfHkBs3dBRGh-w9qH, one, two, Q2SZfHkBs3dBRGh-9dp2 + 7 transformation errors were encountered: + - space:default: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + - space:first: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + - space:forth: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + - space:second: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + - space:fifth: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + - space:third: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + - space:sixth: Error: Migration function for version 7.14.0 threw an error + Caused by: + TypeError: Cannot set properties of undefined (setting 'bar') + + To allow migrations to proceed, please delete or fix these documents. + Note that you can configure Kibana to automatically discard corrupt documents and transform errors for this migration. + Please refer to https://www.elastic.co/guide/en/kibana/master/resolve-migrations-failures.html for more information." + `); return; } // Fail test if above expression doesn't throw anything.