|
| 1 | +import { expect, test, type Page } from '@playwright/test' |
| 2 | + |
| 3 | +const DOCKER = '/docs/local/docker' |
| 4 | +const NPM = '/docs/local/npm' |
| 5 | + |
| 6 | +function body(page: Page) { |
| 7 | + return page.locator('#nd-page') |
| 8 | +} |
| 9 | + |
| 10 | +function requirements(page: Page) { |
| 11 | + return body(page).locator('h3#system-requirements ~ p') |
| 12 | +} |
| 13 | + |
| 14 | +function desktop(page: Page) { |
| 15 | + return requirements(page).filter({ hasText: 'If you use Docker Desktop' }) |
| 16 | +} |
| 17 | + |
| 18 | +test.describe('Local installation system requirements', () => { |
| 19 | + test('@scenario:docker-guide-scopes-host-requirements-to-docker-desktop a Docker reader sees the container minimum, with host minimums only for Docker Desktop', async ({ |
| 20 | + page, |
| 21 | + }) => { |
| 22 | + await page.goto(DOCKER) |
| 23 | + |
| 24 | + await expect( |
| 25 | + body(page).getByRole('heading', { level: 3, name: 'System Requirements' }), |
| 26 | + ).toBeVisible() |
| 27 | + |
| 28 | + const containers = requirements(page).filter({ hasText: '1 GiB of RAM and 1 vCPU' }) |
| 29 | + await expect(containers).toHaveCount(1) |
| 30 | + await expect(containers.getByRole('link', { name: 'minimum', exact: true })).toHaveAttribute( |
| 31 | + 'href', |
| 32 | + '/docs/remote#minimum-requirements', |
| 33 | + ) |
| 34 | + |
| 35 | + // The Docker Desktop host minimums are conditional, so a native Docker |
| 36 | + // Engine install on Linux is not ruled out by them. |
| 37 | + await expect(desktop(page)).toHaveCount(1) |
| 38 | + await expect(desktop(page)).toContainText('at least 4 GB of system RAM') |
| 39 | + await expect(desktop(page)).toContainText('Docker Engine installed directly on Linux') |
| 40 | + for (const [name, href] of [ |
| 41 | + ['macOS', 'https://docs.docker.com/desktop/setup/install/mac-install/'], |
| 42 | + ['Linux', 'https://docs.docker.com/desktop/setup/install/linux/'], |
| 43 | + ['Windows', 'https://docs.docker.com/desktop/setup/install/windows-install/'], |
| 44 | + ]) { |
| 45 | + await expect(desktop(page).getByRole('link', { name, exact: true })).toHaveAttribute( |
| 46 | + 'href', |
| 47 | + href, |
| 48 | + ) |
| 49 | + } |
| 50 | + |
| 51 | + await page.goto('/docs/remote') |
| 52 | + await expect(page.locator('#minimum-requirements')).toBeVisible() |
| 53 | + }) |
| 54 | + |
| 55 | + test('@scenario:docker-guide-memory-setting-matches-desktop-backend Hyper-V and WSL 2 readers are each sent to the control that sets container memory', async ({ |
| 56 | + page, |
| 57 | + }) => { |
| 58 | + await page.goto(DOCKER) |
| 59 | + |
| 60 | + await expect(desktop(page).getByRole('link', { name: 'resource settings' })).toHaveAttribute( |
| 61 | + 'href', |
| 62 | + 'https://docs.docker.com/desktop/settings-and-maintenance/settings/', |
| 63 | + ) |
| 64 | + await expect(desktop(page)).toContainText('with the Windows WSL 2 backend') |
| 65 | + await expect( |
| 66 | + desktop(page).getByRole('link', { name: "Docker's WSL guidance" }), |
| 67 | + ).toHaveAttribute('href', 'https://docs.docker.com/desktop/features/wsl/best-practices/') |
| 68 | + }) |
| 69 | + |
| 70 | + test('@scenario:docker-guide-admin-panel-needs-session-secret the admin panel is not promised to run without its session secret', async ({ |
| 71 | + page, |
| 72 | + }) => { |
| 73 | + await page.goto(DOCKER) |
| 74 | + |
| 75 | + const compose = requirements(page).filter({ hasText: 'default Docker Compose file' }) |
| 76 | + await expect(compose).toContainText('ADMIN_PANEL_SESSION_SECRET') |
| 77 | + await expect(compose.getByRole('link', { name: 'Admin Panel' })).toHaveAttribute( |
| 78 | + 'href', |
| 79 | + '/docs/features/admin_panel', |
| 80 | + ) |
| 81 | + }) |
| 82 | + |
| 83 | + test('@scenario:npm-guide-links-to-system-requirements an npm reader is pointed at the requirements section', async ({ |
| 84 | + page, |
| 85 | + }) => { |
| 86 | + await page.goto(NPM) |
| 87 | + |
| 88 | + const link = body(page).getByRole('link', { name: 'System Requirements' }) |
| 89 | + await expect(link).toHaveAttribute('href', `${DOCKER}#system-requirements`) |
| 90 | + |
| 91 | + await link.click() |
| 92 | + await expect(page).toHaveURL(new RegExp(`${DOCKER}#system-requirements$`)) |
| 93 | + await expect(page.locator('#system-requirements')).toBeVisible() |
| 94 | + }) |
| 95 | + |
| 96 | + test('@scenario:npm-guide-warns-source-build-needs-more-memory an npm reader learns the frontend build needs more memory than the runtime minimum', async ({ |
| 97 | + page, |
| 98 | + }) => { |
| 99 | + await page.goto(NPM) |
| 100 | + |
| 101 | + const build = body(page) |
| 102 | + .locator('li') |
| 103 | + .filter({ hasText: 'Building the frontend from source' }) |
| 104 | + .last() |
| 105 | + await expect(build).toContainText('npm run reinstall') |
| 106 | + await expect(build).toContainText('8 GB of heap') |
| 107 | + await expect(build.getByRole('link', { name: 'Docker', exact: true })).toHaveAttribute( |
| 108 | + 'href', |
| 109 | + DOCKER, |
| 110 | + ) |
| 111 | + }) |
| 112 | +}) |
0 commit comments