Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Gateway и Conversation Service, который создаёт действие

Команда подтверждения также проходит через Channel Gateway. Поэтому тест воспроизводит границу,
которой будут пользоваться Widget SDK и адаптеры каналов, а не обращается к Action Service напрямую.
Тест читает короткий статус через тот же Gateway до и после выполнения и проверяет, что полный
`payload` и `payloadHash` не попадают в ответ каналу.

Сначала подними полный локальный стенд в репозитории `deploy`. Затем заполни в локальном `.env`
учётные данные только тестового пользователя и ключ проверочного API:
Expand Down
3 changes: 3 additions & 0 deletions scripts/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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." }
}
Expand Down
24 changes: 24 additions & 0 deletions tests/calendar-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down Expand Up @@ -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`,
Expand Down
Loading