DEV: Prevent potential site state leaks in tests (#18663)

If one were to modify nested objects in `Site.current()` those changes would be carried over subsequent tests.
This commit is contained in:
Jarek Radosz 2022-10-19 11:46:01 +02:00 committed by GitHub
parent b6ba106f26
commit a53eb0882a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -127,14 +127,14 @@ export function withFrozenTime(timeString, timezone, callback) {
let _pretenderCallbacks = {};
export function resetSite(siteSettings, extras) {
let siteAttrs = Object.assign(
{},
siteFixtures["site.json"].site,
extras || {}
);
siteAttrs.siteSettings = siteSettings;
PreloadStore.store("site", siteAttrs);
export function resetSite(siteSettings, extras = {}) {
const siteAttrs = {
...siteFixtures["site.json"].site,
...extras,
siteSettings,
};
PreloadStore.store("site", cloneJSON(siteAttrs));
Site.resetCurrent();
}