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: [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]