def test_language_switch_in_react(self): # You can change from "en" to "el" and back and the UI will be translated b = self.browser login(b, self.user.email, self.user.email) b.visit("/workflows") # Start in workflows page with en b.assert_element( 'form.create-workflow button[type="submit"]', text="Create your first workflow", wait=True, ) # Change locale to el switch_locale_react(b, "Language", "Ελληνικά") b.assert_element( 'form.create-workflow button[type="submit"]', text="Δημιουργήστε την πρώτη σας ροή εργασιών", wait=True, ) # Move to another page and confirm it's in el too b.click_link("Συνταγές") b.assert_element("h1", text="Συνταγές", wait=True) # Change locale to en again switch_locale_react(b, "Γλώσσα", "English") b.assert_element("a", text="Community workflows", wait=True)
def test_report_share_public(self): user1 = self.account_admin.create_user("*****@*****.**") self._create_workflow(title="Example Workflow") self._build_chart() # Share report with public b = self.browser b.click_button("Report Editor") # switch to report with b.scope(".share-card"): b.click_button("Edit privacy", wait=True) with b.scope(".share-modal", wait=True): # wait for dialog b.choose("Public") # Wait for server response b.assert_element("fieldset.share-public-options:not(:disabled)", wait=True) b.click_button("Close") url = b.value(".share-url input", wait=True) # user1 can view the report accounts.logout(b) accounts.login(b, user1.email, user1.password) b.visit(url) b.assert_element("h1", text="Example Workflow", wait=True) # anonymous user can view the report accounts.logout(b) b.visit(url) b.assert_element("h1", text="Example Workflow", wait=True)
def test_report_share_public(self): user1 = self.account_admin.create_user('*****@*****.**') self._create_workflow(title='Example Workflow') self._build_chart() # Share report with public b = self.browser b.click_button('Report') # switch to report with b.scope('.share-card'): b.click_button('Edit Privacy', wait=True) with b.scope('.share-modal', wait=True): # wait for dialog b.check('Anyone can view') # This fires and forgets an AJAX request. Wait for it to finish. time.sleep(2) b.click_button('Close') b.assert_element('.share-card .accessible-to', text='Anyone can view') url = b.text('.share-card .url .copy', wait=True) # user1 can view the report accounts.logout(b) accounts.login(b, user1.email, user1.password) b.visit(url) b.assert_element('h1', text='Example Workflow', wait=True) # anonymous user can view the report accounts.logout(b) b.visit(url) b.assert_element('h1', text='Example Workflow', wait=True)
def test_share_read_write(self): b = self.browser accounts.login(b, '*****@*****.**', '*****@*****.**') self._create_workflow() url = self._share_workflow_with('*****@*****.**', True) self.browser.clear_cookies() accounts.login(b, '*****@*****.**', '*****@*****.**') b.visit(url) # We see things b.assert_element('.wf-module[data-module-name="Paste data"]', wait=True) # We can edit them b.fill_in('csv', 'A,B\n1,2') b.click_button('submit') b.assert_element('.column-key', text='A', wait=True) # We can view collaborators, read-only b.click_button('Share') with b.scope('.share-modal', wait=True): # wait for dialog b.assert_element('.acl-entry.owner', text='*****@*****.**', wait=True) # wait for collaborator list b.assert_element('.acl-entry .email', text='*****@*****.**') b.assert_no_element('button.delete') # can't edit collaborators
def test_remember_locale_on_login(self): # When a user logs out, their locale continues to be used. # When a user logs in, the locale they used the last time they were logged in is used. b = self.browser # Login (in English) login(b, self.user.email, self.user.email) b.visit("/workflows") b.assert_element( 'form.create-workflow button[type="submit"]', text="Create your first workflow", wait=True, ) # Switch to Greek and then logout. After logout, page must still be in Greek. switch_locale_react(b, "Language", "Ελληνικά") logout(b) b.assert_element('input[name="password"][placeholder="Συνθηματικό"]', wait=True) b.assert_element('button[type="submit"]', text="Σύνδεση") # Switch to English and then login. After login, page must be in Greek. switch_locale_django(b, "English") login(b, self.user.email, self.user.email) b.assert_element( 'form.create-workflow button[type="submit"]', text="Δημιουργήστε την πρώτη σας ροή εργασιών", wait=True, )
def test_tab_deps(self): b = self.browser accounts.login(b, '*****@*****.**', '*****@*****.**') self._create_workflow() self.add_wf_module('Paste data') b.fill_in('csv', 'foo,bar\n1,2', wait=True) self.submit_wf_module() # Switch to Tab 2 b.click_button('Create tab') self._select_tab('Tab 2') b.assert_no_element('.wf-module[data-module-name="Paste data"]') # Load data from tab 1 self.add_wf_module('Start from tab') self.select_tab_param('Start from tab', 'tab', 'Tab 1') self.submit_wf_module() # Wait for data to load from tab 1 b.assert_element('.data-grid-column-header', text='bar', wait=True) # Confirm changes to tab 1 affect tab 2 # We'll change the Tab1 colnames from "foo,bar" to "bar,baz" and check # Tab2's output changed, too. self._select_tab('Tab 1') b.fill_in('csv', 'bar,baz\n1,2', wait=True) self.submit_wf_module() self._select_tab('Tab 2') # Wait for tab1's data to go away (in case there's a race somewhere) b.assert_no_element('.data-grid-column-header', text='foo', wait=True) b.assert_element('.data-grid-column-header', text='baz', wait=True)
def test_tab_cycle(self): b = self.browser accounts.login(b, '*****@*****.**', '*****@*****.**') self._create_workflow() # Create Tab 2, and make Tab 1 depend on it b.click_button('Create tab') # wait for server to add it b.assert_no_element('.tabs>ul>li.pending', wait=True) # make Tab 1 depend on Tab 2 self.add_wf_module('Start from tab') self.select_tab_param('Start from tab', 'tab', 'Tab 2') self.submit_wf_module() # Now make Tab 2 depend on Tab 1 self._select_tab('Tab 2') self.add_wf_module('Start from tab') self.select_tab_param('Start from tab', 'tab', 'Tab 1') self.submit_wf_module(wait=True) # wait for previous render to end b.assert_element('.wf-module-error-msg', text='The chosen tab depends on this one', wait=True) # wait for render self._select_tab('Tab 1') b.assert_element('.wf-module-error-msg', text='The chosen tab depends on this one')
def test_everybody_gets_a_version(self): b = self.browser url = self._create_example_workflow() def wait_for_page_load_then_edit(): # wait for page load _and_ assert the edit has not happened b.assert_element(".module-name", text="Drop empty columns", wait=True) self.delete_wf_module(1) # Wait for output to update b.assert_element(".column-key", text="baz", wait=True) # Anonymous b.visit(url) wait_for_page_load_then_edit() b.clear_cookies() # User1 accounts.login(b, self.user1.email, self.user1.email) b.visit(url) wait_for_page_load_then_edit() b.clear_cookies() # Owner accounts.login(b, self.admin.email, self.admin.email) b.visit(url) wait_for_page_load_then_edit() b.clear_cookies() # Now a new anonymous user will see the edits b.visit(url) b.assert_element(".module-name", text="Paste data", wait=True) b.assert_no_element(".module-name", text="Drop empty columns")
def test_report_share_with_collaborators(self): user1 = self.account_admin.create_user('*****@*****.**') user2 = self.account_admin.create_user('*****@*****.**') self._create_workflow(title='Example Workflow') self._build_chart() # Share report with user1, but not user2 b = self.browser b.click_button('Report') # switch to report with b.scope('.share-card'): b.click_button('Edit Privacy', wait=True) with b.scope('.share-modal', wait=True): # wait for dialog b.fill_in('email', user1.email) b.click_button('Grant access') # This fires and forgets an AJAX request. Wait for it to finish. time.sleep(2) b.click_button('Close') b.assert_element('.share-card .accessible-to', text='Only collaborators') url = b.text('.share-card .url .copy', wait=True) # user1 can view the report accounts.logout(b) accounts.login(b, user1.email, user1.password) b.visit(url) b.assert_element('h1', text='Example Workflow', wait=True) # user2 can't access the report (we test for its title) accounts.logout(b) accounts.login(b, user2.email, user2.password) b.visit(url) b.assert_no_element('h1', text='Example Workflow', wait=True)
def test_tab_deps(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() self.add_data_step("Paste data") b.fill_in("csv", "foo,bar\n1,2", wait=True) self.submit_wf_module() # Switch to Tab 2 b.click_button("Create tab") self._select_tab("Tab 2") b.assert_no_element('.wf-module[data-module-name="Paste data"]') # Load data from tab 1 self.add_data_step("Start from tab") self.select_tab_param("Start from tab", "tab", "Tab 1") self.submit_wf_module() # Wait for data to load from tab 1 b.assert_element(".data-grid-column-header", text="bar", wait=True) # Confirm changes to tab 1 affect tab 2 # We'll change the Tab1 colnames from "foo,bar" to "bar,baz" and check # Tab2's output changed, too. self._select_tab("Tab 1") b.fill_in("csv", "bar,baz\n1,2", wait=True) self.submit_wf_module() self._select_tab("Tab 2") # Wait for tab1's data to go away (in case there's a race somewhere) b.assert_no_element(".data-grid-column-header", text="foo", wait=True) b.assert_element(".data-grid-column-header", text="baz", wait=True)
def test_tabs_have_distinct_modules(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() self.import_module("pastecsv") self.add_data_step("Paste data") b.fill_in("csv", "A,B\n1,2,\n2,3", wait=True) b.click_button("Create tab") # Switch to Tab 2 self._select_tab("Tab 2") b.assert_no_element('.step[data-module-name="Paste data"]') # Add a module that should not appear on Tab 1 self.import_module("loadurl") self.add_data_step("Load from URL") # Switch to Tab 1 self._select_tab("Tab 1") b.assert_element('.step[data-module-name="Paste data"]') b.assert_no_element('.step[data-module-name="Load from URL"]')
def test_report_share_public(self): user1 = self.account_admin.create_user("*****@*****.**") self._create_workflow(title="Example Workflow") self._build_chart() # Share report with public b = self.browser b.click_button("Report") # switch to report with b.scope(".share-card"): b.click_button("Edit privacy", wait=True) with b.scope(".share-modal", wait=True): # wait for dialog b.check("Anyone can view") # This fires and forgets an AJAX request. Wait for it to finish. time.sleep(2) b.click_button("Close") b.assert_element(".share-card .accessible-to", text="Anyone can view") url = b.value(".share-url input", wait=True) # user1 can view the report accounts.logout(b) accounts.login(b, user1.email, user1.password) b.visit(url) b.assert_element("h1", text="Example Workflow", wait=True) # anonymous user can view the report accounts.logout(b) b.visit(url) b.assert_element("h1", text="Example Workflow", wait=True)
def setUp(self): super().setUp() self.user = self.account_admin.create_user('*****@*****.**') self.user_email = self.account_admin.verify_user_email(self.user) accounts.login(self.browser, self.user.email, self.user.email)
def test_share_read_write(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() self._share_workflow_with("*****@*****.**", "Can edit") url = b.get_url() self.browser.clear_cookies() accounts.login(b, "*****@*****.**", "*****@*****.**") b.visit(url) # We see things b.assert_element('.step[data-module-name="Paste data"]', wait=True) # We can edit them b.fill_in("csv", "A,B\n1,2") self.submit_step() b.assert_element(".column-key", text="A", wait=True) # We can view collaborators, read-only b.click_button("Share") with b.scope(".share-modal", wait=True): # wait for dialog b.assert_element(".acl-entry.owner", text="*****@*****.**") b.assert_element(".acl-entry .email", text="*****@*****.**") b.assert_no_element("button.delete") # can't edit collaborators
def setUp(self): super().setUp() # is_staff=True so user can import modules to use in e.g. lesson tests self.user = self.account_admin.create_user("*****@*****.**", is_staff=True) accounts.login(self.browser, self.user.email, self.user.email)
def test_share_read_only(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() url = self._share_workflow_with("*****@*****.**", False) self.browser.clear_cookies() accounts.login(b, "*****@*****.**", "*****@*****.**") b.visit(url) # We see things b.assert_element('.wf-module[data-module-name="Paste data"]', wait=True) # We can't edit them b.assert_no_element("button", text="ADD STEP") # We can view collaborators, read-only b.click_button("Share") with b.scope(".share-modal", wait=True): # wait for dialog b.assert_element(".acl-entry.owner", text="*****@*****.**") b.assert_element(".acl-entry .email", text="*****@*****.**") b.assert_no_element("button.delete") # can't edit collaborators
def test_tab_cycle(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() self.import_module("pastecsv") self.import_module("startfromtab") # Create Tab 2, and make Tab 1 depend on it b.click_button("Create tab") # wait for server to add it b.assert_no_element(".tabs>ul>li.pending", wait=True) # make Tab 1 depend on Tab 2 self.add_data_step("Start from tab") self.select_tab_param("Start from tab", "tab", "Tab 2") self.submit_step() # Now make Tab 2 depend on Tab 1 self._select_tab("Tab 2") self.add_data_step("Start from tab") self.select_tab_param("Start from tab", "tab", "Tab 1") self.submit_step(wait=True) # wait for previous render to end b.assert_element(".step-error-msg", text="The chosen tab depends on this one", wait=True) # wait for render self._select_tab("Tab 1") b.assert_element(".step-error-msg", text="The chosen tab depends on this one")
def test_report_share_with_collaborators(self): user1 = self.account_admin.create_user("*****@*****.**") user2 = self.account_admin.create_user("*****@*****.**") self._create_workflow(title="Example Workflow") self._build_chart() # Share report with user1, but not user2 b = self.browser b.click_button("Report") # switch to report with b.scope(".share-card"): b.click_button("Edit privacy", wait=True) with b.scope(".share-modal", wait=True): # wait for dialog b.fill_in("email", user1.email) b.click_button("Grant access") # This fires and forgets an AJAX request. Wait for it to finish. time.sleep(2) b.click_button("Close") b.assert_element(".share-card .accessible-to", text="Only collaborators") url = b.value(".share-url input", wait=True) # user1 can view the report accounts.logout(b) accounts.login(b, user1.email, user1.password) b.visit(url) b.assert_element("h1", text="Example Workflow", wait=True) # user2 can't access the report accounts.logout(b) accounts.login(b, user2.email, user2.password) b.visit(url) b.assert_element(".error-number", text="403", wait=True)
def test_lesson_list_logged_in(self): self.user = self.account_admin.create_user("*****@*****.**") accounts.login(self.browser, self.user.email, self.user.email) b = self.browser b.visit("/lessons/") b.assert_element("h2", text="1. Load public data and make a chart", wait=True)
def test_lesson_list_logged_in(self): self.user = self.account_admin.create_user('*****@*****.**') accounts.login(self.browser, self.user.email, self.user.email) b = self.browser b.visit('/lessons/') b.assert_element('h2', text='I. Load public data and make a chart', wait=True)
def test_js_english_interpolation(self): # "by {owner}" is a message that uses JS interpolation # It's in WorkflowNavBar.js b = self.browser login(b, self.user.email, self.user.email) b.visit("/workflows/") b.click_button("Create your first workflow") # Wait for page to load b.assert_element('input[name="name"][value="Untitled Workflow"]', wait=True) b.assert_element(".attribution .metadata", text="by Jane Doe")
def test_lesson_detail_logged_in(self): self.user = self.account_admin.create_user('*****@*****.**') accounts.login(self.browser, self.user.email, self.user.email) b = self.browser b.visit('/lessons/') b.click_whatever('h2', text='I. Load public data and make a chart', wait=True) b.assert_element('.module-stack') b.assert_element('h2', text='Overview') b.assert_element('.current-and-total', text='1 of 4') b.click_button('Next') b.assert_element('h2', text='Load Public Data by URL')
def test_lesson_detail_logged_in(self): self.user = self.account_admin.create_user("*****@*****.**") accounts.login(self.browser, self.user.email, self.user.email) b = self.browser b.visit("/lessons/") b.click_whatever("h2", text="1. Load public data and make a chart", wait=True) b.assert_element(".step-list") b.assert_element("h2", text="Overview") b.assert_element(".current-and-total", text="1 of 4") b.click_button("Next") b.assert_element("h2", text="Load Public Data by URL")
def test_start_from_empty_tab(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() # Create Tab 2, and make Tab 1 depend on it b.click_button("Create tab") # wait for server to add it b.assert_no_element(".tabs>ul>li.pending", wait=True) # make Tab 1 depend on Tab 2 self.add_data_step("Start from tab") self.select_tab_param("Start from tab", "tab", "Tab 2") self.submit_wf_module() b.assert_element(".wf-module-error-msg", text="The chosen tab has no output. ", wait=True) # wait for render
def test_other_user_can_edit(self): self._create_example_workflow() b = self.browser accounts.login(b, self.user1.email, self.user1.email) # Demo should appear in Workflow list b.visit("/workflows/examples") # Wait for page to load b.assert_element("a", text="Example Workflow", wait=True) b.click_link("Example Workflow") # Wait for page to load b.assert_element(".module-name", text="Drop empty columns", wait=True) # Prove it's editable by editing it! self.delete_step(1) b.assert_element(".column-key", text="baz", wait=True)
def test_start_from_empty_tab(self): b = self.browser accounts.login(b, '*****@*****.**', '*****@*****.**') self._create_workflow() # Create Tab 2, and make Tab 1 depend on it b.click_button('Create tab') # wait for server to add it b.assert_no_element('.tabs>ul>li.pending', wait=True) # make Tab 1 depend on Tab 2 self.add_wf_module('Start from tab') self.select_tab_param('Start from tab', 'tab', 'Tab 2') self.submit_wf_module() b.assert_element('.wf-module-error-msg', text='The chosen tab has no output', wait=True) # wait for render
def _create_example_workflow(self): b = self.browser accounts.login(b, self.admin.email, self.admin.email) b.visit("/workflows/") b.click_button("Create Workflow") # Wait for page to load b.assert_element('input[name="name"][value="Untitled Workflow"]', wait=True) b.fill_in("name", "Example Workflow") self.import_module("pastecsv") self.add_data_step("Paste data") b.fill_in("csv", "foo,bar,baz\n1,2,\n2,3,\n3,4,", wait=True) self.submit_wf_module() self.import_module("nulldropper") self.add_wf_module("Drop empty columns") # Wait for _any_ output to load b.assert_element(".column-key", text="bar", wait=True) # Wait for the _final_ output to load -- which means the "baz" column # will not be there. b.assert_no_element(".column-key", text="baz", wait=True) # Wait for the _data_ to load -- not just the headers b.assert_element(".react-grid-Cell", text="2", wait=True) url = b.get_url() # Make it an example b.visit("/adminserver/workflow/") b.click_link("Example Workflow", wait=True) b.check("Public") b.check("Example") b.check("In all users workflow lists") b.click_button("Save") b.assert_element("li.success") b.clear_cookies() return url
def test_duplicate_tab(self): b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() self.add_data_step("Paste data") b.fill_in("csv", "foo,bar\n1,2", wait=True) self.submit_wf_module() # duplicate tab b.click_whatever(".tabs>ul>li.selected button.toggle") with b.scope(".dropdown-menu"): b.click_button("Duplicate") # wait for server to add it b.assert_no_element(".tabs>ul>li.pending", wait=True) self._select_tab("Tab 1 (1)") # assume this is how it's named # Make sure everything's there. b.assert_element('.wf-module[data-module-name="Paste data"]')
def test_duplicate_tab(self): b = self.browser accounts.login(b, '*****@*****.**', '*****@*****.**') self._create_workflow() self.add_wf_module('Paste data') b.fill_in('csv', 'foo,bar\n1,2', wait=True) self.submit_wf_module() # duplicate tab b.click_whatever('.tabs>ul>li.selected button.toggle') with b.scope('.dropdown-menu'): b.click_button('Duplicate') # wait for server to add it b.assert_no_element('.tabs>ul>li.pending', wait=True) self._select_tab('Tab 1 (1)') # assume this is how it's named # Make sure everything's there. b.assert_element('.wf-module[data-module-name="Paste data"]')
def test_403_then_log_in_as_owner(self): self.account_admin.create_user("*****@*****.**", is_staff=False) b = self.browser accounts.login(b, "*****@*****.**", "*****@*****.**") self._create_workflow() url = b.get_url() b.clear_cookies() b.visit(url) b.assert_element("h1", text="Private workflow") b.click_link("Sign in", wait=True) b.fill_in("login", "*****@*****.**") b.fill_in("password", "*****@*****.**") b.click_button("Sign In") b.wait_for_element("main.workflow-root") self.assertEqual(b.get_url(), url)