diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js b/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js index 21e27a1b12c460..7b55ff16926033 100644 --- a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js +++ b/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js @@ -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', () => { @@ -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: { @@ -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); }); }); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 84020926955906..d785a897093af6 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -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} のシミュレーションが完了しました", @@ -13243,4 +13242,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。", "xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。" } -} +} \ No newline at end of file diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index f3af5ec10338cd..4e422e9aea7d9f 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -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}", @@ -13242,4 +13241,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。", "xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。" } -} +} \ No newline at end of file