Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Apr 16, 2020
1 parent 9a009ca commit 3074ed4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ export default function({ getService }: FtrProviderContext) {
});

it('can change the settings', async () => {
const newSettings = { heartbeatIndices: 'myIndex1*' };
const newSettings = {
heartbeatIndices: 'myIndex1*',
certificatesThresholds: {
errorState: 5,
warningState: 15,
},
};
const postResponse = await supertest
.post(`/api/uptime/dynamic_settings`)
.set('kbn-xsrf', 'true')
Expand Down
36 changes: 35 additions & 1 deletion x-pack/test/functional/apps/uptime/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,41 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
// Verify that the settings page shows the value we previously saved
await settings.go();
const fields = await settings.loadFields();
expect(fields).to.eql(newFieldValues);
expect(fields.heartbeatIndices).to.eql(newFieldValues.heartbeatIndices);
});

it('changing certificate expiration error threshold is reflected in settings page', async () => {
const settings = uptimeService.settings;

await settings.go();

const newErrorThreshold = '5';
await settings.changeErrorThresholdInput(newErrorThreshold);
await settings.apply();

await uptimePage.goToRoot();

// Verify that the settings page shows the value we previously saved
await settings.go();
const fields = await settings.loadFields();
expect(fields.certificatesThresholds.errorState).to.eql(newErrorThreshold);
});

it('changing certificate expiration warning threshold is reflected in settings page', async () => {
const settings = uptimeService.settings;

await settings.go();

const newWarningThreshold = '15';
await settings.changeWarningThresholdInput(newWarningThreshold);
await settings.apply();

await uptimePage.goToRoot();

// Verify that the settings page shows the value we previously saved
await settings.go();
const fields = await settings.loadFields();
expect(fields.certificatesThresholds.warningState).to.eql(newWarningThreshold);
});
});
};
33 changes: 27 additions & 6 deletions x-pack/test/functional/services/uptime/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,41 @@ export function UptimeSettingsProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');

const changeInputField = async (text: string, field: string) => {
const input = await testSubjects.find(field, 5000);
await input.clearValueWithKeyboard();
await input.type(text);
};

return {
go: async () => {
await testSubjects.click('settings-page-link', 5000);
},

changeHeartbeatIndicesInput: async (text: string) => {
const input = await testSubjects.find('heartbeat-indices-input-loaded', 5000);
await input.clearValueWithKeyboard();
await input.type(text);
await changeInputField(text, 'heartbeat-indices-input-loaded');
},
changeErrorThresholdInput: async (text: string) => {
await changeInputField(text, 'error-state-threshold-input-loaded');
},
changeWarningThresholdInput: async (text: string) => {
await changeInputField(text, 'warning-state-threshold-input-loaded');
},
loadFields: async () => {
const input = await testSubjects.find('heartbeat-indices-input-loaded', 5000);
const heartbeatIndices = await input.getAttribute('value');
const indInput = await testSubjects.find('heartbeat-indices-input-loaded', 5000);
const errorInput = await testSubjects.find('error-state-threshold-input-loaded', 5000);
const warningInput = await testSubjects.find('warning-state-threshold-input-loaded', 5000);
const heartbeatIndices = await indInput.getAttribute('value');
const errorThreshold = await errorInput.getAttribute('value');
const warningThreshold = await warningInput.getAttribute('value');

return { heartbeatIndices };
return {
heartbeatIndices,
certificatesThresholds: {
errorState: errorThreshold,
warningState: warningThreshold,
},
};
},
applyButtonIsDisabled: async () => {
return !!(await (await testSubjects.find('apply-settings-button')).getAttribute('disabled'));
Expand Down

0 comments on commit 3074ed4

Please sign in to comment.