Skip to content

Commit

Permalink
Fixed api integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech committed Nov 20, 2020
1 parent 25ea117 commit 5eeb8d7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,74 +450,76 @@ describe('Data Streams tab', () => {
});
});

describe('delete data stream privileges', () => {
const { setLoadDataStreamsResponse, setLoadDataStreamResponse } = httpRequestsMockHelpers;
describe('data stream privileges', () => {
describe('delete', () => {
const { setLoadDataStreamsResponse, setLoadDataStreamResponse } = httpRequestsMockHelpers;

const dataStreamWithDelete = createDataStreamPayload({
name: 'dataStreamWithDelete',
privileges: { delete_index: true },
});
const dataStreamNoDelete = createDataStreamPayload({
name: 'dataStreamNoDelete',
privileges: { delete_index: false },
});
const dataStreamWithDelete = createDataStreamPayload({
name: 'dataStreamWithDelete',
privileges: { delete_index: true },
});
const dataStreamNoDelete = createDataStreamPayload({
name: 'dataStreamNoDelete',
privileges: { delete_index: false },
});

beforeEach(async () => {
setLoadDataStreamsResponse([dataStreamWithDelete, dataStreamNoDelete]);
beforeEach(async () => {
setLoadDataStreamsResponse([dataStreamWithDelete, dataStreamNoDelete]);

testBed = await setup({ history: createMemoryHistory() });
await act(async () => {
testBed.actions.goToDataStreamsList();
testBed = await setup({ history: createMemoryHistory() });
await act(async () => {
testBed.actions.goToDataStreamsList();
});
testBed.component.update();
});
testBed.component.update();
});

test('displays/hides delete button depending on data streams privileges', async () => {
const { table } = testBed;
const { tableCellsValues } = table.getMetaData('dataStreamTable');
test('displays/hides delete button depending on data streams privileges', async () => {
const { table } = testBed;
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', 'dataStreamNoDelete', 'green', '1', ''],
['', 'dataStreamWithDelete', 'green', '1', 'Delete'],
]);
});
expect(tableCellsValues).toEqual([
['', 'dataStreamNoDelete', 'green', '1', ''],
['', 'dataStreamWithDelete', 'green', '1', 'Delete'],
]);
});

test('displays/hides delete action depending on data streams privileges', async () => {
const {
actions: { selectDataStream },
find,
} = testBed;
test('displays/hides delete action depending on data streams privileges', async () => {
const {
actions: { selectDataStream },
find,
} = testBed;

selectDataStream('dataStreamNoDelete', true);
expect(find('deleteDataStreamsButton').exists()).toBeFalsy();
selectDataStream('dataStreamNoDelete', true);
expect(find('deleteDataStreamsButton').exists()).toBeFalsy();

selectDataStream('dataStreamWithDelete', true);
expect(find('deleteDataStreamsButton').exists()).toBeFalsy();
selectDataStream('dataStreamWithDelete', true);
expect(find('deleteDataStreamsButton').exists()).toBeFalsy();

selectDataStream('dataStreamNoDelete', false);
expect(find('deleteDataStreamsButton').exists()).toBeTruthy();
});
selectDataStream('dataStreamNoDelete', false);
expect(find('deleteDataStreamsButton').exists()).toBeTruthy();
});

test('displays delete button in detail panel', async () => {
const {
actions: { clickNameAt },
find,
} = testBed;
setLoadDataStreamResponse(dataStreamWithDelete);
await clickNameAt(1);
test('displays delete button in detail panel', async () => {
const {
actions: { clickNameAt },
find,
} = testBed;
setLoadDataStreamResponse(dataStreamWithDelete);
await clickNameAt(1);

expect(find('deleteDataStreamButton').exists()).toBeTruthy();
});
expect(find('deleteDataStreamButton').exists()).toBeTruthy();
});

test('hides delete button in detail panel', async () => {
const {
actions: { clickNameAt },
find,
} = testBed;
setLoadDataStreamResponse(dataStreamNoDelete);
await clickNameAt(0);
test('hides delete button in detail panel', async () => {
const {
actions: { clickNameAt },
find,
} = testBed;
setLoadDataStreamResponse(dataStreamNoDelete);
await clickNameAt(0);

expect(find('deleteDataStreamButton').exists()).toBeFalsy();
expect(find('deleteDataStreamButton').exists()).toBeFalsy();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export default function ({ getService }: FtrProviderContext) {
expect(dataStreams).to.eql([
{
name: testDataStreamName,
privileges: {
delete_index: true,
},
timeStampField: { name: '@timestamp' },
indices: [
{
Expand Down Expand Up @@ -105,6 +108,9 @@ export default function ({ getService }: FtrProviderContext) {
expect(dataStreams.length).to.be(1);
expect(dataStreamWithoutStorageSize).to.eql({
name: testDataStreamName,
privileges: {
delete_index: true,
},
timeStampField: { name: '@timestamp' },
indices: [
{
Expand Down Expand Up @@ -132,6 +138,9 @@ export default function ({ getService }: FtrProviderContext) {

expect(dataStreamWithoutStorageSize).to.eql({
name: testDataStreamName,
privileges: {
delete_index: true,
},
timeStampField: { name: '@timestamp' },
indices: [
{
Expand Down

0 comments on commit 5eeb8d7

Please sign in to comment.