mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[CM] Fix flaky test in the example app (#153310)
## Summary close https://github.com/elastic/kibana/issues/152852 🤞 https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2010
This commit is contained in:
parent
fbba6fe70c
commit
3872fd66cf
2 changed files with 70 additions and 49 deletions
|
@ -6,7 +6,14 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { EuiButtonGroup, EuiButtonIcon, EuiCheckbox, EuiFieldText, EuiSpacer } from '@elastic/eui';
|
||||
import {
|
||||
EuiButtonGroup,
|
||||
EuiButtonIcon,
|
||||
EuiCheckbox,
|
||||
EuiFieldText,
|
||||
EuiSpacer,
|
||||
EuiLoadingSpinner,
|
||||
} from '@elastic/eui';
|
||||
import {
|
||||
useCreateContentMutation,
|
||||
useDeleteContentMutation,
|
||||
|
@ -55,7 +62,7 @@ const filters = [
|
|||
export const Todos = () => {
|
||||
const [filterIdSelected, setFilterIdSelected] = React.useState<TodoFilter>('all');
|
||||
|
||||
const { data, isLoading, isError, error } = useSearchTodosQuery({
|
||||
const { data, isError, error, isFetching, isLoading } = useSearchTodosQuery({
|
||||
filter: filterIdSelected === 'all' ? undefined : filterIdSelected,
|
||||
});
|
||||
|
||||
|
@ -63,7 +70,13 @@ export const Todos = () => {
|
|||
const deleteTodoMutation = useDeleteTodoMutation();
|
||||
const updateTodoMutation = useUpdateTodoMutation();
|
||||
|
||||
if (isLoading) return <p>Loading...</p>;
|
||||
const isPending =
|
||||
isFetching ||
|
||||
isLoading ||
|
||||
createTodoMutation.isLoading ||
|
||||
deleteTodoMutation.isLoading ||
|
||||
updateTodoMutation.isLoading;
|
||||
|
||||
if (isError) return <p>Error: {error}</p>;
|
||||
|
||||
return (
|
||||
|
@ -77,6 +90,7 @@ export const Todos = () => {
|
|||
}}
|
||||
/>
|
||||
<EuiSpacer />
|
||||
{!isLoading && (
|
||||
<ul>
|
||||
{data.hits.map((todo: Todo) => (
|
||||
<React.Fragment key={todo.id}>
|
||||
|
@ -116,7 +130,10 @@ export const Todos = () => {
|
|||
</React.Fragment>
|
||||
))}
|
||||
</ul>
|
||||
<EuiSpacer />
|
||||
)}
|
||||
<div style={{ minHeight: 24 }}>
|
||||
{isPending && <EuiLoadingSpinner data-test-subj={'todoPending'} />}
|
||||
</div>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
const inputRef = (e.target as HTMLFormElement).elements.namedItem(
|
||||
|
|
|
@ -15,14 +15,13 @@ import { PluginFunctionalProviderContext } from '../../plugin_functional/service
|
|||
export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
const retry = getService('retry');
|
||||
const PageObjects = getPageObjects(['common']);
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/152852
|
||||
describe.skip('Todo app', () => {
|
||||
describe('Todo app', () => {
|
||||
it('Todo app works', async () => {
|
||||
const appId = 'contentManagementExamples';
|
||||
await PageObjects.common.navigateToApp(appId);
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
|
||||
// check that initial state is correct
|
||||
let todos = await testSubjects.findAll(`~todoItem`);
|
||||
|
@ -30,24 +29,26 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
|
|||
|
||||
// check that filters work
|
||||
await (await find.byCssSelector('label[title="Completed"]')).click();
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
todos = await testSubjects.findAll(`~todoItem`);
|
||||
expect(todos.length).to.be(1);
|
||||
|
||||
await (await find.byCssSelector('label[title="Todo"]')).click();
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
todos = await testSubjects.findAll(`~todoItem`);
|
||||
expect(todos.length).to.be(1);
|
||||
|
||||
await (await find.byCssSelector('label[title="All"]')).click();
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
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 () => {
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
todos = await testSubjects.findAll(`~todoItem`);
|
||||
expect(todos.length).to.be(3);
|
||||
});
|
||||
|
||||
// check that updating todo works
|
||||
let newTodo = todos[2];
|
||||
|
@ -55,8 +56,10 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
|
|||
let newTodoCheckbox = await newTodo.findByTestSubject('~todoCheckbox');
|
||||
expect(await newTodoCheckbox.isSelected()).to.be(false);
|
||||
await (await newTodo.findByTagName('label')).click();
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
|
||||
await (await find.byCssSelector('label[title="Completed"]')).click();
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
todos = await testSubjects.findAll(`~todoItem`);
|
||||
expect(todos.length).to.be(2);
|
||||
newTodo = todos[1];
|
||||
|
@ -66,6 +69,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
|
|||
|
||||
// check that deleting todo works
|
||||
await (await newTodo.findByCssSelector('[aria-label="Delete"]')).click();
|
||||
await testSubjects.missingOrFail(`todoPending`);
|
||||
todos = await testSubjects.findAll(`~todoItem`);
|
||||
expect(todos.length).to.be(1);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue