diff options
Diffstat (limited to 'test/haketilo_test/unit')
-rw-r--r-- | test/haketilo_test/unit/test_indexeddb.py | 44 |
1 files changed, 44 insertions, 0 deletions
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. |