Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ const snapshot = (rendered) => {
expect(rendered).toMatchSnapshot();
};

const names = (rendered) => {
return findTestSubject(rendered, 'indexTableIndexNameLink');
};

const namesText = (rendered) => {
return names(rendered).map((button) => button.text());
};

const openMenuAndClickButton = (rendered, rowIndex, buttonSelector) => {
// Select a row.
const checkboxes = findTestSubject(rendered, 'indexTableRowCheckbox');
Expand All @@ -111,7 +119,8 @@ const testEditor = (rendered, buttonSelector, rowIndex = 0) => {
snapshot(findTestSubject(rendered, 'detailPanelTabSelected').text());
};

const testAction = (rendered, buttonSelector, rowIndex = 0) => {
const testAction = (rendered, buttonSelector, indexName = 'testy0') => {
const rowIndex = namesText(rendered).indexOf(indexName);
// This is leaking some implementation details about how Redux works. Not sure exactly what's going on
// but it looks like we're aware of how many Redux actions are dispatched in response to user interaction,
// so we "time" our assertion based on how many Redux actions we observe. This is brittle because it
Expand All @@ -132,14 +141,6 @@ const testAction = (rendered, buttonSelector, rowIndex = 0) => {
snapshot(status(rendered, rowIndex));
};

const names = (rendered) => {
return findTestSubject(rendered, 'indexTableIndexNameLink');
};

const namesText = (rendered) => {
return names(rendered).map((button) => button.text());
};

const getActionMenuButtons = (rendered) => {
return findTestSubject(rendered, 'indexContextMenu')
.find('button')
Expand Down Expand Up @@ -487,24 +488,23 @@ describe('index table', () => {
});

test('open index button works from context menu', async () => {
const rendered = mountWithIntl(component);
await runAllPromises();
rendered.update();

const modifiedIndices = indices.map((index) => {
return {
...index,
status: index.name === 'testy1' ? 'open' : index.status,
status: index.name === 'testy1' ? 'closed' : index.status,
};
});

server.respondWith(`${API_BASE_PATH}/indices/reload`, [
server.respondWith(`${API_BASE_PATH}/indices`, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify(modifiedIndices),
]);

testAction(rendered, 'openIndexMenuButton', 1);
const rendered = mountWithIntl(component);
await runAllPromises();
rendered.update();
testAction(rendered, 'openIndexMenuButton', 'testy1');
});

test('show settings button works from context menu', async () => {
Expand Down