fix: allow legacy clerk album entries
Some checks failed
Build and Push Backend / docker (push) Failing after 5s
Some checks failed
Build and Push Backend / docker (push) Failing after 5s
This commit is contained in:
@@ -238,6 +238,56 @@ class WxClerkAlbumUpdateApiTest extends AbstractApiTest {
|
||||
.isNotBlank();
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateAlbumAllowsMixedLegacyUrlsAndNewMediaIdsForReview() throws Exception {
|
||||
ensureTenantContext();
|
||||
String clerkId = ApiTestDataSeeder.DEFAULT_CLERK_ID;
|
||||
String clerkToken = wxTokenService.createWxUserToken(clerkId);
|
||||
clerkUserInfoService.updateTokenById(clerkId, clerkToken);
|
||||
|
||||
// 预置一条已就绪的媒资,模拟“新上传的视频/图片”
|
||||
PlayMediaEntity media = seedMedia(clerkId);
|
||||
|
||||
// 模拟老相册中的 URL(未媒资化的历史数据)
|
||||
String legacyUrl1 = "https://oss.apitest/legacy-1.png";
|
||||
String legacyUrl2 = "https://oss.apitest/legacy-2.png";
|
||||
|
||||
long reviewCountBefore = dataReviewInfoService.lambdaQuery()
|
||||
.eq(com.starry.admin.modules.clerk.module.entity.PlayClerkDataReviewInfoEntity::getClerkId, clerkId)
|
||||
.eq(com.starry.admin.modules.clerk.module.entity.PlayClerkDataReviewInfoEntity::getDataType, "2")
|
||||
.count();
|
||||
|
||||
ObjectNode payload = objectMapper.createObjectNode();
|
||||
com.fasterxml.jackson.databind.node.ArrayNode albumArray = payload.putArray("album");
|
||||
albumArray.add(legacyUrl1);
|
||||
albumArray.add(legacyUrl2);
|
||||
albumArray.add(media.getId());
|
||||
|
||||
MvcResult result = mockMvc.perform(post("/wx/clerk/user/updateAlbum")
|
||||
.header(USER_HEADER, DEFAULT_USER)
|
||||
.header(TENANT_HEADER, DEFAULT_TENANT)
|
||||
.header(Constants.CLERK_USER_LOGIN_TOKEN, Constants.TOKEN_PREFIX + clerkToken)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(payload.toString()))
|
||||
.andExpect(status().isOk())
|
||||
.andReturn();
|
||||
|
||||
String body = result.getResponse().getContentAsString();
|
||||
com.fasterxml.jackson.databind.JsonNode root = new ObjectMapper().readTree(body);
|
||||
assertThat(root.path("code").asInt())
|
||||
.as("mixed legacy URLs and new media ids should be accepted for review, response=%s", body)
|
||||
.isEqualTo(200);
|
||||
|
||||
ensureTenantContext();
|
||||
long reviewCountAfter = dataReviewInfoService.lambdaQuery()
|
||||
.eq(com.starry.admin.modules.clerk.module.entity.PlayClerkDataReviewInfoEntity::getClerkId, clerkId)
|
||||
.eq(com.starry.admin.modules.clerk.module.entity.PlayClerkDataReviewInfoEntity::getDataType, "2")
|
||||
.count();
|
||||
assertThat(reviewCountAfter)
|
||||
.as("mixed legacy URLs and new media ids should create exactly one new review record")
|
||||
.isEqualTo(reviewCountBefore + 1);
|
||||
}
|
||||
|
||||
private PlayMediaEntity seedMedia(String clerkId) {
|
||||
String mediaId = "media-" + java.util.UUID.randomUUID().toString().substring(0, 16);
|
||||
PlayMediaEntity entity = new PlayMediaEntity();
|
||||
|
||||
Reference in New Issue
Block a user