sadpandajoe commented on code in PR #40865:
URL: https://github.com/apache/superset/pull/40865#discussion_r3382725308
##########
superset-frontend/src/explore/controlUtils/standardizedFormData.test.ts:
##########
@@ -344,6 +344,47 @@ describe('should collect control values and create SFD',
() => {
]);
});
+ test('strips inherit/custom time shifts when target viz does not support
them', () => {
+ // Table/Big Number period-over-period offer "inherit" and "custom" time
+ // shifts; the timeseries advanced-analytics target (target_viz) does not.
+ // Carrying them over leaves un-removable tags on the new chart (SC-99170).
+ const store = {
+ ...sourceMockStore,
+ form_data: {
+ ...sourceMockFormData,
+ time_compare: ['1 year ago', 'inherit', 'custom'],
+ },
+ };
+ const sfd = new StandardizedFormData(store.form_data);
+ const { formData } = sfd.transform('target_viz', store);
+ // the free-form delta survives, the special markers are dropped
+ expect(formData.time_compare).toEqual(['1 year ago']);
+ });
+
+ test('preserves inherit/custom time shifts when target viz supports them',
() => {
+ getChartControlPanelRegistry().registerValue('target_viz_inherit', {
+ controlPanelSections: [
+ sections.timeComparisonControls({}),
+ {
+ label: 'transform controls',
+ controlSetRows: publicControls
+ .filter(c => c !== 'dashboardId' && c !== 'time_compare')
+ .map(control => [control]),
+ },
+ ],
+ });
+ const store = {
+ ...sourceMockStore,
+ form_data: {
+ ...sourceMockFormData,
+ time_compare: ['1 year ago', 'inherit'],
+ },
+ };
+ const sfd = new StandardizedFormData(store.form_data);
+ const { formData } = sfd.transform('target_viz_inherit', store);
+ expect(formData.time_compare).toEqual(['1 year ago', 'inherit']);
+ });
Review Comment:
The new tests only exercise the "some values survive" branch of
`filtered.length ? filtered : null`. Could we add a case where every value is
special (e.g. `time_compare: ['inherit']` → expect `null`) so the empty-result
path is locked in, along with the `time_compare: null` serialization that flows
out of `getFormDataFromControls`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]