test(postcard): unit tests for overrides, fallback, partials, samples, validation, sync and branding
- Pin override precedence, fallback, partials, samples, draft validation and branding - Postgres TestStore/TestSync for index sync, drift hashes and reset - Pact row-state and mail capability method-set pins; attach AbsolutePublicURL cases Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -255,15 +255,56 @@ func TestRelationHookInterfaces(t *testing.T) {
|
||||
// TestRowStateValues pins the wire values of the fixed row-state set: the
|
||||
// admin SPA and plugin CSS match on these exact strings.
|
||||
func TestRowStateValues(t *testing.T) {
|
||||
got := []RowState{RowStateDeleted, RowStateNegative, RowStateDisabled}
|
||||
want := []string{"deleted", "negative", "disabled"}
|
||||
got := []RowState{RowStateDeleted, RowStateNegative, RowStateDisabled, RowStateCustomized, RowStateOutdated}
|
||||
want := []string{"deleted", "negative", "disabled", "customized", "outdated"}
|
||||
for i, state := range got {
|
||||
if string(state) != want[i] {
|
||||
t.Fatalf("row state %d = %q, want %q", i, state, want[i])
|
||||
}
|
||||
}
|
||||
// Compile-time and reflect pins: HasMailTemplates and HasMailPartials
|
||||
// method sets stay exactly as Phase 35 found them.
|
||||
var _ HasMailTemplates = mailTemplatesPin{}
|
||||
var _ HasMailPartials = mailPartialsPin{}
|
||||
tm := reflect.TypeOf((*HasMailTemplates)(nil)).Elem()
|
||||
methods := map[string]bool{}
|
||||
for i := 0; i < tm.NumMethod(); i++ {
|
||||
methods[tm.Method(i).Name] = true
|
||||
}
|
||||
for _, name := range []string{"MailTemplatesFS", "MailTemplates", "MailLayouts"} {
|
||||
if !methods[name] {
|
||||
t.Fatalf("HasMailTemplates missing %s", name)
|
||||
}
|
||||
}
|
||||
if len(methods) != 3 {
|
||||
t.Fatalf("HasMailTemplates methods = %v", methods)
|
||||
}
|
||||
pm := reflect.TypeOf((*HasMailPartials)(nil)).Elem()
|
||||
pmethods := map[string]bool{}
|
||||
for i := 0; i < pm.NumMethod(); i++ {
|
||||
pmethods[pm.Method(i).Name] = true
|
||||
}
|
||||
for _, name := range []string{"MailPartialsFS", "MailPartials"} {
|
||||
if !pmethods[name] {
|
||||
t.Fatalf("HasMailPartials missing %s", name)
|
||||
}
|
||||
}
|
||||
if len(pmethods) != 2 {
|
||||
t.Fatalf("HasMailPartials methods = %v", pmethods)
|
||||
}
|
||||
}
|
||||
|
||||
type mailTemplatesPin struct{}
|
||||
|
||||
func (mailTemplatesPin) MailTemplatesFS() fs.FS { return nil }
|
||||
func (mailTemplatesPin) MailTemplates() []string { return nil }
|
||||
func (mailTemplatesPin) MailLayouts() map[string]string { return nil }
|
||||
|
||||
type mailPartialsPin struct{}
|
||||
|
||||
func (mailPartialsPin) MailPartialsFS() fs.FS { return nil }
|
||||
func (mailPartialsPin) MailPartials() []string { return nil }
|
||||
|
||||
type formSeams struct{}
|
||||
|
||||
func (formSeams) FormVirtualFields() []string { return []string{"password", "password_confirmation"} }
|
||||
@@ -410,9 +451,12 @@ func TestPhase121ContractsOnSampleController(t *testing.T) {
|
||||
if err != nil || len(got) != 2 || got[0] != nil || len(got[1]) != 1 || got[1][0] != RowStateNegative {
|
||||
t.Fatalf("row states = %v err=%v", got, err)
|
||||
}
|
||||
// The fixed set has exactly three values, each its own string.
|
||||
set := map[RowState]bool{RowStateDeleted: true, RowStateNegative: true, RowStateDisabled: true}
|
||||
if len(set) != 3 || string(RowStateDeleted) != "deleted" || string(RowStateNegative) != "negative" || string(RowStateDisabled) != "disabled" {
|
||||
// The fixed set has exactly five values, each its own string.
|
||||
set := map[RowState]bool{
|
||||
RowStateDeleted: true, RowStateNegative: true, RowStateDisabled: true,
|
||||
RowStateCustomized: true, RowStateOutdated: true,
|
||||
}
|
||||
if len(set) != 5 || string(RowStateCustomized) != "customized" || string(RowStateOutdated) != "outdated" {
|
||||
t.Fatalf("row state set = %v", set)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user