forked from mtusi2026/mtusi2026lab2
47 lines
1.0 KiB
Plaintext
47 lines
1.0 KiB
Plaintext
meta {
|
|
name: Create chat
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
post {
|
|
url: {{baseUrl}}/api/v1/chats
|
|
body: json
|
|
auth: none
|
|
}
|
|
|
|
headers {
|
|
Authorization: Bearer {{token}}
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"title": "Демо-чат {{suffix}}",
|
|
"member_ids": ["{{userId}}", "{{secondUserId}}"]
|
|
}
|
|
}
|
|
|
|
script:post-response {
|
|
bru.setVar("chatId", res.body.id);
|
|
}
|
|
|
|
tests {
|
|
test("201 created", function() {
|
|
expect(res.status).to.equal(201);
|
|
});
|
|
|
|
test("оба участника в чате", function() {
|
|
expect(res.body.member_ids).to.have.members([
|
|
bru.getVar("userId"),
|
|
bru.getVar("secondUserId")
|
|
]);
|
|
});
|
|
}
|
|
|
|
docs {
|
|
Составная операция в одной транзакции: проверка участников, вставка чата
|
|
и всех chat_members. Текущий пользователь обязан входить в member_ids,
|
|
неизвестные и дублирующиеся ID дают 400 без частичных данных.
|
|
Сохраняет chatId.
|
|
}
|