Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade react-select and make multi-select sortable #9628

Merged
merged 10 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ export default () =>
});

it('should apply filter', () => {
cy.wait(10);

cy.get('.Select-placeholder')
cy.get('.Select__control')
.contains('Select [region]')
.click()
.next()
.find('input')
.click({ force: true });
cy.get('.Select__control input[type=text]')
.first()
.type('South Asia{enter}', { force: true });

// wait again after applied filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ export default () =>
cy.wait('@treemapRequest');

// apply filter
cy.get('.Select-control')
.first()
.find('input')
cy.get('.Select__control').first().should('be.visible');
cy.get('.Select__control').first().click({ force: true });
cy.get('.Select__control input[type=text]')
.first()
.should('be.visible')
.type('South Asia{enter}', { force: true });

// send new query from same tab
Expand Down Expand Up @@ -182,8 +183,11 @@ export default () =>
.find('ul.nav.nav-tabs li')
.first()
.click();
cy.get('.tab-content ul.nav.nav-tabs li').first().click();
cy.get('span.Select-clear').click();
cy.get('.tab-content ul.nav.nav-tabs li')
.first()
.should('be.visible')
.click();
cy.get('.Select__clear-indicator').click();

// trigger 1 new query
cy.wait('@treemapRequest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
import readResponseBlob from '../../utils/readResponseBlob';

describe('No Results', () => {
beforeEach(() => {
Expand All @@ -39,7 +38,6 @@ describe('No Results', () => {
comparator: ['Fake State'],
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
ktmud marked this conversation as resolved.
Show resolved Hide resolved
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ describe('Groupby', () => {
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('[data-test=groupby]').within(() => {
cy.get('.Select-control').click();
cy.get('input.select-input').type('state', { force: true });
cy.get('.VirtualizedSelectFocusedOption').click();
cy.get('.Select__control').click();
cy.get('input[type=text]').type('state{enter}');
});
cy.get('button.query').click();
cy.verifySliceSuccess({ waitAlias: '@postJson', chartSelector: 'svg' });
Expand All @@ -50,16 +49,16 @@ describe('AdhocMetrics', () => {
});

it('Clear metric and set simple adhoc metric', () => {
const metric = 'sum(sum_girls)';
const metricName = 'Girl Births';

cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('[data-test=metrics]').within(() => {
cy.get('.select-clear').click();
cy.get('.Select-control').click({ force: true });
cy.get('input').type('sum_girls', { force: true });
cy.get('.VirtualizedSelectFocusedOption').trigger('mousedown').click();
cy.get('.Select__clear-indicator').click();
cy.get('.Select__control input').type('sum_girls');
cy.get('.Select__option--is-focused').trigger('mousedown').click();
});

cy.get('#metrics-edit-popover').within(() => {
Expand All @@ -69,30 +68,29 @@ describe('AdhocMetrics', () => {
});
cy.get('button').contains('Save').click();
});
cy.get('.Select__multi-value__label').contains(metricName);

cy.get('button.query').click();
cy.verifySliceSuccess({
waitAlias: '@postJson',
querySubstring: metricName,
querySubstring: `${metric} AS "${metricName}"`, // SQL statement
chartSelector: 'svg',
});
});

it('Clear metric and set custom sql adhoc metric', () => {
const metric = 'SUM(num)/COUNT(DISTINCT name)';

it('Switch from simple to custom sql', () => {
cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

// select column "num"
cy.get('[data-test=metrics]').within(() => {
cy.get('.select-clear').click();
cy.get('.Select-control').click({ force: true });
cy.get('input').type('num', { force: true });
cy.get('.VirtualizedSelectOption[data-test=_col_num]')
.trigger('mousedown')
.click();
cy.get('.Select__clear-indicator').click();
cy.get('.Select__control').click();
cy.get('.Select__control input').type('num');
cy.get('.option-label').contains(/^num$/).click();
});

// add custom SQL
cy.get('#metrics-edit-popover').within(() => {
cy.get('#adhoc-metric-edit-tabs-tab-SQL').click();
cy.get('.ace_content').click();
Expand All @@ -101,39 +99,56 @@ describe('AdhocMetrics', () => {
});

cy.get('button.query').click();

const metric = 'SUM(num)/COUNT(DISTINCT name)';
cy.verifySliceSuccess({
waitAlias: '@postJson',
querySubstring: metric,
querySubstring: `${metric} AS "${metric}"`,
chartSelector: 'svg',
});
});

it('Switch between simple and custom sql tabs', () => {
cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

it('Switch from custom sql tabs to simple', () => {
cy.get('[data-test=metrics]').within(() => {
cy.get('.select-clear').click();
cy.get('.Select-control').click({ force: true });
cy.get('input').type('sum_girls', { force: true });
cy.get('.VirtualizedSelectFocusedOption').trigger('mousedown').click();
cy.get('.Select__dropdown-indicator').click();
cy.get('input[type=text]').type('sum_girls{enter}');
});

cy.get('#metrics-edit-popover').within(() => {
cy.get('#adhoc-metric-edit-tabs-tab-SQL').click();
cy.get('.ace_identifier').contains('sum_girls');
cy.get('.ace_content').click();
cy.get('.ace_text-input').type('{selectall}{backspace}SUM(num)', {
force: true,
});
cy.get('.ace_text-input').type('{selectall}{backspace}SUM(num)');
cy.get('#adhoc-metric-edit-tabs-tab-SIMPLE').click();
cy.get('.select-value-label').contains('num');
cy.get('.Select__single-value').contains(/^num$/);
cy.get('button').contains('Save').click();
});

cy.get('button.query').click();

const metric = 'SUM(num)';
cy.verifySliceSuccess({
waitAlias: '@postJson',
querySubstring: `${metric} AS "${metric}"`,
chartSelector: 'svg',
});
});

it('Typing starts with aggregate function name', () => {
// select column "num"
cy.get('[data-test=metrics]').within(() => {
cy.get('.Select__dropdown-indicator').click();
cy.get('.Select__control input[type=text]').type('avg(');
cy.get('.Select__option').contains('ds');
cy.get('.Select__option').contains('name');
cy.get('.Select__option').contains('sum_boys').click();
});

const metric = 'AVG(sum_boys)';
cy.get('button.query').click();
cy.verifySliceSuccess({
waitAlias: '@postJson',
querySubstring: `${metric} AS "${metric}"`,
chartSelector: 'svg',
});
});
Expand All @@ -152,16 +167,13 @@ describe('AdhocFilters', () => {
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('[data-test=adhoc_filters]').within(() => {
cy.get('.Select-control').click({ force: true });
cy.get('input').type('name', { force: true });
cy.get('.VirtualizedSelectFocusedOption').trigger('mousedown').click();
cy.get('.Select__control').click();
cy.get('input[type=text]').type('name{enter}');
ktmud marked this conversation as resolved.
Show resolved Hide resolved
});
cy.get('.adhoc-filter-option').click({ force: true });
cy.get('#filter-edit-popover').within(() => {
cy.get('[data-test=adhoc-filter-simple-value]').within(() => {
cy.get('div.select-input').click({ force: true });
cy.get('input.select-input').type('Amy', { force: true });
cy.get('.VirtualizedSelectFocusedOption').trigger('mousedown').click();
cy.get('.Select__control').click();
cy.get('input[type=text]').type('Any{enter}');
});
cy.get('button').contains('Save').click();
});
Expand All @@ -178,16 +190,14 @@ describe('AdhocFilters', () => {
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('[data-test=adhoc_filters]').within(() => {
cy.get('.Select-control').click({ force: true });
cy.get('input').type('name', { force: true });
cy.get('.VirtualizedSelectFocusedOption').trigger('mousedown').click();
cy.get('.Select__control').click();
cy.get('input[type=text]').type('name{enter}');
});

cy.get('.adhoc-filter-option').click({ force: true });
cy.get('#filter-edit-popover').within(() => {
cy.get('#adhoc-filter-edit-tabs-tab-SQL').click();
cy.get('.ace_content').click();
cy.get('.ace_text-input').type("'Amy' OR name = 'Bob'", { force: true });
cy.get('.ace_text-input').type("'Amy' OR name = 'Bob'");
cy.get('button').contains('Save').click();
});

Expand All @@ -211,17 +221,15 @@ describe('Advanced analytics', () => {
cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('span')
.contains('Advanced Analytics')
.parent()
.siblings()
.first()
.click();
cy.get('.panel-title').contains('Advanced Analytics').click();

cy.get('[data-test=time_compare]').within(() => {
cy.get('.Select-control').click({ force: true });
cy.get('input').type('364 days', { force: true });
cy.get('.VirtualizedSelectOption').trigger('mousedown').click();
cy.get('.Select__control').click();
cy.get('input[type=text]').type('28 days{enter}');
ktmud marked this conversation as resolved.
Show resolved Hide resolved

cy.get('.Select__control').click();
cy.get('input[type=text]').type('364 days{enter}');
cy.get('.Select__multi-value__label').contains('364 days');
});

cy.get('button.query').click();
Expand All @@ -233,7 +241,8 @@ describe('Advanced analytics', () => {
});

cy.get('[data-test=time_compare]').within(() => {
cy.get('.select-value-label').contains('364 days');
cy.get('.Select__multi-value__label').contains('364 days');
cy.get('.Select__multi-value__label').contains('28 days');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('Test explore links', () => {
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('[data-test=groupby]').within(() => {
cy.get('span.select-clear-zone').click();
cy.get('.Select__clear-indicator').click();
});
cy.get('button[data-target="#save_modal"]').click();
cy.get('.modal-content').within(() => {
Expand Down Expand Up @@ -149,11 +149,11 @@ describe('Test explore links', () => {
cy.get('.modal-content').within(() => {
cy.get('input[name=new_slice_name]').type(chartName);
cy.get('input[data-test=add-to-existing-dashboard]').check();
cy.get('.select.save-modal-selector')
cy.get('.save-modal-selector')
.click()
.within(() => {
cy.get('input').type(dashboardTitle, { force: true });
cy.get('.select-option.is-focused').trigger('mousedown');
cy.get('input').type(dashboardTitle);
cy.get('.Select__option--is-focused').trigger('mousedown');
});
cy.get('button#btn_modal_save').click();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export default () =>
comparator: ['South Asia', 'North America'],
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default () =>
comparator: ['Aaron', 'Amy', 'Andrea'],
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_4y6teao56zs_ebjsvwy48c',
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default () =>
comparator: 'South Asia',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export default () =>
comparator: 'South+Asia',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_b2tfg1rs8y_8kmrcyxvsqd',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export default () =>
comparator: 'boy',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default () =>
comparator: 'girl',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_1ep6q50g8vk_48jj6qxdems',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default () =>
comparator: 'boy',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
ktmud marked this conversation as resolved.
Show resolved Hide resolved
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export default () =>
comparator: 'boy',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default () =>
},
aggregate: 'SUM',
hasCustomLabel: false,
fromFormData: false,
label: 'SUM(sum_boys)',
optionName: 'metric_gvpdjt0v2qf_6hkf56o012',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default () =>
subject: null,
operator: null,
comparator: null,
fromFormData: false,
filterOptionName: 'filter_jbdwe0hayaj_h9jfer8fy58',
},
{
Expand All @@ -70,7 +69,6 @@ export default () =>
comparator: 'Energy',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_8e0otka9uif_vmqri4gmbqc',
},
],
Expand Down
Loading