Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for query params replace and refreshModel not working together #15148

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/ember/tests/routing/query_params_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,51 @@ moduleFor('Query Params - main', class extends QueryParamTestCase {
});
}

['@test refreshModel and replace work together'](assert) {
assert.expect(8);

this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');

let appModelCount = 0;
this.add('route:application', Route.extend({
model(params) {
appModelCount++;
}
}));

let indexModelCount = 0;
this.add('route:index', Route.extend({
queryParams: {
omg: {
refreshModel: true,
replace: true
}
},
model(params) {
indexModelCount++;

if (indexModelCount === 1) {
assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass');
} else if (indexModelCount === 2) {
assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass');
}
}
}));

return this.visitAndAssert('/').then(() => {
assert.equal(appModelCount, 1, 'app model hook ran');
assert.equal(indexModelCount, 1, 'index model hook ran');

let indexController = this.getController('index');
this.expectedReplaceURL = '/?omg=lex';
this.setAndFlush(indexController, 'omg', 'lex');

assert.equal(appModelCount, 1, 'app model hook did not run again');
assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel');
});
}

['@test multiple QP value changes only cause a single model refresh'](assert) {
assert.expect(2);

Expand Down