From ac39bb92171c699dee9cf7400333f182cc74a760 Mon Sep 17 00:00:00 2001 From: Liam Potter Date: Sun, 12 Apr 2026 13:44:44 +0100 Subject: [PATCH 1/3] enables loading and error substates --- src/strict-resolver.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/strict-resolver.ts b/src/strict-resolver.ts index 4e3ff87..43adfa4 100644 --- a/src/strict-resolver.ts +++ b/src/strict-resolver.ts @@ -4,6 +4,7 @@ export class StrictResolver implements Resolver { #modules = new Map(); #plurals = new Map(); original: any; + moduleBasedResolver = true; constructor( modules: Record, @@ -71,9 +72,13 @@ export class StrictResolver implements Resolver { (type === 'template' && name.indexOf('components/') === 0) ) { return name.replace(/_/g, '-'); - } else { + } else if ( + name.indexOf('_loading') === -1 && + name.indexOf('_error') === -1 + ) { return dasherize(name.replace(/\./g, '/')); } + return name.replace(/\./g, '/'); } #resolveSelf(type: string, name: string): Result { From 6732432ffeeebbb04316bf242e4b026f7deca142 Mon Sep 17 00:00:00 2001 From: Liam Potter Date: Sun, 12 Apr 2026 17:41:29 +0100 Subject: [PATCH 2/3] add tests --- tests/registry-test.ts | 28 ++++++++++++++++++++++++++++ tests/test-helper.ts | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/tests/registry-test.ts b/tests/registry-test.ts index eb755c1..0bc5b64 100644 --- a/tests/registry-test.ts +++ b/tests/registry-test.ts @@ -50,4 +50,32 @@ module('Registry', function (hooks) { assert.strictEqual(value.two, 2); }); + + test('has an application_loading substate template', function (assert) { + // @ts-expect-error private API + const instance = [...this.owner.application._applicationInstances][0]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + instance.setupRouter(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + const routerHasRoute = instance.router.hasRoute('application_loading'); + const template = this.owner.factoryFor('template:application_loading'); + const route = this.owner.factoryFor('route:application_loading'); + + assert.ok(routerHasRoute, 'router has route'); + assert.ok(template || route, 'has template or route'); + }); + + test('has an application_error substate template', function (assert) { + // @ts-expect-error private API + const instance = [...this.owner.application._applicationInstances][0]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + instance.setupRouter(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + const routerHasRoute = instance.router.hasRoute('application_error'); + const template = this.owner.factoryFor('template:application_error'); + const route = this.owner.factoryFor('route:application_error'); + + assert.ok(routerHasRoute, 'router has route'); + assert.ok(template || route, 'has template or route'); + }); }); diff --git a/tests/test-helper.ts b/tests/test-helper.ts index c2ea925..8fc108e 100644 --- a/tests/test-helper.ts +++ b/tests/test-helper.ts @@ -1,6 +1,7 @@ import EmberApp from '#src/index.ts'; import Service from '@ember/service'; import EmberRouter from '@ember/routing/router'; +import Component from '@glimmer/component'; import * as QUnit from 'qunit'; import { setApplication } from '@ember/test-helpers'; import { setup } from 'qunit-dom'; @@ -14,12 +15,18 @@ class Router extends EmberRouter { location = 'none'; rootURL = '/'; } +// eslint-disable-next-line ember/no-empty-glimmer-component-classes +class ApplicationLoadingComponent extends Component {} +// eslint-disable-next-line ember/no-empty-glimmer-component-classes +class ApplicationErrorComponent extends Component {} class TestApp extends EmberApp { modules = { './router': { default: Router }, './services/manual': { default: Manual }, './services/manual-shorthand': Manual, + './templates/application_loading': ApplicationLoadingComponent, + './templates/application_error': ApplicationErrorComponent, ...import.meta.glob('./services/*', { eager: true }), }; } From c53a473655b8ecdfee2e66c8fdf62428bc0b9884 Mon Sep 17 00:00:00 2001 From: Liam Potter Date: Mon, 13 Apr 2026 10:18:42 +0100 Subject: [PATCH 3/3] dasherizing is fine --- src/strict-resolver.ts | 8 ++------ tests/test-helper.ts | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/strict-resolver.ts b/src/strict-resolver.ts index 43adfa4..e4831ae 100644 --- a/src/strict-resolver.ts +++ b/src/strict-resolver.ts @@ -72,13 +72,9 @@ export class StrictResolver implements Resolver { (type === 'template' && name.indexOf('components/') === 0) ) { return name.replace(/_/g, '-'); - } else if ( - name.indexOf('_loading') === -1 && - name.indexOf('_error') === -1 - ) { - return dasherize(name.replace(/\./g, '/')); } - return name.replace(/\./g, '/'); + + return dasherize(name.replace(/\./g, '/')); } #resolveSelf(type: string, name: string): Result { diff --git a/tests/test-helper.ts b/tests/test-helper.ts index 8fc108e..779cc17 100644 --- a/tests/test-helper.ts +++ b/tests/test-helper.ts @@ -25,8 +25,8 @@ class TestApp extends EmberApp { './router': { default: Router }, './services/manual': { default: Manual }, './services/manual-shorthand': Manual, - './templates/application_loading': ApplicationLoadingComponent, - './templates/application_error': ApplicationErrorComponent, + './templates/application-loading': ApplicationLoadingComponent, + './templates/application-error': ApplicationErrorComponent, ...import.meta.glob('./services/*', { eager: true }), }; }