Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions app/routes/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ export default class MobileRoute extends Route {
@service toast;
@service router;

beforeModel(transition) {
if (transition?.to?.queryParams?.dev !== 'true') {
this.router.transitionTo('/page-not-found');
}
}

async model() {
try {
const response = await fetch(SELF_USER_PROFILE_URL, {
Expand Down
26 changes: 4 additions & 22 deletions tests/unit/routes/mobile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,16 @@ module('Unit | Route | mobile', function (hooks) {
hooks.beforeEach(function () {
this.fetchStub = sinon.stub(window, 'fetch');
this.route = this.owner.lookup('route:mobile');
sinon.stub(this.route.router, 'transitionTo');
});

hooks.afterEach(function () {
this.fetchStub.restore();
sinon.restore();
});

test('redirects to 404 page if dev flag is not present', function (assert) {
const transition = { to: { queryParams: { dev: 'false' } } };

this.route.beforeModel(transition);

assert.ok(
this.route.router.transitionTo.calledOnceWith('/page-not-found'),
'Redirected to /page-not-found when dev is not true',
);
});

test('allows access when dev flag is true', function (assert) {
const transition = { to: { queryParams: { dev: 'true' } } };

this.route.beforeModel(transition);

assert.ok(
this.route.router.transitionTo.notCalled,
'No redirection occurs when dev query param is true',
);
test('mobile route exists and is accessible', function (assert) {
assert.expect(1);
const route = this.owner.lookup('route:mobile');
assert.ok(route, 'The mobile route exists');
});

test('it fetches user profile and returns userId if API responds with 200', async function (assert) {
Expand Down