Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Sync implementation #87

Merged
merged 7 commits into from
Jan 31, 2024
Merged

Adding Sync implementation #87

merged 7 commits into from
Jan 31, 2024

Conversation

prklm10
Copy link
Contributor

@prklm10 prklm10 commented Jan 21, 2024

Adding Sync implementation

  • Adding 600s timeout in comparison call.

@prklm10 prklm10 requested a review from a team as a code owner January 21, 2024 09:38
@prklm10 prklm10 added the enhancement New feature or request label Jan 24, 2024
@@ -42,13 +42,13 @@ def is_percy_enabled():
log(e, on_debug=True)
return False

def post_screenshots(self, name, tag, tiles, external_debug_url=None, ignored_elements_data=None, considered_elements_data=None):
body = self._request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
def post_screenshots(self, name, tag, tiles, external_debug_url=None, ignored_elements_data=None, considered_elements_data=None, sync=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pass default value for sync

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passed None

@@ -65,7 +65,7 @@ def post_failed_event(self, error):
"errorKind": 'sdk'
}

response = requests.post(f'{PERCY_CLI_API}/percy/events', json=body, timeout=30)
response = requests.post(f'{PERCY_CLI_API}/percy/events', json=body, timeout=600)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why increase timeout here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

@@ -77,36 +77,38 @@ def post_failed_event(self, error):
log(e, on_debug=True)
return None

def post_poa_screenshots(self, name, session_id, command_executor_url, capabilities, desired_capabilities, options=None):
def post_poa_screenshots(self, name, session_id, command_executor_url, capabilities, desired_capabilities, options=None, sync=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove default value for sync

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default to None

@@ -39,16 +40,18 @@ def screenshot(self, name: str, **kwargs):

ignore_region_elements = [element.id for element in options.get(IGNORE_ELEMENT_KEY, [])]
consider_region_elements = [element.id for element in options.get(CONSIDER_ELEMENT_KEY, [])]
sync = options.get(SYNC, False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove default value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None

@@ -15,6 +15,7 @@ def supports(remote_url) -> bool:

def screenshot(self, name: str, **kwargs):
session_details = self.execute_percy_screenshot_begin(name)
sync = kwargs.get('sync', False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None

driver.command_executor._url = 'https://hub-cloud.browserstack.com/wd/hub'
self.mock_webdriver.capabilities = { 'key': 'value' }

self.assertEqual(percy_screenshot(driver, 'Snapshot 3', options = {'sync': True}), 'sync-data')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use variable for assertion matching not hardcoded value

def mock_poa_screenshot(fail=False):
def mock_poa_screenshot(fail=False, sync=False):
body = '{ "success": ' + ("true" if not fail else 'false, "error": "test"') + "}"
if sync: body = '{ "success": "true", "data": "sync-data" }'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this should be closer to actual data object.

@this-is-shivamsingh this-is-shivamsingh enabled auto-merge (squash) January 31, 2024 10:46
Copy link
Contributor

@ninadbstack ninadbstack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blind approve as app percy owner

@this-is-shivamsingh this-is-shivamsingh merged commit bf9aad1 into master Jan 31, 2024
6 checks passed
@this-is-shivamsingh this-is-shivamsingh deleted the PER-2862 branch January 31, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants