同步移动端源码并修复小程序嵌入标题
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-28 18:37:40 +08:00
parent 06ad609e1f
commit 540bb8627f
62 changed files with 4196 additions and 1410 deletions

View File

@@ -66,7 +66,7 @@ test('hall goes directly to paged guide objects without outline requests', async
expect(requests.filter((url) => url.includes('/stops/page')).map((url) => new URL(url).searchParams.get('pageNo'))).toEqual(['1', '2'])
})
test('embedded direct hall list delegates browser return to the host mini program', async ({ page }) => {
test('embedded hall list exposes an H5 return control that keeps host markers', async ({ page }) => {
await page.route('**/app-api/gis/guide/catalog/**', async (route) => {
const url = route.request().url()
if (url.includes('/catalog/halls?')) {
@@ -76,38 +76,31 @@ test('embedded direct hall list delegates browser return to the host mini progra
await route.fulfill({ json: { code: 0, data: {} } })
})
await page.addInitScript(() => {
document.documentElement.dataset.wechatNavigateBackCount = '0'
;(window as Window & { wx?: unknown }).wx = {
miniProgram: {
navigateBack: () => {
const count = Number(document.documentElement.dataset.wechatNavigateBackCount || '0')
document.documentElement.dataset.wechatNavigateBackCount = String(count + 1)
}
}
}
})
await page.goto('/#/pages/explain/list?embedded=wechat-mini-program&weapp=1')
await expect(page.locator('.header-back')).toHaveCount(0)
const back = page.locator('.header-back')
await expect(back).toHaveCount(1)
await expect(back).toBeVisible()
await expect(page.locator('.hall-overview-card')).toHaveCount(1)
for (const width of [375, 390, 430]) {
await page.setViewportSize({ width, height: 844 })
const layout = await page.locator('.explain-hall-select').evaluate((container) => {
const header = container.querySelector<HTMLElement>('.explain-page-header')
const card = container.querySelector<HTMLElement>('.hall-overview-card')
if (!card) throw new Error('missing hall card')
if (!header || !card) throw new Error('missing header or hall card')
const headerRect = header.getBoundingClientRect()
const cardRect = card.getBoundingClientRect()
return {
clientWidth: container.clientWidth,
scrollWidth: container.scrollWidth,
headerBottom: headerRect.bottom,
cardTop: cardRect.top
}
})
expect(layout.scrollWidth).toBeLessThanOrEqual(layout.clientWidth)
expect(layout.cardTop).toBeGreaterThanOrEqual(0)
expect(layout.cardTop).toBeGreaterThanOrEqual(layout.headerBottom)
}
await page.evaluate(() => window.history.back())
await expect.poll(() => page.locator('html').getAttribute('data-wechat-navigate-back-count')).toBe('1')
await back.click()
await expect(page).toHaveURL(/#\/\?tab=guide&embedded=wechat-mini-program&weapp=1$/)
})
test('ordinary H5 hall list return reaches the guide home', async ({ page }) => {