From b2d2b6a781b70eeaaceff6f3a56e380ebafb710f Mon Sep 17 00:00:00 2001 From: DanliaQwerty20 Date: Tue, 27 Oct 2026 00:02:10 +0300 Subject: [PATCH] test: check compact action status through gateway --- README.md | 2 ++ scripts/check.ps1 | 3 +++ tests/calendar-event.js | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/README.md b/README.md index 5154776..e5c3e2f 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Gateway и Conversation Service, который создаёт действие Команда подтверждения также проходит через Channel Gateway. Поэтому тест воспроизводит границу, которой будут пользоваться Widget SDK и адаптеры каналов, а не обращается к Action Service напрямую. +Тест читает короткий статус через тот же Gateway до и после выполнения и проверяет, что полный +`payload` и `payloadHash` не попадают в ответ каналу. Сначала подними полный локальный стенд в репозитории `deploy`. Затем заполни в локальном `.env` учётные данные только тестового пользователя и ключ проверочного API: diff --git a/scripts/check.ps1 b/scripts/check.ps1 index 2d920d4..888eb3e 100644 --- a/scripts/check.ps1 +++ b/scripts/check.ps1 @@ -16,6 +16,9 @@ foreach ($required in @("AWAITING_APPROVAL", "SUCCEEDED", "payloadHash", "reques if ($calendarScript -notmatch [regex]::Escape('${channelUrl}/api/v1/actions/${card.actionId}/decisions')) { throw "Widget decision must pass through Channel Gateway." } +if ($calendarScript -notmatch [regex]::Escape('${channelUrl}/api/v1/actions/${actionId}/status')) { + throw "Action status must pass through Channel Gateway." +} foreach ($oldName in @("utterance", "tenant_id", "actor_id", "available_connectors", "requires_approval")) { if ($calendarScript -match [regex]::Escape($oldName)) { throw "Calendar acceptance test still contains old field $oldName." } } diff --git a/tests/calendar-event.js b/tests/calendar-event.js index 892c1ee..dfca68b 100644 --- a/tests/calendar-event.js +++ b/tests/calendar-event.js @@ -31,6 +31,7 @@ export default function () { const requestKey = `calendar-test-${Date.now()}-${__VU}-${__ITER}`; const card = createConversation(requestKey); const action = getAction(card.actionId); + const waitingStatus = getStatus(card.actionId); check(action, { 'action waits for approval': (item) => item.status === 'AWAITING_APPROVAL', @@ -40,18 +41,35 @@ export default function () { item.payload.endAt === eventData.endAt && item.payload.timeZone === eventData.timeZone, }); + check(waitingStatus, { + 'channel shows waiting action without payload': (item) => + item.actionId === action.id && + item.status === 'AWAITING_APPROVAL' && + item.title === eventData.title && + !('payload' in item) && + !('payloadHash' in item), + }); check(findEvents(requestKey), { 'calendar is empty before approval': (items) => items.length === 0, }); confirmAction(card); const done = waitForDone(action.id); + const doneStatus = getStatus(action.id); const events = findEvents(requestKey); check(done, { 'action succeeds after approval': (item) => item.status === 'SUCCEEDED', 'action returns event id': (item) => Boolean(item.result?.eventId), }); + check(doneStatus, { + 'channel shows completed action without payload': (item) => + item.actionId === done.id && + item.status === 'SUCCEEDED' && + item.title === eventData.title && + !('payload' in item) && + !('payloadHash' in item), + }); check(events, { 'calendar has one event': (items) => items.length === 1, 'calendar keeps the exact title': (items) => items[0]?.title === eventData.title, @@ -110,6 +128,12 @@ function getAction(actionId) { return response.json(); } +function getStatus(actionId) { + const response = http.get(`${channelUrl}/api/v1/actions/${actionId}/status`, authHeaders()); + expectStatus(response, 200, 'channel-gateway did not return the action status'); + return response.json(); +} + function confirmAction(card) { const response = http.post( `${channelUrl}/api/v1/actions/${card.actionId}/decisions`,