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

#762 #764 google ecommerce tests #767

Merged
merged 9 commits into from
Mar 14, 2019
Merged

Conversation

ArtemijRodionov
Copy link
Contributor

@ArtemijRodionov ArtemijRodionov commented Mar 12, 2019

Closes #762 Closes #764

@ArtemijRodionov ArtemijRodionov self-assigned this Mar 12, 2019
@ArtemijRodionov ArtemijRodionov force-pushed the 762-google-ecommerce-tests branch from 2b0e597 to 71df91f Compare March 12, 2019 22:35
@ArtemijRodionov ArtemijRodionov force-pushed the 762-google-ecommerce-tests branch 3 times, most recently from 6bcbcab to 2d7e10b Compare March 13, 2019 01:22
@ArtemijRodionov ArtemijRodionov changed the title WIP #762 google ecommerce tests #762 #764 google ecommerce tests Mar 13, 2019
@ArtemijRodionov ArtemijRodionov requested a review from duker33 March 13, 2019 01:38
Copy link
Contributor

@duker33 duker33 left a comment

Choose a reason for hiding this comment

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

some arch questions

from shopelectro.selenium import SiteDriver

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


def matched_url(fn):
Copy link
Contributor

Choose a reason for hiding this comment

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

decorator requires self: Page object with driver and path fields inside. So, it has not clear interface.
Here we have function, that contains self: Page and can be used only inside Page class. This is pretty the definition of method.
We should turn this decorator to Page's method, i think.

After putting it to Page class we can clarify it's semantic. The purpose of method is to wait until a page is loaded. Url waiting is just realization, it should not be visible throw the method interface.
Smth like Page.wait_loaded is good name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The responsibility of this decorator isn't to wait for a page to load

Right now we have to synchronize the browser location and Page abstraction manually to prevent an inconsistent state issue, so i have created this decorator to forbid usage of wrong Page instance at a specific browser location

If we will make a method instead of the decorator, it maybe will be more clear from semantic point of view, but we still have to manually call it

I want to propose Navigation class instead that will responsible for this synchronization.
I will create todo for it and edit the decorator's comment to clarify its purpose

Copy link
Contributor

Choose a reason for hiding this comment

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

@artemiy312 , i thought about separated class too, but it seems to me too much to create separated class for one method. The url sync mech is good related to Page class.

have to synchronize the browser location and Page abstraction manually to prevent an inconsistent state issue

but this sync is just common waiting by it's semantic. Waiting text in input has the same nature, but we use term "wait", not sync.
Anyway Page.sync method (or sync_page deco) looks much good then matched_urls

@@ -0,0 +1,36 @@
from django.test import override_settings, tag
Copy link
Contributor

Choose a reason for hiding this comment

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

test_counters is more wide name. We'll move here all Ya.Metrica tests in the future, as i see.
By the way, if we should move, create pls pdd task to do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

counters are part of web analytics and js eCommerce is not a counter, so i'd prefer tests_js_analytics.py


fixtures = ['dump.json']

order: Order
Copy link
Contributor

Choose a reason for hiding this comment

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

this field looks strange: we don't use it anywhere

order = Order.objects.order_by('-created').first()
reached = self.browser.execute_script('return gaObject.results;')

# @todo #762:30m Implement assertion of an order and reached targets for test_google_ecommerce_purchase.
Copy link
Contributor

Choose a reason for hiding this comment

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

the header is too long for task, i think.

# @todo ... Assert if counter object results are successful for order.
  GA counter object should contain a correct order and reached targets data.

Up to you

def add_to_cart(browser, live_server_url):
browser.get(live_server_url + Product.objects.first().url)
def add_to_cart(browser):
browser.get(Product.objects.first().url)
browser.find_element_by_class_name('btn-to-basket').click()
Copy link
Contributor

Choose a reason for hiding this comment

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

seems some waiting should be good here. Maybe do pdd for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe until it doesn't raise issues we shouldn't wait it, but if you will insist i create a todo

@duker33 duker33 added the discuss issue needs to finish discussion before start working label Mar 13, 2019
@ArtemijRodionov ArtemijRodionov merged commit f97e76b into master Mar 14, 2019
@ArtemijRodionov ArtemijRodionov deleted the 762-google-ecommerce-tests branch March 14, 2019 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss issue needs to finish discussion before start working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants