Skip to content

Commit

Permalink
Merge branch 'development' into dependabot/npm_and_yarn/fortawesome/r…
Browse files Browse the repository at this point in the history
…eact-fontawesome-0.2.2
  • Loading branch information
mfacar authored Jun 20, 2024
2 parents 95dd65f + 6268183 commit 04a1ffe
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 38 deletions.
8 changes: 4 additions & 4 deletions app/api/sync/specs/syncWorker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('syncWorker', () => {
await db.disconnect();
});

it('should sync the configured templates and its defined properties', async () => {
it('should sync the whitelisted templates and properties', async () => {
await runAllTenants();
await tenants.run(async () => {
const syncedTemplates = await templates.get();
Expand Down Expand Up @@ -459,15 +459,15 @@ describe('syncWorker', () => {
}, 'target1');
});

describe('when a template that is configured has been deleted', () => {
describe('when a template that is whitelisted has been deleted', () => {
it('should not throw an error', async () => {
await tenants.run(async () => {
await entitiesModel.delete({ template: template1 });
//@ts-ignore
await templates.delete({ _id: template1 });
}, 'host1');

await expect(syncWorker.runAllTenants()).resolves.not.toThrowError();
await expect(syncWorker.runAllTenants()).resolves.not.toThrow();
});
});

Expand Down Expand Up @@ -575,7 +575,7 @@ describe('syncWorker', () => {
fixtures.settings[0].sync[0].config.pages = [];
await applyFixtures(fixtures, {});

await expect(runAllTenants).rejects.toThrowError(
await expect(runAllTenants).rejects.toThrow(
new Error('Invalid elements found in ordering - pages')
);

Expand Down
55 changes: 30 additions & 25 deletions app/api/sync/syncWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InvalidSyncConfig extends Error {
}
}

export interface SyncConfig {
interface SyncConfig {
url: string;
active?: boolean;
username: string;
Expand Down Expand Up @@ -71,39 +71,42 @@ export const syncWorker = {
await previousSync;
const syncConfig = validateConfig(config);
if (syncConfig.active) {
const cookie = await this.login(syncConfig);
await this.syncronizeConfig(syncConfig, cookie);
await this.syncronizeConfig(syncConfig);
}
}, Promise.resolve());
},

async syncronizeConfig(config: SyncConfig, cookie: string) {
async syncronizeConfig(config: SyncConfig) {
await createSyncIfNotExists(config);

const syncConfig = await createSyncConfig(config, config.name, this.UPDATE_LOG_TARGET_COUNT);

await (
await syncConfig.lastChanges()
).reduce(async (previousChange, change) => {
await previousChange;
const shouldSync: { skip?: boolean; data?: any } = await syncConfig.shouldSync(change);
if (shouldSync.skip) {
await synchronizer.syncDelete(change, config.url, cookie);
}
const lastChanges = await syncConfig.lastChanges();

if (shouldSync.data) {
await synchronizer.syncData(
{
url: config.url,
change,
data: shouldSync.data,
cookie,
},
'post'
);
}
await updateSyncs(config.name, change.namespace, change.timestamp);
}, Promise.resolve());
if (lastChanges.length) {
const cookie = await this.login(config);

await lastChanges.reduce(async (previousChange, change) => {
await previousChange;
const shouldSync: { skip?: boolean; data?: any } = await syncConfig.shouldSync(change);
if (shouldSync.skip) {
await synchronizer.syncDelete(change, config.url, cookie);
}

if (shouldSync.data) {
await synchronizer.syncData(
{
url: config.url,
change,
data: shouldSync.data,
cookie,
},
'post'
);
}
await updateSyncs(config.name, change.namespace, change.timestamp);
}, Promise.resolve());
}
},

async login({ url, username, password }: SyncConfig) {
Expand All @@ -112,3 +115,5 @@ export const syncWorker = {
return response.cookie || '';
},
};

export type { SyncConfig };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
"copy-webpack-plugin": "12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"cypress": "13.6.4",
"cypress": "13.11.0",
"cypress-axe": "^1.5.0",
"cypress-plugin-snapshots": "^1.4.4",
"cypress-real-events": "^1.12.0",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6777,7 +6777,7 @@ buffer-xor@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz"

buffer@^5.2.0, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0:
buffer@^5.2.0, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
Expand Down Expand Up @@ -7911,10 +7911,10 @@ cypress-real-events@^1.12.0:
resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.12.0.tgz#ffeb2b23686ba5b16ac91dd9bc3b6785d36d38d3"
integrity sha512-oiy+4kGKkzc2PT36k3GGQqkGxNiVypheWjMtfyi89iIk6bYmTzeqxapaLHS3pnhZOX1IEbTDUVxh8T4Nhs1tyQ==

cypress@13.6.4:
version "13.6.4"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.4.tgz#42c88d3ee0342f1681abfacabf9c1f082676bc53"
integrity sha512-pYJjCfDYB+hoOoZuhysbbYhEmNW7DEDsqn+ToCLwuVowxUXppIWRr7qk4TVRIU471ksfzyZcH+mkoF0CQUKnpw==
cypress@13.11.0:
version "13.11.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.11.0.tgz#17097366390424cba5db6bf0ee5e97503f036e07"
integrity sha512-NXXogbAxVlVje4XHX+Cx5eMFZv4Dho/2rIcdBHg9CNPFUGZdM4cRdgIgM7USmNYsC12XY0bZENEQ+KBk72fl+A==
dependencies:
"@cypress/request" "^3.0.0"
"@cypress/xvfb" "^1.2.4"
Expand All @@ -7923,7 +7923,7 @@ [email protected]:
arch "^2.2.0"
blob-util "^2.0.2"
bluebird "^3.7.2"
buffer "^5.6.0"
buffer "^5.7.1"
cachedir "^2.3.0"
chalk "^4.1.0"
check-more-types "^2.24.0"
Expand All @@ -7941,7 +7941,7 @@ [email protected]:
figures "^3.2.0"
fs-extra "^9.1.0"
getos "^3.2.1"
is-ci "^3.0.0"
is-ci "^3.0.1"
is-installed-globally "~0.4.0"
lazy-ass "^1.6.0"
listr2 "^3.8.3"
Expand Down Expand Up @@ -11273,7 +11273,7 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.1.5, is-callable@^1.2.7:
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==

is-ci@^3.0.0:
is-ci@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867"
integrity sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==
Expand Down

0 comments on commit 04a1ffe

Please sign in to comment.