| 1 |
import { expect, test } from '../fixtures'; |
| 2 |
|
| 3 |
test.beforeEach(async ({ requestUtils }) => { |
| 4 |
await requestUtils.login(); |
| 5 |
}); |
| 6 |
|
| 7 |
test('Assist dashboard makes a single router-data POST and no data GETs on load', async ({ |
| 8 |
admin, |
| 9 |
page, |
| 10 |
}) => { |
| 11 |
const requests: { url: string; method: string }[] = []; |
| 12 |
page.on('request', (req) => { |
| 13 |
const url = req.url(); |
| 14 |
if (url.includes('/extendify/v1/assist')) { |
| 15 |
requests.push({ url, method: req.method() }); |
| 16 |
} |
| 17 |
}); |
| 18 |
|
| 19 |
await admin.visitAdminPage('admin.php', 'page=extendify-assist'); |
| 20 |
await expect(page.getByTestId('assist-landing')).toBeVisible({ |
| 21 |
timeout: 15_000, |
| 22 |
}); |
| 23 |
await page.waitForLoadState('networkidle'); |
| 24 |
|
| 25 |
const matches = (path: string, method: string) => |
| 26 |
requests.filter((r) => r.url.includes(path) && r.method === method); |
| 27 |
|
| 28 |
expect(matches('assist/task-data', 'GET')).toHaveLength(0); |
| 29 |
expect(matches('assist/router-data', 'GET')).toHaveLength(0); |
| 30 |
expect(matches('assist/global-data', 'GET')).toHaveLength(0); |
| 31 |
expect(matches('assist/recommendation-data', 'GET')).toHaveLength(0); |
| 32 |
expect(matches('assist/dependency-completed', 'GET')).toHaveLength(0); |
| 33 |
|
| 34 |
expect(matches('assist/global-data', 'POST')).toHaveLength(0); |
| 35 |
expect(matches('assist/delete-domains-recommendations', 'POST')).toHaveLength( |
| 36 |
0, |
| 37 |
); |
| 38 |
expect(matches('assist/recommendation-data', 'POST')).toHaveLength(0); |
| 39 |
|
| 40 |
expect(matches('assist/router-data', 'POST')).toHaveLength(1); |
| 41 |
}); |
| 42 |
|