allow cache and force refresh on table list (#6078)

* allow cache and force refresh on table list

* wording

* flake8

* javascript test

* address comments

* nit
This commit is contained in:
Junda Yang
2018-10-16 13:14:45 -07:00
committed by Beto Dealmeida
parent 7d49255926
commit 177bed3bb6
6 changed files with 113 additions and 80 deletions

View File

@@ -41,14 +41,10 @@ describe('SqlEditorLeftBar', () => {
expect(wrapper.find(TableElement)).toHaveLength(1);
});
describe('onDatabaseChange', () => {
it('should fetch tables', () => {
sinon.stub(wrapper.instance(), 'fetchTables');
it('should fetch schemas', () => {
sinon.stub(wrapper.instance(), 'fetchSchemas');
wrapper.instance().onDatabaseChange({ value: 1, label: 'main' });
expect(wrapper.instance().fetchTables.getCall(0).args[0]).toBe(1);
expect(wrapper.instance().fetchSchemas.getCall(0).args[0]).toBe(1);
wrapper.instance().fetchTables.restore();
wrapper.instance().fetchSchemas.restore();
});
it('should clear tableOptions', () => {
@@ -103,9 +99,9 @@ describe('SqlEditorLeftBar', () => {
d.resolve(tables);
return d.promise();
});
wrapper.instance().fetchTables(1, 'main', 'birth_names');
wrapper.instance().fetchTables(1, 'main', 'true', 'birth_names');
expect(ajaxStub.getCall(0).args[0]).toBe('/superset/tables/1/main/birth_names/');
expect(ajaxStub.getCall(0).args[0]).toBe('/superset/tables/1/main/birth_names/true/');
expect(wrapper.state().tableLength).toBe(3);
});
it('should handle error', () => {