feat: 完善相册 AI 修图模板选择流程
This commit is contained in:
@@ -240,12 +240,33 @@ final class TravelAlbumAIRetouchTemplateViewModelTests: XCTestCase {
|
||||
XCTAssertFalse(viewModel.isSubmitting)
|
||||
}
|
||||
|
||||
private func makeAPI() -> TravelAlbumMockAPI {
|
||||
func testRemainingQuotaDisablesSubmissionWhenSelectedOutputsExceedBalance() async {
|
||||
let api = makeAPI(remainingQuota: 2)
|
||||
let viewModel = TravelAlbumAIRetouchTemplateViewModel(
|
||||
albumId: 8,
|
||||
scenicId: 18,
|
||||
materialIds: [1, 2]
|
||||
)
|
||||
await viewModel.loadTemplates(api: api)
|
||||
|
||||
XCTAssertEqual(viewModel.remainingQuota, 2)
|
||||
XCTAssertEqual(viewModel.requiredQuota, 2)
|
||||
XCTAssertTrue(viewModel.canSubmit)
|
||||
|
||||
viewModel.toggleTemplate(id: 21, category: .atmosphere)
|
||||
|
||||
XCTAssertEqual(viewModel.requiredQuota, 4)
|
||||
XCTAssertFalse(viewModel.canSubmit)
|
||||
XCTAssertEqual(viewModel.validationMessage, "剩余修图次数不足,需要4次,当前剩余2次")
|
||||
}
|
||||
|
||||
private func makeAPI(remainingQuota: Int = 100) -> TravelAlbumMockAPI {
|
||||
let api = TravelAlbumMockAPI()
|
||||
api.aiRetouchTemplatesResponse = TravelAlbumAIRetouchTemplatesResponse(
|
||||
refinedTemplates: [template(11, "清透"), template(12, "自然")],
|
||||
atmosphereTemplates: [template(21, "暖阳")],
|
||||
coverTemplates: [template(31, "杂志")]
|
||||
coverTemplates: [template(31, "杂志")],
|
||||
remainingQuota: remainingQuota
|
||||
)
|
||||
return api
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user