diff --git a/addon/-private/properties/collection.js b/addon/-private/properties/collection.js index df7d9da6..a07a0447 100644 --- a/addon/-private/properties/collection.js +++ b/addon/-private/properties/collection.js @@ -1,4 +1,5 @@ import { deprecate } from '@ember/application/deprecations'; +import { warn } from '@ember/debug'; import { collection as mainCollection } from './collection/main'; import { collection as legacyCollection } from './collection/legacy'; @@ -123,5 +124,13 @@ export function collection(scopeOrDefinition, definitionOrNothing) { url: 'https://gist.github.com/san650/17174e4b7b1fd80b049a47eb456a7cdc#file-old-collection-api-js', }); + warn( + 'Legacy page object collection definition is invalid. Please, make sure you include a `itemScope` selector.', + scopeOrDefinition.itemScope, + { + id: 'ember-cli-page-object.legacy-collection-missing-item-scope' + } + ); + return legacyCollection(scopeOrDefinition); } diff --git a/tests/integration/deprecations/legacy-collection-test.js b/tests/integration/deprecations/legacy-collection-test.js index 6bf718a5..c9709d8f 100644 --- a/tests/integration/deprecations/legacy-collection-test.js +++ b/tests/integration/deprecations/legacy-collection-test.js @@ -27,3 +27,12 @@ test("doesn't show a deprecation warning when first parameter is a string", func assert.expectNoDeprecation(); }); + +test('shows a warning on invalid legacy collection definitions', function(assert) { + assert.expectWarning(function() { + create({ + foo: collection({ + }) + }); + }, 'Legacy page object collection definition is invalid. Please, make sure you include a `itemScope` selector.'); +});