You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/10/07 18:56:38 UTC
[GitHub] [superset] justinpark commented on a diff in pull request #21711: chore(sqllab): refactor addQueryEditor for new tab
justinpark commented on code in PR #21711:
URL: https://github.com/apache/superset/pull/21711#discussion_r990415735
##########
superset-frontend/src/SqlLab/components/TabbedSqlEditors/TabbedSqlEditors.test.jsx:
##########
@@ -163,23 +169,32 @@ describe('TabbedSqlEditors', () => {
wrapper.instance().props.actions.removeQueryEditor.getCall(0).args[0],
).toBe(queryEditors[0]);
});
- it('should add new query editor', () => {
- wrapper = getWrapper();
- sinon.stub(wrapper.instance().props.actions, 'addQueryEditor');
-
- wrapper.instance().newQueryEditor();
- expect(
- wrapper.instance().props.actions.addQueryEditor.getCall(0).args[0].name,
- ).toContain('Untitled Query');
+ it('should add new query editor', async () => {
+ const { getAllByLabelText } = setup(mockedProps);
+ fireEvent.click(getAllByLabelText('Add tab')[0]);
+ const actions = store.getActions();
+ await waitFor(() =>
+ expect(actions).toContainEqual({
+ type: 'ADD_QUERY_EDITOR',
+ queryEditor: expect.objectContaining({
+ name: expect.stringMatching(/Untitled Query (\d+)+/),
+ }),
+ }),
+ );
});
- it('should properly increment query tab name', () => {
- wrapper = getWrapper();
- sinon.stub(wrapper.instance().props.actions, 'addQueryEditor');
- const newTitle = newQueryTabName(wrapper.instance().props.queryEditors);
- wrapper.instance().newQueryEditor();
- expect(
- wrapper.instance().props.actions.addQueryEditor.getCall(0).args[0].name,
- ).toContain(newTitle);
+ it('should properly increment query tab name', async () => {
Review Comment:
Good suggestion. However, it's a little complicated to setup entire SqlLab redux state to simulate the behavior in the screen. It'd be better to minimize the redux usage in the future for better screen testing environment.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org