1
0
Fork 0
liza/test/bucket/StagingBucketTest.js

282 lines
8.0 KiB
JavaScript
Raw Normal View History

/**
* Test of staging key/value store
*
* Copyright (C) 2017 R-T Specialty, LLC.
*
* This file is part of liza.
*
* liza is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @todo This needs tests for the rest of StagingBucket
*/
"use strict";
const { Class } = require( 'easejs' );
const root = require( '../../' );
const expect = require( 'chai' ).expect;
const sinon = require( 'sinon' );
const {
Bucket,
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
StagingBucket: Sut,
// TODO: decouple test from this
QuoteDataBucket,
} = root.bucket;
describe( 'StagingBucket', () =>
{
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
it( 'pre-update event allows updating data before set', () =>
{
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
const sut = Sut( createStubBucket() );
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
const data = {
foo: [ 'bar', 'baz' ],
};
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
sut.on( 'preStagingUpdate', data =>
{
data.foo[ 1 ] = 'quux';
} );
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
// triggers setValues
sut.setValues( data );
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
expect( sut.getDataByName( 'foo' ) )
.to.deep.equal( [ 'bar', 'quux' ] );
} );
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
[
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'bar', 'baz' ] },
is_change: false,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: {},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
// actual changes
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'change', 'baz' ] },
is_change: true,
expected: {
data: { foo: [ 'change', 'baz' ] },
diff: { foo: [ 'change' ] },
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'bar', 'change' ] },
is_change: true,
expected: {
data: { foo: [ 'bar', 'change' ] },
diff: { foo: [ , 'change' ] },
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ undefined, 'change' ] },
is_change: true,
expected: {
data: { foo: [ 'bar', 'change' ] },
diff: { foo: [ , 'change' ] },
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ undefined, 'baz' ] },
is_change: false,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: {},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'bar', undefined ] },
is_change: false,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: {},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'bar', null ] },
is_change: true,
expected: {
data: { foo: [ 'bar' ] },
diff: { foo: [ , null ] },
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'bar', 'baz', null ] },
is_change: false,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: {},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [ 'bar', 'baz', 'quux' ] },
is_change: true,
expected: {
data: { foo: [ 'bar', 'baz', 'quux' ] },
diff: { foo: [ , , 'quux' ]},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
{
initial: { foo: [ 'bar', 'baz' ] },
update: { foo: [] },
is_change: false,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: {},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
// null not at end of set means unchanged
{
initial: { foo: [ 'bar', 'baz', 'quux' ] },
update: { foo: [ null, null, 'quux' ] },
is_change: false,
expected: {
data: { foo: [ 'bar', 'baz', 'quux' ] },
diff: {},
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
// but the last one is
{
initial: { foo: [ 'bar', 'baz', 'quux' ] },
update: { foo: [ null, 'baz', null ] },
is_change: true,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: { foo: [ , , null ] },
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
// given a string of nulls, only the last one is terminating; the
// rest are interpreted as undefined (because JSON serializes
// undefined values to `null' -_-)
{
initial: { foo: [ 'bar', 'baz', 'quux' ] },
update: { foo: [ null, null, null ] },
is_change: true,
expected: {
data: { foo: [ 'bar', 'baz' ] },
diff: { foo: [ , , null ] },
},
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
},
].forEach( ( { initial, update, is_change, expected }, i ) =>
{
it( `pre-commit, properly processes diff and change (${i})`, () =>
{
const sut = Sut( createStubBucket() );
let called = false;
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
sut.setValues( initial );
expect( sut.getDiff() ).to.deep.equal( initial );
sut.on( 'preStagingUpdate', () => called = true );
sut.setValues( update );
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
expect( called ).to.equal( is_change );
if ( expected )
{
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
expect( sut.getData() ).to.deep.equal( expected.data );
}
} );
it( `post-commit, properly processes diff and change (${i})`, () =>
{
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
const sut = Sut( createStubBucket() );
let called = false;
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
sut.setValues( initial );
sut.commit();
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
sut.on( 'preStagingUpdate', () => called = true );
sut.setValues( update );
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
expect( called ).to.equal( is_change );
if ( expected )
{
expect( sut.getData() ).to.deep.equal( expected.data );
expect( sut.getDiff() ).to.deep.equal( expected.diff );
}
} );
} );
describe( "#setCommittedValues", () =>
{
it( "bypasses staging bucket without no bypass flag", () =>
{
const b = createStubBucket();
const bmock = sinon.mock( b );
const data = { foo: [ "bar" ] };
const sut = Sut( b );
bmock.expects( 'setValues' )
.once()
.withExactArgs( data );
sut.setCommittedValues( data );
// no diff if bypassed
expect( sut.getDiff() ).to.deep.equal( {} );
bmock.verify();
} );
it( "does not bypasses staging bucket with no bypass flag", () =>
{
const b = createStubBucket();
const bmock = sinon.mock( b );
const data = { foo: [ "bar" ] };
const sut = Sut( b );
bmock.expects( 'setValues' ).never();
sut.forbidBypass();
sut.setCommittedValues( data );
// should have been staged
expect( sut.getDiff() ).to.deep.equal( data );
bmock.verify();
} );
} );
} );
function createStubBucket( bucket_obj )
{
[DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls This mixes in support for non-terminating nulls. It would have been nice to handle that in a separate commit for clarity, but the refactoring came as a consequence of trying to provide a working implementation. Various inconsistencies and subtle bugs in unlikely situations have been fixed by this, including modifying objects passed as arguments to various methods, and inconsistent handling of diff data. Changes are more consistently recognized. Perhaps the most noticeable consequence is that moving between steps no longer prompts to discard changes---previously calculated values would trigger the dirty flag on steps even if the user didn't actually change anything. I (and others) have wanted this fixed for many years. This is a very dense commit that touches a core part of the system. Hopefully the Changelog below helps. * src/bucket/Bucket.js (setValues): [BC-BREAK] Remove parameters `merge_index' and `merge_null' parameters. * src/bucket/DelayedStagingBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove distinction between `merge_index' and non-. * src/bucket/QuoteDataBucket.js (setValues): [BC-BREAK] Remove `merge_index' and `merge_null parameters. Remove respective arguments from `_mergeData' call. (_mergeData): Remove same parameters. Remove handling of `merge_index' and `merge_null'. (overwriteValues): Append `null' to each vector. * src/bucket/StagingBucket.js (_initState): Use `Object.create' instead of explicit prototype instantiation (functionally equivalent). (merge): Minor comment correction. (_hasChanged): Rename to `_parseChanges'. (_parseChanges): Rename from `_hasChanged'. Remove `merge_index' parameter. Generate new object rather than mutation original data (prevent dangerous and subtle bugs from side-effects). Clone each vector rather than modifying/referencing directly (this was previously done during merge). Remove `merge_index' distinction. Handle non-terminating `null' values. (setValues): [BC-BREAK] Remove `merge_index' and `merge_null' parameters. Use new object generated by `_parseChanges'. Remove cloning of each vector (`_parseChanges' now does that). Remove `merge_index' distinction. (overwriteValues): Remove argument to `setValues' call. (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'. (commit): Remove second and third arguments of call to `setValues' of underlying bucket. * src/client/Client.js (_initStepUi): Remove second argument of calls to quote `setData'. * src/client/quote/ClientQuote.js (setData): [BC-BREAK] Remove `merge_nulls' parameter. Remove second and third arguments of call to staging bucket `setValues'. Add comment indicating a long-standing problem with committing the staging bucket contents before save has succeeded. * src/server/request/DataProcessor.js (processDiff): Remove `permit_null' argument of `sanitizeDiff' call. (sanitizeDiff): Remove `permit_null' parameter. Hard-code filter call's `permit_null' argument to `true'. (_determineDapiFields): Properly handle `null's (ignore) rather than inadvertently converting them into the string "null". * test/bucket/StagingBucketTest.js: Modify test cases accordingly. Add tests to verify that updates and diffs operate as expected, especially support for non-terminating `null's. (createStubBucket): Use `QuoteDataBucket'. Ideally remove this coupling in the future, but this is a more realistic test case for the time being. * test/server/request/DataProcessorTest.js: Update test to account for hard-coded `given_null' argument.
2017-09-05 16:33:46 -04:00
return QuoteDataBucket();
}