fix(plugins): address Greptile feedback on testing.ts
Remove unnecessary `as any` casts on capability strings (now valid PluginCapability members) and add company-membership guards to match production behavior in plugin-host-services.ts.
This commit is contained in:
@@ -423,20 +423,30 @@ export function createTestHarness(options: TestHarnessOptions): TestHarness {
|
|||||||
return comment;
|
return comment;
|
||||||
},
|
},
|
||||||
documents: {
|
documents: {
|
||||||
async list(_issueId, _companyId) {
|
async list(issueId, companyId) {
|
||||||
requireCapability(manifest, capabilitySet, "issue.documents.read" as any);
|
requireCapability(manifest, capabilitySet, "issue.documents.read");
|
||||||
|
if (!isInCompany(issues.get(issueId), companyId)) return [];
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
async get(_issueId, _key, _companyId) {
|
async get(issueId, _key, companyId) {
|
||||||
requireCapability(manifest, capabilitySet, "issue.documents.read" as any);
|
requireCapability(manifest, capabilitySet, "issue.documents.read");
|
||||||
|
if (!isInCompany(issues.get(issueId), companyId)) return null;
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
async upsert(_input) {
|
async upsert(input) {
|
||||||
requireCapability(manifest, capabilitySet, "issue.documents.write" as any);
|
requireCapability(manifest, capabilitySet, "issue.documents.write");
|
||||||
|
const parentIssue = issues.get(input.issueId);
|
||||||
|
if (!isInCompany(parentIssue, input.companyId)) {
|
||||||
|
throw new Error(`Issue not found: ${input.issueId}`);
|
||||||
|
}
|
||||||
throw new Error("documents.upsert is not implemented in test context");
|
throw new Error("documents.upsert is not implemented in test context");
|
||||||
},
|
},
|
||||||
async delete(_issueId, _key, _companyId) {
|
async delete(issueId, _key, companyId) {
|
||||||
requireCapability(manifest, capabilitySet, "issue.documents.write" as any);
|
requireCapability(manifest, capabilitySet, "issue.documents.write");
|
||||||
|
const parentIssue = issues.get(issueId);
|
||||||
|
if (!isInCompany(parentIssue, companyId)) {
|
||||||
|
throw new Error(`Issue not found: ${issueId}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user