feat: lab2 done

This commit is contained in:
2026-10-09 15:48:03 +03:00
parent f743ee10a2
commit 575f8ee386
104 changed files with 7038 additions and 1099 deletions
+46
View File
@@ -0,0 +1,46 @@
meta {
name: Create chat
type: http
seq: 1
}
post {
url: {{baseUrl}}/api/v1/chats
body: json
auth: none
}
headers {
Authorization: Bearer {{token}}
}
docs {
Составная операция в одной транзакции: проверка участников, вставка чата
и всех chat_members. Текущий пользователь обязан входить в member_ids,
неизвестные и дублирующиеся ID дают 400 без частичных данных.
Сохраняет chatId.
}
body:json {
{
"title": "Демо-чат {{suffix}}",
"member_ids": ["{{userId}}", "{{secondUserId}}"]
}
}
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")
]);
});
}
script:post-response {
bru.setVar("chatId", res.body.id);
}
+30
View File
@@ -0,0 +1,30 @@
meta {
name: Get chat by id
type: http
seq: 3
}
get {
url: {{baseUrl}}/api/v1/chats/{{chatId}}
body: none
auth: none
}
headers {
Authorization: Bearer {{token}}
}
docs {
Участник получает чат, посторонний — 404 (не 403: существование чужого
объекта не раскрывается).
}
tests {
test("200 ok", function() {
expect(res.status).to.equal(200);
});
test("id совпадает", function() {
expect(res.body.id).to.equal(bru.getVar("chatId"));
});
}
+30
View File
@@ -0,0 +1,30 @@
meta {
name: List my chats
type: http
seq: 2
}
get {
url: {{baseUrl}}/api/v1/chats?limit=100
body: none
auth: none
}
headers {
Authorization: Bearer {{token}}
}
docs {
Список только доступных чатов, сортировка по (created_at, id), keyset-cursor.
}
tests {
test("200 ok", function() {
expect(res.status).to.equal(200);
});
test("созданный чат виден", function() {
const ids = res.body.items.map(function(item) { return item.id; });
expect(ids).to.include(bru.getVar("chatId"));
});
}