feat: 接通图片预览 AI 修图流程
This commit is contained in:
@@ -153,7 +153,7 @@ final class TravelAlbumAPITests: XCTestCase {
|
||||
materialIds: [11, 12, 13, 14],
|
||||
refinedTemplateId: 21,
|
||||
atmosphereTemplateId: 22,
|
||||
aiPreviewTabs: 31
|
||||
coverTemplateId: 31
|
||||
)
|
||||
)
|
||||
|
||||
@@ -165,7 +165,14 @@ final class TravelAlbumAPITests: XCTestCase {
|
||||
XCTAssertEqual(body?["material_ids"] as? [Int], [11, 12, 13, 14])
|
||||
XCTAssertEqual(body?["refined_template_id"] as? Int, 21)
|
||||
XCTAssertEqual(body?["atmosphere_template_id"] as? Int, 22)
|
||||
XCTAssertEqual(body?["ai_preview_tabs"] as? Int, 31)
|
||||
XCTAssertEqual(body?["cover_template_id"] as? Int, 31)
|
||||
XCTAssertEqual(Set(body?.keys.map { $0 } ?? []), [
|
||||
"user_equity_travel_id",
|
||||
"material_ids",
|
||||
"refined_template_id",
|
||||
"atmosphere_template_id",
|
||||
"cover_template_id",
|
||||
])
|
||||
}
|
||||
|
||||
func testSubmitAIRetouchOmitsAllOptionalTemplatesWhenAbsent() async throws {
|
||||
@@ -178,13 +185,75 @@ final class TravelAlbumAPITests: XCTestCase {
|
||||
materialIds: [11],
|
||||
refinedTemplateId: 21,
|
||||
atmosphereTemplateId: nil,
|
||||
aiPreviewTabs: nil
|
||||
coverTemplateId: nil
|
||||
)
|
||||
)
|
||||
|
||||
let body = try JSONSerialization.jsonObject(with: try XCTUnwrap(session.requests.first?.httpBody)) as? [String: Any]
|
||||
XCTAssertNil(body?["atmosphere_template_id"])
|
||||
XCTAssertNil(body?["ai_preview_tabs"])
|
||||
XCTAssertNil(body?["cover_template_id"])
|
||||
XCTAssertEqual(Set(body?.keys.map { $0 } ?? []), [
|
||||
"user_equity_travel_id",
|
||||
"material_ids",
|
||||
"refined_template_id",
|
||||
])
|
||||
}
|
||||
|
||||
func testSubmitAIReretouchEncodesOnlyFieldsRequiredByEachType() async throws {
|
||||
let session = MockURLSession(responses: [
|
||||
envelopeJSON(#"{"accepted":true}"#),
|
||||
envelopeJSON(#"{"accepted":true}"#),
|
||||
envelopeJSON(#"{"accepted":true}"#),
|
||||
])
|
||||
let api = TravelAlbumAPI(client: APIClient(environment: .testing, session: session))
|
||||
|
||||
try await api.submitAIReretouch(
|
||||
TravelAlbumAIReretouchRequest(
|
||||
id: 11,
|
||||
aiRetouchBatchId: 51,
|
||||
type: .refined,
|
||||
refinedTemplateId: 21,
|
||||
atmosphereTemplateId: nil
|
||||
)
|
||||
)
|
||||
try await api.submitAIReretouch(
|
||||
TravelAlbumAIReretouchRequest(
|
||||
id: 12,
|
||||
aiRetouchBatchId: 52,
|
||||
type: .atmosphere,
|
||||
refinedTemplateId: nil,
|
||||
atmosphereTemplateId: 22
|
||||
)
|
||||
)
|
||||
try await api.submitAIReretouch(
|
||||
TravelAlbumAIReretouchRequest(
|
||||
id: 13,
|
||||
aiRetouchBatchId: 53,
|
||||
type: .all,
|
||||
refinedTemplateId: 21,
|
||||
atmosphereTemplateId: 22
|
||||
)
|
||||
)
|
||||
|
||||
let bodies = try session.requests.map { request in
|
||||
try JSONSerialization.jsonObject(with: XCTUnwrap(request.httpBody)) as? [String: Any]
|
||||
}
|
||||
XCTAssertEqual(session.requests.map { $0.url?.path }, Array(
|
||||
repeating: "/api/yf-handset-app/photog/travel-album/ai-reretouch",
|
||||
count: 3
|
||||
))
|
||||
XCTAssertEqual(Set(bodies[0]?.keys.map { $0 } ?? []), ["id", "ai_retouch_batch_id", "type", "refined_template_id"])
|
||||
XCTAssertEqual(Set(bodies[1]?.keys.map { $0 } ?? []), ["id", "ai_retouch_batch_id", "type", "atmosphere_template_id"])
|
||||
XCTAssertEqual(Set(bodies[2]?.keys.map { $0 } ?? []), [
|
||||
"id",
|
||||
"ai_retouch_batch_id",
|
||||
"type",
|
||||
"refined_template_id",
|
||||
"atmosphere_template_id",
|
||||
])
|
||||
XCTAssertEqual(bodies[0]?["type"] as? Int, 1)
|
||||
XCTAssertEqual(bodies[1]?["type"] as? Int, 2)
|
||||
XCTAssertEqual(bodies[2]?["type"] as? Int, 3)
|
||||
}
|
||||
|
||||
private func envelopeJSON(_ dataJSON: String) -> Data {
|
||||
|
||||
Reference in New Issue
Block a user