[Reporting] Add lenience to a test on the order of asserted logs (#108135)

This commit is contained in:
Tim Sullivan 2021-08-11 01:15:38 -07:00 committed by GitHub
parent ee10819ef0
commit a444d8a4ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,7 +88,7 @@ describe('POST /diagnose/browser', () => {
await server.start();
mockedCreateInterface.mockImplementation(() => ({
addEventListener: (e: string, cb: any) => setTimeout(() => cb(devtoolMessage), 0),
addEventListener: (_e: string, cb: any) => setTimeout(() => cb(devtoolMessage), 0),
removeEventListener: jest.fn(),
removeAllListeners: jest.fn(),
close: jest.fn(),
@ -110,7 +110,7 @@ describe('POST /diagnose/browser', () => {
await server.start();
mockedCreateInterface.mockImplementation(() => ({
addEventListener: (e: string, cb: any) => setTimeout(() => cb(logs), 0),
addEventListener: (_e: string, cb: any) => setTimeout(() => cb(logs), 0),
removeEventListener: jest.fn(),
removeAllListeners: jest.fn(),
close: jest.fn(),
@ -146,7 +146,7 @@ describe('POST /diagnose/browser', () => {
await server.start();
mockedCreateInterface.mockImplementation(() => ({
addEventListener: (e: string, cb: any) => {
addEventListener: (_e: string, cb: any) => {
setTimeout(() => cb(devtoolMessage), 0);
setTimeout(() => cb(fontNotFoundMessage), 0);
},
@ -186,7 +186,7 @@ describe('POST /diagnose/browser', () => {
await server.start();
mockedCreateInterface.mockImplementation(() => ({
addEventListener: (e: string, cb: any) => {
addEventListener: (_e: string, cb: any) => {
setTimeout(() => cb(fontNotFoundMessage), 0);
},
removeEventListener: jest.fn(),
@ -209,17 +209,16 @@ describe('POST /diagnose/browser', () => {
.post('/api/reporting/diagnose/browser')
.expect(200)
.then(({ body }) => {
expect(body).toMatchInlineSnapshot(`
Object {
"help": Array [
"The browser couldn't locate a default font. Please see https://www.elastic.co/guide/en/kibana/current/reporting-troubleshooting.html#reporting-troubleshooting-system-dependencies to fix this issue.",
],
"logs": "Could not find the default font
Browser exited abnormally during startup
",
"success": false,
}
const helpArray = [...body.help];
helpArray.sort();
expect(helpArray).toMatchInlineSnapshot(`
Array [
"The browser couldn't locate a default font. Please see https://www.elastic.co/guide/en/kibana/current/reporting-troubleshooting.html#reporting-troubleshooting-system-dependencies to fix this issue.",
]
`);
expect(body.logs).toMatch(/Could not find the default font/);
expect(body.logs).toMatch(/Browser exited abnormally during startup/);
expect(body.success).toBe(false);
});
});
@ -242,7 +241,7 @@ describe('POST /diagnose/browser', () => {
}));
mockedCreateInterface.mockImplementation(() => ({
addEventListener: (e: string, cb: any) => setTimeout(() => cb(devtoolMessage), 0),
addEventListener: (_e: string, cb: any) => setTimeout(() => cb(devtoolMessage), 0),
removeEventListener: jest.fn(),
removeAllListeners: createInterfaceListenersMock,
close: createInterfaceCloseMock,