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") } }