Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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