Skip to content

Commit a0dd448

Browse files
committed
fix(V2): allow mutations on ownerless records and skip non-home project tests
Records without orgUid or resolvable parent FKs (e.g. standalone AEF T5 entities) were blocked by the ownership guard. Use hasOwnershipFields to only require ownership resolution when the record has ownership markers. Also skip live non-home project tests when no synced project from another org is available in the CI environment.
1 parent 554c2db commit a0dd448

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/models/v2/staging-v2.model.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,14 @@ class StagingV2 extends Model {
336336
if (existingRecord) {
337337
const tableExcludedFields = StagingV2.getExcludedFieldsForTable(values.table);
338338
const existingUnresolved = [];
339+
const existingOwnerOrgUids = await StagingV2.collectOwnerOrgUids(
340+
existingRecord, options, new Set(), 0, false, existingUnresolved, tableExcludedFields,
341+
);
342+
const hasOwnershipChain = StagingV2.hasOwnershipFields(existingRecord, values.table);
339343
await StagingV2.assertOwnerOrgUidsAreHome(
340-
await StagingV2.collectOwnerOrgUids(
341-
existingRecord, options, new Set(), 0, false, existingUnresolved, tableExcludedFields,
342-
),
344+
existingOwnerOrgUids,
343345
values.table,
344-
true,
346+
hasOwnershipChain,
345347
existingUnresolved,
346348
);
347349
} else if (values.action !== 'UPDATE') {

tests/v2/live-api/project-validation.live.spec.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ const findNonHomeProject = async (request, homeOrgId) => {
4646
return null;
4747
};
4848

49-
const requireNonHomeProject = async (request, homeOrgId) => {
49+
const requireNonHomeProject = async (request, homeOrgId, mochaContext) => {
5050
const nonHomeProject = await findNonHomeProject(request, homeOrgId);
51-
expect(
52-
nonHomeProject,
53-
'Expected at least one synced project from another subscribed organization',
54-
).to.exist;
51+
if (!nonHomeProject) {
52+
mochaContext.skip();
53+
}
5554
return nonHomeProject;
5655
};
5756

@@ -227,7 +226,7 @@ describe('Project Live API Validation Tests', function () {
227226
});
228227
describe('Step 7: PUT Request Tests', function () {
229228
it('should reject updating a project not owned by the home organization', async function () {
230-
const nonHomeProject = await requireNonHomeProject(request, homeOrgId);
229+
const nonHomeProject = await requireNonHomeProject(request, homeOrgId, this);
231230

232231
const updateData = buildProjectUpdateData(nonHomeProject, {
233232
projectName: `Should Not Update ${Date.now()}`,
@@ -360,7 +359,7 @@ describe('Project Live API Validation Tests', function () {
360359
});
361360

362361
it('should include synced project data from another organization', async function () {
363-
const nonHomeProject = await requireNonHomeProject(request, homeOrgId);
362+
const nonHomeProject = await requireNonHomeProject(request, homeOrgId, this);
364363
expect(nonHomeProject.orgUid).to.not.equal(homeOrgId);
365364
});
366365

@@ -376,7 +375,7 @@ describe('Project Live API Validation Tests', function () {
376375
});
377376
describe('Step 9: DELETE Request Tests', function () {
378377
it('should reject deleting a project not owned by the home organization', async function () {
379-
const nonHomeProject = await requireNonHomeProject(request, homeOrgId);
378+
const nonHomeProject = await requireNonHomeProject(request, homeOrgId, this);
380379

381380
try {
382381
const response = await request

0 commit comments

Comments
 (0)