Add responsible signature to aftersales confirmation
This commit is contained in:
@@ -214,9 +214,11 @@ func TestAftersalesService_CustomerConfirm_Authorize(t *testing.T) {
|
||||
}, owner)
|
||||
|
||||
sig := validSignatureFixture()
|
||||
responsibleSig := validSignatureFixture()
|
||||
view, err := svc.CustomerConfirm(order.SerialNumber, models.CustomerConfirmDTO{
|
||||
Action: "authorize",
|
||||
Signature: sig,
|
||||
Action: "authorize",
|
||||
Signature: sig,
|
||||
ResponsibleSignature: responsibleSig,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, view)
|
||||
@@ -224,10 +226,12 @@ func TestAftersalesService_CustomerConfirm_Authorize(t *testing.T) {
|
||||
assert.Equal(t, AuthorizationStatusAuthorized, view.AuthorizationStatus)
|
||||
assert.NotNil(t, view.ConfirmedAt)
|
||||
assert.Equal(t, sig, view.Signature)
|
||||
assert.Equal(t, responsibleSig, view.ResponsibleSignature)
|
||||
|
||||
var refreshed models.AftersalesOrder
|
||||
database.DB.Where("serial_number = ?", order.SerialNumber).First(&refreshed)
|
||||
assert.Equal(t, sig, refreshed.Signature)
|
||||
assert.Equal(t, responsibleSig, refreshed.ResponsibleSignature)
|
||||
}
|
||||
|
||||
func TestAftersalesService_CustomerConfirm_AuthorizeRejectsEmptySignature(t *testing.T) {
|
||||
@@ -244,8 +248,31 @@ func TestAftersalesService_CustomerConfirm_AuthorizeRejectsEmptySignature(t *tes
|
||||
}, owner)
|
||||
|
||||
_, err := svc.CustomerConfirm(order.SerialNumber, models.CustomerConfirmDTO{
|
||||
Action: "authorize",
|
||||
Signature: "",
|
||||
Action: "authorize",
|
||||
Signature: "",
|
||||
ResponsibleSignature: validSignatureFixture(),
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "签名")
|
||||
}
|
||||
|
||||
func TestAftersalesService_CustomerConfirm_AuthorizeRejectsEmptyResponsibleSignature(t *testing.T) {
|
||||
confirmTest(t)
|
||||
owner := seedTechnician(t, "aftersales_empty_responsible_sig_owner")
|
||||
defer database.DB.Unscoped().Delete(&owner)
|
||||
|
||||
order := createOrderFor(t, owner, "13800007778")
|
||||
defer database.DB.Unscoped().Delete(order)
|
||||
|
||||
svc := AftersalesService{}
|
||||
_, _ = svc.SubmitForConfirmation(order.SerialNumber, models.SubmitForConfirmationDTO{
|
||||
ResolutionNote: "done",
|
||||
}, owner)
|
||||
|
||||
_, err := svc.CustomerConfirm(order.SerialNumber, models.CustomerConfirmDTO{
|
||||
Action: "authorize",
|
||||
Signature: validSignatureFixture(),
|
||||
ResponsibleSignature: "",
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "签名")
|
||||
@@ -266,8 +293,9 @@ func TestAftersalesService_CustomerConfirm_AuthorizeRejectsInvalidSignature(t *t
|
||||
|
||||
// 非 dataURL 格式
|
||||
_, err := svc.CustomerConfirm(order.SerialNumber, models.CustomerConfirmDTO{
|
||||
Action: "authorize",
|
||||
Signature: "not-a-data-url",
|
||||
Action: "authorize",
|
||||
Signature: "not-a-data-url",
|
||||
ResponsibleSignature: validSignatureFixture(),
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "签名格式")
|
||||
@@ -275,8 +303,9 @@ func TestAftersalesService_CustomerConfirm_AuthorizeRejectsInvalidSignature(t *t
|
||||
// 太短
|
||||
tiny := "data:image/png;base64," + base64.StdEncoding.EncodeToString([]byte("xx"))
|
||||
_, err = svc.CustomerConfirm(order.SerialNumber, models.CustomerConfirmDTO{
|
||||
Action: "authorize",
|
||||
Signature: tiny,
|
||||
Action: "authorize",
|
||||
Signature: tiny,
|
||||
ResponsibleSignature: validSignatureFixture(),
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "过短")
|
||||
@@ -348,8 +377,9 @@ func TestAftersalesService_CustomerConfirm_RejectsWrongStatus(t *testing.T) {
|
||||
svc := AftersalesService{}
|
||||
// 未提交客户确认,工单仍是 created,应该拒绝
|
||||
_, err := svc.CustomerConfirm(order.SerialNumber, models.CustomerConfirmDTO{
|
||||
Action: "authorize",
|
||||
Signature: validSignatureFixture(),
|
||||
Action: "authorize",
|
||||
Signature: validSignatureFixture(),
|
||||
ResponsibleSignature: validSignatureFixture(),
|
||||
})
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user