Skip to content

Commit

Permalink
[CLEANUP beta] remove router service refresh feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Mar 12, 2022
1 parent 4836389 commit e91d863
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 83 deletions.
4 changes: 0 additions & 4 deletions packages/@ember/canary-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ENV } from '@ember/-internals/environment';
export const DEFAULT_FEATURES = {
EMBER_LIBRARIES_ISREGISTERED: null,
EMBER_IMPROVED_INSTRUMENTATION: null,
EMBER_ROUTING_ROUTER_SERVICE_REFRESH: true,
EMBER_CACHED: true,
EMBER_UNIQUE_ID_HELPER: true,
};
Expand Down Expand Up @@ -67,8 +66,5 @@ function featureValue(value: null | boolean) {

export const EMBER_LIBRARIES_ISREGISTERED = featureValue(FEATURES.EMBER_LIBRARIES_ISREGISTERED);
export const EMBER_IMPROVED_INSTRUMENTATION = featureValue(FEATURES.EMBER_IMPROVED_INSTRUMENTATION);
export const EMBER_ROUTING_ROUTER_SERVICE_REFRESH = featureValue(
FEATURES.EMBER_ROUTING_ROUTER_SERVICE_REFRESH
);
export const EMBER_CACHED = featureValue(FEATURES.EMBER_CACHED);
export const EMBER_UNIQUE_ID_HELPER = featureValue(FEATURES.EMBER_UNIQUE_ID_HELPER);
155 changes: 76 additions & 79 deletions packages/ember/tests/routing/router_service_test/refresh_test.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,97 @@
import { Route } from '@ember/-internals/routing';
import { EMBER_ROUTING_ROUTER_SERVICE_REFRESH } from '@ember/canary-features';
import { RouterTestCase, moduleFor } from 'internal-test-helpers';

if (EMBER_ROUTING_ROUTER_SERVICE_REFRESH) {
moduleFor(
'Router Service - refresh',
class extends RouterTestCase {
async ['@test RouterService#refresh can be used to re-run the model hooks of active routes'](
assert
) {
let parentCounter = 0;
this.add(
'route:parent',
class extends Route {
model() {
++parentCounter;
}
moduleFor(
'Router Service - refresh',
class extends RouterTestCase {
async ['@test RouterService#refresh can be used to re-run the model hooks of active routes'](
assert
) {
let parentCounter = 0;
this.add(
'route:parent',
class extends Route {
model() {
++parentCounter;
}
);
}
);

let childCounter = 0;
this.add(
'route:parent.child',
class extends Route {
model() {
++childCounter;
}
let childCounter = 0;
this.add(
'route:parent.child',
class extends Route {
model() {
++childCounter;
}
);
}
);

let sisterCounter = 0;
this.add(
'route:parent.sister',
class extends Route {
model() {
++sisterCounter;
}
let sisterCounter = 0;
this.add(
'route:parent.sister',
class extends Route {
model() {
++sisterCounter;
}
);
}
);

await this.visit('/');
assert.equal(parentCounter, 1);
assert.equal(childCounter, 0);
assert.equal(sisterCounter, 0);
await this.visit('/');
assert.equal(parentCounter, 1);
assert.equal(childCounter, 0);
assert.equal(sisterCounter, 0);

await this.routerService.refresh();
assert.equal(parentCounter, 2);
assert.equal(childCounter, 0);
assert.equal(sisterCounter, 0);
await this.routerService.refresh();
assert.equal(parentCounter, 2);
assert.equal(childCounter, 0);
assert.equal(sisterCounter, 0);

await this.routerService.refresh('application');
assert.equal(parentCounter, 3);
assert.equal(childCounter, 0);
assert.equal(sisterCounter, 0);
await this.routerService.refresh('application');
assert.equal(parentCounter, 3);
assert.equal(childCounter, 0);
assert.equal(sisterCounter, 0);

await this.routerService.transitionTo('parent.child');
assert.equal(parentCounter, 3);
assert.equal(childCounter, 1);
assert.equal(sisterCounter, 0);
await this.routerService.transitionTo('parent.child');
assert.equal(parentCounter, 3);
assert.equal(childCounter, 1);
assert.equal(sisterCounter, 0);

await this.routerService.refresh('parent.child');
assert.equal(parentCounter, 3);
assert.equal(childCounter, 2);
assert.equal(sisterCounter, 0);
await this.routerService.refresh('parent.child');
assert.equal(parentCounter, 3);
assert.equal(childCounter, 2);
assert.equal(sisterCounter, 0);

await this.routerService.refresh('parent');
assert.equal(parentCounter, 4);
assert.equal(childCounter, 3);
assert.equal(sisterCounter, 0);
await this.routerService.refresh('parent');
assert.equal(parentCounter, 4);
assert.equal(childCounter, 3);
assert.equal(sisterCounter, 0);

await this.routerService.transitionTo('parent.sister');
assert.equal(parentCounter, 4);
assert.equal(childCounter, 3);
assert.equal(sisterCounter, 1);
await this.routerService.transitionTo('parent.sister');
assert.equal(parentCounter, 4);
assert.equal(childCounter, 3);
assert.equal(sisterCounter, 1);

await this.routerService.refresh();
assert.equal(parentCounter, 5);
assert.equal(childCounter, 3);
assert.equal(sisterCounter, 2);
}
await this.routerService.refresh();
assert.equal(parentCounter, 5);
assert.equal(childCounter, 3);
assert.equal(sisterCounter, 2);
}

async ['@test RouterService#refresh verifies that the provided route exists']() {
await this.visit('/');
async ['@test RouterService#refresh verifies that the provided route exists']() {
await this.visit('/');

expectAssertion(() => {
this.routerService.refresh('this-route-does-not-exist');
}, 'The route "this-route-does-not-exist" was not found');
}
expectAssertion(() => {
this.routerService.refresh('this-route-does-not-exist');
}, 'The route "this-route-does-not-exist" was not found');
}

async ['@test RouterService#refresh verifies that the provided route is active']() {
await this.visit('/');
async ['@test RouterService#refresh verifies that the provided route is active']() {
await this.visit('/');

expectAssertion(() => {
this.routerService.refresh('parent.child');
}, 'The route "parent.child" is currently not active');
}
expectAssertion(() => {
this.routerService.refresh('parent.child');
}, 'The route "parent.child" is currently not active');
}
);
}
}
);

0 comments on commit e91d863

Please sign in to comment.