feat: 服务端接口逻辑添加用例增量保存、冲突检测、历史记录diff着色功能 #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
主要是对应 基于百度脑图的用例增量保存 + diff 展示整体设计 进行的服务端改动。
改动涉及到 case_backup 表的字段增加,请先应用 sql/case-server.sql 末尾新增
# 添加2个字段,记录每次保存的增量修改内容
后的 DDL 修改语句。增量生成、应用、标记的逻辑全部在
case-server/src/main/java/com/xiaoju/framework/util/MinderJsonPatchUtil.java
这个工具类配套单测在
case-server/src/test/java/com/xiaoju/framework/util/MinderJsonPatchUtilTest.java
前端由于非基于现有 react 开发,故此 pr 未包含前端改动,逻辑内也对当前未有改动的前端进行了兼容。前端大概需要改动的点:
1、在打开界面/保存成功后,记录一下此刻的用例数据至 baseCaseContent 参数中(请确认保存的是值,非引用。建议直接
JSON.stringify
转为 json 文本存储)。保存时 update 接口带上这个信息。2、测试任务界面,可以去掉编辑器的 readOnly ,允许修改用例内容。
3、因目前前端未有历史记录的列表页及展示页,有需要请添加。并建议历史记录列表页的接口,不要返回 caseContent、recordContent、jsonPatch 这些大字段,提高性能。服务端已补充单个历史记录的查询接口
/api/backup/getBackupById
,着色规则如下图文字描述所示:特别注意:调整的整体思路是完全不涉及基于 websocket 的用例增量变化同步的,所有 diff 均是服务端基于前端的保存时提供的刚打开时用例内容 baseCaseContent 及保存时的用例内容 caseContent 。基本思想是更改的内容只包含用户想修改的,然后只要和服务端最新的没有冲突,就允许应用。未测试过与 websocket 用例增量变化自动同步的兼容性。
此理念可能和本身 AgileTC 的多人协作理念有一定差异,建议按官方内部实际需要进行取用。