Skip to content

Commit

Permalink
[Reporting] Add lenience to a test on the order of asserted logs (#10…
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan authored Aug 11, 2021
1 parent 4756cb3 commit f75b598
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions x-pack/plugins/reporting/server/routes/diagnostic/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,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(),
Expand All @@ -107,7 +107,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(),
Expand Down Expand Up @@ -143,7 +143,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);
},
Expand Down Expand Up @@ -183,7 +183,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(),
Expand All @@ -206,17 +206,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);
});
});

Expand All @@ -239,7 +238,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,
Expand Down

0 comments on commit f75b598

Please sign in to comment.