remove login block complete prompt override by default (#5648)
Some checks are pending
Run tests and pre-commit / Run tests and pre-commit hooks (push) Waiting to run
Run tests and pre-commit / Frontend Lint and Build (push) Waiting to run
Publish Fern Docs / run (push) Waiting to run

This commit is contained in:
Shuchang Zheng 2026-04-24 10:01:12 -07:00 committed by GitHub
parent f065269274
commit 5092a8bead
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 110 deletions

View file

@ -5,7 +5,7 @@ from typing import Any, cast
import structlog
from skyvern.config import settings
from skyvern.constants import DEFAULT_LOGIN_COMPLETE_CRITERION, DEFAULT_LOGIN_PROMPT
from skyvern.constants import DEFAULT_LOGIN_PROMPT
from skyvern.forge.sdk.db.enums import TaskType
from skyvern.forge.sdk.db.id import (
generate_aws_secret_parameter_id,
@ -646,9 +646,6 @@ def block_yaml_to_block(
login_navigation_goal = block_yaml.navigation_goal
if not login_navigation_goal or not login_navigation_goal.strip():
login_navigation_goal = DEFAULT_LOGIN_PROMPT
login_complete_criterion = block_yaml.complete_criterion
if not login_complete_criterion or not login_complete_criterion.strip():
login_complete_criterion = DEFAULT_LOGIN_COMPLETE_CRITERION
return LoginBlock(
**base_kwargs,
url=block_yaml.url,
@ -662,7 +659,7 @@ def block_yaml_to_block(
totp_verification_url=block_yaml.totp_verification_url,
totp_identifier=block_yaml.totp_identifier,
disable_cache=block_yaml.disable_cache,
complete_criterion=login_complete_criterion,
complete_criterion=block_yaml.complete_criterion,
terminate_criterion=block_yaml.terminate_criterion,
complete_verification=block_yaml.complete_verification,
)

View file

@ -1,105 +0,0 @@
"""Tests for LoginBlock default complete_criterion in workflow_definition_converter."""
from datetime import UTC, datetime
from skyvern.forge.sdk.workflow.models.block import LoginBlock
from skyvern.forge.sdk.workflow.models.parameter import OutputParameter
from skyvern.forge.sdk.workflow.workflow_definition_converter import block_yaml_to_block
from skyvern.schemas.workflows import LoginBlockYAML
_NOW = datetime.now(UTC)
def _make_output_parameter(label: str) -> OutputParameter:
return OutputParameter(
parameter_type="output",
key=f"{label}_output",
workflow_id="test_wf",
output_parameter_id=f"op_{label}",
created_at=_NOW,
modified_at=_NOW,
)
def _convert_login_block(block_yaml: LoginBlockYAML) -> LoginBlock:
"""Helper to convert a LoginBlockYAML through block_yaml_to_block."""
output_param = _make_output_parameter(block_yaml.label)
parameters = {output_param.key: output_param}
block = block_yaml_to_block(block_yaml, parameters)
assert isinstance(block, LoginBlock)
return block
class TestLoginBlockDefaultCompleteCriterion:
"""Tests that LoginBlocks get a sensible default complete_criterion when none is provided."""
def test_no_complete_criterion_gets_default(self) -> None:
"""LoginBlock without complete_criterion should get the default login verification string."""
block_yaml = LoginBlockYAML(
label="login",
navigation_goal="Log in to the website",
)
assert block_yaml.complete_criterion is None
block = _convert_login_block(block_yaml)
assert block.complete_criterion is not None
assert "logged-in indicators" in block.complete_criterion
assert "homepage" in block.complete_criterion.lower()
def test_empty_string_complete_criterion_gets_default(self) -> None:
"""LoginBlock with empty string complete_criterion should get the default."""
block_yaml = LoginBlockYAML(
label="login",
navigation_goal="Log in to the website",
complete_criterion="",
)
block = _convert_login_block(block_yaml)
assert block.complete_criterion is not None
assert "logged-in indicators" in block.complete_criterion
def test_whitespace_only_complete_criterion_gets_default(self) -> None:
"""LoginBlock with whitespace-only complete_criterion should get the default."""
block_yaml = LoginBlockYAML(
label="login",
navigation_goal="Log in to the website",
complete_criterion=" ",
)
block = _convert_login_block(block_yaml)
assert block.complete_criterion is not None
assert "logged-in indicators" in block.complete_criterion
def test_explicit_complete_criterion_preserved(self) -> None:
"""LoginBlock with an explicit complete_criterion should keep it unchanged."""
custom_criterion = "URL contains '/dashboard'"
block_yaml = LoginBlockYAML(
label="login",
navigation_goal="Log in to the website",
complete_criterion=custom_criterion,
)
block = _convert_login_block(block_yaml)
assert block.complete_criterion == custom_criterion
def test_default_criterion_mentions_key_indicators(self) -> None:
"""The default criterion should mention the key logged-in indicators."""
block_yaml = LoginBlockYAML(
label="login",
navigation_goal="Log in to the website",
)
block = _convert_login_block(block_yaml)
criterion = block.complete_criterion
assert criterion is not None
# Should mention checking for logout button / sign out
assert "Sign out" in criterion or "Log out" in criterion or "Logout" in criterion
# Should mention checking for username/account in header
assert "user name" in criterion or "email" in criterion or "account name" in criterion
# Should warn about homepage redirect not meaning failure
assert "homepage" in criterion.lower()