2022-01-11 13:48:50 -05:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
import json
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from superset import db
|
|
|
|
from superset.models.dashboard import Dashboard
|
2022-07-26 20:01:56 -04:00
|
|
|
from superset.utils.core import shortid
|
|
|
|
from tests.integration_tests.dashboards.superset_factory_util import create_dashboard
|
2022-01-11 13:48:50 -05:00
|
|
|
|
|
|
|
|
2022-07-26 20:01:56 -04:00
|
|
|
@pytest.fixture
|
|
|
|
def tabbed_dashboard(app_context):
|
2022-01-11 13:48:50 -05:00
|
|
|
position_json = {
|
|
|
|
"DASHBOARD_VERSION_KEY": "v2",
|
|
|
|
"GRID_ID": {
|
2022-07-26 20:01:56 -04:00
|
|
|
"children": ["TABS-L1A", "TABS-L1B"],
|
2022-01-11 13:48:50 -05:00
|
|
|
"id": "GRID_ID",
|
|
|
|
"parents": ["ROOT_ID"],
|
|
|
|
"type": "GRID",
|
|
|
|
},
|
|
|
|
"HEADER_ID": {
|
|
|
|
"id": "HEADER_ID",
|
|
|
|
"meta": {"text": "tabbed dashboard"},
|
|
|
|
"type": "HEADER",
|
|
|
|
},
|
|
|
|
"ROOT_ID": {"children": ["GRID_ID"], "id": "ROOT_ID", "type": "ROOT"},
|
2022-07-26 20:01:56 -04:00
|
|
|
"TAB-L1AA": {
|
2022-01-11 13:48:50 -05:00
|
|
|
"children": [],
|
2022-07-26 20:01:56 -04:00
|
|
|
"id": "TAB-L1AA",
|
2022-01-11 13:48:50 -05:00
|
|
|
"meta": {
|
|
|
|
"defaultText": "Tab title",
|
|
|
|
"placeholder": "Tab title",
|
2022-07-26 20:01:56 -04:00
|
|
|
"text": "Tab L1AA",
|
2022-01-11 13:48:50 -05:00
|
|
|
},
|
2022-07-26 20:01:56 -04:00
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L1A"],
|
2022-01-11 13:48:50 -05:00
|
|
|
"type": "TAB",
|
|
|
|
},
|
2022-07-26 20:01:56 -04:00
|
|
|
"TAB-L1AB": {
|
2022-01-11 13:48:50 -05:00
|
|
|
"children": [],
|
2022-07-26 20:01:56 -04:00
|
|
|
"id": "TAB-L1AB",
|
|
|
|
"meta": {
|
|
|
|
"defaultText": "Tab title",
|
|
|
|
"placeholder": "Tab title",
|
|
|
|
"text": "Tab L1AB",
|
|
|
|
},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L1A"],
|
|
|
|
"type": "TAB",
|
|
|
|
},
|
|
|
|
"TABS-L1A": {
|
|
|
|
"children": ["TAB-L1AA", "TAB-L1AB"],
|
|
|
|
"id": "TABS-L1A",
|
|
|
|
"meta": {},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID"],
|
|
|
|
"type": "TABS",
|
|
|
|
},
|
|
|
|
"TAB-L1BA": {
|
|
|
|
"children": [],
|
|
|
|
"id": "TAB-L1BA",
|
|
|
|
"meta": {
|
|
|
|
"defaultText": "Tab title",
|
|
|
|
"placeholder": "Tab title",
|
|
|
|
"text": "Tab L1B",
|
|
|
|
},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L1B"],
|
|
|
|
"type": "TAB",
|
|
|
|
},
|
|
|
|
"TAB-L1BB": {
|
|
|
|
"children": ["TABS-L2A"],
|
|
|
|
"id": "TAB-L1BB",
|
2022-01-11 13:48:50 -05:00
|
|
|
"meta": {
|
|
|
|
"defaultText": "Tab title",
|
|
|
|
"placeholder": "Tab title",
|
|
|
|
"text": "Tab 2",
|
|
|
|
},
|
2022-07-26 20:01:56 -04:00
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L1B"],
|
2022-01-11 13:48:50 -05:00
|
|
|
"type": "TAB",
|
|
|
|
},
|
2022-07-26 20:01:56 -04:00
|
|
|
"TABS-L1B": {
|
|
|
|
"children": ["TAB-L1BA", "TAB-L1BB"],
|
|
|
|
"id": "TABS-L1B",
|
2022-01-11 13:48:50 -05:00
|
|
|
"meta": {},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID"],
|
|
|
|
"type": "TABS",
|
|
|
|
},
|
2022-07-26 20:01:56 -04:00
|
|
|
"TAB-L2AA": {
|
|
|
|
"children": [],
|
|
|
|
"id": "TAB-L2AA",
|
|
|
|
"meta": {
|
|
|
|
"defaultText": "Tab title",
|
|
|
|
"placeholder": "Tab title",
|
|
|
|
"text": "Tab L2AA",
|
|
|
|
},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L2A"],
|
|
|
|
"type": "TAB",
|
|
|
|
},
|
|
|
|
"TAB-L2AB": {
|
|
|
|
"children": [],
|
|
|
|
"id": "TAB-L2AB",
|
|
|
|
"meta": {
|
|
|
|
"defaultText": "Tab title",
|
|
|
|
"placeholder": "Tab title",
|
|
|
|
"text": "Tab L2AB",
|
|
|
|
},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L2A"],
|
|
|
|
"type": "TAB",
|
|
|
|
},
|
|
|
|
"TABS-L2A": {
|
|
|
|
"children": ["TAB-L2AA", "TAB-L2AB"],
|
|
|
|
"id": "TABS-L2A",
|
|
|
|
"meta": {},
|
|
|
|
"parents": ["ROOT_ID", "GRID_ID", "TABS-L1BB"],
|
|
|
|
"type": "TABS",
|
|
|
|
},
|
2022-01-11 13:48:50 -05:00
|
|
|
}
|
2022-07-26 20:01:56 -04:00
|
|
|
dash = create_dashboard(
|
|
|
|
slug=f"tabbed-dash-{shortid()}",
|
|
|
|
dashboard_title="Test tabbed dash",
|
|
|
|
position_json=json.dumps(position_json),
|
|
|
|
slices=[],
|
|
|
|
)
|
|
|
|
db.session.add(dash)
|
|
|
|
db.session.commit()
|
2022-01-11 13:48:50 -05:00
|
|
|
yield dash
|
2022-07-26 20:01:56 -04:00
|
|
|
db.session.query(Dashboard).filter_by(id=dash.id).delete()
|
|
|
|
db.session.commit()
|