From dc07fc8baca782734215e25ef9ea6674cfb845bf Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 25 Aug 2017 18:44:09 +0200 Subject: [PATCH] [FIX] barcodes: tests: don't add undefined widget to registry Resetting the key 'test_barcode_handler' to its value before the test was technically the best solution, as a test should leave the environment unchanged. However, in this case, the widget is undefined (there is obviously no 'test_barcode_handler'). Whereas this should not be a problem (the fields in the registry are supposed to be accessed using get(), and the presence of a key mapping undefined is equivalent to the absence of the key in this case), this breaks a test in Studio if the latter one is executed after the barcode test. This is because Studio browses the map of the field registry to access each field's prototype. When it encounters an undefined value, it crashes. --- addons/barcodes/static/tests/barcode_tests.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/barcodes/static/tests/barcode_tests.js b/addons/barcodes/static/tests/barcode_tests.js index add55ed4d5d..7487972ea62 100644 --- a/addons/barcodes/static/tests/barcode_tests.js +++ b/addons/barcodes/static/tests/barcode_tests.js @@ -348,7 +348,6 @@ QUnit.test('specification of widget barcode_handler', function (assert) { }); }, }); - var previousField = fieldRegistry.get('test_barcode_handler'); fieldRegistry.add('test_barcode_handler', TestBarcodeHandler); var form = createView({ @@ -402,6 +401,6 @@ QUnit.test('specification of widget barcode_handler', function (assert) { form.destroy(); barcodeEvents.BarcodeEvents.max_time_between_keys_in_ms = delay; - fieldRegistry.add('test_barcode_handler', previousField); + delete fieldRegistry.map.test_barcode_handler; }); });