Add AMap location and weather header with warm mini program theme
ci-cd / verify (push) Successful in 1m54s
ci-cd / deploy (push) Skipped

This commit is contained in:
2026-10-04 11:03:34 +08:00
parent c2b51f96e0
commit 7fc50f9212
37 changed files with 568 additions and 122 deletions
+37
View File
@@ -97,3 +97,40 @@ test("约遛详情识别已报名并能退出", async () => {
await screen.leave();
assert.deepEqual(calls[1], { route: "/meetups/event-1/join", method: "DELETE" });
});
test("首页使用 GCJ-02 定位并展示真实城市天气", async () => {
const screen = page("home", async (route, method, body) => {
assert.equal(route, "/environment");
assert.equal(method, "GET");
assert.deepEqual(body, { latitude: 30.2, longitude: 120.1 });
return { location_name: "杭州市 · 西湖区", weather: { description: "小雨", temperature: "19" } };
}, {
getSetting: ({ success }) => success({ authSetting: { "scope.userLocation": true } }),
getLocation: ({ type, success }) => {
assert.equal(type, "gcj02");
success({ latitude: 30.2, longitude: 120.1 });
},
});
await screen.refreshEnvironment();
assert.equal(screen.data.locationName, "杭州市 · 西湖区");
assert.match(screen.data.headerSubtitle, /周. · 小雨 19°C$/);
});
test("拒绝定位不请求后端,点击后可以恢复授权", async () => {
let calls = 0;
const screen = page("home", async () => {
calls++;
return { location_name: "杭州市", weather: null };
}, {
getSetting: ({ success }) => success({ authSetting: { "scope.userLocation": false } }),
openSetting: ({ success }) => success({ authSetting: { "scope.userLocation": true } }),
getLocation: ({ success }) => success({ latitude: 30.2, longitude: 120.1 }),
});
await screen.refreshEnvironment();
assert.equal(calls, 0);
assert.equal(screen.data.locationName, "开启定位");
await screen.refreshEnvironment({ type: "locationtap" });
assert.equal(calls, 1);
assert.equal(screen.data.locationName, "杭州市");
assert.match(screen.data.headerSubtitle, /天气暂不可用$/);
});