Skip to content

Commit e92d87e

Browse files
mmalerbaalxhub
authored andcommitted
test(compiler): Enable passing i18n tests (angular#52390)
Enables a handful of i18n tests that are currently skipped, but pass if enabled. Some of them require alternate golden files because of inconsequential differences in the cost array order. PR Close angular#52390
1 parent b0bc25d commit e92d87e

File tree

14 files changed

+194
-26
lines changed

14 files changed

+194
-26
lines changed

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/es5_support/TEST_CASES.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"verifyUniqueConsts"
1717
]
1818
}
19-
],
20-
"skipForTemplatePipeline": true
19+
]
2120
}
2221
]
2322
}

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/TEST_CASES.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"verifyUniqueConsts"
2929
]
3030
}
31-
],
32-
"skipForTemplatePipeline": true
31+
]
3332
},
3433
{
3534
"description": "should support ICU-only templates",
@@ -43,8 +42,7 @@
4342
"verifyUniqueConsts"
4443
]
4544
}
46-
],
47-
"skipForTemplatePipeline": true
45+
]
4846
},
4947
{
5048
"description": "should generate i18n instructions for icus generated outside of i18n blocks",

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/namespaces/TEST_CASES.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
],
99
"expectations": [
1010
{
11+
"files": [
12+
{
13+
"generated": "foreign_object.js",
14+
"expected": "foreign_object.template.js",
15+
"templatePipelineExpected": "foreign_object.pipeline.js"
16+
}
17+
],
1118
"extraChecks": [
1219
"verifyPlaceholdersIntegrity",
1320
"verifyUniqueConsts"
1421
]
1522
}
16-
],
17-
"skipForTemplatePipeline": true
23+
]
1824
},
1925
{
2026
"description": "should handle namespaces on i18n block containers",
@@ -23,13 +29,19 @@
2329
],
2430
"expectations": [
2531
{
32+
"files": [
33+
{
34+
"generated": "namespaced_div.js",
35+
"expected": "namespaced_div.template.js",
36+
"templatePipelineExpected": "namespaced_div.pipeline.js"
37+
}
38+
],
2639
"extraChecks": [
2740
"verifyPlaceholdersIntegrity",
2841
"verifyUniqueConsts"
2942
]
3043
}
31-
],
32-
"skipForTemplatePipeline": true
44+
]
3345
}
3446
]
3547
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
consts: () => {
3+
let $I18N_0$;
4+
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
5+
/**
6+
* @suppress {msgDescriptions}
7+
*/
8+
const $MSG_EXTERNAL_7128002169381370313$$APP_SPEC_TS_1$ = goog.getMsg("{$startTagXhtmlDiv} Count: {$startTagXhtmlSpan}5{$closeTagXhtmlSpan}{$closeTagXhtmlDiv}", {
9+
"closeTagXhtmlDiv": "\uFFFD/#3\uFFFD",
10+
"closeTagXhtmlSpan": "\uFFFD/#4\uFFFD",
11+
"startTagXhtmlDiv": "\uFFFD#3\uFFFD",
12+
"startTagXhtmlSpan": "\uFFFD#4\uFFFD"
13+
}, {
14+
original_code: {
15+
"closeTagXhtmlDiv": "</xhtml:div>",
16+
"closeTagXhtmlSpan": "</span>",
17+
"startTagXhtmlDiv": "<xhtml:div xmlns=\"http://www.w3.org/1999/xhtml\">",
18+
"startTagXhtmlSpan": "<span>"
19+
}
20+
});
21+
$I18N_0$ = $MSG_EXTERNAL_7128002169381370313$$APP_SPEC_TS_1$;
22+
}
23+
else {
24+
$I18N_0$ = $localize `${"\uFFFD#3\uFFFD"}:START_TAG__XHTML_DIV: Count: ${"\uFFFD#4\uFFFD"}:START_TAG__XHTML_SPAN:5${"\uFFFD/#4\uFFFD"}:CLOSE_TAG__XHTML_SPAN:${"\uFFFD/#3\uFFFD"}:CLOSE_TAG__XHTML_DIV:`;
25+
}
26+
return [
27+
$i18n_0$,
28+
["xmlns", "http://www.w3.org/2000/svg"],
29+
["xmlns", "http://www.w3.org/1999/xhtml"]
30+
];
31+
},
32+
template: function MyComponent_Template(rf, ctx) {
33+
if (rf & 1) {
34+
$r3$.ɵɵnamespaceSVG();
35+
$r3$.ɵɵelementStart(0, "svg", 1)(1, "foreignObject");
36+
$r3$.ɵɵi18nStart(2, 0);
37+
$r3$.ɵɵnamespaceHTML();
38+
$r3$.ɵɵelementStart(3, "div", 2);
39+
$r3$.ɵɵelement(4, "span");
40+
$r3$.ɵɵelementEnd();
41+
$r3$.ɵɵi18nEnd();
42+
$r3$.ɵɵelementEnd()();
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
consts: () => {
2+
let $I18N_0$;
3+
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
4+
/**
5+
* @suppress {msgDescriptions}
6+
*/
7+
const $MSG_EXTERNAL_7428861019045796010$$APP_SPEC_TS_1$ = goog.getMsg(" Count: {$startTagXhtmlSpan}5{$closeTagXhtmlSpan}", {
8+
"closeTagXhtmlSpan": "\uFFFD/#4\uFFFD",
9+
"startTagXhtmlSpan": "\uFFFD#4\uFFFD"
10+
}, {
11+
original_code: {
12+
"closeTagXhtmlSpan": "</span>",
13+
"startTagXhtmlSpan": "<span>"
14+
}
15+
});
16+
$I18N_0$ = $MSG_EXTERNAL_7428861019045796010$$APP_SPEC_TS_1$;
17+
}
18+
else {
19+
$I18N_0$ = $localize ` Count: ${"\uFFFD#4\uFFFD"}:START_TAG__XHTML_SPAN:5${"\uFFFD/#4\uFFFD"}:CLOSE_TAG__XHTML_SPAN:`;
20+
}
21+
return [
22+
$i18n_0$,
23+
["xmlns", "http://www.w3.org/2000/svg"],
24+
["xmlns", "http://www.w3.org/1999/xhtml"]
25+
];
26+
},
27+
template: function MyComponent_Template(rf, ctx) {
28+
if (rf & 1) {
29+
$r3$.ɵɵnamespaceSVG();
30+
$r3$.ɵɵelementStart(0, "svg", 1)(1, "foreignObject");
31+
$r3$.ɵɵnamespaceHTML();
32+
$r3$.ɵɵelementStart(2, "div", 2);
33+
$r3$.ɵɵi18nStart(3, 0);
34+
$r3$.ɵɵelement(4, "span");
35+
$r3$.ɵɵi18nEnd();
36+
$r3$.ɵɵelementEnd()()();
37+
}
38+
}

packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/nested_nodes/TEST_CASES.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@
9898
"verifyUniqueConsts"
9999
]
100100
}
101-
],
102-
"skipForTemplatePipeline": true
101+
]
103102
},
104103
{
105104
"description": "should support interpolations with complex expressions",
@@ -113,8 +112,7 @@
113112
"verifyUniqueConsts"
114113
]
115114
}
116-
],
117-
"skipForTemplatePipeline": true
115+
]
118116
},
119117
{
120118
"description": "should handle i18n attributes with bindings in content",
@@ -128,8 +126,7 @@
128126
"verifyUniqueConsts"
129127
]
130128
}
131-
],
132-
"skipForTemplatePipeline": true
129+
]
133130
},
134131
{
135132
"description": "should handle i18n attributes with bindings and nested elements in content",
@@ -143,8 +140,7 @@
143140
"verifyUniqueConsts"
144141
]
145142
}
146-
],
147-
"skipForTemplatePipeline": true
143+
]
148144
},
149145
{
150146
"description": "should handle i18n attributes with bindings in content and element attributes",
@@ -168,13 +164,19 @@
168164
],
169165
"expectations": [
170166
{
167+
"files": [
168+
{
169+
"generated": "nested_templates.js",
170+
"expected": "nested_templates.template.js",
171+
"templatePipelineExpected": "nested_templates.pipeline.js"
172+
}
173+
],
171174
"extraChecks": [
172175
"verifyPlaceholdersIntegrity",
173176
"verifyUniqueConsts"
174177
]
175178
}
176-
],
177-
"skipForTemplatePipeline": true
179+
]
178180
},
179181
{
180182
"description": "should ignore i18n attributes on self-closing tags",
@@ -213,13 +215,19 @@
213215
],
214216
"expectations": [
215217
{
218+
"files": [
219+
{
220+
"generated": "directives.js",
221+
"expected": "directives.template.js",
222+
"templatePipelineExpected": "directives.pipeline.js"
223+
}
224+
],
216225
"extraChecks": [
217226
"verifyPlaceholdersIntegrity",
218227
"verifyUniqueConsts"
219228
]
220229
}
221-
],
222-
"skipForTemplatePipeline": true
230+
]
223231
},
224232
{
225233
"description": "should generate event listeners instructions before i18n ones",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function MyComponent_div_0_Template(rf, ctx) {
2+
if (rf & 1) {
3+
$r3$.ɵɵelementStart(0, "div");
4+
$r3$.ɵɵi18nStart(1, 0);
5+
$r3$.ɵɵelement(2, "span");
6+
$r3$.ɵɵi18nEnd();
7+
$r3$.ɵɵelementEnd();
8+
}
9+
if (rf & 2) {
10+
const $ctx_r0$ = $r3$.ɵɵnextContext();
11+
$r3$.ɵɵadvance(2);
12+
$r3$.ɵɵi18nExp($ctx_r0$.valueA);
13+
$r3$.ɵɵi18nApply(1);
14+
}
15+
}
16+
17+
decls: 1,
18+
vars: 1,
19+
consts: () => {
20+
__i18nMsg__('Some other content {$startTagSpan}{$interpolation}{$closeTagSpan}', [['closeTagSpan', String.raw`\uFFFD/#2\uFFFD`], ['interpolation', String.raw`\uFFFD0\uFFFD`], ['startTagSpan', String.raw`\uFFFD#2\uFFFD`]], {original_code: {'closeTagSpan': '</span>', 'interpolation': '{{ valueA }}', 'startTagSpan': '<span>',}}, {})
21+
return [
22+
$i18n_0$,
23+
[__AttributeMarker.Template__, "ngIf"]
24+
];
25+
},
26+
template: function MyComponent_Template(rf, ctx) {
27+
if (rf & 1) {
28+
$r3$.ɵɵtemplate(0, MyComponent_div_0_Template, 3, 1, "div", 1);
29+
}
30+
if (rf & 2) {
31+
$r3$.ɵɵproperty("ngIf", ctx.visible);
32+
}
33+
}

0 commit comments

Comments
 (0)