From 56aae708e7217d46a99d7484d5e9f60a24114ded Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Thu, 15 Oct 2026 14:24:18 +0800 Subject: [PATCH] test(promotion): seed object JSON in H2 approval fixtures Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- .../PromotionApprovalFlowIntegrationTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/PromotionApprovalFlowIntegrationTest.java b/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/PromotionApprovalFlowIntegrationTest.java index 7d9249b1..b9cd2c07 100644 --- a/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/PromotionApprovalFlowIntegrationTest.java +++ b/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/PromotionApprovalFlowIntegrationTest.java @@ -34,6 +34,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.test.context.ActiveProfiles; @@ -66,6 +67,9 @@ class PromotionApprovalFlowIntegrationTest { @Autowired private MockMvc mockMvc; + @Autowired + private JdbcTemplate jdbcTemplate; + @Autowired private UserAccountJpaRepository userAccountRepository; @@ -138,6 +142,8 @@ class PromotionApprovalFlowIntegrationTest { assertThat(targetSkill.getNamespaceId()).isEqualTo(graph.globalNamespace().getId()); assertThat(targetSkill.getSlug()).isEqualTo(graph.sourceSkill().getSlug()); assertThat(targetSkill.getSourceSkillId()).isEqualTo(graph.sourceSkill().getId()); + assertThat(targetSkill.getDisplayName()).isEqualTo("Selected version title"); + assertThat(targetSkill.getSummary()).isEqualTo("Selected version summary."); assertThat(targetSkill.getLatestVersionId()).isNotNull(); List targetVersions = skillVersionRepository.findBySkillId(targetSkill.getId()); @@ -320,9 +326,17 @@ class PromotionApprovalFlowIntegrationTest { sourceVersion.setStatus(SkillVersionStatus.PUBLISHED); sourceVersion.setPublishedAt(Instant.now()); sourceVersion.setRequestedVisibility(SkillVisibility.PUBLIC); - sourceVersion.setParsedMetadataJson("{\"name\":\"promotion-flow\"}"); + String metadataJson = """ + {"name":"promotion-flow","description":"Selected version summary.", + "frontmatter":{"metadata":{"display-name":"Selected version title"}}} + """; + sourceVersion.setParsedMetadataJson(metadataJson); sourceVersion.setManifestJson("{\"version\":\"1.0.0\"}"); sourceVersion = skillVersionRepository.saveAndFlush(sourceVersion); + // H2's JSON mapping can quote a Java String as a JSON scalar. Seed an actual + // JSON object, matching the PostgreSQL snapshots produced by publishing. + jdbcTemplate.update("UPDATE skill_version SET parsed_metadata_json = ? FORMAT JSON WHERE id = ?", + metadataJson, sourceVersion.getId()); sourceSkill.setLatestVersionId(sourceVersion.getId()); sourceSkill.setUpdatedBy(submitterId);