Fix twenty-server integration test on main (#14905)

Following https://github.com/twentyhq/twenty/pull/14869

Dynamically clearing the cache, as one entry was forgotten
It seems like a permission test deletes a role that's expected to be
existing in following tests, as now cache is getting invalidated tests
are failing

Seems to be related to
https://discord.com/channels/1130383047699738754/1423768505911869460

## Singleton local cache key collision
When set for the first time caches local keys looks like
`workspaceId:undefined", singleton is shared between several cache
instances
If the given key is undefined it will read on other entity cache entry.
This commit is contained in:
Paul Rastoin
2025-10-06 15:51:48 +02:00
committed by GitHub
parent db7fe8b327
commit b870ed238f
13 changed files with 183 additions and 191 deletions
@@ -40,11 +40,13 @@ export class GetDataFromCacheWithRecomputeService<T, U> {
cachedVersion = await getCacheVersion(workspaceId);
const cacheKey = `${workspaceId}-${cachedVersion}`;
const cachedValue = this.cache.get(cacheKey);
if (isDefined(cachedVersion)) {
const cacheKey = `${workspaceId}-${cachedVersion}`;
const cachedValue = this.cache.get(cacheKey);
if (cachedValue) {
return cachedValue;
if (cachedValue) {
return cachedValue;
}
}
cachedData = await getCacheData(workspaceId);
@@ -77,6 +79,8 @@ export class GetDataFromCacheWithRecomputeService<T, U> {
}
}
const cacheKey = `${workspaceId}-${cachedVersion}`;
this.cache.set(cacheKey, {
version: cachedVersion,
data: cachedData,