it("proper inheritance of list policy from show policy",()=>{
returnwithRunningApp(
(t)=>{
returnextend(t,{show:newPolicies.Noone()});
},
async({app})=>{
assert.strictEqual(
app.collections.coins.getPolicy("list")instanceof
Policies.Noone,
true
);
}
);
});
it("proper inheritance of show policy from list policy",()=>{
returnwithRunningApp(
(t)=>{
returnextend(t,{list:newPolicies.Noone()});
},
async({app})=>{
assert.strictEqual(
app.collections.coins.getPolicy("show")instanceof
Policies.Noone,
true
);
}
);
});
it("action policy is favoured over inherited policy",()=>{
returnwithRunningApp(
(t)=>{
returnextend(t,{
list:newPolicies.Noone(),
show:newPolicies.LoggedIn(),
});
},
async({app})=>{
assert.strictEqual(
app.collections.coins.getPolicy("list")instanceof
Policies.Noone,
true
);
}
);
});
});
describe("types",()=>{
it("throws a ts error when a required field is missing",()=>{
// this test does not have to run in runitme, just creating a code structure to reflect the use case mentioned here: https://forum.sealcode.org/t/sealious-problem-z-typami/1399/3
returnwithRunningApp(
(t:TestAppConstructor<TestApp>)=>
classTheAppextendst{
collections={
...App.BaseCollections,
withRequired:
new(classwithRequiredextendsCollection{
fields={
required:FieldTypes.Required(
newFieldTypes.Int()
),
};
})(),
};
},
async({app})=>{
awaitapp.collections.withRequired.create(
newapp.SuperContext(),
{required:2}// try removing or renaming this property and you should get an error