diff --git a/tests/test_website_onboarding_page.py b/tests/test_website_onboarding_page.py new file mode 100644 index 000000000..170b9b11c --- /dev/null +++ b/tests/test_website_onboarding_page.py @@ -0,0 +1,194 @@ +"""The onboarding page (website/docs/onboarding-mockup.html) renders and says true things. + +MkDocs copies this hand-written page to the site unrendered, so nothing else checks it: +its doc links are not rewritten, its commands are not run, and its scroll motion, +print layout and colours are only seen in a browser. These tests load it in Chromium +and check it against the real CLI. Chromium is installed on the 3.13 CI shards; the +browser tests skip where it is absent. +""" + +from __future__ import annotations + +import re +import shlex +from collections.abc import Iterator +from pathlib import Path + +import click +import pytest +from playwright.sync_api import Browser, Page, sync_playwright + +from gflow_cli.cli import main +from gflow_cli.errors import EXIT_CODE_MAP, GFlowError + +_DOCS = Path(__file__).resolve().parents[1] / "website" / "docs" +_PAGE = _DOCS / "onboarding-mockup.html" +_HTML = _PAGE.read_text(encoding="utf-8") + +_STEP_MIN_OPACITY = """() => [...document.querySelectorAll('.step')].map(s => + Math.min(...[...s.children].map(c => +getComputedStyle(c).opacity)))""" + + +@pytest.fixture(scope="module") +def browser() -> Iterator[Browser]: + with sync_playwright() as p: + try: + b = p.chromium.launch() + except Exception as exc: # pragma: no cover - only the 3.13 CI shards install it + # Skip only a missing browser; any other launch failure is a real failure. + if "Executable doesn't exist" not in str(exc): + raise + pytest.skip(f"Playwright Chromium is not installed: {exc}") + yield b + b.close() + + +def _open(browser: Browser, *, javascript: bool = True) -> tuple[Page, list[str]]: + page = browser.new_page(java_script_enabled=javascript, viewport={"width": 1100, "height": 800}) + errors: list[str] = [] + page.on("pageerror", lambda e: errors.append(str(e))) + page.goto(_PAGE.as_uri()) + return page, errors + + +def test_doc_links_use_the_directory_urls_mkdocs_publishes() -> None: + hrefs = re.findall(r'href="([^"]+)"', _HTML) + local = [h for h in hrefs if not h.startswith(("http", "#", "mailto:"))] + assert local, "expected the page to link to other docs" + for href in local: + # A .md target exists only as source; MkDocs publishes it as /. + assert href.endswith("/") and (_DOCS / f"{href.rstrip('/')}.md").is_file(), href + + +def test_print_shows_every_step_before_any_scroll(browser: Browser) -> None: + page, _ = _open(browser) + page.emulate_media(media="print") + assert page.evaluate(_STEP_MIN_OPACITY) == [1] * len(page.query_selector_all(".step")) + + +def test_without_javascript_every_step_is_visible(browser: Browser) -> None: + page, _ = _open(browser, javascript=False) + assert all(o == 1 for o in page.evaluate(_STEP_MIN_OPACITY)) + + +def test_scrolling_deals_in_every_step_and_marks_the_last_current(browser: Browser) -> None: + page, errors = _open(browser) + # Before scrolling, the steps below the fold are still hidden: the motion is on. + assert min(page.evaluate(_STEP_MIN_OPACITY)) == 0 + for step in page.query_selector_all(".step"): + step.scroll_into_view_if_needed() + page.wait_for_function("s => s.classList.contains('in')", arg=step) + page.evaluate("window.scrollTo(0, document.body.scrollHeight)") + page.wait_for_function( + """() => { const s = [...document.querySelectorAll('.step')]; + return s.at(-1).classList.contains('active') + && s.slice(0, -1).every(x => x.classList.contains('done')); }""" + ) + classes = page.evaluate("() => [...document.querySelectorAll('.step')].map(s => s.className)") + assert all("in" in c.split() for c in classes), classes + assert "active" in classes[-1].split() and all("done" in c for c in classes[:-1]), classes + assert errors == [] + + +def _luminance(rgb: tuple[int, int, int]) -> float: + srgb = [c / 255 for c in rgb] + lin = [c / 12.92 if c <= 0.03928 else ((c + 0.055) / 1.055) ** 2.4 for c in srgb] + return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2] + + +def _contrast(a: str, b: str) -> float: + la, lb = sorted((_luminance(_hex(a)), _luminance(_hex(b))), reverse=True) + return (la + 0.05) / (lb + 0.05) + + +def _hex(value: str) -> tuple[int, int, int]: + h = value.strip().lstrip("#") + return int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16) + + +def test_contrast_helper_matches_known_wcag_ratios() -> None: + assert round(_contrast("#000000", "#ffffff"), 1) == 21.0 + assert round(_contrast("#b9740f", "#f6f3ec"), 1) == 3.4 + + +@pytest.mark.parametrize("scheme", ["slate", "default"]) +@pytest.mark.parametrize("token", ["--gf-ink", "--gf-muted", "--gf-faint", "--gf-amber"]) +def test_text_tokens_meet_wcag_aa_in_both_themes(browser: Browser, scheme: str, token: str) -> None: + page, _ = _open(browser) + page.evaluate(f"document.documentElement.setAttribute('data-md-color-scheme', '{scheme}')") + css = page.evaluate( + """t => { const s = getComputedStyle(document.documentElement); + return [s.getPropertyValue(t), s.getPropertyValue('--gf-ground'), + s.getPropertyValue('--gf-surface')]; }""", + token, + ) + fg, ground, surface = css + for bg in (ground, surface): + assert _contrast(fg, bg) >= 4.5, f"{token} {fg} on {bg} ({scheme})" + + +def test_copy_button_copies_every_command_without_prompts(browser: Browser) -> None: + page, _ = _open(browser) + page.evaluate( + "() => { window.__copied = []; navigator.clipboard.writeText = t => " + "{ window.__copied.push(t); return Promise.resolve(); }; }" + ) + # A DOM click fires each button's onclick without waiting out the reveal animation. + page.evaluate("() => document.querySelectorAll('.copy-btn').forEach(b => b.click())") + copied: list[str] = page.evaluate("window.__copied") + # Each block's commands, in page order, as the reader sees them in the terminal. + expected: list[str] = page.evaluate( + """() => [...document.querySelectorAll('.copy-btn')].map(b => + [...b.closest('.terminal').querySelectorAll('.terminal-body .cmd')] + .map(c => c.textContent.trim()).join('\\n'))""" + ) + assert copied == expected and all(copied), copied + assert "/plugin marketplace add ffroliva/gflow-cli\n/plugin install gflow@gflow-cli" in copied + assert ( + "gflow mcp setup\ngflow mcp setup --target cursor\ngflow mcp setup --target vscode" + in copied + ) + assert all(not line.startswith(("$", ">")) for text in copied for line in text.splitlines()) + + +def _gflow_commands() -> list[str]: + cmds = re.findall(r'(gflow [^<]+)', _HTML) + return [c.replace(""", '"').replace("&", "&") for c in cmds] + + +@pytest.mark.parametrize("command", _gflow_commands()) +def test_every_gflow_command_on_the_page_parses(command: str) -> None: + args = shlex.split(command)[1:] + if args == ["--version"]: + return + cmd: click.Command = main + ctx = click.Context(main, info_name="gflow") + while isinstance(cmd, click.Group) and args and not args[0].startswith("-"): + sub = cmd.get_command(ctx, args[0]) + assert sub is not None, f"{command}: no command {args[0]!r}" + cmd, args = sub, args[1:] + ctx = click.Context(cmd, info_name=cmd.name, parent=ctx) + # Parsing validates every option and choice without invoking the command. + cmd.make_context(cmd.name, args, parent=ctx.parent) + + +def test_error_cards_name_real_exit_codes() -> None: + cards = re.findall(r'
(.+?) \(exit (\d+)\)
', _HTML) + assert cards + # A subclass such as ProfileLockedError inherits its parent's exit code. + classes: list[type[GFlowError]] = [GFlowError] + for cls in classes: + classes.extend(cls.__subclasses__()) + codes = { + cls: next((EXIT_CODE_MAP[c] for c in cls.__mro__ if c in EXIT_CODE_MAP), None) + for cls in classes + } + by_name = {cls.__name__: code for cls, code in codes.items()} + by_title = {(getattr(cls, "title", ""), code) for cls, code in codes.items()} + for label, code in cards: + if label == "No profiles found": + assert code == "2" # a usage exit, raised before any GFlowError exists + elif label.endswith("Error"): + assert by_name.get(label) == int(code), label + else: + assert (label, int(code)) in by_title, f"{label} (exit {code})" diff --git a/website/docs/onboarding-mockup.html b/website/docs/onboarding-mockup.html index fe8d27f2b..73e55a01b 100644 --- a/website/docs/onboarding-mockup.html +++ b/website/docs/onboarding-mockup.html @@ -13,7 +13,7 @@ --gf-amber-dim: rgba(255, 176, 58, .13); --gf-ink: #ecebe5; --gf-muted: #8c939d; - --gf-faint: #5c636e; + --gf-faint: #7d848f; --gf-ground: #0e1014; --gf-surface: #161a21; --gf-hair: #262b34; @@ -27,13 +27,14 @@ [data-md-color-scheme="default"] { --gf-ink: #1b1d22; --gf-muted: #4a5058; - --gf-faint: #9aa0a7; + --gf-faint: #686e76; --gf-ground: #f6f3ec; --gf-surface: #fffefa; --gf-hair: #e3dfd5; --gf-code-bg: #0b0d12; - --gf-amber-dim: rgba(185, 116, 15, .10); - --gf-amber: #b9740f; + --gf-amber-dim: rgba(143, 90, 11, .10); + /* Darker than the brand amber so amber text meets WCAG AA (4.5:1) on paper. */ + --gf-amber: #8f5a0b; --gf-green: #2d8b6f; --gf-red: #c9302c; --gf-yellow: #8a7024; @@ -246,8 +247,8 @@ .output .success { color: #4ec9b0; } .output .error { color: #f44747; } .output-label { - font-size: .68rem; - color: #5c636e; + font-size: .72rem; + color: #7d848f; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; @@ -421,6 +422,73 @@ color: var(--gf-faint); } + /* ── Deck motion: steps are dealt downward, the rail fills as you read ── */ + html { scroll-behavior: smooth; scroll-padding-top: 24px; } + .step::before { + z-index: 1; + transition: background-color .3s ease, box-shadow .3s ease; + } + .step::after { + content: ""; + position: absolute; + left: -2px; + top: 0; + bottom: 0; + width: 2px; + background: var(--gf-amber); + transform: scaleY(var(--fill, 0)); + transform-origin: top; + } + .step.done::after { --fill: 1; } + .motion .step:not(.done):not(.active)::before { + background: var(--gf-surface); + color: var(--gf-muted); + box-shadow: inset 0 0 0 2px var(--gf-hair); + } + .step:last-child::after { display: none; } + .motion .step > * { + opacity: 0; + transform: translateY(-28px); + clip-path: inset(0 0 100% 0); + transition: + opacity .45s ease, + transform .65s cubic-bezier(.16, 1, .3, 1), + clip-path .65s cubic-bezier(.16, 1, .3, 1); + } + .motion .step.in > * { + opacity: 1; + transform: none; + clip-path: inset(-24px); + transition-delay: calc(var(--i, 0) * 45ms); + } + .next-deck { + display: inline-flex; + align-items: center; + gap: 6px; + margin-top: 4px; + padding: 6px 0; + font-family: var(--gf-mono); + font-size: .85rem; + color: var(--gf-amber); + } + .next-deck svg { transition: transform .2s cubic-bezier(.16, 1, .3, 1); } + .next-deck:hover svg, .next-deck:focus-visible svg { transform: translateY(3px); } + .next-deck:focus-visible { outline: 2px solid var(--gf-amber); outline-offset: 3px; border-radius: 4px; } + @media (prefers-reduced-motion: reduce) { + html { scroll-behavior: auto; } + .motion .step > *, .motion .step.in > * { + transform: none; + clip-path: none; + transition: opacity .2s ease; + transition-delay: 0s; + } + .next-deck svg { transition: none; } + } + /* A printout shows every step, scrolled to or not. */ + @media print { + .motion .step > * { opacity: 1; transform: none; clip-path: none; transition: none; } + } + /* ── Responsive ── */ @media (max-width: 600px) { .container { padding: 32px 16px 60px; } @@ -439,11 +507,11 @@

Get started with gflow-cli

-

From install to your first AI-generated image in about 5 minutes. Or hand the whole thing to your AI assistant.

+

One package, two doors onto Google Flow: the gflow CLI in your terminal and an MCP server for your AI assistant. Install once, sign in once, then use either.

Before you begin
- gflow-cli is alpha and reverse-engineered — not affiliated with Google. It drives a headed browser on your own Google Flow session. It works with any Google account that has Flow access, and every generation bills your account. Not affiliated with Google. + gflow-cli is beta, reverse-engineered and not affiliated with Google. It drives a real Chrome session signed in to your own Google account, which needs Flow access. Video spends your Flow credits; images spend none, but count against a daily image quota.
@@ -453,6 +521,7 @@

Prerequisites

✓ Google account with Flow access ✓ Google Chrome installed ✓ Display for one-time browser login + ✓ Optional: an MCP client (Claude Code, Claude Desktop, Cursor, VS Code, Codex) @@ -506,12 +575,13 @@

Prerequisites

Output
-
gflow, version 0.41.0
+
gflow, version 0.106.0
+ Next: Authenticate -
+
Authenticate

A one-time login opens a real Chrome window. Sign in with your Google account and keep going until the Flow editor loads — gflow closes the window for you and verifies the session automatically.

@@ -543,15 +613,66 @@

Prerequisites

On first run, the profile is created as default then auto-renamed to your email's local-part (e.g. your.name@gmail.com → your-name). Single-account users never have to think about profiles. To use a custom name, pass --profile myname.

+ Next: Connect your assistant +
+ + +
+
Connect your assistant
+

Register the MCP server with your client. It runs the same code as the CLI, on the same signed-in profile, so an assistant can generate, upscale and manage media for you.

+ +

Claude Code: install the plugin from inside Claude Code. It adds the MCP server and two skills, and ships disabled until you enable it.

+
+
+ + + + Claude Code + +
+
+> /plugin marketplace add ffroliva/gflow-cli
+> /plugin install gflow@gflow-cli +
+
+ +

Claude Desktop, Cursor or VS Code: one command writes the server entry into the client's config.

+
+
+ + + + Terminal + +
+
+$ gflow mcp setup
+$ gflow mcp setup --target cursor
+$ gflow mcp setup --target vscode +
+
+
+
What happens
+
The gflow entry is merged into the client's config file.
+
Existing content is kept; the old file is backed up as <name>.gflow-backup.
+
An entry that is already there is left untouched.
+
Restart the client to load the server.
+
+ +

+ Any other MCP client: command uvx, arguments gflow-cli mcp run, or gflow serve for Streamable HTTP at /mcp. + To keep an assistant away from your credits, register gflow mcp run --no-spend: the tools that spend credits are never registered. + Full setup: MCP server. +

+ Next: Generate
- -
+ +
Generate
-

The shortest happy path — one command, real output. Images are free; only Veo video costs credits.

+

From the terminal, one command gives you a real file. From your assistant, ask in plain language and it picks the tool, model and aspect.

- -

Generate a text-to-image with the --tool creative-director flag, which expands your prompt with Google's 5-component formula before any credits are spent.

+

Make an image. --tool creative-director expands your prompt before anything is sent to Flow.

@@ -568,15 +689,10 @@

Prerequisites

Output
Flow project created: project/abc123
Generating images…
-
✓ out/images/2026-07-20/8f3a1b2c_1.png
+
✓ out/images/2026-11-23/8f3a1b2c_1.png
-

- Files are saved to the output directory automatically — by default ./out/images/. - Route outputs to S3, MinIO, or GCS with external storage. -

- -

Turn that still into an 8-second Veo clip. This step costs 1 Veo credit.

+

Make a short video. --max-credits caps what the run may spend: if Flow quotes more, gflow stops before submitting (exit 45).

@@ -586,32 +702,40 @@

Prerequisites

-$ gflow video i2v out/images/2026-07-20/8f3a1b2c_1.png "slow cinematic push-in" --aspect 9:16 +$ gflow video t2v "a paper boat drifting across a calm pond at dawn" --max-credits 10
Output
-
Generating video… (~60-90s)
-
✓ out/videos/2026-07-20/9e4d7f2a.mp4
+
Generating video… (about a minute)
+
✓ out/videos/2026-11-23/9e4d7f2a.mp4
+
+ +

Or ask your assistant:

+
+
Prompt
+
Make a 16:9 image of a lighthouse in a storm, then turn it into a short video. Spend at most 10 credits.

- Video outputs land in ./out/videos/. + Files land in ./out/images/ and ./out/videos/ by default. + Route outputs to S3, MinIO, or GCS with external storage.

+ Next: Your first result
- -
+ +
Success!
🎬
Your first generation is ready
./out/images/YYYY-MM-DD/<id>_1.png
-
Files are saved automatically. Image generations are free — only Veo video costs credits.
+
Saved automatically and catalogued locally. Images spend no credits; video spends your Flow credits.
@@ -635,13 +759,23 @@

Troubleshooting

No profiles found (exit 2)
-
You ran a generation command before authenticating.
+
You ran a generation command before signing in, so no profile exists yet.
Fix: Run the one-time login first:
gflow auth login --browser chrome
+ +
+
Authentication credential missing (exit 8)
+
The profile exists but has no usable Flow session: the account is signed in to Google but not to Flow, or the login did not finish.
+
+ Fix: Sign in again with the real-Chrome strategy:
+ gflow auth login --browser chrome +
+
+
Authentication expired (exit 3)
@@ -661,39 +795,13 @@

Troubleshooting

- -

Let your assistant drive it

-

Everything above, an agent can do for you. Start the MCP server and point Claude, Cursor, or Copilot at it.

-
-
- - - - Terminal - -
-
-$ gflow mcp run -
-
-
-
Output
-
serving over stdio:
-
• gflow_generate_image
-
• gflow_generate_video
-
ready — your assistant can drive Flow.
-
-

- Just ask in plain language — the agent picks the model, aspect, and prompt tooling. See Agent-driven for the full setup. -

-

Where to next