From 882b4370b650bcedfd97b41abf25360a10c17981 Mon Sep 17 00:00:00 2001 From: Michael Dokolin Date: Thu, 23 Sep 2021 18:13:45 +0200 Subject: [PATCH] Add integration test for the partial results example plugin --- test/examples/config.js | 1 + test/examples/partial_results/index.ts | 47 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/examples/partial_results/index.ts diff --git a/test/examples/config.js b/test/examples/config.js index ee0c3b63b55c1..c2930068b631f 100644 --- a/test/examples/config.js +++ b/test/examples/config.js @@ -32,6 +32,7 @@ export default async function ({ readConfigFile }) { require.resolve('./expressions_explorer'), require.resolve('./index_pattern_field_editor_example'), require.resolve('./field_formats'), + require.resolve('./partial_results'), ], services: { ...functionalConfig.get('services'), diff --git a/test/examples/partial_results/index.ts b/test/examples/partial_results/index.ts new file mode 100644 index 0000000000000..8fb2824163024 --- /dev/null +++ b/test/examples/partial_results/index.ts @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from 'test/functional/ftr_provider_context'; + +// eslint-disable-next-line import/no-default-export +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const testSubjects = getService('testSubjects'); + const PageObjects = getPageObjects(['common']); + + describe('Partial Results Example', function () { + before(async () => { + this.tags('ciGroup2'); + await PageObjects.common.navigateToApp('partialResultsExample'); + + const element = await testSubjects.find('example-help'); + + await element.click(); + await element.click(); + await element.click(); + }); + + it('should trace mouse events', async () => { + const events = await Promise.all( + ( + await testSubjects.findAll('example-column-event') + ).map((wrapper) => wrapper.getVisibleText()) + ); + expect(events).to.eql(['mousedown', 'mouseup', 'click']); + }); + + it('should keep track of the events number', async () => { + const counters = await Promise.all( + ( + await testSubjects.findAll('example-column-count') + ).map((wrapper) => wrapper.getVisibleText()) + ); + expect(counters).to.eql(['3', '3', '3']); + }); + }); +}