Skip to content

Commit

Permalink
Unskip test scripted fields preview (#124358) (#124957)
Browse files Browse the repository at this point in the history
* unskip test and change we how assert for expected states

* REVERT - added .only for flaky test runner

* remove .only

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit ee9f01e)
  • Loading branch information
jloleysens authored Feb 8, 2022
1 parent e8868b3 commit 4fb5419
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/functional/apps/management/_scripted_fields_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['settings']);
const SCRIPTED_FIELD_NAME = 'myScriptedField';

// FLAKY: https://github.com/elastic/kibana/issues/118981
describe.skip('scripted fields preview', () => {
const scriptResultToJson = (scriptResult) => {
try {
return JSON.parse(scriptResult);
} catch (e) {
expect().fail(`Could JSON.parse script result: "${scriptResult}"`);
}
};

describe('scripted fields preview', () => {
before(async function () {
await browser.setWindowSize(1200, 800);
await PageObjects.settings.navigateTo();
Expand Down Expand Up @@ -46,15 +53,25 @@ export default function ({ getService, getPageObjects }) {
const scriptResults = await PageObjects.settings.executeScriptedField(
`doc['bytes'].value * 2`
);
expect(scriptResults.replace(/\s/g, '')).to.contain('"myScriptedField":[6196');
const [
{
_id,
[SCRIPTED_FIELD_NAME]: { [0]: scriptedField },
},
] = scriptResultToJson(scriptResults);
expect(_id).to.be.a('string');
expect(scriptedField).to.be.a('number');
expect(scriptedField).to.match(/[0-9]+/);
});

it('should display additional fields', async function () {
const scriptResults = await PageObjects.settings.executeScriptedField(
`doc['bytes'].value * 2`,
['bytes']
);
expect(scriptResults.replace(/\s/g, '')).to.contain('"bytes":3098');
const [{ _id, bytes }] = scriptResultToJson(scriptResults);
expect(_id).to.be.a('string');
expect(bytes).to.be.a('number');
});
});
}

0 comments on commit 4fb5419

Please sign in to comment.