Skip to content

Commit

Permalink
fix test plugin name in package.json and make sure to opt out of tele…
Browse files Browse the repository at this point in the history
…metry when the test finishes
  • Loading branch information
jloleysens committed May 25, 2021
1 parent 1990c1f commit fec95b6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/plugin_functional/plugins/telemetry/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "usage_collection_test_plugin",
"name": "telemetry_test_plugin",
"version": "1.0.0",
"main": "target/test/plugin_functional/plugins/usage_collection",
"main": "target/test/plugin_functional/plugins/telemetry",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
Expand Down
4 changes: 4 additions & 0 deletions test/plugin_functional/plugins/telemetry/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export class TelemetryTestPlugin implements Plugin {
await telemetry.telemetryService.setOptIn(true);
return telemetry.telemetryService.canSendTelemetry();
};

window._resetTelemetry = async () => {
await telemetry.telemetryService.setOptIn(false);
};
}
start() {}
}
1 change: 1 addition & 0 deletions test/plugin_functional/plugins/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
declare global {
interface Window {
_checkCanSendTelemetry: () => Promise<boolean>;
_resetTelemetry: () => Promise<void>;
}
}

Expand Down
11 changes: 9 additions & 2 deletions test/plugin_functional/test_suites/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
});
};

after(async () => browser.removeLocalStorageItem(KBN_SCREENSHOT_MODE_ENABLED_KEY));
after(async () => {
await browser.removeLocalStorageItem(KBN_SCREENSHOT_MODE_ENABLED_KEY);
await browser.executeAsync<void>((cb) => {
((window as unknown) as Record<string, () => Promise<boolean>>)
._resetTelemetry()
.then(() => cb());
});
});

it('does not send telemetry when in screenshot mode', async () => {
it('detects that telemetry cannot be sent in screenshot mode', async () => {
await PageObjects.common.navigateToApp('home');
expect(await checkCanSendTelemetry()).to.be(true);

Expand Down

0 comments on commit fec95b6

Please sign in to comment.