Skip to content

Commit 6840201

Browse files
authored
Merge pull request #19233 from emberjs/fix-multiple-deprecations
Ensure multiple deprecations (warnings, etc) are tracked correctly
2 parents 8635659 + 1f92f8d commit 6840201

File tree

7 files changed

+40
-7
lines changed

7 files changed

+40
-7
lines changed

packages/@ember/-internals/glimmer/tests/integration/helpers/custom-helper-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,13 @@ moduleFor(
718718
});
719719

720720
expectDeprecation(() => {
721+
// TODO: this must be a bug??
722+
expectDeprecation(
723+
backtrackingMessageFor('undefined', undefined, {
724+
renderTree: ['\\(result of a `<\\(unknown\\).*?>` helper\\)'],
725+
})
726+
);
727+
721728
this.render('{{hello-world}}');
722729
}, expectedMessage);
723730
}

packages/@ember/-internals/glimmer/tests/integration/helpers/partial-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ moduleFor(
239239
names: emberA(['Alex', 'Ben']),
240240
}
241241
);
242-
}, 'The use of `{{partial}}` is deprecated, please refactor the "outer-partial" partial to a component');
242+
}, /The use of `{{partial}}` is deprecated, please refactor the "(inner|outer)-partial" partial to a component/);
243243

244244
this.assertStableRerender();
245245

246246
this.assertText('0: [outer: Alex] [inner: Alex]1: [outer: Ben] [inner: Ben]');
247247

248248
expectDeprecation(() => {
249249
runTask(() => this.context.names.pushObject('Sophie'));
250-
}, 'The use of `{{partial}}` is deprecated, please refactor the "outer-partial" partial to a component');
250+
}, /The use of `{{partial}}` is deprecated, please refactor the "(inner|outer)-partial" partial to a component/);
251251

252252
this.assertText(
253253
'0: [outer: Alex] [inner: Alex]1: [outer: Ben] [inner: Ben]2: [outer: Sophie] [inner: Sophie]'
@@ -294,7 +294,7 @@ moduleFor(
294294
{{/with}}`,
295295
{ age: 0 }
296296
);
297-
}, 'The use of `{{partial}}` is deprecated, please refactor the "person2-partial" partial to a component');
297+
}, /The use of `{{partial}}` is deprecated, please refactor the "person(2|3|4)-partial" partial to a component/);
298298

299299
this.assertStableRerender();
300300

@@ -332,7 +332,7 @@ moduleFor(
332332
},
333333
}
334334
);
335-
}, 'The use of `{{partial}}` is deprecated, please refactor the "odd" partial to a component');
335+
}, /The use of `{{partial}}` is deprecated, please refactor the "(odd|even)" partial to a component/);
336336

337337
this.assertStableRerender();
338338

packages/@ember/-internals/glimmer/tests/integration/helpers/tracked-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ moduleFor(
418418
});
419419

420420
expectDeprecation(() => {
421+
// TODO: this must be a bug??
422+
expectDeprecation(
423+
backtrackingMessageFor('undefined', undefined, {
424+
renderTree: ['\\(result of a `.*` helper\\)'],
425+
})
426+
);
427+
421428
this.render('{{hello-world this.model}}', { model: {} });
422429
}, expectedMessage);
423430
}

packages/@ember/-internals/glimmer/tests/utils/backtracking-rerender.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
export function backtrackingMessageFor(key, obj, { renderTree } = {}) {
22
// Start off with standard backtracking assertion
3-
let regex = [`You attempted to update \`${key}\` on \`${obj}\``];
3+
let regex;
4+
5+
if (obj) {
6+
regex = [`You attempted to update \`${key}\` on \`${obj}\``];
7+
} else {
8+
regex = [`You attempted to update \`${key}\``];
9+
}
410

511
if (renderTree) {
612
// match the renderTree if it was included

packages/@ember/-internals/metal/tests/accessors/get_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ moduleFor(
314314
let obj = new EmberObject();
315315

316316
expectDeprecation(() => {
317+
// TODO: this must be a bug??
318+
expectDeprecation(
319+
/You attempted to update `undefined`, but it had already been used previously in the same computation/
320+
);
321+
317322
track(() => {
318323
get(obj, 'bar');
319324
});

packages/ember/tests/routing/decoupled_basic_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ moduleFor(
14181418
expectDeprecation(() => {
14191419
assert.equal(appController.get('currentPath'), expectedPath);
14201420
assert.equal(appController.get('currentRouteName'), expectedRouteName);
1421-
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.');
1421+
}, /Accessing `(currentPath|currentRouteName)` on `controller:application` is deprecated, use the `(currentPath|currentRouteName)` property on `service:router` instead\./);
14221422
}
14231423

14241424
transitionAndCheck(null, 'index', 'index');

packages/internal-test-helpers/lib/ember-dev/method-call-tracker.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export default class MethodCallTracker {
101101

102102
let actual: Actual | undefined;
103103
let match: Actual | undefined = undefined;
104+
let matched: Set<number> = new Set();
104105

105106
for (o = 0; o < expectedMessages.length; o++) {
106107
const expectedMessage = expectedMessages[o];
@@ -135,7 +136,8 @@ export default class MethodCallTracker {
135136

136137
if (matchesMessage && matchesOptionList) {
137138
match = actual;
138-
break;
139+
matched.add(i);
140+
continue;
139141
}
140142
}
141143

@@ -171,5 +173,11 @@ export default class MethodCallTracker {
171173
);
172174
}
173175
}
176+
177+
for (i = 0; i < actuals.length; i++) {
178+
if (!matched.has(i) && actuals[i][1] !== true) {
179+
assert.ok(false, `Unexpected Ember.${methodName} call: ${actuals[i][0]}`);
180+
}
181+
}
174182
}
175183
}

0 commit comments

Comments
 (0)