Skip to content

Commit

Permalink
[cascading] from release/11.4.0-rc to main (#2452)
Browse files Browse the repository at this point in the history
<!--
{"currentBranch":"release/11.4.0-rc","targetBranch":"main","bypassReviewers":false,"isConflicting":false}
-->

## Cascading from release/11.4.0-rc to main

---

:heavy_exclamation_mark: The pull request is conflicting with the target
branch.
You can fix the issue locally with the following commands:

<details open>
  <summary>Using <b>gh CLI</b></summary>

  ```shell
  gh pr checkout 2452
  git pull --ff origin main
  ```

  and update this Pull Request with

  ```shell
  gh pr push 2452
  ```
</details>

<details>
  <summary>Using <b>git</b> only</summary>

  ```shell
  git fetch origin
  git checkout origin/cascading/11.4.0-rc-main
  git pull --ff origin main
  ```

  and update this Pull Request with

  ```shell
  git push origin HEAD:cascading/11.4.0-rc-main
  ```
</details>

---

<small>This Pull Request has been generated with :heart: by the
[Otter](https://github.com/AmadeusITGroup/otter) cascading tool.</small>
  • Loading branch information
fpaul-1A authored Nov 13, 2024
2 parents b16af53 + 4732cfb commit f3d81c9
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export class StatePanelComponent {
/**
* Remove a state from the Chrome Extension application and store.
* Note that the active store cannot be deleted.
*
* @param stateName
*/
public deleteState(stateName: string) {
Expand All @@ -208,7 +207,6 @@ export class StatePanelComponent {

/**
* Download a state as a json file
*
* @param stateName
*/
public exportState(stateName: string) {
Expand All @@ -225,7 +223,6 @@ export class StatePanelComponent {

/**
* Download a state file, add it to the state list and share it .
*
* @param event
*/
public async onFileChange(event: InputEvent) {
Expand Down
3 changes: 0 additions & 3 deletions apps/chrome-devtools/src/extension/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const isInjectionContentMessage = (content: any): content is InjectContentMessag

/**
* determinate if the message contains application information to share in the global panel
*
* @param data
*/
const isApplicationInformationMessage = (data?: OtterMessageContent): data is ApplicationInformationContentMessage => data?.dataType === 'applicationInformation';
Expand All @@ -48,7 +47,6 @@ const activeStateAppliedOn = new Set<number>();

/**
* List of host which can access to the Chrome Extension store
*
* @param url
*/
const isWhitelistedHost = async (url?: string) => {
Expand All @@ -63,7 +61,6 @@ const isWhitelistedHost = async (url?: string) => {
/**
* Retrieve a state and send a message to the Otter application connected to the DevTool that they should apply this
* state.
*
* @param appName
* @param tabId
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncPipe, formatDate } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, inject, input, Input, type OnDestroy, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, inject, Input, input, type OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { toObservable } from '@angular/core/rxjs-interop';
import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { configSignal, DynamicConfigurableWithSignal, O3rConfig } from '@o3r/configuration';
Expand Down Expand Up @@ -32,7 +32,7 @@ const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
AsyncPipe
]
})
export class RulesEnginePresComponent implements OnDestroy, DynamicConfigurableWithSignal<RulesEnginePresConfig>, Translatable<RulesEnginePresTranslation> {
export class RulesEnginePresComponent implements OnDestroy, DynamicConfigurableWithSignal<RulesEnginePresConfig>, Translatable<RulesEnginePresTranslation>, OnInit {
private readonly tripService = inject(TripFactsService);
private readonly localizationService = inject(LocalizationService);
private readonly rulesService = inject(RulesEngineRunnerService);
Expand Down
2 changes: 1 addition & 1 deletion packages/@ama-sdk/create/src/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('Create new sdk command', () => {
}, execAppOptions)
).not.toThrow();
expect(() => packageManagerRun({script: 'build'}, { ...execAppOptions, cwd: sdkPackagePath })).not.toThrow();
const packageJson = JSON.parse(fs.readFileSync(path.join(sdkPackagePath, 'package.json'), 'utf-8'));
const packageJson = JSON.parse(fs.readFileSync(path.join(sdkPackagePath, 'package.json'), 'utf8'));
const resolutions = packageManager === 'yarn' ? packageJson.resolutions : packageJson.overrides;
// all otter dependencies in package.json must be pinned:
[
Expand Down
2 changes: 1 addition & 1 deletion packages/@ama-sdk/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
},
"generatorDependencies": {
"@swc/cli": "~0.5.0",
"@swc/core": "~1.7.0",
"@swc/core": "~1.9.0",
"@swc/helpers": "~0.5.0",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/@o3r/create/src/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ describe('Create new otter project command', () => {
expect(existsSync(path.join(inProjectPath, 'project'))).toBe(false);
expect(() => packageManagerRunOnProject(appName, true, { script: 'build' }, execInAppOptions)).not.toThrow();

const rootPackageJson = JSON.parse(await fs.readFile(path.join(inProjectPath, 'package.json'), 'utf-8'));
const rootPackageJson = JSON.parse(await fs.readFile(path.join(inProjectPath, 'package.json'), 'utf8'));
const resolutions = packageManager === 'yarn' ? rootPackageJson.resolutions : rootPackageJson.overrides;
const appPackageJson = JSON.parse(await fs.readFile(path.join(inProjectPath, 'apps', appName, 'package.json'), 'utf-8'));
const appPackageJson = JSON.parse(await fs.readFile(path.join(inProjectPath, 'apps', appName, 'package.json'), 'utf8'));
// all otter dependencies in both package.json files must be pinned:
[
...Object.entries(rootPackageJson.dependencies), ...Object.entries(rootPackageJson.devDependencies), ...Object.entries(resolutions),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export async function getFilesFromRegistry(packageDescriptor: string, paths: str
const extractedFiles = paths.reduce((acc: Record<string, string>, path) => {
const portablePath = npath.toPortablePath(join(result.prefixPath, path));
if (result.packageFs.existsSync(portablePath)) {
acc[path] = result.packageFs.readFileSync(portablePath, 'utf-8');
acc[path] = result.packageFs.readFileSync(portablePath, 'utf8');
}
return acc;
}, {});
Expand Down
2 changes: 1 addition & 1 deletion packages/@o3r/extractors/src/core/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For more details and instructions on how to change these settings, see https://g
const pmr = getPackageManagerRunner(packageJson);

try {
const version = JSON.parse(await promises.readFile(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')).version;
const version = JSON.parse(await promises.readFile(path.join(__dirname, '..', '..', 'package.json'), 'utf8')).version;
execFileSync(`${pmr} ng add @o3r/telemetry@${version}`);
} catch {
ctx.logger.warn('Failed to install `@o3r/telemetry`.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EffectsModule } from '@ngrx/effects';
import { select, Store, StoreModule } from '@ngrx/store';
import { computeItemIdentifier } from '@o3r/core';
import { BehaviorSubject, firstValueFrom, Observable, of, Subject } from 'rxjs';
import { distinctUntilChanged, map, take } from 'rxjs/operators';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { jsonOneRulesetOneRuleNoCondPlaceholder } from '../../../testing/mocks/oneruleset-onerule-nocond-placeholder.mock';
import { jsonOneRulesetOneRuleNoCond } from '../../../testing/mocks/oneruleset-onerule-nocond.mock';
import { jsonOneRulesetOneRuleReexecution } from '../../../testing/mocks/oneruleset-onerule-reexecution.mock';
Expand Down Expand Up @@ -100,15 +100,25 @@ describe('Rules engine service', () => {
expect(actions[0].actionType).toBe('UPDATE_LOCALISATION');
});

it('should handle linked components and validity range properly', (done) => {
service.events$.pipe(take(1)).subscribe((actions) => {
expect(actions.length).toBe(1);
expect(actions[0].actionType).toBe('UPDATE_LOCALISATION');
done();
});
it('should handle linked components and validity range properly', async () => {
store.dispatch(setRulesetsEntities({entities: jsonOneRulesetValidOneRuleNoCond.ruleSets}));
});
const actions = await firstValueFrom(service.events$);
expect(actions.length).toBe(1);
expect(actions[0].actionType).toBe('UPDATE_LOCALISATION');
expect(actions[0].value).toBe('my.custom.ssci.loc.key2');
service.enableRuleSetFor(computeItemIdentifier('TestComponent', '@otter/comps'));
const nextActions = await firstValueFrom(service.events$);
expect(nextActions.length).toBe(2);
expect(nextActions[1].actionType).toBe('UPDATE_LOCALISATION');
expect(nextActions[1].value).toBe('my.custom.ssci.loc.key3');
// out of range validity for ruleset linked to TestComponent2
service.enableRuleSetFor(computeItemIdentifier('TestComponent2', '@otter/comps'));
const lastActions = await firstValueFrom(service.events$);
expect(lastActions.length).toBe(2);
expect(lastActions[1].actionType).toBe('UPDATE_LOCALISATION');
expect(lastActions[1].value).toBe('my.custom.ssci.loc.key3');

});

it('should have configuration updated in the store', async () => {
service.engine.upsertFacts<any>([{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ describe('RuleSets Selector tests', () => {
}
};

const r9: RulesetsModel = {
id: 'r9',
name: 'r9_name',
rules: [],
validityRange: {
from: afterTomorrow.toISOString()
},
linkedComponent: {
library: '@mylibrary',
name: 'thisComponentWillBeIgnored'
},
linkedComponents: {
or: [
{
library: '@mylibrary',
name: 'mycomponent'
},
{
library: '@mylibrary',
name: 'mycomponent2'
}
]
}
};

it('should return the ruleset in range', () => {
const state: RulesetsState = {
ids: [r1.id, r2.id],
Expand All @@ -110,8 +135,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual(['r1']);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual(['r1']);
});

it('should return the rulest with no validity or on demand', () => {
Expand All @@ -124,8 +150,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual(['r3']);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual(['r3']);
});

it('should exclude the one not in validity range', () => {
Expand All @@ -138,8 +165,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual(['r3']);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual(['r3']);
});

it('should not find valid rulesets', () => {
Expand All @@ -152,8 +180,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual([]);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual([]);
});

it('should find a ruleset valid starting from a date in the past', () => {
Expand All @@ -167,8 +196,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual(['r5']);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual(['r5']);
});

it('should find a ruleset valid until a date in the future', () => {
Expand All @@ -182,8 +212,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual(['r6']);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual(['r6']);
});

it('should consider valid a ruleset with validity empty', () => {
Expand All @@ -197,8 +228,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual(['r7']);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual(['r7']);
});

it('onDemand should take precedence over validity', () => {
Expand All @@ -212,8 +244,9 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectActiveRuleSets.projector(allRuleSetsArray)).toEqual([]);
expect(selectors.selectActiveRuleSets.projector(rulesetsInRange)).toEqual([]);
});

it('should select the linked components rulesets', () => {
Expand All @@ -227,11 +260,13 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

const componentsWithRulesets = {
[computeItemIdentifier('mycomponent', '@mylibrary')]: [r2.id, r8.id],
[computeItemIdentifier('mycomponent2', '@mylibrary')]: [r8.id]
};
expect(selectors.selectRuleSetLinkComponents.projector(allRuleSetsArray)).toEqual(componentsWithRulesets);
expect(selectors.selectRuleSetLinkComponents.projector(rulesetsInRange)).toEqual(componentsWithRulesets);
});

it('should select the map of rulesets linked components', () => {
Expand All @@ -245,6 +280,8 @@ describe('RuleSets Selector tests', () => {
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

const comp2 = computeItemIdentifier('mycomponent2', '@mylibrary');
const comp = computeItemIdentifier('mycomponent', '@mylibrary');
const componentsWithRulesets = {
Expand All @@ -253,7 +290,56 @@ describe('RuleSets Selector tests', () => {
[r8.id]: [comp, comp2]
}
};
expect(selectors.selectComponentsLinkedToRuleset.projector(allRuleSetsArray)).toEqual(componentsWithRulesets);
expect(selectors.selectComponentsLinkedToRuleset.projector(rulesetsInRange)).toEqual(componentsWithRulesets);
});

it('should filter out the linked components rulesets outside the validity range', () => {
const state: RulesetsState = {
ids: [r9.id],
entities: {
'r9': r9
},
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectRuleSetLinkComponents.projector(rulesetsInRange)).toEqual({});
});

it('should filter out the map of rulesets linked components outside the validity range', () => {
const state: RulesetsState = {
ids: [r9.id],
entities: {
'r9': r9
},
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);
const rulesetsInRange = selectors.selectRuleSetsInRange.projector(allRuleSetsArray);

expect(selectors.selectComponentsLinkedToRuleset.projector(rulesetsInRange)).toEqual({ or: {} });
});

it('selectRuleSetsInRange should filter out rulesets outside of the validity range', () => {
const state: RulesetsState = {
ids: [r1.id, r2.id, r3.id, r4.id, r5.id, r6.id, r7.id, r8.id, r9.id],
entities: {
'r1': r1,
'r2': r2,
'r3': r3,
'r4': r4,
'r5': r5,
'r6': r6,
'r7': r7,
'r8': r8,
'r9': r9
},
requestIds: []
};
const allRuleSetsArray = selectors.selectAllRulesets.projector(state);

expect(selectors.selectRuleSetsInRange.projector(allRuleSetsArray)).toEqual([r1, r2, r3, r5, r6, r7, r8]);
});

});
Expand Down
Loading

0 comments on commit f3d81c9

Please sign in to comment.