mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-15 04:18:20 +00:00
fix(review): require review score contract
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
parent
26dad593e1
commit
f98f4b1d78
7 changed files with 28 additions and 2 deletions
|
|
@ -3,9 +3,10 @@ package com.iflytek.skillhub.dto;
|
|||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record SkillReviewRequest(
|
||||
@Min(1) @Max(5) short score,
|
||||
@NotNull @Min(1) @Max(5) Short score,
|
||||
@NotBlank @Size(max = 2000) String reviewText
|
||||
) {}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,19 @@ class SkillReviewControllerTest {
|
|||
verify(reviewAppService).upsert(eq(10L), eq("user-42"), eq((short) 4), eq("Useful"), any(), eq(Set.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reviewScoreIsRequiredByTheApiContract() throws Exception {
|
||||
var principal = principal("user-42", Set.of());
|
||||
|
||||
mockMvc.perform(put("/api/v1/skills/10/reviews/me")
|
||||
.with(authentication(authToken(principal, "ROLE_USER")))
|
||||
.with(csrf())
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"reviewText\":\"Useful\"}"))
|
||||
.andExpect(status().isBadRequest())
|
||||
.andExpect(jsonPath("$.code").value(400));
|
||||
}
|
||||
|
||||
@Test
|
||||
void skillAdminCanHideReview() throws Exception {
|
||||
var principal = principal("admin", Set.of("SKILL_ADMIN"));
|
||||
|
|
|
|||
2
web/src/api/generated/schema.d.ts
vendored
2
web/src/api/generated/schema.d.ts
vendored
|
|
@ -3747,7 +3747,7 @@ export interface components {
|
|||
};
|
||||
SkillReviewRequest: {
|
||||
/** Format: int32 */
|
||||
score?: number;
|
||||
score: number;
|
||||
reviewText: string;
|
||||
};
|
||||
ApiResponseSkillReviewMeResponse: {
|
||||
|
|
|
|||
|
|
@ -143,6 +143,11 @@ describe('skill reviews', () => {
|
|||
expect(locale.skillReviews.hide).toBeTruthy()
|
||||
expect(locale.skillReviews.restore).toBeTruthy()
|
||||
}
|
||||
expect(en.skillReviews.count_one).toBe('{{count}} review')
|
||||
expect(en.skillReviews.count_other).toBe('{{count}} reviews')
|
||||
expect(ru.skillReviews.count_one).toBeTruthy()
|
||||
expect(ru.skillReviews.count_few).toBeTruthy()
|
||||
expect(ru.skillReviews.count_many).toBeTruthy()
|
||||
})
|
||||
|
||||
it('lets an authenticated author clear existing text when the skill is not interactable', () => {
|
||||
|
|
|
|||
|
|
@ -1302,6 +1302,8 @@
|
|||
"skillReviews": {
|
||||
"title": "User reviews",
|
||||
"count": "{{count}} reviews",
|
||||
"count_one": "{{count}} review",
|
||||
"count_other": "{{count}} reviews",
|
||||
"write": "Write a review",
|
||||
"edit": "Edit my review",
|
||||
"scoreLabel": "Your score",
|
||||
|
|
|
|||
|
|
@ -1514,6 +1514,10 @@
|
|||
"skillReviews": {
|
||||
"title": "Отзывы пользователей",
|
||||
"count": "Отзывов: {{count}}",
|
||||
"count_one": "{{count}} отзыв",
|
||||
"count_few": "{{count}} отзыва",
|
||||
"count_many": "{{count}} отзывов",
|
||||
"count_other": "{{count}} отзыва",
|
||||
"write": "Написать отзыв",
|
||||
"edit": "Изменить мой отзыв",
|
||||
"scoreLabel": "Ваша оценка",
|
||||
|
|
|
|||
|
|
@ -1302,6 +1302,7 @@
|
|||
"skillReviews": {
|
||||
"title": "用户评价",
|
||||
"count": "共 {{count}} 条评价",
|
||||
"count_other": "共 {{count}} 条评价",
|
||||
"write": "写评价",
|
||||
"edit": "编辑我的评价",
|
||||
"scoreLabel": "你的评分",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue