| 1 |
// e2e:disabled |
| 2 |
import { expect, test } from '../fixtures'; |
| 3 |
|
| 4 |
type OptionResponse = { success: boolean; data: string | null }; |
| 5 |
|
| 6 |
test.beforeEach(async ({ requestUtils, admin }) => { |
| 7 |
await requestUtils.login(); |
| 8 |
// wp-playground's default admin user matches `admin_email`, so the first |
| 9 |
// /wp-admin/ visit with no `extendify_launch_loaded` option seeded fires |
| 10 |
// AdminPageRouter::redirectOnce — it writes `extendify_attempted_redirect` |
| 11 |
// synchronously in PHP and redirects to ?page=extendify-launch, where the |
| 12 |
// React mount writes `extendify_launch_loaded` via POST /launch/options. |
| 13 |
await admin.visitAdminPage('index.php', ''); |
| 14 |
}); |
| 15 |
|
| 16 |
test('Tests the Launch redirect and db value', async ({ |
| 17 |
page, |
| 18 |
requestUtils, |
| 19 |
}) => { |
| 20 |
await expect(page).toHaveURL(/admin\.php\?page=extendify-launch/); |
| 21 |
|
| 22 |
await expect |
| 23 |
.poll(async () => { |
| 24 |
const res = await requestUtils.rest<OptionResponse>({ |
| 25 |
path: '/extendify/v1/launch/options?option=extendify_attempted_redirect', |
| 26 |
}); |
| 27 |
return res.data ?? ''; |
| 28 |
}) |
| 29 |
.toMatch(/\d{4}-\d{2}-\d{2}/); |
| 30 |
|
| 31 |
await expect |
| 32 |
.poll(async () => { |
| 33 |
const res = await requestUtils.rest<OptionResponse>({ |
| 34 |
path: '/extendify/v1/launch/options?option=extendify_launch_loaded', |
| 35 |
}); |
| 36 |
return res.data ?? ''; |
| 37 |
}) |
| 38 |
.toMatch(/\d{4}-\d{2}-\d{2}/); |
| 39 |
}); |
| 40 |
|