Implement authorization import and revocation checks (T-503)

This commit is contained in:
ila
2026-07-20 09:07:30 +08:00
parent b4453130de
commit 76f6108496
36 changed files with 2197 additions and 68 deletions
+43
View File
@@ -0,0 +1,43 @@
package gio
import (
"testing"
"softbox.local/core/application"
)
func TestAuthorizationViewRendersSanitizedStateAndQueuesImport(t *testing.T) {
shell := NewAppShell(adapterContractEdition, adapterContractItems()...)
if err := shell.ApplyEvent(application.NewAuthorizationEvent(application.AuthorizationSnapshot{
State: application.AuthorizationStateGrace,
MachineHash: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
Products: []application.AuthorizedProduct{{
ProductID: "product-test", Kind: application.LicenseKindNonPerpetual, RebindPolicy: "support-only",
}},
})); err != nil {
t.Fatal(err)
}
shell.viewLicense.Click()
nodes := adapterContractLayout(shell, adapterContractViewport)
if !shell.showLicense || !adapterContractHasSemantic(nodes, "授权") ||
!adapterContractHasSemantic(nodes, "导入许可证") ||
!adapterContractHasSemantic(nodes, "product-test · 非永久许可证(License v1 未提供试用到期信息)") {
t.Fatal("authorization state did not render its accessible content")
}
shell.importLicense.Click()
adapterContractLayout(shell, adapterContractViewport)
if !shell.TakeLicenseImportRequest() || shell.TakeLicenseImportRequest() {
t.Fatal("import click did not produce exactly one UI-only request")
}
if err := shell.ApplyEvent(application.NewAuthorizationEvent(application.AuthorizationSnapshot{
State: application.AuthorizationStateUnconfigured, Products: []application.AuthorizedProduct{},
})); err != nil {
t.Fatal(err)
}
shell.importLicense.Click()
adapterContractLayout(shell, adapterContractViewport)
if shell.TakeLicenseImportRequest() {
t.Fatal("unconfigured authorization accepted an import request")
}
}