def test_title_add_before_length(self): """ Tests add before where length limit is exceeded """ long_text = 'Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong' expected_listings_1 = [ long_text + 'First something 1234 (1)\n2 characters remaining', long_text + 'Second something 1235 (2)\n1 character remaining', long_text + 'Third something LG-512a (3)\n1 character over limit' ] expected_listings_2 = [ long_text + 'First something 1234 (1)\n2 characters remaining', long_text + 'Second something 1235 (2)\n1 character remaining', 'Third something LG-512a (3)\n113 characters remaining' ] select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) input_field = bp.operation_input() # Test long text send_keys(input_field, long_text) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 # Apply (client only) click(bp.operation_apply()) sleep(1) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_2 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ')
def test_title_replace(self): """ Tests title replace - basic test """ expected_listings_1 = [ 'Prvni something 1234 (1)\n116 characters remaining', 'Second something 1235 (2)\n115 characters remaining', 'Third something LG-512a (3)\n113 characters remaining' ] select_listings_to_edit(self.driver, 'Find & Replace') d = self.driver bp = BulkPage(d) input_find_field = bp.operation_input_find() input_replace_field = bp.operation_input_replace() # Normal Replace send_keys(input_find_field, 'First') send_keys(input_replace_field, 'Prvni') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 # Apply (client only) click(bp.operation_apply()) sleep(1) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ')
def test_create_category(self): """ Tests that a category can be created in bulk edit """ expected_listings_01 = [ 'First something 1234 (1)\nClothing\nMen\'s Clothing\nSocks\nChoose Category', 'Second something 1235 (2)\nClothing\nMen\'s Clothing\nSocks\nChoose Category', 'Third something LG-512a (3)\nClothing\nMen\'s Clothing\nPants' ] expected_listings_02 = [ 'First something 1234 (1)\nAccessories\nCostume Accessories\nCostume Tails & Ears\nCostume Ears', 'Second something 1235 (2)\nAccessories\nCostume Accessories\nCostume Tails & Ears\nCostume Ears', 'Third something LG-512a (3)\nAccessories\nCostume Accessories\nCostume Tails & Ears\nCostume Ears' ] self.select_listings_to_edit() d = self.driver bp = BulkPage(d) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings_01 bp.select_category(['Accessories', 'Costume Accessories', 'Costume Tails & Ears', 'Costume Ears']) # Apply changes click(bp.operation_apply()) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings_02 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ')
def test_title_delete(self): """ Tests tile delete basic """ expected_listings_1 = [ 'First something 1234 (1)\n122 characters remaining', 'Second something 1235 (2)\n115 characters remaining', 'Third something LG-512a (3)\n113 characters remaining' ] expected_listings_2 = [ 'Second something 1235 (2)\n115 characters remaining', 'Third something LG-512a (3)\n113 characters remaining', 'something 1234 (1)\n122 characters remaining' ] select_listings_to_edit(self.driver, 'Delete') d = self.driver bp = BulkPage(d) input_field = bp.operation_input() # Normal Delete send_keys(input_field, 'First ') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 # Apply (client only) click(bp.operation_apply()) sleep(1) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_2 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ')
def test_title_add_before_starting_chars(self): """ Tests that add before title starts with valid chars """ expected_listings_1 = [ '123First something 1234 (1)\n113 characters remaining', '123Second something 1235 (2)\n112 characters remaining', '123Third something LG-512a (3)\n110 characters remaining' ] expected_listings_2 = [ '@ First something 1234 (1)\nMust begin with alphanumerical character', '@ Second something 1235 (2)\nMust begin with alphanumerical character', '@ Third something LG-512a (3)\nMust begin with alphanumerical character' ] expected_listings_3 = [ 'á First something 1234 (1)\n114 characters remaining', 'á Second something 1235 (2)\n113 characters remaining', 'á Third something LG-512a (3)\n111 characters remaining' ] select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) input_field = bp.operation_input() # Test 123 prefix - OK send_keys(input_field, '123') listings = bp.listing_rows_texts_sorted() error_msg = bp.error_baloon() assert error_msg == '' assert listings == expected_listings_1 # Test @ prefix - show error, temp title does not contain it send_keys(input_field, BACKSPACE_KEYS) send_keys(input_field, '@ ') sleep(2) listings = bp.listing_rows_texts_sorted() error_msg = bp.error_baloon() assert error_msg == 'Must begin with alphanumerical character' assert listings == expected_listings_2 # Test á prefix - no error, temp title contains it send_keys(input_field, BACKSPACE_KEYS) send_keys(input_field, 'á ') listings = bp.listing_rows_texts_sorted() error_msg = bp.error_baloon() assert error_msg == '' assert listings == expected_listings_3
def test_edit_single_category(self): """ Tests that a single category can be edited """ expected_listings_01 = [ 'First something 1234 (1)\nClothing\nMen\'s Clothing\nSocks\nChoose Category', 'Second something 1235 (2)\nClothing\nMen\'s Clothing\nSocks\nChoose Category', 'Third something LG-512a (3)\nClothing\nMen\'s Clothing\nPants' ] expected_data = [['1', '1761']] self.select_listings_to_edit() d = self.driver bp = BulkPage(d) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings_01 # update category of the 1st listing row = bp.listing_row('First something 1234 (1)') bp.select_category(['Accessories', 'Costume Accessories', 'Costume Tails & Ears', 'Costume Ears'], row, True) click(bp.sync_updates_button()) wait_for_assert(expected_data, lambda: run_sql('HIVE', 'select_taxonomy_id_modified', True), 'Unexpected taxonomy ID in DB')
def test_bulk_occasion_validation(self): """ Tests that occasion can't be set at all or changed on certain categories that don't permit it """ expected_listings_01 = [ 'Four\nThe category of this listing does not support occasion', 'One\nAnniversary', 'Three\nChoose Occasion', 'Two\nChoose Occasion' ] expected_listings_02 = [ 'Four\nThe category of this listing does not support occasion', 'One\nGrief & Mourning', 'Three\nChoose Occasion\nOccasion cannot be changed due to category', 'Two\nChoose Occasion\nOccasion cannot be changed due to category' ] expected_listings_03 = [ 'Four\nThe category of this listing does not support occasion', 'One\nGrief & Mourning', 'Three\nChoose Occasion', 'Two\nChoose Occasion' ] bp = BulkPage(self.driver) select_listings_to_edit(self.driver) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings_01 # Change occasion using bulk bp.select_occasion('Grief & Mourning') actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings_02 # Apply changes and check listings click(bp.operation_apply()) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings_03 # Check apply button wait_for_web_assert(False, bp.operation_apply().is_enabled, 'Apply button is enabled')
def test_title_add_before_restricted_chars_existing(self): """ Tests add before where restricted character already exists in the title """ restricted_char = '%' expected_listings_1 = [ 'A%First something 1234 (1)\n114 characters remaining', 'A%Second something 1235 (2)\n113 characters remaining', 'A%Third something LG-512a (3)\n111 characters remaining' ] expected_listings_2 = [ 'A%A%First something 1234 (1)\nCharacters % : & must be used at most once', 'A%A%Second something 1235 (2)\nCharacters % : & must be used at most once', 'A%A%Third something LG-512a (3)\nCharacters % : & must be used at most once' ] select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) input_field = bp.operation_input() # Test single restricted char - OK send_keys(input_field, BACKSPACE_KEYS + 'A' + restricted_char) error_msg = bp.error_baloon() assert error_msg == '' # Apply (client only) click(bp.operation_apply()) sleep(1) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ') # Test another restricted char - Err send_keys(input_field, BACKSPACE_KEYS + 'A' + restricted_char) error_msg = bp.error_baloon() listings = bp.listing_rows_texts_sorted() assert error_msg == '' assert listings == expected_listings_2 # Error per listing with double %
def test_inline_holiday_change(self): """ Tests setting/changing holiday on a listing using inline edit """ self.custom_setup('listings_push_attributes') expected_listings = [ 'Four\nThe category of this listing does not support holiday', 'One\nEaster', 'Three\nVeterans\' Day', 'Two\nFather\'s Day' ] expected_api_calls = [{ 'PUT': '/v2/listings/100001/attributes/46803063659?value_ids=37', 'body': {} }, { 'PUT': '/v2/listings/100002/attributes/46803063659?value_ids=38', 'body': {} }, { 'PUT': '/v2/listings/100003/attributes/46803063659?value_ids=49', 'body': {} }] select_listings_to_edit(self.driver) bp = BulkPage(self.driver) # set holiday bp.select_single_holiday('One', 'Easter') # change holiday bp.select_single_holiday('Two', 'Father\'s Day') bp.select_single_holiday('Three', 'Veterans\' Day') # Check listings actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings # Check that sync button is enabled and blue dot is displayed after clicking on Apply wait_for_web_assert(True, bp.sync_updates_button().is_enabled, 'Sync button is not enabled') assert bp.is_part_modified( 'Holiday') is True, 'Blue dot didn\'t show up' # Sync changes click(bp.sync_updates_button()) # Check that sync button is disabled and blue dot is not displayed after clicking on Sync wait_for_web_assert(False, bp.sync_updates_button().is_enabled, 'Sync button is not disabled') assert bp.is_part_modified( 'Holiday') is False, 'Blue dot is still shown' # Check holiday data in DB and Etsy requests check_etsy_emulator_requests(expected_api_calls)
def test_bulk_holiday_delete(self): """ Tests deleting holiday from listings using bulk """ self.custom_setup('listings_delete_holiday_bulk') expected_listings = [ 'Four\nThe category of this listing does not support holiday', 'One\nChoose Holiday', 'Three\nChoose Holiday', 'Two\nChoose Holiday' ] expected_holiday_db = [] expected_api_calls = [{ 'DELETE': '/v2/listings/100002/attributes/46803063659', 'body': {} }, { 'DELETE': '/v2/listings/100003/attributes/46803063659', 'body': {} }] # Delete holiday from listings using bulk select_listings_to_edit(self.driver, 'None') bp = BulkPage(self.driver) # Apply changes and check listings click(bp.operation_apply()) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings # Check that sync button is enabled and blue dot is displayed after clicking on Apply wait_for_web_assert(True, bp.sync_updates_button().is_enabled, 'Sync button is not enabled') assert bp.is_part_modified( 'Holiday') is True, 'Blue dot didn\'t show up' # Sync changes click(bp.sync_updates_button()) # Check that sync button is disabled and blue dot is not displayed after clicking on Sync wait_for_web_assert(False, bp.sync_updates_button().is_enabled, 'Sync button is not disabled') assert bp.is_part_modified( 'Holiday') is False, 'Blue dot is still shown' # Check Etsy requests and holiday data in DB after resync check_etsy_emulator_requests(expected_api_calls) check_db_state(expected_holiday_db)
def test_inline_occasion_change(self): """ Tests setting/changing of occasion on listings using inline edit """ self.custom_setup('listings_push_attributes') expected_listings = [ 'Four\nThe category of this listing does not support occasion', 'One\nEngagement', 'Three\nChoose Occasion', 'Two\nWedding' ] expected_api_calls = [{ 'PUT': '/v2/listings/100001/attributes/46803063641?value_ids=22', 'body': {} }, { 'PUT': '/v2/listings/100002/attributes/46803063641?value_ids=32', 'body': {} }] select_listings_to_edit(self.driver) bp = BulkPage(self.driver) # Change occasion bp.select_single_occasion('One', 'Engagement') # Set occasion bp.select_single_occasion('Two', 'Wedding') # Check listings actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings # Check that sync button is enabled and blue dot is displayed after clicking on Apply wait_for_web_assert(True, bp.sync_updates_button().is_enabled, 'Sync button is not enabled') assert bp.is_part_modified( 'Occasion') is True, 'Blue dot didn\'t show up' # Sync changes click(bp.sync_updates_button()) # Check that sync button is disabled and blue dot is not displayed after clicking on Sync wait_for_web_assert(False, bp.sync_updates_button().is_enabled, 'Sync button is not disabled') assert bp.is_part_modified( 'Occasion') is False, 'Blue dot is still shown' # Check occasion data in Etsy requests check_etsy_emulator_requests(expected_api_calls)
def test_bulk_holiday_set(self): """ Tests setting/changing holiday using bulk on listings """ self.custom_setup('listings_push_attributes') expected_listings = [ 'Four\nThe category of this listing does not support holiday', 'One\nChristmas', 'Three\nChristmas', 'Two\nChristmas' ] expected_api_calls = [{ 'PUT': '/v2/listings/100001/attributes/46803063659?value_ids=35', 'body': {} }, { 'PUT': '/v2/listings/100002/attributes/46803063659?value_ids=35', 'body': {} }, { 'PUT': '/v2/listings/100003/attributes/46803063659?value_ids=35', 'body': {} }] # Set/change holiday using bulk select_listings_to_edit(self.driver, 'Christmas') bp = BulkPage(self.driver) # Apply changes and check listings click(bp.operation_apply()) actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings # Check that sync button is enabled and blue dot is displayed after clicking on Apply wait_for_web_assert(True, bp.sync_updates_button().is_enabled, 'Sync button is not enabled') assert bp.is_part_modified( 'Holiday') is True, 'Blue dot didn\'t show up' # Sync changes click(bp.sync_updates_button()) # Check that sync button is disabled and blue dot is not displayed after clicking on Sync wait_for_web_assert(False, bp.sync_updates_button().is_enabled, 'Sync button is not disabled') assert bp.is_part_modified( 'Holiday') is False, 'Blue dot is still shown' # Check holiday data in DB and Etsy requests check_etsy_emulator_requests(expected_api_calls)
def test_title_delete_first_char(self): """ Tests title delete - first character must be alphanumeric """ expected_listings_1 = [ 'First something 1234 (1)\nMust begin with alphanumerical character', 'Second something 1235 (2)\n115 characters remaining', 'Third something LG-512a (3)\n113 characters remaining' ] expected_listings_2 = [ 'First something 1234 (1)\n116 characters remaining', 'Second something 1235 (2)\n115 characters remaining', 'Third something LG-512a (3)\n113 characters remaining' ] select_listings_to_edit(self.driver, 'Delete') d = self.driver bp = BulkPage(d) input_field = bp.operation_input() # Normal Delete send_keys(input_field, 'First') # title starts with a space now -> Error sleep(2) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 # Apply (client only) click(bp.operation_apply()) sleep(1) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_2 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ')
def test_inline_occasion_delete(self): """ Tests deleting occasion from a listing using inline edit """ self.custom_setup('listings_delete_occasion') expected_listings = [ 'Four\nThe category of this listing does not support occasion', 'One\nChoose Occasion', 'Three\nChoose Occasion', 'Two\nChoose Occasion' ] expected_occasion_db = [] expected_api_calls = [{ 'DELETE': '/v2/listings/100001/attributes/46803063641', 'body': {} }] select_listings_to_edit(self.driver) bp = BulkPage(self.driver) # Delete occasion from listing bp.select_single_occasion('One', 'None') # Check listings actual_listings = bp.listing_rows_texts_sorted() assert actual_listings == expected_listings # Check that sync button is enabled and blue dot is displayed after clicking on Apply wait_for_web_assert(True, bp.sync_updates_button().is_enabled, 'Sync button is not enabled') assert bp.is_part_modified( 'Occasion') is True, 'Blue dot didn\'t show up' # Sync changes click(bp.sync_updates_button()) # Check that sync button is disabled and blue dot is not displayed after clicking on Sync wait_for_web_assert(False, bp.sync_updates_button().is_enabled, 'Sync button is not disabled') assert bp.is_part_modified( 'Occasion') is False, 'Blue dot is still shown' # Check Etsy requests and occasion data in DB after resync check_etsy_emulator_requests(expected_api_calls) check_db_state(expected_occasion_db)
def test_title_add_before_correct(self): """ Tests that correct text can be added before """ expected_listings = [ 'hello First something 1234 (1)\n110 characters remaining', 'hello Second something 1235 (2)\n109 characters remaining', 'hello Third something LG-512a (3)\n107 characters remaining' ] select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) input_field = bp.operation_input() send_keys(input_field, 'hello ') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings
def test_delete_single_tag(self): """ Tests that single tag can be deleted """ select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) row = bp.listing_row('First something 1234 (1)') tag_names = bp.tag_names(row) assert tag_names == ['Tag01'] tags = bp.tag_elements(row) close_icon = tags[0].find_element_by_css_selector('span.close') click(close_icon) sleep(2) tag_names = bp.tag_names(row) assert tag_names == [] titles = bp.listing_rows_texts_sorted() assert titles[0] == "First something 1234 (1)\n13 remaining"
def test_bulk_edit_view_listings_base(self): """ Tests that the bulk edit view shows the listings """ d = self.driver pg = MainPage(d) bp = BulkPage(d) checked_listings_page_1 = [ 'Fifth something (5)', 'First something 1234 (1)', 'Forth something 123456 (4)', ] bulk_listings_page_1 = [ 'Fifth something (5)\n121 characters remaining', 'First something 1234 (1)\n116 characters remaining', 'Forth something 123456 (4)\n114 characters remaining' ] pg.select_filter_tab('Active') sleep(1) # check checkboxes page 1 [checked_listings_page_1] listing_rows = pg.listing_rows() listings_to_select = [ r for r in listing_rows if r.find_element_by_css_selector('div.table-row-column div.title' ).text in checked_listings_page_1 ] for listing_row in listings_to_select: click(listing_row) # click the Edit Listings edit_listings_button = pg.edit_listings_button() click(edit_listings_button) sleep(1) # check the listings listing_titles = bp.listing_rows_texts_sorted() assert listing_titles == bulk_listings_page_1
def test_delete_single_material(self): """ Tests that single material can be deleted """ select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) row = bp.listing_row('First something 1234 (1)') material_names = bp.material_names(row) assert material_names == ['wool'] materials = bp.material_elements(row) close_icon = materials[0].find_element_by_css_selector('span.close') click(close_icon) sleep(1) material_names = bp.material_names( bp.listing_row('First something 1234 (1)')) assert material_names == [] titles = bp.listing_rows_texts_sorted() assert titles[0] == "First something 1234 (1)\n13 remaining"
def test_title_add_before_uncheck(self): """ Tests add before where a listing is unselected """ expected_listings_1 = [ 'Hello First something 1234 (1)\n110 characters remaining', 'Hello Second something 1235 (2)\n109 characters remaining', 'Hello Third something LG-512a (3)\n107 characters remaining' ] expected_listings_2 = [ 'Hello First something 1234 (1)\n110 characters remaining', 'Hello Second something 1235 (2)\n109 characters remaining', 'Third something LG-512a (3)\n113 characters remaining' ] select_listings_to_edit(self.driver) d = self.driver bp = BulkPage(d) input_field = bp.operation_input() listing_row = bp.listing_row('Third something LG-512a (3)', bp.TITLE_ROW_SELECTOR) # Normal add before send_keys(input_field, 'Hello ') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 # Uncheck Third row click(listing_row) sleep(2) row_class = listing_row.get_attribute('class') assert 'selected' not in row_class.split(' ') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_2 # Check Third row click(listing_row) sleep(2) row_class = listing_row.get_attribute('class') assert 'selected' in row_class.split(' ') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_1 # Uncheck Third row click(listing_row) sleep(2) row_class = listing_row.get_attribute('class') assert 'selected' not in row_class.split(' ') listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_2 # Apply (client only) click(bp.operation_apply()) sleep(1) listings = bp.listing_rows_texts_sorted() assert listings == expected_listings_2 apply_class = bp.operation_apply().get_attribute('class') assert 'inactive' in apply_class.split(' ')