mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
fix(tabs): keep the case-default GET read-only, forget a stale id outside the rollback
Merge-time fix for #676 (review nits 4 and 5). sessionCreated forgot a stale case default inside the try whose catch rolls the registration back; it now does so after the try, once the session is committed, so the cleanup can never drop a committed session from the live map. caseDefaultGroup (behind GET /api/cases/:name/default-group) no longer deletes a stale id as a side effect: it reports Ungrouped and leaves the value for the next creation to forget. The two tests that expected the read to clear it now expect it to write nothing; the creation test still pins the cleanup. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3ca1d4832e
commit
a3efc9b963
5 files changed
+23
-18
No files matched your search
@@ -299,7 +299,7 @@ describe('TabLayoutService case default placement', () => {
|
||||
});
|
||||
|
||||
describe('TabLayoutService case default reads and writes', () => {
|
||||
it('reports the selection with the owner group options, clearing a stale id', async () => {
|
||||
it('reports the selection with the owner group options, and a stale id as Ungrouped without writing', async () => {
|
||||
const h = createHarness({ layouts: { alice: grouped() }, live: facts() });
|
||||
expect(await h.service.caseDefaultGroup('alice', 'app')).toEqual({
|
||||
groupId: null,
|
||||
@@ -310,7 +310,9 @@ describe('TabLayoutService case default reads and writes', () => {
|
||||
});
|
||||
h.defaults.alice = { app: 'gone' };
|
||||
expect((await h.service.caseDefaultGroup('alice', 'app')).groupId).toBeNull();
|
||||
expect(h.caseDefaults.getCaseDefaultGroup('alice', 'app')).toBeUndefined();
|
||||
// A read never writes: the next creation for the case is what forgets the stale id.
|
||||
expect(h.caseDefaults.deleteCaseDefaultGroup).not.toHaveBeenCalled();
|
||||
expect(h.caseDefaults.getCaseDefaultGroup('alice', 'app')).toBe('gone');
|
||||
});
|
||||
|
||||
it('saves a known group or null, and refuses an id that is not in the owner layout', async () => {
|
||||
|
||||
@@ -343,10 +343,11 @@ describe('case default group: GET/PUT /api/cases/:name/default-group', () => {
|
||||
expect(data.groups[1]).toEqual({ id: 'g-ops', name: 'Operations' });
|
||||
});
|
||||
|
||||
it('a deleted group reads back as Ungrouped and is cleared', async () => {
|
||||
it('a deleted group reads back as Ungrouped, and the read changes nothing', async () => {
|
||||
world.defaults[OWNER] = { [CASE]: 'g-gone' };
|
||||
expect((await get()).json().data.groupId).toBeNull();
|
||||
expect(CASE in world.defaults[OWNER]).toBe(false);
|
||||
// GET is read-only; the next session created for the case forgets the stale id.
|
||||
expect(world.defaults[OWNER][CASE]).toBe('g-gone');
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
Reference in new issue
Block a user