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
3 changes: 2 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def _run(fn, *args, **kwargs):

if not _creds().configured():
return ("Google isn't configured. Set google.client_id / client_secret / refresh_token "
"(or GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET / GOOGLE_REFRESH_TOKEN).")
"(or GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET / GOOGLE_REFRESH_TOKEN). "
"Setup guide: https://github.com/protoLabsAI/google-plugin#connect-one-click-oauth")
try:
return fn(*args, **kwargs)
except GoogleError as exc:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def test_tools_hint_when_unconfigured(monkeypatch):
monkeypatch.setattr(plugin, "_CREDS", Creds("", "", ""))
out = plugin.gmail_list_unread.invoke({})
assert "isn't configured" in out and "GOOGLE_CLIENT_ID" in out
# The hint points the agent at the README OAuth setup section (bare URL, not HTML).
assert "https://github.com/protoLabsAI/google-plugin#connect-one-click-oauth" in out


def test_list_unread_quotes_the_label(monkeypatch):
Expand Down Expand Up @@ -158,3 +160,12 @@ def test_page_is_four_rules_compliant():
assert "apiFetch" in page # authed fetch via the kit
assert ":root{" not in page and ":root {" not in page # no hand-rolled theme map
assert 'addEventListener("message"' not in page # kit owns the handshake


def test_setup_badge_links_to_readme_oauth_guide():
# The "no client" badge tells the operator what to set AND links to how (README).
page = view.PAGE
href = "https://github.com/protoLabsAI/google-plugin#connect-one-click-oauth"
assert 'class="pl-badge pl-badge--error"' in page # keeps the DS badge classes
assert f'href="{href}"' in page # the badge text is wrapped in an <a> to the guide
assert "color:inherit" in page # readable on the error badge background
2 changes: 1 addition & 1 deletion view.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
? '<span class="pl-badge pl-badge--success">connected' + (s.email ? " — " + esc(s.email) : "") + '</span>'
: (s.has_client
? '<button class="pl-btn pl-btn--primary" id="connect">Connect Google</button>'
: '<span class="pl-badge pl-badge--error">set client_id / client_secret in Settings ▸ Plugins ▸ Google</span>');
: '<span class="pl-badge pl-badge--error"><a href="https://github.com/protoLabsAI/google-plugin#connect-one-click-oauth" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline">set client_id / client_secret in Settings ▸ Plugins ▸ Google</a></span>');
let rows = '<div class="row"><span class="k">Account</span>' + badge + '</div>';
if (s.configured) rows += '<div class="row"><span class="k"></span><button class="pl-btn" id="connect">Reconnect</button></div>';
return rows;
Expand Down
Loading