Commit Graph

29 Commits

Author SHA1 Message Date
Anders Kaseorg
f24a0a6b81 ruff: Fix RUF059 Unpacked variable is never used.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-30 16:47:54 -07:00
Anders Kaseorg
3f514a4e00 tools: Convert message-screenshot, thread-screenshot to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-10 15:54:28 -07:00
Niloth P
52fb13a2f6 generate-integration-docs-screenshot: Use bot-name option to set email.
Previously, only one bot can be created using the
generate-integration-docs-screenshot script for each integration. This
was because the bot's email was constructed using the integration's
name.

Thus, the bot-name commandline option would not work if a bot already
exists for the integration.

Now, we create the email by cleaning the bot-name value, if passed.
2025-08-04 10:00:02 -07:00
Niloth P
0d30435b29 generate-integration-docs-screenshot: Fix usage of fixtureless options.
Fixed copy paste error in loading commandline options for
fixtureless-integrations.
2025-08-04 10:00:02 -07:00
Niloth P
6a1d231689 integrations: Use directory name to get HTTP headers from fixtures.
Previously, the integration's name was directly being used.
Due to this, the GitHub Sponsors integration which is in the same module
as the GitHub integration could not be used with the
`generate-integration-docs-screenshot` script, as it would be unable to
locate the fixtures.
2025-06-09 15:59:39 -07:00
Niloth P
dac9e476f8 generate-integration-docs-screenshot: Add batch options.
Adds
- `--all-webhook` to batch process all webhook integrations,
- `--all-fixtureless` to batch process all fixtureless integrations.
2025-06-01 11:38:02 -07:00
Niloth P
866785784a generate-integration-docs-screenshot: Add fixtureless arguments.
Add a `fixtureless_group` of arguments to allow passing in the message,
topic and channel via the commandline.
By default, the script uses the screenshot config from
`integrations.py`.
2025-06-01 11:38:02 -07:00
Niloth P
287e1f8fac generate-integration-docs-screenshot: Support fixtureless integrations.
Example screenshots can now be generated for fixtureless integrations,
by sending mock messages using the topic and message text included in
the screenshot config added in the previous commit.
2025-06-01 11:38:02 -07:00
Niloth P
0b8e042627 integrations: Split the getters for fixture_path and image_path.
This is in preparation of adding support for generating screenshots of
fixtureless integrations, which would need to get image_path, without
involving fixture_path.
2025-06-01 11:38:02 -07:00
Niloth P
94a5ced243 integrations: Rename ScreenshotConfig to WebhookScreenshotConfig.
This is in preparation to differentiate the current config dataclass
(used for webhooks) from the FixturelessScreenshotConfig that will be
added for non-webhook integrations in the following commits.
2025-06-01 11:38:02 -07:00
Niloth P
9f92ae710f integrations: Remove support for non-webhook example screenshots.
- Removed the BaseScreenshotConfig dataclass, and merge it with
ScreenshotConfig dataclass.
- Simplified get_fixture_and_image_paths.
- Simplified generate_screenshot_from_config in the screenshot script.
- Deleted send_bot_mock_message.
2025-06-01 11:38:02 -07:00
Niloth P
88e92d050c generate-integration-docs-screenshot: Handle incorrect fixture_name. 2025-06-01 11:35:00 -07:00
Niloth P
68e03f8316 generate-integration-docs-screenshot: Refactor parsing of webhook args.
- Simplified the loading of commandline options into the config dict.
- Split the logic into two new functions. This is in preparation to
later commits that will parse commandline options for non-webhook
integrations by re-using the created functions.
2025-06-01 11:35:00 -07:00
Niloth P
2b358db46b generate-integration-docs-screenshot: Group options by integration type.
Group argparse arguments into common and webhook-specific options.

The common group contains arguments that apply to both webhook and
non-webhook integrations. It is not assigned a description.

A fixtureless, non-webhook group will be added later, when its arguments
are created.
2025-06-01 11:35:00 -07:00
Niloth P
3cb34ef03d generate-integration-docs-screenshot: Rename the fixture option.
to `fixture-name` to match the name of the corresponding field in the
ScreenshotConfig dataclass.

This is in preparation to loading all the options into a config dict
in a single step in a later commit.
2025-06-01 11:35:00 -07:00
Niloth P
20b0ddc4d1 generate-integration-docs-screenshot: Improve help and error messages. 2025-06-01 11:35:00 -07:00
Niloth P
802d1a57c1 generate-integration-docs-screenshot: Rename argument group for clarity.
Rename `group` to `batch_group`.

It's a mutually exclusive group that lets the user decide whether to
generate screenshots one at a time or in a batch.
2025-06-01 11:35:00 -07:00
Niloth P
af1ccbabf1 generate-integration-docs-screenshot: Remove unused argument group.
Removed `fixture_group`.
2025-06-01 11:35:00 -07:00
Niloth P
de0c24fdb8 generate-integration-docs-screenshot: Remove unused function parameter. 2025-06-01 11:35:00 -07:00
Niloth P
7e3218ee45 generate-integration-docs-screenshot: Support plain/text payloads.
All *.txt fixtures were assumed to only contain URL parameters,
now fixtures with plain/text payloads are also supported.
2025-04-16 14:05:29 -07:00
Anders Kaseorg
f223251ffe requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-14 09:42:16 -08:00
Niloth P
a0a1f55965 screenshot webhooks: Add support for multipart/form-data fixtures.
Add a common function for webhooks to convert multipart strings to dict.
This facilitates loading a multipart/form-data fixture as a file string,
and converting it.

This will allow testing integrations that use multipart/form-data,
and generating their example screenshots using a script.

Note that this only supports text fields, accommodation for binary files
is not included at the moment.
2024-12-02 18:08:58 -08:00
Niloth P
02049fbbf3 tools/screenshots: Create integration bots using display_name.
Will be adding the updated screenshots of affected integrations as soon
as the PR with the new logos and example screenshots gets merged.
2024-11-21 11:10:12 -08:00
Niloth P
29ef4a05fe tools/screenshots: Fix custom headers crash when using custom options. 2024-11-21 11:10:12 -08:00
Anders Kaseorg
91ade25ba3 python: Simplify with str.removeprefix, str.removesuffix.
These are available in Python ≥ 3.9.
https://docs.python.org/3/library/stdtypes.html#str.removeprefix

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-09-03 12:30:16 -07:00
Anders Kaseorg
531b34cb4c ruff: Fix UP007 Use X | Y for type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-07-13 22:28:22 -07:00
Anders Kaseorg
e08a24e47f ruff: Fix UP006 Use list instead of List for type annotation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-07-13 22:28:22 -07:00
Alex Vandiver
08b24484d1 upload: Remove redundant acting_user_profile argument.
This argument, effectively added in 9eb47f108c, was never actually
used.
2024-06-26 16:43:11 -07:00
roanster007
0a7c0ea326 refactor: Relocate screenshots scripts to new tools/screenshots dir.
This commit relocates all the scripts in the tools directory which
are used for auto-generating screenshots to the new
tools/screenshots directory to avoid cluttering the tools/ root.
2024-05-14 16:17:44 -07:00