Skip to content

Commit

Permalink
update tests + fix i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Jan 16, 2020
1 parent 71dbb4c commit 2d32f53
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,39 @@ describe('action_status', () => {
};
});

it(`correctly calculates ACTION_STATES.ERROR`, () => {
upstreamJson.actionStatusJson.last_execution.successful = false;
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
describe(`correctly calculates ACTION_STATES.ERROR`, () => {
it('lastExecutionSuccessful is equal to false', () => {
upstreamJson.actionStatusJson.last_execution.successful = false;
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
});

expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
it('action is acked and lastAcknowledged is less than lastExecution', () => {
const actionStatus = ActionStatus.fromUpstreamJson({
...upstreamJson,
actionStatusJson: {
ack: {
state: 'acked',
timestamp: '2017-03-01T00:00:00.000Z',
},
last_execution: {
timestamp: '2017-03-02T00:00:00.000Z',
},
},
});
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
});

it('action is ackable and lastSuccessfulExecution is less than lastExecution', () => {
delete upstreamJson.actionStatusJson.last_throttle;
upstreamJson.actionStatusJson.ack.state = 'ackable';
upstreamJson.actionStatusJson.last_successful_execution.timestamp =
'2017-03-01T00:00:00.000Z';
upstreamJson.actionStatusJson.last_execution.timestamp = '2017-03-02T00:00:00.000Z';
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);

expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
});
});

it('correctly calculates ACTION_STATES.CONFIG_ERROR', () => {
Expand Down Expand Up @@ -192,18 +220,7 @@ describe('action_status', () => {
});
});

it(`correctly calculates ACTION_STATES.ERROR`, () => {
delete upstreamJson.actionStatusJson.last_throttle;
upstreamJson.actionStatusJson.ack.state = 'ackable';
upstreamJson.actionStatusJson.last_successful_execution.timestamp =
'2017-03-01T00:00:00.000Z';
upstreamJson.actionStatusJson.last_execution.timestamp = '2017-03-02T00:00:00.000Z';
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);

expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
});

it(`throws an error if it can not determine ACTION_STATE`, () => {
it(`correctly calculates ACTION_STATES.UNKNOWN if it can not determine state`, () => {
upstreamJson = {
id: 'my-action',
actionStatusJson: {
Expand All @@ -213,9 +230,7 @@ describe('action_status', () => {
};
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);

expect(() => {
actionStatus.state;
}).to.throwError(/could not determine action status/i);
expect(actionStatus.state).to.be(ACTION_STATES.UNKNOWN);
});
});

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -12921,7 +12921,6 @@
"xpack.watcher.deleteSelectedWatchesConfirmModal.deleteButtonLabel": "{numWatchesToDelete, plural, one {ウォッチ} other {# ウォッチ}}を削除 ",
"xpack.watcher.deleteSelectedWatchesConfirmModal.descriptionText": "{numWatchesToDelete, plural, one {削除されたウォッチ} other {削除されたウォッチ}}は回復できません",
"xpack.watcher.models.actionStatus.actionStatusJsonPropertyMissingBadRequestMessage": "JSON引数には\"{missingProperty}\"プロパティが含まれている必要があります",
"xpack.watcher.models.actionStatus.notDetermineActionStatusBadImplementationMessage": "アクションステータスを把握できませんでした; action = {actionStatusJson}",
"xpack.watcher.models.baseAction.selectMessageText": "アクションを実行します。",
"xpack.watcher.models.baseAction.simulateButtonLabel": "今すぐこのアクションをシミュレート",
"xpack.watcher.models.baseAction.simulateMessage": "アクション {id} のシミュレーションが完了しました",
Expand Down Expand Up @@ -13243,4 +13242,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。",
"xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。"
}
}
}
3 changes: 1 addition & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -12920,7 +12920,6 @@
"xpack.watcher.deleteSelectedWatchesConfirmModal.deleteButtonLabel": "删除 {numWatchesToDelete, plural, one {个监视} other {# 个监视}} ",
"xpack.watcher.deleteSelectedWatchesConfirmModal.descriptionText": "无法恢复{numWatchesToDelete, plural, one {已删除监视} other {已删除监视}}。",
"xpack.watcher.models.actionStatus.actionStatusJsonPropertyMissingBadRequestMessage": "JSON 参数必须包含“{missingProperty}”属性",
"xpack.watcher.models.actionStatus.notDetermineActionStatusBadImplementationMessage": "无法确定操作状态;操作 = {actionStatusJson}",
"xpack.watcher.models.baseAction.selectMessageText": "执行操作。",
"xpack.watcher.models.baseAction.simulateButtonLabel": "立即模拟此操作",
"xpack.watcher.models.baseAction.simulateMessage": "已成功模拟操作 {id}",
Expand Down Expand Up @@ -13242,4 +13241,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。",
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。"
}
}
}

0 comments on commit 2d32f53

Please sign in to comment.