fix: 100% coverage, WCAG accessibility fixes, and documentation updates for per-user OAuth wizards
Test coverage: - Add config=None branch test for dropbox, onedrive, google_drive views (100% coverage) - Add WATCH_FOLDER source-type test (folder_path vs folder key) - Add integration-not-found fallback-to-admin-mode test WCAG 2.1 AA fixes: - Add aria-labelledby="modalTitle" to role="dialog" modals in setup templates - Add aria-hidden="true" to decorative SVGs in callback templates - Add role="status" aria-label="Loading" to spinner divs - Add aria-live="polite" to processing-message and success/folder-selection regions - Add role="alert" aria-live="assertive" to error containers - Update "Return to Setup" link to preserve integration_id in user mode Docs: update DropboxSetup.md, GoogleDriveSetup.md, OneDriveSetup.md with per-user OAuth flow section Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -72,7 +72,58 @@ class TestDropboxViews:
|
||||
# Should render user mode without errors despite the bad config
|
||||
assert b"user_mode" not in response.content or b"Back to Integrations" in response.content
|
||||
|
||||
def test_dropbox_setup_user_mode_valid_config(self, client, db_session):
|
||||
def test_dropbox_setup_user_mode_none_config(self, client, db_session):
|
||||
"""Test user-mode renders correctly when integration.config is None (no folder path)."""
|
||||
owner_id = "user_none_cfg@example.com"
|
||||
integration = UserIntegration(
|
||||
owner_id=owner_id,
|
||||
direction="DESTINATION",
|
||||
integration_type="DROPBOX",
|
||||
name="My Dropbox (no cfg)",
|
||||
config=None,
|
||||
is_active=True,
|
||||
)
|
||||
db_session.add(integration)
|
||||
db_session.commit()
|
||||
db_session.refresh(integration)
|
||||
|
||||
with patch("app.views.dropbox.get_current_owner_id", return_value=owner_id):
|
||||
response = client.get(f"/dropbox-setup?integration_id={integration.id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
# Should render user mode without errors, with empty folder_path
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_dropbox_setup_user_mode_watchfolder_config(self, client, db_session):
|
||||
"""Test user-mode correctly loads folder_path from WATCH_FOLDER source config."""
|
||||
owner_id = "user_wf_cfg@example.com"
|
||||
integration = UserIntegration(
|
||||
owner_id=owner_id,
|
||||
direction="SOURCE",
|
||||
integration_type="WATCH_FOLDER",
|
||||
name="My Dropbox Watch",
|
||||
config=json.dumps({"source_type": "dropbox", "folder_path": "/Inbox"}),
|
||||
is_active=True,
|
||||
)
|
||||
db_session.add(integration)
|
||||
db_session.commit()
|
||||
db_session.refresh(integration)
|
||||
|
||||
with patch("app.views.dropbox.get_current_owner_id", return_value=owner_id):
|
||||
response = client.get(f"/dropbox-setup?integration_id={integration.id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert b"/Inbox" in response.content
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_dropbox_setup_user_mode_integration_not_found(self, client, db_session):
|
||||
"""Test user-mode falls back to admin mode when integration not owned by user."""
|
||||
with patch("app.views.dropbox.get_current_owner_id", return_value="other_user@example.com"):
|
||||
response = client.get("/dropbox-setup?integration_id=999999")
|
||||
|
||||
assert response.status_code == 200
|
||||
# Falls back to admin mode (no "Back to Integrations" link)
|
||||
assert b"Dropbox Integration Setup" in response.content
|
||||
"""Test user-mode correctly loads folder path from integration config."""
|
||||
owner_id = "user_valid_cfg@example.com"
|
||||
integration = UserIntegration(
|
||||
|
||||
@@ -182,6 +182,37 @@ class TestGoogleDriveViews:
|
||||
# Should render user mode without errors despite the bad config
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_google_drive_setup_user_mode_none_config(self, client, db_session):
|
||||
"""Test user-mode renders correctly when integration.config is None (no folder ID)."""
|
||||
owner_id = "user_gd_none_cfg@example.com"
|
||||
integration = UserIntegration(
|
||||
owner_id=owner_id,
|
||||
direction="DESTINATION",
|
||||
integration_type="GOOGLE_DRIVE",
|
||||
name="My GDrive (no cfg)",
|
||||
config=None,
|
||||
is_active=True,
|
||||
)
|
||||
db_session.add(integration)
|
||||
db_session.commit()
|
||||
db_session.refresh(integration)
|
||||
|
||||
with patch("app.views.google_drive.get_current_owner_id", return_value=owner_id):
|
||||
response = client.get(f"/google-drive-setup?integration_id={integration.id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
# Should render user mode without errors, with empty folder_id
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_google_drive_setup_user_mode_integration_not_found(self, client, db_session):
|
||||
"""Test user-mode falls back to admin mode when integration not owned by user."""
|
||||
with patch("app.views.google_drive.get_current_owner_id", return_value="other_user@example.com"):
|
||||
response = client.get("/google-drive-setup?integration_id=999999")
|
||||
|
||||
assert response.status_code == 200
|
||||
# Falls back to admin mode (no "Back to Integrations" link)
|
||||
assert b"Google Drive Integration Setup" in response.content
|
||||
|
||||
def test_google_drive_setup_user_mode_valid_config(self, client, db_session):
|
||||
"""Test user-mode correctly loads folder ID from integration config."""
|
||||
owner_id = "user_gd_valid_cfg@example.com"
|
||||
|
||||
@@ -70,6 +70,59 @@ class TestOnedriveViews:
|
||||
# Should render user mode without errors despite the bad config
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_onedrive_setup_user_mode_none_config(self, client, db_session):
|
||||
"""Test user-mode renders correctly when integration.config is None (no folder path)."""
|
||||
owner_id = "user_od_none_cfg@example.com"
|
||||
integration = UserIntegration(
|
||||
owner_id=owner_id,
|
||||
direction="DESTINATION",
|
||||
integration_type="ONEDRIVE",
|
||||
name="My OneDrive (no cfg)",
|
||||
config=None,
|
||||
is_active=True,
|
||||
)
|
||||
db_session.add(integration)
|
||||
db_session.commit()
|
||||
db_session.refresh(integration)
|
||||
|
||||
with patch("app.views.onedrive.get_current_owner_id", return_value=owner_id):
|
||||
response = client.get(f"/onedrive-setup?integration_id={integration.id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
# Should render user mode without errors, with empty folder_path
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_onedrive_setup_user_mode_watchfolder_config(self, client, db_session):
|
||||
"""Test user-mode correctly loads folder_path from WATCH_FOLDER source config."""
|
||||
owner_id = "user_od_wf_cfg@example.com"
|
||||
integration = UserIntegration(
|
||||
owner_id=owner_id,
|
||||
direction="SOURCE",
|
||||
integration_type="WATCH_FOLDER",
|
||||
name="My OneDrive Watch",
|
||||
config=json.dumps({"source_type": "onedrive", "folder_path": "Work/Inbox"}),
|
||||
is_active=True,
|
||||
)
|
||||
db_session.add(integration)
|
||||
db_session.commit()
|
||||
db_session.refresh(integration)
|
||||
|
||||
with patch("app.views.onedrive.get_current_owner_id", return_value=owner_id):
|
||||
response = client.get(f"/onedrive-setup?integration_id={integration.id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert b"Work/Inbox" in response.content
|
||||
assert b"Back to Integrations" in response.content
|
||||
|
||||
def test_onedrive_setup_user_mode_integration_not_found(self, client, db_session):
|
||||
"""Test user-mode falls back to admin mode when integration not owned by user."""
|
||||
with patch("app.views.onedrive.get_current_owner_id", return_value="other_user@example.com"):
|
||||
response = client.get("/onedrive-setup?integration_id=999999")
|
||||
|
||||
assert response.status_code == 200
|
||||
# Falls back to admin mode (no "Back to Integrations" link)
|
||||
assert b"OneDrive Integration Setup" in response.content
|
||||
|
||||
def test_onedrive_setup_user_mode_valid_config(self, client, db_session):
|
||||
"""Test user-mode correctly loads folder path from integration config."""
|
||||
owner_id = "user_od_valid_cfg@example.com"
|
||||
|
||||
Reference in New Issue
Block a user