Skip to content

Commit

Permalink
Fix API integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Oct 15, 2021
1 parent cf2efdc commit 38e49d7
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import { FtrProviderContext } from '../../ftr_provider_context';
import { API_BASE_PATH } from './constants';

const INDEX_NAME = 'api-integration-test-field-preview';
const DOC_ID = '1';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');

const document = { foo: 1, bar: 'hello' };

const createIndex = async () => {
await es.indices.create({
index: INDEX_NAME,
Expand All @@ -35,19 +38,29 @@ export default function ({ getService }: FtrProviderContext) {
});
};

const addDoc = async () => {
await es.index({
index: INDEX_NAME,
id: DOC_ID,
body: document,
refresh: 'wait_for',
});
};

const deleteIndex = async () => {
await es.indices.delete({
index: INDEX_NAME,
});
};

describe('Field preview', function () {
before(async () => await createIndex());
before(async () => {
await createIndex();
await addDoc();
});
after(async () => await deleteIndex());

describe('should return the script value', () => {
const document = { foo: 1, bar: 'hello' };

const tests = [
{
context: 'keyword_field',
Expand Down Expand Up @@ -77,6 +90,7 @@ export default function ({ getService }: FtrProviderContext) {
const payload = {
script: test.script,
document,
documentId: DOC_ID,
context: test.context,
index: INDEX_NAME,
};
Expand Down

0 comments on commit 38e49d7

Please sign in to comment.