website 1.12.1: the With map layouts show the map
- Accounts' profile never has the address's geo, so Service times' and Contact's map layouts never drew a map. church/geocode.ts looks the address up on OpenStreetMap's Nominatim (the street, else the suburb and city) for the public site and the preview, kept in AppSetting church_geocode per address; one not found is retried after a day. - Tests: backend (157, one new, with a stand-in Nominatim). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,6 +128,29 @@ describe('the public site\'s content', () => {
|
||||
});
|
||||
}
|
||||
|
||||
it("finds the church's address on the map once when Accounts has no geo (the With map layouts)", async () => {
|
||||
const h = await harness({ linked: false });
|
||||
const base = demoProfile('http://x.test');
|
||||
const address = { ...base.contact.address!, geo: null };
|
||||
await h.ctx.settings.set('church_profile_local', JSON.stringify({ ...base, contact: { ...base.contact, address } }));
|
||||
const asked: string[] = [];
|
||||
let answer: unknown[] = [{ lat: '-25.75', lon: '28.19' }];
|
||||
h.ctx.fetch = async (url) => { asked.push(url); return new Response(JSON.stringify(answer), { headers: { 'content-type': 'application/json' } }); };
|
||||
assert.deepEqual((await siteContent(h.ctx)).church?.contact.address?.geo, { lat: -25.75, lng: 28.19 });
|
||||
assert.deepEqual((await siteContent(h.ctx)).church?.contact.address?.geo, { lat: -25.75, lng: 28.19 });
|
||||
assert.equal(asked.length, 1, 'kept, not asked again');
|
||||
assert.match(asked[0]!, /^https:\/\/nominatim\.openstreetmap\.org\/search\?.*countrycodes=za.*12%20Acacia%20Avenue/);
|
||||
// A new address that isn't found: the street, then the suburb and city; no geo, no map.
|
||||
answer = [];
|
||||
await h.ctx.settings.set('church_profile_local', JSON.stringify({ ...base, contact: { ...base.contact, address: { ...address, line1: '1 Nowhere Road' } } }));
|
||||
assert.equal((await siteContent(h.ctx)).church?.contact.address?.geo, null);
|
||||
assert.equal(asked.length, 3);
|
||||
// A profile that has its geo already is left alone.
|
||||
await h.ctx.settings.set('church_profile_local', JSON.stringify(base));
|
||||
assert.deepEqual((await siteContent(h.ctx)).church?.contact.address?.geo, base.contact.address!.geo);
|
||||
assert.equal(asked.length, 3);
|
||||
});
|
||||
|
||||
for (const profile of agent.WEBSITE_DEMO_PROFILES) {
|
||||
it(`1.3.0: loads the ${profile} demo, keeping the church's own profile and naming it`, async () => {
|
||||
const h = await harness({ linked: false });
|
||||
|
||||
Reference in New Issue
Block a user