Skip to content

Commit 2d32f53

Browse files
update tests + fix i18n
1 parent 71dbb4c commit 2d32f53

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/__tests__/action_status.js

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,39 @@ describe('action_status', () => {
106106
};
107107
});
108108

109-
it(`correctly calculates ACTION_STATES.ERROR`, () => {
110-
upstreamJson.actionStatusJson.last_execution.successful = false;
111-
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
109+
describe(`correctly calculates ACTION_STATES.ERROR`, () => {
110+
it('lastExecutionSuccessful is equal to false', () => {
111+
upstreamJson.actionStatusJson.last_execution.successful = false;
112+
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
113+
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
114+
});
112115

113-
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
116+
it('action is acked and lastAcknowledged is less than lastExecution', () => {
117+
const actionStatus = ActionStatus.fromUpstreamJson({
118+
...upstreamJson,
119+
actionStatusJson: {
120+
ack: {
121+
state: 'acked',
122+
timestamp: '2017-03-01T00:00:00.000Z',
123+
},
124+
last_execution: {
125+
timestamp: '2017-03-02T00:00:00.000Z',
126+
},
127+
},
128+
});
129+
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
130+
});
131+
132+
it('action is ackable and lastSuccessfulExecution is less than lastExecution', () => {
133+
delete upstreamJson.actionStatusJson.last_throttle;
134+
upstreamJson.actionStatusJson.ack.state = 'ackable';
135+
upstreamJson.actionStatusJson.last_successful_execution.timestamp =
136+
'2017-03-01T00:00:00.000Z';
137+
upstreamJson.actionStatusJson.last_execution.timestamp = '2017-03-02T00:00:00.000Z';
138+
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
139+
140+
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
141+
});
114142
});
115143

116144
it('correctly calculates ACTION_STATES.CONFIG_ERROR', () => {
@@ -192,18 +220,7 @@ describe('action_status', () => {
192220
});
193221
});
194222

195-
it(`correctly calculates ACTION_STATES.ERROR`, () => {
196-
delete upstreamJson.actionStatusJson.last_throttle;
197-
upstreamJson.actionStatusJson.ack.state = 'ackable';
198-
upstreamJson.actionStatusJson.last_successful_execution.timestamp =
199-
'2017-03-01T00:00:00.000Z';
200-
upstreamJson.actionStatusJson.last_execution.timestamp = '2017-03-02T00:00:00.000Z';
201-
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
202-
203-
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
204-
});
205-
206-
it(`throws an error if it can not determine ACTION_STATE`, () => {
223+
it(`correctly calculates ACTION_STATES.UNKNOWN if it can not determine state`, () => {
207224
upstreamJson = {
208225
id: 'my-action',
209226
actionStatusJson: {
@@ -213,9 +230,7 @@ describe('action_status', () => {
213230
};
214231
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
215232

216-
expect(() => {
217-
actionStatus.state;
218-
}).to.throwError(/could not determine action status/i);
233+
expect(actionStatus.state).to.be(ACTION_STATES.UNKNOWN);
219234
});
220235
});
221236

x-pack/plugins/translations/translations/ja-JP.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12921,7 +12921,6 @@
1292112921
"xpack.watcher.deleteSelectedWatchesConfirmModal.deleteButtonLabel": "{numWatchesToDelete, plural, one {ウォッチ} other {# ウォッチ}}を削除 ",
1292212922
"xpack.watcher.deleteSelectedWatchesConfirmModal.descriptionText": "{numWatchesToDelete, plural, one {削除されたウォッチ} other {削除されたウォッチ}}は回復できません",
1292312923
"xpack.watcher.models.actionStatus.actionStatusJsonPropertyMissingBadRequestMessage": "JSON引数には\"{missingProperty}\"プロパティが含まれている必要があります",
12924-
"xpack.watcher.models.actionStatus.notDetermineActionStatusBadImplementationMessage": "アクションステータスを把握できませんでした; action = {actionStatusJson}",
1292512924
"xpack.watcher.models.baseAction.selectMessageText": "アクションを実行します。",
1292612925
"xpack.watcher.models.baseAction.simulateButtonLabel": "今すぐこのアクションをシミュレート",
1292712926
"xpack.watcher.models.baseAction.simulateMessage": "アクション {id} のシミュレーションが完了しました",
@@ -13243,4 +13242,4 @@
1324313242
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。",
1324413243
"xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。"
1324513244
}
13246-
}
13245+
}

x-pack/plugins/translations/translations/zh-CN.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12920,7 +12920,6 @@
1292012920
"xpack.watcher.deleteSelectedWatchesConfirmModal.deleteButtonLabel": "删除 {numWatchesToDelete, plural, one {个监视} other {# 个监视}} ",
1292112921
"xpack.watcher.deleteSelectedWatchesConfirmModal.descriptionText": "无法恢复{numWatchesToDelete, plural, one {已删除监视} other {已删除监视}}。",
1292212922
"xpack.watcher.models.actionStatus.actionStatusJsonPropertyMissingBadRequestMessage": "JSON 参数必须包含“{missingProperty}”属性",
12923-
"xpack.watcher.models.actionStatus.notDetermineActionStatusBadImplementationMessage": "无法确定操作状态;操作 = {actionStatusJson}",
1292412923
"xpack.watcher.models.baseAction.selectMessageText": "执行操作。",
1292512924
"xpack.watcher.models.baseAction.simulateButtonLabel": "立即模拟此操作",
1292612925
"xpack.watcher.models.baseAction.simulateMessage": "已成功模拟操作 {id}",
@@ -13242,4 +13241,4 @@
1324213241
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。",
1324313242
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。"
1324413243
}
13245-
}
13244+
}

0 commit comments

Comments
 (0)