Files
raucao c56917e122 WIP: Stack parent sheets behind the mobile bottom drawer
Derive the sheet stack from the URL instead of mutating it: the route
template keeps rendering the top sheet, and application.gjs renders the
service-driven parent (search results, lists index, app menu) behind it on
mobile, inert, so closing the top sheet reveals the parent at its
remembered size.

- bottom-sheet modifier: `background` arg — background instances settle
  immediately, inject no handle, take no gestures, never own the inset slot,
  and never write the remembered detent (restore-only).
- z-index: demote background sheets below the top sheet, including the app
  menu whose desktop z-index was inverted.
- outside tap on mobile pops to the parent without hideSidebar(), keeping
  the session and detent alive; desktop keeps today's close-all.
- tracked matchMedia-backed viewport service for the mobile breakpoint.
- lists index extracted into a component so it can render top or background.
- scope .sidebar-content lookups and test selectors to .sheet-top.

Known v1 limitation: popping hard-cuts to the parent route (no exit
animation). The full derived stack with independent detents for 3-level
chains is deferred.
2026-11-30 15:17:20 +04:00

153 lines
3.8 KiB
JavaScript

import { module, test } from 'qunit';
import { visit, currentURL, click, waitFor } from '@ember/test-helpers';
import { setupApplicationTest } from 'marco/tests/helpers';
import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';
class MockActivityService extends Service {
@tracked items = [
{
type: 'zap',
photoEventId: 'photo-1',
photo: {
url: 'https://x.com/photo.jpg',
thumbUrl: 'https://x.com/thumb.jpg',
},
placeIdentifier: 'osm:node:123',
senderPubkey: 'b'.repeat(64),
amountSats: 21,
message: 'Great photo!',
createdAt: Math.floor(Date.now() / 1000) - 3600,
senderName: 'Alice',
senderAvatar: 'https://x.com/avatar.jpg',
senderProfileLoading: false,
},
];
@tracked sourceMode = 'home';
@tracked isLoadingMore = false;
@tracked isLoading = false;
async load() {}
async setSourceMode() {}
async retryUnresolvedProfiles() {}
loadMore() {}
stop() {
this.items = [];
}
}
class MockNostrAuthService extends Service {
@tracked pubkey = 'test-pubkey';
get isConnected() {
return true;
}
}
class MockStorageService extends Service {
initialSyncDone = true;
savedPlaces = [];
findPlaceById() {
return null;
}
isPlaceSaved() {
return false;
}
loadPlacesInBounds() {
return [];
}
get placesInView() {
return [];
}
rs = {
on: () => {},
};
}
class MockOsmService extends Service {
async fetchOsmObject() {
return {
osmId: '123',
osmType: 'node',
lat: 1,
lon: 1,
osmTags: { name: 'Test Place', amenity: 'cafe' },
title: 'Test Place',
};
}
getCachedOsmObject() {
return Promise.resolve(null);
}
}
module('Acceptance | activity', function (hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(function () {
this.owner.register('service:activity', MockActivityService);
this.owner.register('service:nostrAuth', MockNostrAuthService);
this.owner.register('service:storage', MockStorageService);
this.owner.register('service:osm', MockOsmService);
});
test('visiting /activity renders the sidebar with activity items', async function (assert) {
await visit('/activity');
assert.strictEqual(currentURL(), '/activity');
assert.dom('.sheet-top').exists('Sidebar is rendered');
assert
.dom('.sheet-top .sidebar-header-text-centered')
.includesText('Activity');
});
test('activity items are rendered as zap rows', async function (assert) {
await visit('/activity');
await waitFor('.activity-item');
assert.dom('.activity-item').exists({ count: 1 });
assert.dom('.sender-name').hasText('Alice');
assert.dom('.action').includesText('zapped your photo');
assert.dom('.amount').includesText('21 ⚡');
assert.dom('.message').includesText('Great photo!');
});
test('closing the sidebar returns to index', async function (assert) {
await visit('/activity');
assert.strictEqual(currentURL(), '/activity');
await click('.sheet-top .sidebar-header .close-btn');
assert.strictEqual(currentURL(), '/', 'Returns to index');
});
test('clicking back button returns to menu', async function (assert) {
await visit('/activity');
await click('.sheet-top .sidebar-header .back-btn');
assert.strictEqual(currentURL(), '/menu', 'Returns to menu');
});
test('clicking a zap item navigates to the place', async function (assert) {
const mapUi = this.owner.lookup('service:map-ui');
await visit('/activity');
await waitFor('.activity-item');
await click('.activity-item');
assert.ok(
currentURL().includes('/place/osm:node:123'),
'Transitions to place details'
);
assert.deepEqual(
mapUi.returnToRoute,
{ name: 'activity' },
'returnToRoute is set to activity'
);
});
});