[EBT FTR Helpers] Rename getLastEvents to getEvents (#133094)

This commit is contained in:
Alejandro Fernández Haro 2022-05-30 11:48:44 +02:00 committed by GitHub
parent 42198ab481
commit 608ce66a0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 19 deletions

View file

@ -13,8 +13,8 @@ There are 2 FTR helpers to allow you to retrieve the generated events:
The API is the same for both of them:
```typescript
// To retrieve the last 2 events of type "my-event-type
const events = await getService('kibana_ebt_ui').getLastEvents(2, ['my-event-type']);
// To retrieve 2 events of type "my-event-type"
const events = await getService('kibana_ebt_ui').getEvents(2, ['my-event-type']);
expect(events).to...
```

View file

@ -21,7 +21,7 @@ export class AnalyticsFTRHelpers implements Plugin {
setOptIn(optIn: boolean) {
analytics.optIn({ global: { enabled: optIn } });
},
getLastEvents: async (takeNumberOfEvents, eventTypes = []) =>
getEvents: async (takeNumberOfEvents, eventTypes = []) =>
firstValueFrom(
this.events$.pipe(
filter((event) => {

View file

@ -12,7 +12,7 @@ declare global {
interface Window {
__analytics_ftr_helpers__: {
setOptIn: (optIn: boolean) => void;
getLastEvents: (takeNumberOfEvents: number, eventTypes?: EventType[]) => Promise<Event[]>;
getEvents: (takeNumberOfEvents: number, eventTypes?: EventType[]) => Promise<Event[]>;
};
}
}

View file

@ -28,10 +28,10 @@ export function KibanaEBTServerProvider({ getService }: FtrProviderContext) {
setOptIn,
/**
* Returns the last events of the specified types.
* @param numberOfEvents - number of events to return
* @param takeNumberOfEvents - number of events to return
* @param eventTypes (Optional) array of event types to return
*/
getLastEvents: async (takeNumberOfEvents: number, eventTypes: string[] = []) => {
getEvents: async (takeNumberOfEvents: number, eventTypes: string[] = []) => {
await setOptIn(true);
const resp = await supertest
.get(`/internal/analytics_ftr_helpers/events`)
@ -66,11 +66,11 @@ export function KibanaEBTUIProvider({ getService, getPageObjects }: FtrProviderC
* @param numberOfEvents - number of events to return
* @param eventTypes (Optional) array of event types to return
*/
getLastEvents: async (numberOfEvents: number, eventTypes: string[] = []) => {
getEvents: async (numberOfEvents: number, eventTypes: string[] = []) => {
await setOptIn(true);
const events = await browser.execute(
({ eventTypes: _eventTypes, numberOfEvents: _numberOfEvents }) =>
window.__analytics_ftr_helpers__.getLastEvents(_numberOfEvents, _eventTypes),
window.__analytics_ftr_helpers__.getEvents(_numberOfEvents, _eventTypes),
{
eventTypes,
numberOfEvents,

View file

@ -146,7 +146,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(startEvent).to.be.greaterThan(setupEvent);
// This helps us to also test the helpers
const events = await ebtUIHelper.getLastEvents(2, ['test-plugin-lifecycle']);
const events = await ebtUIHelper.getEvents(2, ['test-plugin-lifecycle']);
expect(events).to.eql([
{
timestamp: reportTestPluginLifecycleEventsAction!.meta[setupEvent].timestamp,
@ -164,7 +164,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('it should extend the contexts with pid injected by "analytics_plugin_a"', async () => {
const [event] = await ebtUIHelper.getLastEvents(1, ['test-plugin-lifecycle']);
const [event] = await ebtUIHelper.getEvents(1, ['test-plugin-lifecycle']);
// Validating the remote user_agent because that's the only field that it's added by the FTR plugin.
expect(event.context).to.have.property('user_agent');
expect(event.context.user_agent).to.be.a('string');

View file

@ -139,7 +139,7 @@ export default function ({ getService }: FtrProviderContext) {
expect(startEvent).to.be.greaterThan(setupEvent);
// This helps us to also test the helpers
const events = await ebtServerHelper.getLastEvents(2, ['test-plugin-lifecycle']);
const events = await ebtServerHelper.getEvents(2, ['test-plugin-lifecycle']);
expect(events).to.eql([
{
timestamp: reportTestPluginLifecycleEventsAction!.meta[setupEvent].timestamp,
@ -157,7 +157,7 @@ export default function ({ getService }: FtrProviderContext) {
});
it('it should extend the contexts with pid injected by "analytics_plugin_a"', async () => {
const [event] = await ebtServerHelper.getLastEvents(1, ['test-plugin-lifecycle']);
const [event] = await ebtServerHelper.getEvents(1, ['test-plugin-lifecycle']);
// Validating the remote PID because that's the only field that it's added by the FTR plugin.
expect(event.context).to.have.property('pid');
expect(event.context.pid).to.be.a('number');

View file

@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('should emit a "click" event', async () => {
const [event] = await ebtUIHelper.getLastEvents(1, ['click']);
const [event] = await ebtUIHelper.getEvents(1, ['click']);
expect(event.event_type).to.eql('click');
expect(event.properties.target).to.be.an('array');
const targets = event.properties.target as string[];

View file

@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
let event: Event;
before(async () => {
await common.navigateToApp('home');
[event] = await ebtUIHelper.getLastEvents(1, ['Loaded Kibana']); // Get the loaded Kibana event
[event] = await ebtUIHelper.getEvents(1, ['Loaded Kibana']); // Get the loaded Kibana event
});
it('should have the properties provided by the "cluster info" context provider', () => {
@ -74,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('should have the properties provided by the "license info" context provider', async () => {
await common.clickAndValidate('kibanaChrome', 'kibanaChrome');
[event] = await ebtUIHelper.getLastEvents(1, ['click']); // Get a later event to ensure license has been obtained already.
[event] = await ebtUIHelper.getEvents(1, ['click']); // Get a later event to ensure license has been obtained already.
expect(event.context).to.have.property('license_id');
expect(event.context.license_id).to.be.a('string');
expect(event.context).to.have.property('license_status');

View file

@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('should emit the "Loaded Kibana" event', async () => {
const [event] = await ebtUIHelper.getLastEvents(1, ['Loaded Kibana']);
const [event] = await ebtUIHelper.getEvents(1, ['Loaded Kibana']);
expect(event.event_type).to.eql('Loaded Kibana');
expect(event.properties).to.have.property('kibana_version');
expect(event.properties.kibana_version).to.be.a('string');

View file

@ -20,7 +20,7 @@ export default function ({ getService }: FtrProviderContext) {
let i = 2;
do {
// Wait until we get a GREEN "status_changed" event. At that point all the context providers should be set up.
const events = await ebtServerHelper.getLastEvents(i, ['core-overall_status_changed']);
const events = await ebtServerHelper.getEvents(i, ['core-overall_status_changed']);
event = events[i - 1];
i++;
} while (event.properties.overall_status_level !== 'available');

View file

@ -18,7 +18,7 @@ export default function ({ getService }: FtrProviderContext) {
let secondEvent: Event;
before(async () => {
[initialEvent, secondEvent] = await ebtServerHelper.getLastEvents(2, [
[initialEvent, secondEvent] = await ebtServerHelper.getEvents(2, [
'core-overall_status_changed',
]);
});

View file

@ -14,7 +14,7 @@ export default function ({ getService }: FtrProviderContext) {
describe('kibana_started', () => {
it('should emit the "kibana_started" event', async () => {
const [event] = await ebtServerHelper.getLastEvents(1, ['kibana_started']);
const [event] = await ebtServerHelper.getEvents(1, ['kibana_started']);
expect(event.event_type).to.eql('kibana_started');
expect(event.properties.uptime_per_step.constructor.start).to.be.a('number');
expect(event.properties.uptime_per_step.constructor.end).to.be.a('number');