mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
## Summary
Close https://github.com/elastic/kibana/issues/152002
In https://github.com/elastic/kibana/pull/151163 we introduced a simple
demo todo app run in a storybook with a custom client-side content
management client (no server-side cm registry usage).
This is a follow-up PR that re-uses the same demo todo app, but also
runs it in an example plugin with proper server-side content management
registry usage, so now we have a basic end-to-end demonstration of
content management capabilities. The demo app is covered by functional
tests, so now we also have basic end-to-end test coverage.
As this is the first kind of real-world end-to-end usage of the CM APIs,
I'd like to use this and
[previous](https://github.com/elastic/kibana/pull/151163) prs as a base
for the discussion and polishing current APIs. I'll leave a review with
comments where I think some API polishing is needed.
**Notable changes apart from the example plugin itself:**
1. Move `demo/` todo app and its stories introduced in
https://github.com/elastic/kibana/pull/151163 from
`src/plugins/content_management` to
`examples/content_management_examples`. This was mostly needed to not
export `demo/` code on the public plugin export to avoid increasing
bundle size.
2. Add needed exports to the plugin contract
3. Reshuffle `common/` to not import `@kbn/schema` client side
48aa41403b
4. Fix client-side RPC client to work with the latest server-side
changes (shouldn't break from now on because of the end-to-end test
coverage)
72 lines
2.9 KiB
TypeScript
72 lines
2.9 KiB
TypeScript
/*
|
|
* 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 { Key } from 'selenium-webdriver';
|
|
|
|
import { PluginFunctionalProviderContext } from '../../plugin_functional/services';
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) {
|
|
const testSubjects = getService('testSubjects');
|
|
const find = getService('find');
|
|
const retry = getService('retry');
|
|
const PageObjects = getPageObjects(['common']);
|
|
|
|
describe('Todo app', () => {
|
|
it('Todo app works', async () => {
|
|
const appId = 'contentManagementExamples';
|
|
await PageObjects.common.navigateToApp(appId);
|
|
|
|
// check that initial state is correct
|
|
let todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(2);
|
|
|
|
// check that filters work
|
|
await (await find.byCssSelector('label[title="Completed"]')).click();
|
|
todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(1);
|
|
|
|
await (await find.byCssSelector('label[title="Todo"]')).click();
|
|
todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(1);
|
|
|
|
await (await find.byCssSelector('label[title="All"]')).click();
|
|
todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(2);
|
|
|
|
// check that adding new todo works
|
|
await testSubjects.setValue('newTodo', 'New todo');
|
|
await (await testSubjects.find('newTodo')).pressKeys(Key.ENTER);
|
|
await retry.tryForTime(1000, async () => {
|
|
todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(3);
|
|
});
|
|
|
|
// check that updating todo works
|
|
let newTodo = todos[2];
|
|
expect(await newTodo.getVisibleText()).to.be('New todo');
|
|
let newTodoCheckbox = await newTodo.findByTestSubject('~todoCheckbox');
|
|
expect(await newTodoCheckbox.isSelected()).to.be(false);
|
|
await (await newTodo.findByTagName('label')).click();
|
|
|
|
await (await find.byCssSelector('label[title="Completed"]')).click();
|
|
todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(2);
|
|
newTodo = todos[1];
|
|
expect(await newTodo.getVisibleText()).to.be('New todo');
|
|
newTodoCheckbox = await newTodo.findByTestSubject('~todoCheckbox');
|
|
expect(await newTodoCheckbox.isSelected()).to.be(true);
|
|
|
|
// check that deleting todo works
|
|
await (await newTodo.findByCssSelector('[aria-label="Delete"]')).click();
|
|
todos = await testSubjects.findAll(`~todoItem`);
|
|
expect(todos.length).to.be(1);
|
|
});
|
|
});
|
|
}
|