Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions demo/casts/atmos.d/screengrabs/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ commands:
from cast_checks import (
command_slug,
load_text,
assert_recorded_command,
assert_no_error_output,
assert_no_local_paths,
assert_body_color,
Expand Down Expand Up @@ -966,6 +967,10 @@ commands:
if not path.is_file():
raise SystemExit(f"screengrab cast missing for {command!r}: {path.name}")
text = load_text(path)
# "atmos about --help" is recorded by a cast script with a typed
# title instead of a recorded command header.
if command != "atmos about --help":
assert_recorded_command(path, command)
assert_no_error_output(text)
assert_no_local_paths(text)
assert_body_color(text)
Expand Down
23 changes: 23 additions & 0 deletions demo/casts/cast_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ def load_text(path):
)


def assert_recorded_command(path, command):
"""The cast header must record the command as typed, program name included.

The docs player types the header's ``command`` after the prompt, so a
header that omits the leading ``atmos`` renders "> --help" instead of
"> atmos --help". ``command`` is the full manifest command. The recorder
may widen a trailing ``--help`` to ``--help=all`` (see the source
commands in the screengrab manifest), so that one substitution is allowed.
"""
header = json.loads(Path(path).read_text().splitlines()[0])
recorded = header.get("command")
if not isinstance(recorded, str):
raise SystemExit(f"cast header has no recorded command: {Path(path).name}")
expected = command.split()
actual = recorded.split()
if actual and expected and expected[-1] == "--help" and actual[-1] == "--help=all":
actual = actual[:-1] + ["--help"]
if actual != expected:
raise SystemExit(
f"cast header command {recorded!r} must be {command!r}: {Path(path).name}"
)


def assert_no_experimental(text):
"""The experimental indicator must be silenced at the recording source."""
if "\U0001f9ea" in text or "experimental" in text.lower():
Expand Down
35 changes: 35 additions & 0 deletions demo/casts/test_screengrabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,41 @@
import unittest
from unittest import mock

sys.path.insert(0, str(Path(__file__).parent))
from cast_checks import assert_recorded_command # noqa: E402


class RecordedCommandTest(unittest.TestCase):
def check(self, header, command):
path = Path(self.enterContext(tempfile.TemporaryDirectory())) / "x.cast"
path.write_text(json.dumps(header) + "\n")
assert_recorded_command(path, command)

def test_accepts_command_with_program_name(self):
self.check({"version": 3, "command": "atmos --help"}, "atmos --help")
self.check({"version": 3, "command": "atmos ai ask --help"}, "atmos ai ask --help")

def test_accepts_widened_help_flag(self):
self.check(
{"version": 3, "command": "atmos aws cloudformation source pull --help=all"},
"atmos aws cloudformation source pull --help",
)

def test_rejects_command_without_program_name(self):
with self.assertRaisesRegex(SystemExit, "must be 'atmos --help'"):
self.check({"version": 3, "command": "--help"}, "atmos --help")
with self.assertRaisesRegex(SystemExit, "must be 'atmos ai --help'"):
self.check({"version": 3, "command": "ai --help"}, "atmos ai --help")

def test_rejects_missing_command(self):
with self.assertRaisesRegex(SystemExit, "no recorded command"):
self.check({"version": 3, "title": "atmos --help"}, "atmos --help")

def test_help_widening_does_not_hide_other_mismatches(self):
with self.assertRaises(SystemExit):
self.check({"version": 3, "command": "atmos plugin --help=all"}, "atmos plan --help")


class ScreengrabRecorderTest(unittest.TestCase):
def setUp(self):
manifest = Path(__file__).parent / "atmos.d/screengrabs/cli.yaml"
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cli/commands/help.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Discover Atmos commands and their available options from your terminal. Use inte
browse commands, or request a command's help text when you need a quick usage reference.
</Intro>

<CastPlayer title="atmos help" src="/casts/screengrabs/atmos--help.cast" static chrome />
<CastPlayer title="atmos --help" src="/casts/screengrabs/atmos--help.cast" static chrome />

## Usage

Expand Down
267 changes: 134 additions & 133 deletions website/static/casts/screengrabs/atmos-stack-list--help.cast

Large diffs are not rendered by default.

355 changes: 178 additions & 177 deletions website/static/casts/screengrabs/atmos-stack-plan--help.cast

Large diffs are not rendered by default.

49 changes: 25 additions & 24 deletions website/static/casts/screengrabs/atmos-stack-schema--help.cast

Large diffs are not rendered by default.

113 changes: 57 additions & 56 deletions website/static/casts/screengrabs/atmos-stack-set--help.cast

Large diffs are not rendered by default.

357 changes: 179 additions & 178 deletions website/static/casts/screengrabs/atmos-stack-test--help.cast

Large diffs are not rendered by default.

123 changes: 62 additions & 61 deletions website/static/casts/screengrabs/atmos-stack-validate--help.cast

Large diffs are not rendered by default.

128 changes: 65 additions & 63 deletions website/static/casts/screengrabs/atmos-store--help.cast

Large diffs are not rendered by default.

59 changes: 30 additions & 29 deletions website/static/casts/screengrabs/atmos-store-delete--help.cast

Large diffs are not rendered by default.

71 changes: 36 additions & 35 deletions website/static/casts/screengrabs/atmos-store-get--help.cast

Large diffs are not rendered by default.

63 changes: 32 additions & 31 deletions website/static/casts/screengrabs/atmos-store-list--help.cast

Large diffs are not rendered by default.

55 changes: 28 additions & 27 deletions website/static/casts/screengrabs/atmos-store-set--help.cast

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions website/static/casts/screengrabs/atmos-support--help.cast

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions website/static/casts/screengrabs/atmos-support.cast

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading