fix: stabilize usage loading and session search
This commit is contained in:
@@ -411,6 +411,29 @@ async function main() {
|
||||
await waitFor(() => evaluate(cdp, "!document.querySelector('#usage-dashboard-panel').hidden"), 10000);
|
||||
await waitFor(() => evaluate(cdp, "document.querySelector('#usage-dashboard-panel').dataset.state !== 'loading'"), 30000);
|
||||
await sleep(320);
|
||||
const loadingLayout = await evaluate(cdp, `(() => {
|
||||
const metricGrid = document.querySelector('.usage-dashboard__metric-grid');
|
||||
const beforeTop = metricGrid.getBoundingClientRect().top;
|
||||
document.querySelector('#usage-dashboard-refresh').click();
|
||||
const afterTop = metricGrid.getBoundingClientRect().top;
|
||||
return {
|
||||
state: document.querySelector('#usage-dashboard-panel').dataset.state,
|
||||
label: document.querySelector('#usage-dashboard-refresh-label').textContent,
|
||||
busy: document.querySelector('#usage-dashboard-refresh').getAttribute('aria-busy'),
|
||||
contentShift: Math.round(Math.abs(afterTop - beforeTop) * 10) / 10,
|
||||
standaloneLoading: !!document.querySelector('#usage-dashboard-loading'),
|
||||
};
|
||||
})()`);
|
||||
if (loadingLayout.state !== 'loading'
|
||||
|| loadingLayout.label !== '整理中'
|
||||
|| loadingLayout.busy !== 'true'
|
||||
|| loadingLayout.contentShift > 0.5
|
||||
|| loadingLayout.standaloneLoading) {
|
||||
throw new Error(`加载状态仍引发布局变化:${JSON.stringify(loadingLayout)}`);
|
||||
}
|
||||
await waitFor(() => evaluate(cdp, `document.querySelector('#usage-dashboard-panel').dataset.state !== 'loading'
|
||||
&& document.querySelector('#usage-dashboard-refresh-label').textContent === '刷新'`), 30000);
|
||||
await sleep(300);
|
||||
await evaluate(cdp, `(() => {
|
||||
const from = document.querySelector('#usage-dashboard-from');
|
||||
const to = document.querySelector('#usage-dashboard-to');
|
||||
|
||||
Reference in New Issue
Block a user