diff --git a/e2e-emergency-notify.cjs b/e2e-emergency-notify.cjs
new file mode 100644
index 0000000..dd7d87b
--- /dev/null
+++ b/e2e-emergency-notify.cjs
@@ -0,0 +1,88 @@
+// Verifies that firing a member's death trigger automatically invokes the
+// notify-emergency-contacts Edge Function (mosque/khairat/police/ambulance
+// contacts) alongside the existing heir notification — the one place in
+// this app where "auto-send on trigger" is actually the right behavior.
+const { chromium } = require('playwright');
+const BASE = 'https://moslem04.falahos.my/';
+const OWNER = 'nurfalah.e2etest.owner@gmail.com';
+const AGENT = 'nurfalah.e2etest.agent@gmail.com';
+const PASSWORD = 'TestPassword123!';
+const results = [];
+function record(name, pass, detail = '') { results.push({ name, pass, detail }); console.log(`${pass ? 'PASS' : 'FAIL'} ${name}${detail ? ' — ' + detail : ''}`); }
+
+async function signIn(page, email) {
+ await page.goto(BASE, { waitUntil: 'networkidle' });
+ await page.locator('.field:has-text("Email") input').fill(email);
+ await page.locator('.field:has-text("Password") input').fill(PASSWORD);
+ await page.locator('button.btn-primary', { hasText: 'Sign in' }).click();
+ await page.waitForTimeout(1500);
+}
+
+async function main() {
+ const familyName = `EmergencyNotify ${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
+ const browser = await chromium.launch();
+
+ const ownerCtx = await browser.newContext({ viewport: { width: 390, height: 844 } });
+ const ownerPage = await ownerCtx.newPage();
+ await signIn(ownerPage, OWNER);
+ await ownerPage.locator('.field:has-text("Family name") input').fill(familyName);
+ await ownerPage.locator('button.btn-primary', { hasText: 'Create family' }).click();
+ await ownerPage.waitForTimeout(1200);
+
+ await ownerPage.locator('nav button[aria-label="Assets"]').click();
+ await ownerPage.waitForTimeout(500);
+ await ownerPage.locator('.contacts-section .field:has-text("Name") input').fill('Emergency Test Mosque');
+ await ownerPage.locator('.contacts-section .field:has-text("Category") select').selectOption('mosque');
+ await ownerPage.locator('.contacts-section .field:has-text("Email") input').fill('mosque-emergency-test@example.com');
+ await ownerPage.locator('.contacts-section button.btn-secondary', { hasText: 'Add trusted contact' }).click();
+ await ownerPage.waitForTimeout(1000);
+ record('Setup: mosque contact with email added', await ownerPage.locator('.contact-row', { hasText: 'Emergency Test Mosque' }).isVisible().catch(() => false));
+
+ await ownerPage.locator('nav button[aria-label="Family"]').click();
+ await ownerPage.waitForTimeout(500);
+ await ownerPage.locator('.field:has-text("Invite by email") input').fill(AGENT);
+ await ownerPage.locator('.field:has-text("Role") select').selectOption('agent');
+ await ownerPage.locator('button.btn-primary', { hasText: 'Send invite' }).click();
+ await ownerPage.waitForTimeout(1000);
+
+ const agentCtx = await browser.newContext({ viewport: { width: 390, height: 844 } });
+ const agentPage = await agentCtx.newPage();
+ let notifyStatus = null;
+ agentPage.on('response', r => { if (r.url().includes('functions/v1/notify-emergency-contacts')) notifyStatus = r.status(); });
+ await signIn(agentPage, AGENT);
+ const pending = agentPage.locator('.invite-row', { hasText: familyName });
+ if (await pending.count()) { await pending.locator('button', { hasText: 'Accept' }).click(); await agentPage.waitForTimeout(1000); }
+ const familyRow = agentPage.locator('.family-row', { hasText: familyName });
+ if (await familyRow.count()) { await familyRow.click(); await agentPage.waitForTimeout(1000); }
+
+ await agentPage.locator('nav button[aria-label="Mutawalli"]').click();
+ await agentPage.waitForTimeout(1000);
+ const memberChip = agentPage.locator('.member-chip', { hasText: 'nurfalah.e2etest.owner' });
+ record('Mutawalli: owner appears as a member to fire a trigger for', await memberChip.count() === 1);
+ if (await memberChip.count()) await memberChip.click();
+ await agentPage.waitForTimeout(500);
+
+ const attestorInputs = agentPage.locator('.attestor-row input');
+ await attestorInputs.nth(0).fill('Witness A');
+ await agentPage.locator('.attestor-row .confirm-btn').nth(0).click();
+ await attestorInputs.nth(1).fill('Witness B');
+ await agentPage.locator('.attestor-row .confirm-btn').nth(1).click();
+ await agentPage.locator('.field:has-text("Date of death") input').fill('2026-01-01');
+ await agentPage.locator('.field:has-text("Death certificate") input').fill(`CERT-${Date.now()}`);
+ await agentPage.waitForTimeout(500);
+
+ await agentPage.locator('button.btn-danger-solid').click();
+ await agentPage.waitForTimeout(4000);
+
+ record('Trigger: fires successfully (triggered banner shown)', await agentPage.locator('.triggered-banner').isVisible().catch(() => false));
+ record('Emergency notify: auto-invoked on fire, returns 200', notifyStatus === 200, `status: ${notifyStatus}`);
+ record('Emergency notify: status message shown to the mutawalli', await agentPage.locator('.emergency-notify-status', { hasText: 'Notified' }).isVisible().catch(() => false));
+
+ await browser.close();
+ const passCount = results.filter(r => r.pass).length;
+ const failCount = results.length - passCount;
+ console.log(`\n${passCount} passed, ${failCount} failed, ${results.length} total`);
+ if (failCount > 0) results.filter(r => !r.pass).forEach(r => console.log(` - ${r.name}: ${r.detail}`));
+ process.exit(failCount > 0 ? 1 : 0);
+}
+main().catch(e => { console.error('SCRIPT ERROR:', e); process.exit(2); });
diff --git a/e2e-khairat-lifestyle.cjs b/e2e-khairat-lifestyle.cjs
new file mode 100644
index 0000000..4055c85
--- /dev/null
+++ b/e2e-khairat-lifestyle.cjs
@@ -0,0 +1,148 @@
+// Verifies the Khairat/emergency-contacts round and the lifestyle-companion
+// tabs (Qibla, Prayer Times, Locate, Quran, Neighbourhood) against the live
+// backend. Geolocation-dependent tabs use Playwright's mocked geolocation
+// (Kuala Lumpur coordinates) rather than the real device.
+const { chromium } = require('playwright');
+const { signInFreshFamily } = require('./e2e-auth-helper.cjs');
+const BASE = 'https://moslem04.falahos.my/';
+const results = [];
+const consoleErrors = [];
+function record(name, pass, detail = '') { results.push({ name, pass, detail }); console.log(`${pass ? 'PASS' : 'FAIL'} ${name}${detail ? ' — ' + detail : ''}`); }
+
+async function main() {
+ const browser = await chromium.launch();
+ const context = await browser.newContext({
+ viewport: { width: 390, height: 844 },
+ geolocation: { latitude: 3.1390, longitude: 101.6869 }, // Kuala Lumpur
+ permissions: ['geolocation']
+ });
+ const page = await context.newPage();
+ page.on('console', m => { if (m.type() === 'error') consoleErrors.push(m.text()); });
+ page.on('pageerror', e => consoleErrors.push(e.message));
+
+ await signInFreshFamily(page, BASE, 'e2e-khairat');
+
+ // ── Khairat ──
+ await page.locator('nav button[aria-label="Khairat"]').click();
+ await page.waitForTimeout(600);
+ await page.locator('.field:has-text("Scheme name") input').fill('Kariah Khairat Kematian Masjid Al-Falah');
+ await page.locator('.field:has-text("Organization") input').fill('Masjid Al-Falah');
+ await page.locator('button.btn-primary', { hasText: 'Add khairat membership' }).click();
+ await page.waitForTimeout(1000);
+ const khairatRowVisible = await page.locator('.khairat-row', { hasText: 'Kariah Khairat Kematian' }).isVisible().catch(() => false);
+ record('Khairat: membership added and listed', khairatRowVisible);
+
+ await page.locator('.fund-card .field:has-text("Target amount") input').fill('5000');
+ await page.locator('.fund-card .field:has-text("Current balance") input').fill('1250');
+ await page.waitForTimeout(1000);
+ const fundProgressVisible = await page.locator('.fund-progress-label', { hasText: '25%' }).isVisible().catch(() => false);
+ record('Khairat: emergency fund progress bar computes correctly (1250/5000 = 25%)', fundProgressVisible);
+
+ // ── Trusted contacts with category + email ──
+ await page.locator('nav button[aria-label="Assets"]').click();
+ await page.waitForTimeout(500);
+ await page.locator('.contacts-section .field:has-text("Name") input').fill('Masjid Al-Falah Office');
+ await page.locator('.contacts-section .field:has-text("Category") select').selectOption('mosque');
+ await page.locator('.contacts-section .field:has-text("Email") input').fill('office@example-mosque.test');
+ await page.locator('.contacts-section button.btn-secondary', { hasText: 'Add trusted contact' }).click();
+ await page.waitForTimeout(1000);
+ const contactCategoryVisible = await page.locator('.contact-row', { hasText: 'Masjid Al-Falah Office' }).locator('.contact-category', { hasText: 'mosque' }).isVisible().catch(() => false);
+ record('Trusted Contacts: category badge shows on the new contact', contactCategoryVisible);
+
+ // ── Qibla ──
+ await page.locator('nav button[aria-label="Qibla"]').click();
+ await page.waitForTimeout(500);
+ await page.locator('button.btn-primary', { hasText: 'Find Qibla direction' }).click();
+ await page.waitForTimeout(2000);
+ const bearingVisible = await page.locator('.bearing-readout strong').isVisible().catch(() => false);
+ const bearingText = bearingVisible ? await page.locator('.bearing-readout strong').textContent() : '';
+ record('Qibla: computes a bearing from Kuala Lumpur (expect ~292° toward Makkah)', bearingVisible && /29[0-5]°/.test(bearingText), bearingText);
+ const distanceVisible = await page.locator('.distance-note', { hasText: 'km to Makkah' }).isVisible().catch(() => false);
+ record('Qibla: shows distance to Makkah', distanceVisible);
+
+ // ── Prayer Times ──
+ await page.locator('nav button[aria-label="Prayer Times"]').click();
+ await page.waitForTimeout(500);
+ await page.locator('button.btn-primary', { hasText: "Calculate today's prayer times" }).click();
+ await page.waitForTimeout(2000);
+ const fajrVisible = await page.locator('.time-row', { hasText: 'Fajr' }).locator('.time-value').isVisible().catch(() => false);
+ const timesInOrder = await page.locator('.times-list').innerText();
+ record('Prayer Times: computes all 6 times for Kuala Lumpur', fajrVisible && /Fajr[\s\S]*Sunrise[\s\S]*Dhuhr[\s\S]*Asr[\s\S]*Maghrib[\s\S]*Isha/.test(timesInOrder), timesInOrder.replace(/\n/g, ' '));
+
+ // ── Locate (mosque search via live OpenStreetMap Overpass) ──
+ await page.locator('nav button[aria-label="Locate"]').click();
+ await page.waitForTimeout(500);
+ await page.locator('button.btn-primary', { hasText: 'Search nearby' }).click();
+ await page.waitForTimeout(8000); // live Overpass API call
+ const locateResultOrEmpty = await page.locator('.results-list, .empty').isVisible().catch(() => false);
+ record('Locate: mosque search completes (real results or honest empty state)', locateResultOrEmpty);
+
+ // ── Quran ──
+ await page.locator('nav button[aria-label="Quran"]').click();
+ await page.waitForTimeout(2000);
+ const surahListVisible = await page.locator('.surah-row', { hasText: 'Al-Faatiha' }).isVisible().catch(() => false);
+ record('Quran: Surah list loads from the public API (Al-Faatiha present)', surahListVisible);
+
+ if (surahListVisible) {
+ await page.locator('.surah-row', { hasText: 'Al-Faatiha' }).click();
+ await page.waitForTimeout(2000);
+ const ayahVisible = await page.locator('.ayah-row').first().isVisible().catch(() => false);
+ const arabicVisible = await page.locator('.ayah-arabic').first().isVisible().catch(() => false);
+ record('Quran: opening a Surah loads Arabic text and translation', ayahVisible && arabicVisible);
+ }
+
+ // ── Neighbourhood board ──
+ // Neighbourhoods are scoped to the user account, not the family — the
+ // shared e2e owner account may already belong to one from a prior run,
+ // in which case the create/join form is behind the "add another" toggle.
+ await page.locator('nav button[aria-label="Neighbourhood"]').click();
+ await page.waitForTimeout(600);
+ const addToggleVisible = await page.locator('.add-toggle').isVisible().catch(() => false);
+ if (addToggleVisible) await page.locator('.add-toggle').click();
+ await page.waitForTimeout(300);
+ const nName = `Kariah Test ${Date.now()}`;
+ await page.locator('.form-card .field:has-text("Name") input').fill(nName);
+ await page.locator('button.btn-primary', { hasText: 'Create & get a join code' }).click();
+ await page.waitForTimeout(1000);
+ const joinCodeVisible = await page.locator('.join-code', { hasText: 'Join code:' }).isVisible().catch(() => false);
+ record('Neighbourhood: creating one generates a join code', joinCodeVisible);
+
+ await page.locator('.form-card .field:has-text("Title") input').fill('Friday khutbah reminder');
+ await page.locator('button.btn-primary', { hasText: 'Post announcement' }).click();
+ await page.waitForTimeout(1000);
+ const postVisible = await page.locator('.post-row', { hasText: 'Friday khutbah reminder' }).isVisible().catch(() => false);
+ record('Neighbourhood: posting an announcement shows it in the board', postVisible);
+
+ // Join-by-code isolation: a second account joining via the real code should see the same post
+ const joinCodeText = await page.locator('.join-code').textContent();
+ const code = joinCodeText.replace('Join code:', '').trim();
+
+ // signInFreshFamily always signs in as the same fixed e2e owner account
+ // (just a new family) — since neighbourhoods are user-scoped, this "second
+ // account" already belongs to the neighbourhood created above, so the
+ // join form is behind the same toggle as before.
+ const secondContext = await browser.newContext({ viewport: { width: 390, height: 844 } });
+ const secondPage = await secondContext.newPage();
+ await signInFreshFamily(secondPage, BASE, 'e2e-khairat-neighbour2');
+ await secondPage.locator('nav button[aria-label="Neighbourhood"]').click();
+ await secondPage.waitForTimeout(600);
+ const secondAddToggleVisible = await secondPage.locator('.add-toggle').isVisible().catch(() => false);
+ if (secondAddToggleVisible) await secondPage.locator('.add-toggle').click();
+ await secondPage.waitForTimeout(300);
+ await secondPage.locator('.form-card .field:has-text("Join code") input').fill(code);
+ await secondPage.locator('button.btn-secondary', { hasText: 'Join' }).click();
+ await secondPage.waitForTimeout(1000);
+ const secondSeesPost = await secondPage.locator('.post-row', { hasText: 'Friday khutbah reminder' }).isVisible().catch(() => false);
+ record('Neighbourhood: a second account joining by code sees the same posts', secondSeesPost);
+ await secondContext.close();
+
+ record('No uncaught JS console errors during full session', consoleErrors.length === 0, consoleErrors.slice(0, 5).join(' || '));
+
+ await browser.close();
+ const passCount = results.filter(r => r.pass).length;
+ const failCount = results.length - passCount;
+ console.log(`\n${passCount} passed, ${failCount} failed, ${results.length} total`);
+ if (failCount > 0) results.filter(r => !r.pass).forEach(r => console.log(` - ${r.name}: ${r.detail}`));
+ process.exit(failCount > 0 ? 1 : 0);
+}
+main().catch(e => { console.error('SCRIPT ERROR:', e); process.exit(2); });
diff --git a/e2e-per-member.cjs b/e2e-per-member.cjs
index fa1fc74..e87c250 100644
--- a/e2e-per-member.cjs
+++ b/e2e-per-member.cjs
@@ -127,8 +127,8 @@ async function main() {
const notifyBtn = agentPage.locator('button.btn-secondary', { hasText: 'Notify heirs' });
if (await notifyBtn.isVisible().catch(() => false)) {
await notifyBtn.click();
- await agentPage.locator('.notify-status', { hasText: /Sent|Failed/ }).waitFor({ state: 'visible', timeout: 15000 }).catch(() => {});
- const statusText = await agentPage.locator('.notify-status').textContent().catch(() => '');
+ await agentPage.locator('.heir-notify-status', { hasText: /Sent|Failed/ }).waitFor({ state: 'visible', timeout: 15000 }).catch(() => {});
+ const statusText = await agentPage.locator('.heir-notify-status').textContent().catch(() => '');
record('Mutawalli: heir notification actually sends via the real SMTP relay', statusText.includes('Sent'), statusText);
}
}
diff --git a/src/App.svelte b/src/App.svelte
index acc5062..e1f335f 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -23,6 +23,12 @@
import ZakatCalculator from './lib/ZakatCalculator.svelte';
import JurisdictionSetting from './lib/JurisdictionSetting.svelte';
import SadaqahTracker from './lib/SadaqahTracker.svelte';
+ import KhairatTracker from './lib/KhairatTracker.svelte';
+ import QiblaFinder from './lib/QiblaFinder.svelte';
+ import PrayerTimes from './lib/PrayerTimes.svelte';
+ import Locators from './lib/Locators.svelte';
+ import QuranReader from './lib/QuranReader.svelte';
+ import NeighbourhoodBoard from './lib/NeighbourhoodBoard.svelte';
let currentLang = $state('en');
lang.subscribe(v => currentLang = v);
@@ -46,8 +52,8 @@
}
});
- const tabs = ['Coverage', 'Faraid', 'Assets', 'Insurance', 'Zakat', 'Sadaqah', 'Wassiyah', 'Hibah', 'Family Waqf', 'Nominate', 'Trigger', 'Mutawalli', 'Tree', 'Claims (H2)', 'Family', 'Settings'];
- const icons = ['🎯', '📊', '📁', '🛡️', '🌙', '🤲', '📜', '🎁', '⛲', '📇', '⚡', '🕋', '🌳', '🔗', '👥', '⚙️'];
+ const tabs = ['Coverage', 'Faraid', 'Assets', 'Insurance', 'Zakat', 'Sadaqah', 'Khairat', 'Wassiyah', 'Hibah', 'Family Waqf', 'Nominate', 'Trigger', 'Mutawalli', 'Tree', 'Prayer Times', 'Qibla', 'Locate', 'Quran', 'Neighbourhood', 'Claims (H2)', 'Family', 'Settings'];
+ const icons = ['🎯', '📊', '📁', '🛡️', '🌙', '🤲', '🆘', '📜', '🎁', '⛲', '📇', '⚡', '🕋', '🌳', '🕌', '🧭', '📍', '📖', '📢', '🔗', '👥', '⚙️'];
let activeTab = $state(0);
requestedTab.subscribe(name => {
if (!name) return;
@@ -113,16 +119,22 @@
{:else if activeTab === 3}
Notified or given a read-only export on a triggering event — not an automated death-detection or legal-transfer mechanism.
+Notified automatically by email when your mutawalli fires your death trigger — mosque, khairat officer, police, ambulance/hospital, or family. Not an automated death-detection mechanism.
Your khairat scheme membership, plus a shared family emergency fund.
+ +No khairat membership logged yet — most families should have at least one.
+ {/each} +{fundProgress}% of target
+ {/if} +Real, live-searched results from OpenStreetMap — not a curated directory.
+ +Getting your location…
+ {:else if status === 'searching'} +Searching OpenStreetMap…
+ {:else if status === 'error'} +{errorMsg}
+ + {:else if status === 'ready'} + {#if results.length === 0} +Nothing found nearby in OpenStreetMap's {categoryLabel(category).toLowerCase()} data. It may not be mapped yet in your area.
+ {:else} +{notifyStatus}
{/if} + {#if notifyStatus}{notifyStatus}
{/if} + + {#if emergencyNotifyStatus}{emergencyNotifyStatus}
{/if} {:else}A community board, independent of your estate-planning family.
+ + {#if neighbourhoods.length > 1} +{p.body}
{/if} + +No announcements yet.
+ {/each} +{error}
{/if} + {/if} + +Calculated from your location — not looked up from a directory.
+ + {#if status === 'idle'} + + {:else if status === 'locating'} +Getting your location…
+ {:else if status === 'error'} +{errorMsg}
+ + {:else if status === 'ready' && times} +Great-circle bearing to the Kaaba, calculated from your device's location.
+ + {#if status === 'idle'} + + {:else if status === 'locating'} +Getting your location…
+ {:else if status === 'error'} +{errorMsg}
+ + {:else if status === 'ready'} +No live compass sensor detected — hold a compass app or physical compass and align it to {Math.round(bearing)}°.
+ {/if} +~{distanceKm?.toLocaleString()} km to Makkah
+114 Surahs — tap one to read.
+ + {#if listStatus === 'loading'} +Loading Surah list…
+ {:else if listStatus === 'error'} +Could not reach the Quran text service. Check your connection and reload this tab.
+ {:else} +Loading…
+ {:else if readerStatus === 'error'} +Could not load this Surah. Check your connection and try again.
+ {:else} +{a.arabic}
+{a.translation}
+