aboutsummaryrefslogtreecommitdiff
path: root/test/haketilo_test
diff options
context:
space:
mode:
Diffstat (limited to 'test/haketilo_test')
-rw-r--r--test/haketilo_test/test_integration.py2
-rw-r--r--test/haketilo_test/unit/test_indexeddb.py44
2 files changed, 45 insertions, 1 deletions
diff --git a/test/haketilo_test/test_integration.py b/test/haketilo_test/test_integration.py
index b77afbd..88fef3c 100644
--- a/test/haketilo_test/test_integration.py
+++ b/test/haketilo_test/test_integration.py
@@ -48,7 +48,7 @@ def test_integration(driver):
driver.find_element_by_id('repos_head').click()
lst = driver.find_element_by_css_selector('.active_tab .text_entries')
- assert 'https://hydrilla.koszko.org/api_v1' in lst.text
+ assert 'https://hydrilla.koszko.org/api_v2' in lst.text
# TODO: do some more tests, including popup interaction and repository
# querying
diff --git a/test/haketilo_test/unit/test_indexeddb.py b/test/haketilo_test/unit/test_indexeddb.py
index 773f5c8..ff1b265 100644
--- a/test/haketilo_test/unit/test_indexeddb.py
+++ b/test/haketilo_test/unit/test_indexeddb.py
@@ -51,6 +51,50 @@ def make_sample_mapping():
}
@pytest.mark.get_page('https://gotmyowndoma.in')
+def test_haketilodb_update_1_0_1(driver, execute_in_page):
+ """
+ indexeddb.js modifies data when updating to database version 1.0.1. Verify
+ the update procedure works properly.
+ """
+ execute_in_page(load_script('common/indexeddb.js'))
+ execute_in_page('db_version_nr = version_nr([1, 0, 0]);')
+ mock_broadcast(execute_in_page)
+
+ # Start with no database.
+ clear_indexeddb(execute_in_page)
+
+ v1_url = 'https://hydrilla.koszko.org/api_v1/'
+ v2_url = 'https://hydrilla.koszko.org/api_v2/'
+ urls_v1 = {'https://sample.url/abc/', v1_url}
+ urls_v2 = {'https://sample.url/abc/', v2_url}
+
+ for url in urls_v1:
+ execute_in_page('returnval(set_repo(arguments[0]));', url)
+
+ assert urls_v1 == set(execute_in_page('returnval(get_repos());'))
+
+ # Verify that url gets updated to v2 upon database update.
+ driver.get(driver.execute_script('return window.location.href;'))
+ execute_in_page(load_script('common/indexeddb.js'))
+ mock_broadcast(execute_in_page)
+
+ database_contents = get_db_contents(execute_in_page)
+
+ assert set(execute_in_page('returnval(get_repos());')) == urls_v2
+
+ # Verify that url does not get updated when there is no database update.
+ execute_in_page('returnval(del_repo(arguments[0]));', v2_url)
+ execute_in_page('returnval(set_repo(arguments[0]));', v1_url)
+
+ driver.get(driver.execute_script('return window.location.href;'))
+ execute_in_page(load_script('common/indexeddb.js'))
+ mock_broadcast(execute_in_page)
+
+ database_contents = get_db_contents(execute_in_page)
+
+ assert set(execute_in_page('returnval(get_repos());')) == urls_v1
+
+@pytest.mark.get_page('https://gotmyowndoma.in')
def test_haketilodb_item_modifications(driver, execute_in_page):
"""
indexeddb.js facilitates operating on Haketilo's internal database.