Skip to content

Commit 3c325b8

Browse files
committed
test(schematics): update tests for v49 as per the new data model
1 parent 04d94b3 commit 3c325b8

10 files changed

+317
-2
lines changed

projects/element-ng/schematics/migrations/data/migration-test-data.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ComponentNamesInstruction,
99
ElementMigrationData,
1010
ElementSelectorInstruction,
11+
InputNamesInstruction,
1112
OutputNamesInstruction,
1213
SymbolRemovalInstruction
1314
} from './index.js';
@@ -86,6 +87,18 @@ const COMPONENT_NAMES_MIGRATION: ComponentNamesInstruction[] = [
8687
{
8788
module: /@(siemens|simpl)\/dashboards-ng/,
8889
symbolRenamings: [{ replace: 'CONFIG_TOKEN', replaceWith: 'SI_DASHBOARD_CONFIGURATION' }]
90+
},
91+
{
92+
module: /@(siemens|simpl)\/element-ng(\/toast-notification)?/,
93+
symbolRenamings: [{ replace: 'ToastStateName', replaceWith: 'StatusType' }],
94+
toModule: '@siemens/element-ng/common'
95+
},
96+
{
97+
module: /@(siemens|simpl)\/element-ng(\/(info-page|unauthorized-page))?/,
98+
symbolRenamings: [
99+
{ replace: 'SiUnauthorizedPageComponent', replaceWith: 'SiInfoPageComponent' }
100+
],
101+
toModule: '@siemens/element-ng/info-page'
89102
}
90103
];
91104

@@ -103,7 +116,16 @@ const ELEMENT_SELECTORS_MIGRATION: ElementSelectorInstruction[] = [
103116
// next to current
104117
{ replace: 'si-icon-next', replaceWith: 'si-icon' },
105118
{ replace: 'si-tabset-next', replaceWith: 'si-tabset' },
106-
{ replace: 'si-tab-next', replaceWith: 'si-tab' }
119+
{ replace: 'si-tab-next', replaceWith: 'si-tab' },
120+
// v48 to v49
121+
{
122+
replace: 'si-unauthorized-page',
123+
replaceWith: 'si-info-page',
124+
defaultAttributes: [
125+
{ name: 'icon', value: 'element-warning-filled' },
126+
{ name: 'iconColor', value: 'status-warning' }
127+
]
128+
}
107129
];
108130

109131
const SYMBOL_REMOVALS_MIGRATION: SymbolRemovalInstruction[] = [
@@ -169,6 +191,31 @@ const OUTPUT_NAMES_MIGRATION: OutputNamesInstruction[] = [
169191
}
170192
];
171193

194+
const INPUT_NAMES_MIGRATION: InputNamesInstruction[] = [
195+
// v48 to v49
196+
{
197+
module: /@(siemens|simpl)\/element-ng/,
198+
elementSelector: 'si-filtered-search',
199+
apiMappings: [{ replace: 'readonly', replaceWith: 'disabled' }]
200+
},
201+
{
202+
module: /@(siemens|simpl)\/charts-ng/,
203+
elementSelector: 'si-chart-gauge',
204+
apiMappings: [
205+
{ replace: 'numberOfDecimals', replaceWith: ['minNumberOfDecimals', 'maxNumberOfDecimals'] }
206+
]
207+
},
208+
{
209+
module: /@(siemens|simpl)\/element-ng(\/(info-page|unauthorized-page))?/,
210+
elementSelector: 'si-unauthorized-page',
211+
apiMappings: [
212+
{ replace: 'heading', replaceWith: 'titleText' },
213+
{ replace: 'subHeading', replaceWith: 'copyText' },
214+
{ replace: 'description', replaceWith: 'instructions' }
215+
]
216+
}
217+
];
218+
172219
/**
173220
* Stable migration data for testing.
174221
* This data is frozen and used for testing to ensure test stability.
@@ -179,5 +226,6 @@ export const getElementMigrationTestData = (): ElementMigrationData => ({
179226
componentNameChanges: COMPONENT_NAMES_MIGRATION,
180227
elementSelectorChanges: ELEMENT_SELECTORS_MIGRATION,
181228
symbolRemovalChanges: SYMBOL_REMOVALS_MIGRATION,
182-
outputNameChanges: OUTPUT_NAMES_MIGRATION
229+
outputNameChanges: OUTPUT_NAMES_MIGRATION,
230+
inputNameChanges: INPUT_NAMES_MIGRATION
183231
});

projects/element-ng/schematics/migrations/element-migration/element-migration.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,20 @@ describe('to legacy migration', () => {
146146
it('should remove the deprecated api from module based accordion', async () => {
147147
await checkTemplateMigration(['module-based.accordion-inline-template.ts']);
148148
});
149+
150+
it('should migrate ToastStateName to StatusType', async () => {
151+
await checkTemplateMigration(['toast-state-name.ts']);
152+
});
153+
154+
it('should migrate filtered search readonly attribute in inline templates', async () => {
155+
await checkTemplateMigration(['filtered-search-inline-readonly.ts']);
156+
});
157+
158+
it('should migrate unauthorized page component in inline templates', async () => {
159+
await checkTemplateMigration(['unauthorized-page-inline.ts']);
160+
});
161+
162+
it('should split numberOfDecimals into minNumberOfDecimals and maxNumberOfDecimals', async () => {
163+
await checkTemplateMigration(['chart-gauge-decimals.ts']);
164+
});
149165
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component } from '@angular/core';
2+
import { SiChartGaugeComponent } from '@siemens/charts-ng/gauge';
3+
4+
@Component({
5+
selector: 'app-dashboard',
6+
standalone: true,
7+
template: `
8+
<si-chart-gauge
9+
[value]="75"
10+
[numberOfDecimals]="2"
11+
[min]="0"
12+
[max]="100"
13+
></si-chart-gauge>
14+
15+
<si-chart-gauge [numberOfDecimals]="0"></si-chart-gauge>
16+
17+
<si-chart-gauge
18+
[value]="gaugeValue"
19+
[numberOfDecimals]="decimals"
20+
></si-chart-gauge>
21+
`,
22+
imports: [SiChartGaugeComponent]
23+
})
24+
export class DashboardComponent {
25+
gaugeValue = 85;
26+
decimals = 1;
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component } from '@angular/core';
2+
import { SiChartGaugeComponent } from '@siemens/charts-ng/gauge';
3+
4+
@Component({
5+
selector: 'app-dashboard',
6+
standalone: true,
7+
template: `
8+
<si-chart-gauge
9+
[value]="75"
10+
[minNumberOfDecimals]="2" [maxNumberOfDecimals]="2"
11+
[min]="0"
12+
[max]="100"
13+
></si-chart-gauge>
14+
15+
<si-chart-gauge [minNumberOfDecimals]="0" [maxNumberOfDecimals]="0"></si-chart-gauge>
16+
17+
<si-chart-gauge
18+
[value]="gaugeValue"
19+
[minNumberOfDecimals]="decimals" [maxNumberOfDecimals]="decimals"
20+
></si-chart-gauge>
21+
`,
22+
imports: [SiChartGaugeComponent]
23+
})
24+
export class DashboardComponent {
25+
gaugeValue = 85;
26+
decimals = 1;
27+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) Siemens 2016 - 2025
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
import { Component } from '@angular/core';
6+
import { SiFilteredSearchModule } from '@siemens/element-ng/filtered-search';
7+
8+
@Component({
9+
selector: 'app-inline-readonly-test',
10+
template: `
11+
<div>
12+
<si-filtered-search [disabled]="true"></si-filtered-search>
13+
<si-filtered-search [disabled]="editMode === false" [criteria]="criteria"></si-filtered-search>
14+
<si-filtered-search
15+
[disabled]="isDisabled"
16+
[placeholder]="'Enter search criteria'"
17+
(search)="onSearch($event)">
18+
</si-filtered-search>
19+
</div>
20+
`,
21+
imports: [SiFilteredSearchModule],
22+
standalone: true
23+
})
24+
export class InlineReadonlyTestComponent {
25+
editMode = false;
26+
isDisabled = true;
27+
criteria = [];
28+
29+
onSearch(event: any): void {
30+
console.log(event);
31+
}
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (c) Siemens 2016 - 2025
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
import { Component } from '@angular/core';
6+
import { SiToastNotificationService } from '@siemens/element-ng/toast-notification';
7+
import { StatusType } from '@siemens/element-ng/common';
8+
9+
@Component({
10+
selector: 'app-test',
11+
template: `
12+
<button (click)="showToast()">Show Toast</button>
13+
`
14+
})
15+
export class TestComponent {
16+
17+
constructor(private toastService: SiToastNotificationService) {}
18+
19+
showToast(): void {
20+
const state: StatusType = 'success';
21+
const anotherState: StatusType = 'error';
22+
}
23+
24+
getToastState(): StatusType {
25+
return 'warning';
26+
}
27+
28+
processState(state: StatusType): void {
29+
console.log(state);
30+
}
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Component } from '@angular/core';
2+
import { SiInfoPageComponent } from '@siemens/element-ng/info-page';
3+
4+
@Component({
5+
selector: 'app-test-inline-unauthorized',
6+
standalone: true,
7+
imports: [SiInfoPageComponent],
8+
template: `
9+
<si-info-page icon="element-warning-filled" iconColor="status-warning"
10+
titleText="Access Restricted"
11+
copyText="You need special permissions to view this page."
12+
instructions="Contact admin@company.com for access."
13+
[link]="{ title: 'Return', link: '/home' }"
14+
></si-info-page>
15+
16+
<div class="error-container">
17+
<si-info-page icon="element-warning-filled" iconColor="status-warning"
18+
[titleText]="title"
19+
[copyText]="subtitle"
20+
[instructions]="instructions"
21+
></si-info-page>
22+
</div>
23+
24+
<!-- Multiple instances -->
25+
<si-info-page icon="element-warning-filled" iconColor="status-warning" titleText="Error 403"></si-info-page>
26+
<si-info-page icon="element-warning-filled" iconColor="status-warning"
27+
titleText="Permission Denied"
28+
copyText="Contact support"
29+
></si-info-page>
30+
`
31+
})
32+
export class TestInlineUnauthorizedComponent {
33+
title = 'Not Authorized';
34+
subtitle = 'Your role does not permit access';
35+
instructions = 'Request access from your manager';
36+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) Siemens 2016 - 2025
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
import { Component } from '@angular/core';
6+
import { SiFilteredSearchModule } from '@siemens/element-ng/filtered-search';
7+
8+
@Component({
9+
selector: 'app-inline-readonly-test',
10+
template: `
11+
<div>
12+
<si-filtered-search [readonly]="true"></si-filtered-search>
13+
<si-filtered-search [readonly]="editMode === false" [criteria]="criteria"></si-filtered-search>
14+
<si-filtered-search
15+
[readonly]="isDisabled"
16+
[placeholder]="'Enter search criteria'"
17+
(search)="onSearch($event)">
18+
</si-filtered-search>
19+
</div>
20+
`,
21+
imports: [SiFilteredSearchModule],
22+
standalone: true
23+
})
24+
export class InlineReadonlyTestComponent {
25+
editMode = false;
26+
isDisabled = true;
27+
criteria = [];
28+
29+
onSearch(event: any): void {
30+
console.log(event);
31+
}
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) Siemens 2016 - 2025
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
import { Component } from '@angular/core';
6+
import { ToastStateName , SiToastNotificationService } from '@siemens/element-ng/toast-notification';
7+
8+
@Component({
9+
selector: 'app-test',
10+
template: `
11+
<button (click)="showToast()">Show Toast</button>
12+
`
13+
})
14+
export class TestComponent {
15+
16+
constructor(private toastService: SiToastNotificationService) {}
17+
18+
showToast(): void {
19+
const state: ToastStateName = 'success';
20+
const anotherState: ToastStateName = 'error';
21+
}
22+
23+
getToastState(): ToastStateName {
24+
return 'warning';
25+
}
26+
27+
processState(state: ToastStateName): void {
28+
console.log(state);
29+
}
30+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Component } from '@angular/core';
2+
import { SiUnauthorizedPageComponent } from '@siemens/element-ng/unauthorized-page';
3+
4+
@Component({
5+
selector: 'app-test-inline-unauthorized',
6+
standalone: true,
7+
imports: [SiUnauthorizedPageComponent],
8+
template: `
9+
<si-unauthorized-page
10+
heading="Access Restricted"
11+
subHeading="You need special permissions to view this page."
12+
description="Contact admin@company.com for access."
13+
[link]="{ title: 'Return', link: '/home' }"
14+
></si-unauthorized-page>
15+
16+
<div class="error-container">
17+
<si-unauthorized-page
18+
[heading]="title"
19+
[subHeading]="subtitle"
20+
[description]="instructions"
21+
></si-unauthorized-page>
22+
</div>
23+
24+
<!-- Multiple instances -->
25+
<si-unauthorized-page heading="Error 403"></si-unauthorized-page>
26+
<si-unauthorized-page
27+
heading="Permission Denied"
28+
subHeading="Contact support"
29+
></si-unauthorized-page>
30+
`
31+
})
32+
export class TestInlineUnauthorizedComponent {
33+
title = 'Not Authorized';
34+
subtitle = 'Your role does not permit access';
35+
instructions = 'Request access from your manager';
36+
}

0 commit comments

Comments
 (0)