0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Moved Urls and Rexources reinitialization

refs https://github.com/TryGhost/Toolbox/issues/127

- New instances or Urls and Resources during init were messing up test suites without an obvious solution. Moved them to only be triggered when the cache is present.
- Note the e2e-frontend tests are failing if thie initialization happens every time when init is called. There seems to be some reliance on Resources being the same intsance between "softReset" which seems wrong, but wasn't able to track it down definitevely
This commit is contained in:
Naz 2021-11-16 14:17:50 +04:00 committed by naz
parent 1a3a80cacc
commit 458f5b894b

View file

@ -38,7 +38,9 @@ class UrlService {
// NOTE: Urls and Resources should not be initialized here but only in the init method.
// Way too many tests fail if the initialization is removed so leaving it as is for time being
this.urls = new Urls();
this.resources = new Resources(this.queue);
this.resources = new Resources({
queue: this.queue
});
this._listeners();
}
@ -329,19 +331,21 @@ class UrlService {
persistedResources = await this.readCacheFile(this.resourcesCachePath);
}
this.urls = new Urls({
urls: persistedUrls
});
this.resources = new Resources({
queue: this.queue,
resources: persistedResources
});
this.resources.initResourceConfig();
this.resources.initEvenListeners();
if (persistedUrls && persistedResources) {
this.urls = new Urls({
urls: persistedUrls
});
this.resources = new Resources({
queue: this.queue,
resources: persistedResources
});
this.resources.initResourceConfig();
this.resources.initEvenListeners();
this._onQueueEnded('init');
} else {
this.resources.initResourceConfig();
this.resources.initEvenListeners();
await this.resources.fetchResources();
// CASE: all resources are fetched, start the queue
this.queue.start({