Compare commits
180 Commits
feat-bette
...
fix-chart-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36cf9337a8 | ||
|
|
d952109cbc | ||
|
|
151d7d76da | ||
|
|
4f19bc4c5f | ||
|
|
11607dde04 | ||
|
|
e1bdb94efc | ||
|
|
6535fdd556 | ||
|
|
5fb89b865d | ||
|
|
6948e73ec7 | ||
|
|
c4cf03f899 | ||
|
|
d3de16c5f5 | ||
|
|
78fb09695b | ||
|
|
06818008c2 | ||
|
|
52ba4fd0cb | ||
|
|
4f2fa41f4e | ||
|
|
bf7ec853fa | ||
|
|
9fe3f634ec | ||
|
|
899e9294b2 | ||
|
|
dc9b459b27 | ||
|
|
7d3881f1da | ||
|
|
e5f9a6bf4b | ||
|
|
5cff657812 | ||
|
|
16387b0815 | ||
|
|
0857611a4e | ||
|
|
51ea2c297d | ||
|
|
fbd062165e | ||
|
|
55625c911f | ||
|
|
fca64de8e9 | ||
|
|
03725d1aaa | ||
|
|
a9487cbc84 | ||
|
|
ce5b2aa424 | ||
|
|
e535dce030 | ||
|
|
a7310b1fce | ||
|
|
cd6ce881a5 | ||
|
|
f0ef9f5e9c | ||
|
|
4ae16cb140 | ||
|
|
3d85e8e23b | ||
|
|
690a411cf3 | ||
|
|
be680408c9 | ||
|
|
4bdc8d4c68 | ||
|
|
db7a2bd682 | ||
|
|
2e0d482ccf | ||
|
|
e5b3a9c25d | ||
|
|
c289731212 | ||
|
|
f850c6b1b1 | ||
|
|
8ce234371b | ||
|
|
e5820b6b2b | ||
|
|
69f062b804 | ||
|
|
735dd5dbae | ||
|
|
cd7dddb5a1 | ||
|
|
7c76fd3d81 | ||
|
|
0b419a07f5 | ||
|
|
0b51e9cd5e | ||
|
|
e7b9fb277e | ||
|
|
838ee870d0 | ||
|
|
84af6c9f29 | ||
|
|
05227e8a80 | ||
|
|
76a209663d | ||
|
|
61c45e3dd8 | ||
|
|
e11a50bedf | ||
|
|
f4a6ea0fde | ||
|
|
e542e9f840 | ||
|
|
e0dcb2908d | ||
|
|
eaccb2e471 | ||
|
|
c1a1f2e7e7 | ||
|
|
45d5501aa7 | ||
|
|
388596e4fe | ||
|
|
b11d4f3ef0 | ||
|
|
998b9e387b | ||
|
|
b3e88db87e | ||
|
|
8471e82342 | ||
|
|
c3a0f2749b | ||
|
|
c2d96e0dce | ||
|
|
44e77fdf2b | ||
|
|
18d6feb499 | ||
|
|
0d91f5e982 | ||
|
|
5661fc9128 | ||
|
|
a6156676c8 | ||
|
|
b2bd2329bc | ||
|
|
724f1484b9 | ||
|
|
84f7b4a973 | ||
|
|
ddcb9be9a7 | ||
|
|
8d9b5bd479 | ||
|
|
4b88fc57b4 | ||
|
|
b76080e291 | ||
|
|
411f769896 | ||
|
|
ffcc6e8b63 | ||
|
|
86575e129b | ||
|
|
3e25f02da9 | ||
|
|
002d8ad1e4 | ||
|
|
6287a07912 | ||
|
|
fa97d0357f | ||
|
|
f836c3eccd | ||
|
|
499e27ea54 | ||
|
|
c2a35e2eea | ||
|
|
5138aa2c11 | ||
|
|
66a9e2e16e | ||
|
|
0f417f0040 | ||
|
|
1462ac9282 | ||
|
|
da371217ef | ||
|
|
c971ea3ec6 | ||
|
|
de98fdc37b | ||
|
|
fa1f12a0b5 | ||
|
|
de40b58e10 | ||
|
|
eea3557f61 | ||
|
|
7a243d329e | ||
|
|
98146251c4 | ||
|
|
0aa8cace1b | ||
|
|
450701ecec | ||
|
|
e9911fbac4 | ||
|
|
69c8eef78e | ||
|
|
2ff50667e7 | ||
|
|
f1cf274751 | ||
|
|
b65396ccd4 | ||
|
|
1ad76e847e | ||
|
|
4583ef93a4 | ||
|
|
f632d2474b | ||
|
|
b1d69f5b39 | ||
|
|
aba7e6dae4 | ||
|
|
8bcc90c766 | ||
|
|
e39dd1afce | ||
|
|
680cef0ee0 | ||
|
|
e17cf3c808 | ||
|
|
f49310b8ff | ||
|
|
c7955a38ef | ||
|
|
68067d7f44 | ||
|
|
5815665cc6 | ||
|
|
6649f35a0d | ||
|
|
5263abdc60 | ||
|
|
c49641538d | ||
|
|
d915e4f3ff | ||
|
|
bad5a35fce | ||
|
|
1bde6f3bfd | ||
|
|
4e0890ee1f | ||
|
|
d63308ca37 | ||
|
|
63cceb6a79 | ||
|
|
b8b2bdedf9 | ||
|
|
d5017e60c3 | ||
|
|
2e80f2a473 | ||
|
|
4c2dd63464 | ||
|
|
62302ad8c3 | ||
|
|
ed659958f3 | ||
|
|
36de05fe36 | ||
|
|
a64609f4f3 | ||
|
|
140f0001f2 | ||
|
|
587fe4af63 | ||
|
|
3a3a6536b7 | ||
|
|
4f695e1b4d | ||
|
|
6ba9096870 | ||
|
|
5106afb07f | ||
|
|
2bd4131636 | ||
|
|
7e452df1cc | ||
|
|
a626d06415 | ||
|
|
d159edc9a6 | ||
|
|
96fa2cbd2b | ||
|
|
9750881193 | ||
|
|
3db92021c7 | ||
|
|
5ccfc530b2 | ||
|
|
5f9fc31ae2 | ||
|
|
8e811de564 | ||
|
|
027de6339b | ||
|
|
bf9aff19b5 | ||
|
|
b05764d070 | ||
|
|
7be2acb2f3 | ||
|
|
83ad1eca26 | ||
|
|
92747246fc | ||
|
|
7380a59ab8 | ||
|
|
e56f8cc4fb | ||
|
|
7c79b9ab61 | ||
|
|
a62be684a0 | ||
|
|
a3dfbd7bff | ||
|
|
12eb40db01 | ||
|
|
d796543f5a | ||
|
|
e5ae626433 | ||
|
|
8195574345 | ||
|
|
6b029997d9 | ||
|
|
7a64483e6b | ||
|
|
e424b55036 | ||
|
|
613e6d6cde | ||
|
|
b3a402d936 |
5
.github/CODEOWNERS
vendored
@@ -22,6 +22,11 @@
|
||||
|
||||
/.github/ @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @kgabryje @dpgaspar @sadpandajoe @hainenber
|
||||
|
||||
# Notify PMC members of changes to CI-executed scripts (supply-chain risk:
|
||||
# scripts/ files run directly in CI workflows and can execute arbitrary code)
|
||||
|
||||
/scripts/ @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @kgabryje @dpgaspar @sadpandajoe @hainenber
|
||||
|
||||
# Notify PMC members of changes to required GitHub Actions
|
||||
|
||||
/.asf.yaml @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @kgabryje @dpgaspar @Antonio-RiveroMartnez
|
||||
|
||||
4
.github/dependabot.yml
vendored
@@ -4,6 +4,10 @@ updates:
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
ignore:
|
||||
# Ignore temporarily as release schedule is too mentally taxing for dep-handling maintainers
|
||||
# Additionally, very few PRs are reviewed by this action.
|
||||
- dependency-name: anthropics/claude-code-action
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
|
||||
5
.github/labeler.yml
vendored
@@ -17,6 +17,11 @@
|
||||
- any-glob-to-any-file:
|
||||
- 'superset/migrations/**'
|
||||
|
||||
"risk:ci-script":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 'scripts/**'
|
||||
|
||||
############################################
|
||||
# Dependencies
|
||||
############################################
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Check and notify
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
script: |
|
||||
|
||||
4
.github/workflows/claude.yml
vendored
@@ -44,7 +44,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Comment access denied
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const message = `👋 Hi @${{ github.event.comment.user.login || github.event.review.user.login || github.event.issue.user.login }}!
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude PR Action
|
||||
uses: anthropics/claude-code-action@58dbe8ed6879f0d3b02ac295b20d5fdfe7733e0c # beta
|
||||
uses: anthropics/claude-code-action@5fb899572b81d2bb648d4d187173a2f423a9677c # beta
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "60"
|
||||
|
||||
2
.github/workflows/embedded-sdk-release.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
working-directory: superset-embedded-sdk
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-embedded-sdk/.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
2
.github/workflows/embedded-sdk-test.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
working-directory: superset-embedded-sdk
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-embedded-sdk/.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
4
.github/workflows/ephemeral-env-pr-close.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
||||
- name: Login to Amazon ECR
|
||||
if: steps.describe-services.outputs.active == 'true'
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2
|
||||
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2
|
||||
|
||||
- name: Delete ECR image tag
|
||||
if: steps.describe-services.outputs.active == 'true'
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
|
||||
- name: Comment (success)
|
||||
if: steps.describe-services.outputs.active == 'true'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{github.token}}
|
||||
script: |
|
||||
|
||||
16
.github/workflows/ephemeral-env.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
- name: Get event SHA
|
||||
id: get-sha
|
||||
if: steps.eval-label.outputs.result == 'up'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
core.setOutput("sha", prSha);
|
||||
|
||||
- name: Looking for feature flags in PR description
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
id: eval-feature-flags
|
||||
if: steps.eval-label.outputs.result == 'up'
|
||||
with:
|
||||
@@ -118,7 +118,7 @@ jobs:
|
||||
return results;
|
||||
|
||||
- name: Reply with confirmation comment
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
if: steps.eval-label.outputs.result == 'up'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -199,7 +199,7 @@ jobs:
|
||||
|
||||
- name: Login to Amazon ECR
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2
|
||||
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2
|
||||
|
||||
- name: Load, tag and push image to ECR
|
||||
id: push-image
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
|
||||
- name: Login to Amazon ECR
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2
|
||||
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2
|
||||
|
||||
- name: Check target image exists in ECR
|
||||
id: check-image
|
||||
@@ -250,7 +250,7 @@ jobs:
|
||||
|
||||
- name: Fail on missing container image
|
||||
if: steps.check-image.outcome == 'failure'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
script: |
|
||||
@@ -324,7 +324,7 @@ jobs:
|
||||
echo "ip=$(aws ec2 describe-network-interfaces --network-interface-ids ${{ steps.get-eni.outputs.eni }} | jq -r '.NetworkInterfaces | first | .Association.PublicIp')" >> $GITHUB_OUTPUT
|
||||
- name: Comment (success)
|
||||
if: ${{ success() }}
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{github.token}}
|
||||
script: |
|
||||
@@ -337,7 +337,7 @@ jobs:
|
||||
});
|
||||
- name: Comment (failure)
|
||||
if: ${{ failure() }}
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{github.token}}
|
||||
script: |
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
|
||||
2
.github/workflows/no-hold-label.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Check for 'hold' label
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
|
||||
4
.github/workflows/pre-commit.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
echo "HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY" >>"${GITHUB_ENV}"
|
||||
brew install norwoodj/tap/helm-docs
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
yarn install --immutable
|
||||
|
||||
- name: Cache pre-commit environments
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit-v2-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
|
||||
6
.github/workflows/release.yml
vendored
@@ -44,13 +44,13 @@ jobs:
|
||||
|
||||
- name: Install Node.js
|
||||
if: env.HAS_TAGS
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
|
||||
- name: Cache npm
|
||||
if: env.HAS_TAGS
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
|
||||
- name: Cache npm
|
||||
if: env.HAS_TAGS
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
id: npm-cache # use this to check for `cache-hit` (`steps.npm-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
|
||||
|
||||
2
.github/workflows/showtime-trigger.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
steps:
|
||||
- name: Security Check - Authorize Maintainers Only
|
||||
id: auth
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
6
.github/workflows/superset-docs-deploy.yml
vendored
@@ -46,7 +46,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './docs/.nvmrc'
|
||||
- name: Setup Python
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
yarn install --check-cache
|
||||
- name: Download database diagnostics (if triggered by integration tests)
|
||||
if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'
|
||||
uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19
|
||||
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
|
||||
continue-on-error: true
|
||||
with:
|
||||
workflow: superset-python-integrationtest.yml
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
path: docs/src/data/
|
||||
- name: Try to download latest diagnostics (for push/dispatch triggers)
|
||||
if: github.event_name != 'workflow_run'
|
||||
uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19
|
||||
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
|
||||
continue-on-error: true
|
||||
with:
|
||||
workflow: superset-python-integrationtest.yml
|
||||
|
||||
6
.github/workflows/superset-docs-verify.yml
vendored
@@ -72,7 +72,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './docs/.nvmrc'
|
||||
- name: yarn install
|
||||
@@ -104,14 +104,14 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './docs/.nvmrc'
|
||||
- name: yarn install
|
||||
run: |
|
||||
yarn install --check-cache
|
||||
- name: Download database diagnostics from integration tests
|
||||
uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19
|
||||
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
|
||||
with:
|
||||
workflow: superset-python-integrationtest.yml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
8
.github/workflows/superset-e2e.yml
vendored
@@ -109,7 +109,7 @@ jobs:
|
||||
run: testdata
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.python || steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install npm dependencies
|
||||
@@ -146,7 +146,7 @@ jobs:
|
||||
SAFE_APP_ROOT=${APP_ROOT//\//_}
|
||||
echo "safe_app_root=$SAFE_APP_ROOT" >> $GITHUB_OUTPUT
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
if: failure()
|
||||
with:
|
||||
path: ${{ github.workspace }}/superset-frontend/cypress-base/cypress/screenshots
|
||||
@@ -226,7 +226,7 @@ jobs:
|
||||
run: playwright_testdata
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.python || steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install npm dependencies
|
||||
@@ -259,7 +259,7 @@ jobs:
|
||||
SAFE_APP_ROOT=${APP_ROOT//\//_}
|
||||
echo "safe_app_root=$SAFE_APP_ROOT" >> $GITHUB_OUTPUT
|
||||
- name: Upload Playwright Artifacts
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
if: failure()
|
||||
with:
|
||||
path: |
|
||||
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload HTML coverage report
|
||||
if: steps.check.outputs.superset-extensions-cli
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: superset-extensions-cli-coverage-html
|
||||
path: htmlcov/
|
||||
|
||||
4
.github/workflows/superset-frontend.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload Docker Image Artifact
|
||||
if: steps.check.outputs.frontend
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: docker-image
|
||||
path: docker-image.tar.zst
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
"npm run test -- --coverage --shard=${{ matrix.shard }}/8 --coverageReporters=json"
|
||||
|
||||
- name: Upload Coverage Artifact
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: coverage-artifacts-${{ matrix.shard }}
|
||||
path: superset-frontend/coverage
|
||||
|
||||
2
.github/workflows/superset-helm-release.yml
vendored
@@ -101,7 +101,7 @@ jobs:
|
||||
CR_RELEASE_NAME_TEMPLATE: "superset-helm-chart-{{ .Version }}"
|
||||
|
||||
- name: Open Pull Request
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const branchName = '${{ env.branch_name }}';
|
||||
|
||||
4
.github/workflows/superset-playwright.yml
vendored
@@ -100,7 +100,7 @@ jobs:
|
||||
run: playwright_testdata
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.python || steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install npm dependencies
|
||||
@@ -133,7 +133,7 @@ jobs:
|
||||
SAFE_APP_ROOT=${APP_ROOT//\//_}
|
||||
echo "safe_app_root=$SAFE_APP_ROOT" >> $GITHUB_OUTPUT
|
||||
- name: Upload Playwright Artifacts
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
if: failure()
|
||||
with:
|
||||
path: |
|
||||
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
"
|
||||
- name: Upload database diagnostics artifact
|
||||
if: steps.check.outputs.python
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: database-diagnostics
|
||||
path: databases-diagnostics.json
|
||||
|
||||
2
.github/workflows/superset-translations.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install dependencies
|
||||
|
||||
2
.github/workflows/supersetbot.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Quickly add thumbs up!
|
||||
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '@supersetbot')
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
|
||||
|
||||
4
.github/workflows/tag-release.yml
vendored
@@ -62,7 +62,7 @@ jobs:
|
||||
build: "true"
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
|
||||
2
.github/workflows/tech-debt.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ cd ../
|
||||
sed -i '' "s/version_string = .*/version_string = \"$SUPERSET_VERSION\"/" setup.py
|
||||
|
||||
# build the python distribution
|
||||
python setup.py sdist
|
||||
python -m build
|
||||
```
|
||||
|
||||
Publish to PyPI
|
||||
|
||||
@@ -287,6 +287,11 @@ categories:
|
||||
url: https://www.gfk.com/home
|
||||
contributors: ["@mherr"]
|
||||
|
||||
- name: Hifadih Business & Technology
|
||||
url: https://hifadih.net/en
|
||||
logo: hifadih.png
|
||||
contributors: ["@saintLaurent00"]
|
||||
|
||||
# Logo approved by @anmol-hpe on behalf of HPE
|
||||
- name: HPE
|
||||
url: https://www.hpe.com/in/en/home.html
|
||||
|
||||
14
UPDATING.md
@@ -24,6 +24,20 @@ assists people when migrating to a new version.
|
||||
|
||||
## Next
|
||||
|
||||
### Granular Export Controls
|
||||
|
||||
A new feature flag `GRANULAR_EXPORT_CONTROLS` introduces three fine-grained permissions that replace the legacy `can_csv` permission:
|
||||
|
||||
| Permission | Controls |
|
||||
|---|---|
|
||||
| `can_export_data` | CSV, Excel, JSON exports |
|
||||
| `can_export_image` | Screenshot/PDF exports |
|
||||
| `can_copy_clipboard` | Copy-to-clipboard operations |
|
||||
|
||||
When the feature flag is enabled, these permissions are enforced on both the frontend (disabled buttons with tooltips) and backend (403 responses from API endpoints). When disabled, legacy `can_csv` behavior is preserved.
|
||||
|
||||
**Migration behavior:** All three new permissions are granted to every role that currently has `can_csv`, preserving existing access. Admins can then selectively revoke individual export permissions from specific roles as needed.
|
||||
|
||||
### Deck.gl MapBox viewport and opacity controls are functional
|
||||
|
||||
The Deck.gl MapBox chart's **Opacity**, **Default longitude**, **Default latitude**, and **Zoom** controls were previously non-functional — changing them had no effect on the rendered map. These controls are now wired up correctly.
|
||||
|
||||
@@ -115,6 +115,10 @@ services:
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
GITHUB_HEAD_REF: ${GITHUB_HEAD_REF:-}
|
||||
GITHUB_SHA: ${GITHUB_SHA:-}
|
||||
@@ -137,6 +141,10 @@ services:
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
healthcheck:
|
||||
disable: true
|
||||
@@ -157,6 +165,7 @@ services:
|
||||
BUILD_SUPERSET_FRONTEND_IN_DOCKER: true
|
||||
NPM_RUN_PRUNE: false
|
||||
SCARF_ANALYTICS: "${SCARF_ANALYTICS:-}"
|
||||
DISABLE_TS_CHECKER: "${DISABLE_TS_CHECKER:-true}"
|
||||
# configuring the dev-server to use the host.docker.internal to connect to the backend
|
||||
superset: "http://superset-light:8088"
|
||||
# Webpack dev server must bind to 0.0.0.0 to be accessible from outside the container
|
||||
|
||||
@@ -80,7 +80,7 @@ case "${1}" in
|
||||
;;
|
||||
app)
|
||||
echo "Starting web app (using development server)..."
|
||||
flask run -p $PORT --reload --debugger --without-threads --host=0.0.0.0 --exclude-patterns "*/node_modules/*:*/.venv/*:*/build/*:*/__pycache__/*"
|
||||
flask run -p $PORT --reload --debugger --host=0.0.0.0 --exclude-patterns "*/node_modules/*:*/.venv/*:*/build/*:*/__pycache__/*:*/superset-frontend/*"
|
||||
;;
|
||||
app-gunicorn)
|
||||
echo "Starting web app..."
|
||||
|
||||
@@ -109,6 +109,14 @@ SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
|
||||
|
||||
You can generate a strong secure key with `openssl rand -base64 42`.
|
||||
|
||||
Alternatively, you can set the secret key using `SUPERSET_SECRET_KEY` environment variable:
|
||||
|
||||
On a Unix-based system, such as Linux or macOS, you can do so by running the following command in your terminal:
|
||||
|
||||
```bash
|
||||
export SUPERSET_SECRET_KEY=$(openssl rand -base64 42)
|
||||
```
|
||||
|
||||
:::caution Use a strong secret key
|
||||
This key will be used for securely signing session cookies and encrypting sensitive information stored in Superset's application metadata database.
|
||||
Your deployment must use a complex, unique key.
|
||||
|
||||
@@ -412,7 +412,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security roles](/developer-docs/api/get-security-roles) | `/api/v1/security/roles/` |
|
||||
| `POST` | [Create security roles](/developer-docs/api/create-security-roles) | `/api/v1/security/roles/` |
|
||||
| `GET` | [Get security roles info](/developer-docs/api/get-security-roles-info) | `/api/v1/security/roles/_info` |
|
||||
| `GET` | [Get security roles info](/developer-docs/api/get-security-roles-info) | `/api/v1/security/roles/_info` |
|
||||
| `DELETE` | [Delete security roles by pk](/developer-docs/api/delete-security-roles-by-pk) | `/api/v1/security/roles/{pk}` |
|
||||
| `GET` | [Get security roles by pk](/developer-docs/api/get-security-roles-by-pk) | `/api/v1/security/roles/{pk}` |
|
||||
| `PUT` | [Update security roles by pk](/developer-docs/api/update-security-roles-by-pk) | `/api/v1/security/roles/{pk}` |
|
||||
@@ -430,7 +430,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security users](/developer-docs/api/get-security-users) | `/api/v1/security/users/` |
|
||||
| `POST` | [Create security users](/developer-docs/api/create-security-users) | `/api/v1/security/users/` |
|
||||
| `GET` | [Get security users info](/developer-docs/api/get-security-users-info) | `/api/v1/security/users/_info` |
|
||||
| `GET` | [Get security users info](/developer-docs/api/get-security-users-info) | `/api/v1/security/users/_info` |
|
||||
| `DELETE` | [Delete security users by pk](/developer-docs/api/delete-security-users-by-pk) | `/api/v1/security/users/{pk}` |
|
||||
| `GET` | [Get security users by pk](/developer-docs/api/get-security-users-by-pk) | `/api/v1/security/users/{pk}` |
|
||||
| `PUT` | [Update security users by pk](/developer-docs/api/update-security-users-by-pk) | `/api/v1/security/users/{pk}` |
|
||||
@@ -443,7 +443,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security permissions](/developer-docs/api/get-security-permissions) | `/api/v1/security/permissions/` |
|
||||
| `GET` | [Get security permissions info](/developer-docs/api/get-security-permissions-info) | `/api/v1/security/permissions/_info` |
|
||||
| `GET` | [Get security permissions info](/developer-docs/api/get-security-permissions-info) | `/api/v1/security/permissions/_info` |
|
||||
| `GET` | [Get security permissions by pk](/developer-docs/api/get-security-permissions-by-pk) | `/api/v1/security/permissions/{pk}` |
|
||||
|
||||
</details>
|
||||
@@ -455,7 +455,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security resources](/developer-docs/api/get-security-resources) | `/api/v1/security/resources/` |
|
||||
| `POST` | [Create security resources](/developer-docs/api/create-security-resources) | `/api/v1/security/resources/` |
|
||||
| `GET` | [Get security resources info](/developer-docs/api/get-security-resources-info) | `/api/v1/security/resources/_info` |
|
||||
| `GET` | [Get security resources info](/developer-docs/api/get-security-resources-info) | `/api/v1/security/resources/_info` |
|
||||
| `DELETE` | [Delete security resources by pk](/developer-docs/api/delete-security-resources-by-pk) | `/api/v1/security/resources/{pk}` |
|
||||
| `GET` | [Get security resources by pk](/developer-docs/api/get-security-resources-by-pk) | `/api/v1/security/resources/{pk}` |
|
||||
| `PUT` | [Update security resources by pk](/developer-docs/api/update-security-resources-by-pk) | `/api/v1/security/resources/{pk}` |
|
||||
@@ -469,7 +469,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security permissions resources](/developer-docs/api/get-security-permissions-resources) | `/api/v1/security/permissions-resources/` |
|
||||
| `POST` | [Create security permissions resources](/developer-docs/api/create-security-permissions-resources) | `/api/v1/security/permissions-resources/` |
|
||||
| `GET` | [Get security permissions resources info](/developer-docs/api/get-security-permissions-resources-info) | `/api/v1/security/permissions-resources/_info` |
|
||||
| `GET` | [Get security permissions resources info](/developer-docs/api/get-security-permissions-resources-info) | `/api/v1/security/permissions-resources/_info` |
|
||||
| `DELETE` | [Delete security permissions resources by pk](/developer-docs/api/delete-security-permissions-resources-by-pk) | `/api/v1/security/permissions-resources/{pk}` |
|
||||
| `GET` | [Get security permissions resources by pk](/developer-docs/api/get-security-permissions-resources-by-pk) | `/api/v1/security/permissions-resources/{pk}` |
|
||||
| `PUT` | [Update security permissions resources by pk](/developer-docs/api/update-security-permissions-resources-by-pk) | `/api/v1/security/permissions-resources/{pk}` |
|
||||
@@ -578,7 +578,29 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get api by version openapi](/developer-docs/api/get-api-by-version-openapi) | `/api/{version}/_openapi` |
|
||||
| `GET` | [Get api by version openapi](/developer-docs/api/get-api-by-version-openapi) | `/api/{version}/_openapi` |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Themes</strong> (14 endpoints) — Manage UI themes for customizing Superset's appearance.</summary>
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `DELETE` | [Bulk delete themes](/developer-docs/api/bulk-delete-themes) | `/api/v1/theme/` |
|
||||
| `GET` | [Get a list of themes](/developer-docs/api/get-a-list-of-themes) | `/api/v1/theme/` |
|
||||
| `POST` | [Create a theme](/developer-docs/api/create-a-theme) | `/api/v1/theme/` |
|
||||
| `GET` | [Get metadata information about this API resource (theme-info)](/developer-docs/api/get-metadata-information-about-this-api-resource-theme-info) | `/api/v1/theme/_info` |
|
||||
| `DELETE` | [Delete a theme](/developer-docs/api/delete-a-theme) | `/api/v1/theme/{pk}` |
|
||||
| `GET` | [Get a theme](/developer-docs/api/get-a-theme) | `/api/v1/theme/{pk}` |
|
||||
| `PUT` | [Update a theme](/developer-docs/api/update-a-theme) | `/api/v1/theme/{pk}` |
|
||||
| `PUT` | [Set a theme as the system dark theme](/developer-docs/api/set-a-theme-as-the-system-dark-theme) | `/api/v1/theme/{pk}/set_system_dark` |
|
||||
| `PUT` | [Set a theme as the system default theme](/developer-docs/api/set-a-theme-as-the-system-default-theme) | `/api/v1/theme/{pk}/set_system_default` |
|
||||
| `GET` | [Download multiple themes as YAML files](/developer-docs/api/download-multiple-themes-as-yaml-files) | `/api/v1/theme/export/` |
|
||||
| `POST` | [Import themes from a ZIP file](/developer-docs/api/import-themes-from-a-zip-file) | `/api/v1/theme/import/` |
|
||||
| `GET` | [Get related fields data (theme-related-column-name)](/developer-docs/api/get-related-fields-data-theme-related-column-name) | `/api/v1/theme/related/{column_name}` |
|
||||
| `DELETE` | [Clear the system dark theme](/developer-docs/api/clear-the-system-dark-theme) | `/api/v1/theme/unset_system_dark` |
|
||||
| `DELETE` | [Clear the system default theme](/developer-docs/api/clear-the-system-default-theme) | `/api/v1/theme/unset_system_default` |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ or a view.
|
||||
When working with tables, the solution would be to create a table that contains all the fields
|
||||
needed for your analysis, most likely through some scheduled batch process.
|
||||
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL queries as a virtual table. This can
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL query as a virtual table. This can
|
||||
allow you to join and union multiple tables and to apply some transformation using arbitrary SQL
|
||||
expressions. The limitation there is your database performance, as Superset effectively will run a
|
||||
query on top of your query (view). A good practice may be to limit yourself to joining your main
|
||||
|
||||
78
docs/docs/security/granular-export-controls.mdx
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: Granular Export Controls
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Granular Export Controls
|
||||
|
||||
Superset provides granular, permission-based controls for data export, image export, and clipboard operations. These replace the legacy `can_csv` permission with three fine-grained permissions that can be assigned independently to roles.
|
||||
|
||||
## Feature Flag
|
||||
|
||||
Granular export controls are gated behind the `GRANULAR_EXPORT_CONTROLS` feature flag. When the flag is disabled, the legacy `can_csv` permission behavior is preserved.
|
||||
|
||||
```python
|
||||
FEATURE_FLAGS = {
|
||||
"GRANULAR_EXPORT_CONTROLS": True,
|
||||
}
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
| Permission | Resource | Controls |
|
||||
| -------------------- | ---------- | ---------------------------------------------------------------------- |
|
||||
| `can_export_data` | `Superset` | CSV, Excel, and JSON data exports from charts, dashboards, and SQL Lab |
|
||||
| `can_export_image` | `Superset` | Screenshot (JPEG/PNG) and PDF exports from charts and dashboards |
|
||||
| `can_copy_clipboard` | `Superset` | Copy-to-clipboard operations in SQL Lab and the Explore data pane |
|
||||
|
||||
## Default Role Assignments
|
||||
|
||||
The migration grants all three new permissions (`can_export_data`, `can_export_image`, `can_copy_clipboard`) to every role that currently has `can_csv`. This preserves existing behavior — no role loses access during the upgrade.
|
||||
|
||||
After the migration, admins can selectively revoke individual export permissions from any role to restrict access. For example, to prevent Gamma users from exporting data or images while still allowing clipboard operations, revoke `can_export_data` and `can_export_image` from the Gamma role.
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
1. **Enable the feature flag** in `superset_config.py`:
|
||||
|
||||
```python
|
||||
FEATURE_FLAGS = {
|
||||
"GRANULAR_EXPORT_CONTROLS": True,
|
||||
}
|
||||
```
|
||||
|
||||
2. **Run the database migration** to register the new permissions:
|
||||
|
||||
```bash
|
||||
superset db upgrade
|
||||
```
|
||||
|
||||
3. **Initialize permissions** so roles are populated:
|
||||
|
||||
```bash
|
||||
superset init
|
||||
```
|
||||
|
||||
4. **Verify role assignments** in **Settings > List Roles**. Confirm that each role has the expected permissions from the table above.
|
||||
|
||||
5. **Customize as needed**: Grant or revoke individual export permissions on any role through the role editor.
|
||||
|
||||
## User Experience
|
||||
|
||||
When a user lacks a required export permission:
|
||||
|
||||
- **Menu items** (CSV, Excel, JSON, screenshot) appear **disabled** with an info tooltip icon explaining the restriction
|
||||
- **Buttons** (SQL Lab download, clipboard copy) appear **disabled** with a tooltip on hover
|
||||
- **API endpoints** return **403 Forbidden** when the corresponding permission is missing
|
||||
|
||||
## API Enforcement
|
||||
|
||||
The following API endpoints enforce granular export permissions when the feature flag is enabled:
|
||||
|
||||
| Endpoint | Required Permission |
|
||||
| --------------------------------------------------------- | ------------------- |
|
||||
| `GET /api/v1/chart/{id}/data/` (CSV/Excel format) | `can_export_data` |
|
||||
| `GET /api/v1/chart/{id}/cache_screenshot/` | `can_export_image` |
|
||||
| `POST /api/v1/dashboard/{id}/cache_dashboard_screenshot/` | `can_export_image` |
|
||||
| `GET /api/v1/sqllab/export/{client_id}/` | `can_export_data` |
|
||||
| `POST /api/v1/sqllab/export_streaming/` | `can_export_data` |
|
||||
@@ -41,12 +41,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^6.1.1",
|
||||
"@docusaurus/core": "3.9.2",
|
||||
"@docusaurus/faster": "^3.9.2",
|
||||
"@docusaurus/plugin-client-redirects": "3.9.2",
|
||||
"@docusaurus/preset-classic": "3.9.2",
|
||||
"@docusaurus/theme-live-codeblock": "^3.9.2",
|
||||
"@docusaurus/theme-mermaid": "^3.9.2",
|
||||
"@docusaurus/core": "^3.10.0",
|
||||
"@docusaurus/faster": "^3.10.0",
|
||||
"@docusaurus/plugin-client-redirects": "^3.10.0",
|
||||
"@docusaurus/preset-classic": "3.10.0",
|
||||
"@docusaurus/theme-live-codeblock": "^3.10.0",
|
||||
"@docusaurus/theme-mermaid": "^3.10.0",
|
||||
"@emotion/core": "^11.0.0",
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
@@ -67,12 +67,12 @@
|
||||
"@storybook/preview-api": "^8.6.18",
|
||||
"@storybook/theming": "^8.6.15",
|
||||
"@superset-ui/core": "^0.20.4",
|
||||
"@swc/core": "^1.15.21",
|
||||
"antd": "^6.3.5",
|
||||
"baseline-browser-mapping": "^2.10.13",
|
||||
"caniuse-lite": "^1.0.30001784",
|
||||
"docusaurus-plugin-openapi-docs": "^4.6.0",
|
||||
"docusaurus-theme-openapi-docs": "^4.6.0",
|
||||
"@swc/core": "^1.15.26",
|
||||
"antd": "^6.3.6",
|
||||
"baseline-browser-mapping": "^2.10.19",
|
||||
"caniuse-lite": "^1.0.30001788",
|
||||
"docusaurus-plugin-openapi-docs": "^5.0.1",
|
||||
"docusaurus-theme-openapi-docs": "^5.0.1",
|
||||
"js-yaml": "^4.1.1",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
@@ -86,14 +86,14 @@
|
||||
"remark-import-partial": "^0.0.2",
|
||||
"reselect": "^5.1.1",
|
||||
"storybook": "^8.6.18",
|
||||
"swagger-ui-react": "^5.32.1",
|
||||
"swagger-ui-react": "^5.32.4",
|
||||
"swc-loader": "^0.2.7",
|
||||
"tinycolor2": "^1.4.2",
|
||||
"unist-util-visit": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "^3.9.1",
|
||||
"@docusaurus/tsconfig": "^3.9.2",
|
||||
"@docusaurus/module-type-aliases": "^3.10.0",
|
||||
"@docusaurus/tsconfig": "^3.10.0",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/react": "^19.1.8",
|
||||
@@ -103,11 +103,11 @@
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"globals": "^17.4.0",
|
||||
"prettier": "^3.8.1",
|
||||
"globals": "^17.5.0",
|
||||
"prettier": "^3.8.3",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.58.0",
|
||||
"webpack": "^5.105.4"
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"webpack": "^5.106.2"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
@@ -124,7 +124,8 @@
|
||||
"resolutions": {
|
||||
"react-redux": "^9.2.0",
|
||||
"@reduxjs/toolkit": "^2.5.0",
|
||||
"baseline-browser-mapping": "^2.9.19"
|
||||
"baseline-browser-mapping": "^2.9.19",
|
||||
"webpackbar": "^7.0.0"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
||||
}
|
||||
|
||||
@@ -129,6 +129,30 @@ def add_missing_schemas(spec: dict[str, Any]) -> tuple[dict[str, Any], list[str]
|
||||
}
|
||||
fixed.append("DashboardColorsConfigUpdateSchema")
|
||||
|
||||
# DashboardChartCustomizationsConfigUpdateSchema (dashboards/schemas.py)
|
||||
if "DashboardChartCustomizationsConfigUpdateSchema" not in schemas:
|
||||
schemas["DashboardChartCustomizationsConfigUpdateSchema"] = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deleted": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"description": "List of deleted chart customization IDs.",
|
||||
},
|
||||
"modified": {
|
||||
"type": "array",
|
||||
"items": {"type": "object"},
|
||||
"description": "List of modified chart customizations.",
|
||||
},
|
||||
"reordered": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"description": "List of chart customization IDs in new order.",
|
||||
},
|
||||
},
|
||||
}
|
||||
fixed.append("DashboardChartCustomizationsConfigUpdateSchema")
|
||||
|
||||
# FormatQueryPayloadSchema - based on superset/sqllab/schemas.py
|
||||
if "FormatQueryPayloadSchema" not in schemas:
|
||||
schemas["FormatQueryPayloadSchema"] = {
|
||||
@@ -295,6 +319,7 @@ TAG_DESCRIPTIONS = {
|
||||
"Security Roles": "Manage security roles and their permissions.",
|
||||
"Security Users": "Manage user accounts.",
|
||||
"Tags": "Organize assets with tags.",
|
||||
"Themes": "Manage UI themes for customizing Superset's appearance.",
|
||||
"User": "User profile and preferences.",
|
||||
}
|
||||
|
||||
|
||||
BIN
docs/static/img/logos/hifadih.png
vendored
Normal file
|
After Width: | Height: | Size: 18 KiB |
5791
docs/static/resources/openapi.json
vendored
@@ -109,6 +109,14 @@ SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
|
||||
|
||||
You can generate a strong secure key with `openssl rand -base64 42`.
|
||||
|
||||
Alternatively, you can set the secret key using `SUPERSET_SECRET_KEY` environment variable:
|
||||
|
||||
On a Unix-based system, such as Linux or macOS, you can do so by running the following command in your terminal:
|
||||
|
||||
```bash
|
||||
export SUPERSET_SECRET_KEY=$(openssl rand -base64 42)
|
||||
```
|
||||
|
||||
:::caution Use a strong secret key
|
||||
This key will be used for securely signing session cookies and encrypting sensitive information stored in Superset's application metadata database.
|
||||
Your deployment must use a complex, unique key.
|
||||
|
||||
@@ -35,7 +35,7 @@ or a view.
|
||||
When working with tables, the solution would be to create a table that contains all the fields
|
||||
needed for your analysis, most likely through some scheduled batch process.
|
||||
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL queries as a virtual table. This can
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL query as a virtual table. This can
|
||||
allow you to join and union multiple tables and to apply some transformation using arbitrary SQL
|
||||
expressions. The limitation there is your database performance, as Superset effectively will run a
|
||||
query on top of your query (view). A good practice may be to limit yourself to joining your main
|
||||
|
||||
2008
docs/yarn.lock
@@ -48,7 +48,7 @@ dependencies = [
|
||||
"cryptography>=42.0.4, <47.0.0",
|
||||
"deprecation>=2.1.0, <2.2.0",
|
||||
"flask>=2.2.5, <4.0.0",
|
||||
"flask-appbuilder>=5.0.2,<6",
|
||||
"flask-appbuilder>=5.2.1, <6.0.0",
|
||||
"flask-caching>=2.1.0, <3",
|
||||
"flask-compress>=1.13, <2.0",
|
||||
"flask-talisman>=1.0.0, <2.0",
|
||||
@@ -183,6 +183,7 @@ risingwave = ["sqlalchemy-risingwave"]
|
||||
shillelagh = ["shillelagh[all]>=1.4.3, <2"]
|
||||
singlestore = ["sqlalchemy-singlestoredb>=1.1.1, <2"]
|
||||
snowflake = ["snowflake-sqlalchemy>=1.2.4, <2"]
|
||||
sqlite = ["syntaqlite>=0.1.0"]
|
||||
spark = [
|
||||
"pyhive[hive]>=0.6.5;python_version<'3.11'",
|
||||
"pyhive[hive_pure_sasl]>=0.7",
|
||||
@@ -226,6 +227,7 @@ development = [
|
||||
"ruff",
|
||||
"sqloxide",
|
||||
"statsd",
|
||||
"syntaqlite>=0.1.0",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
@@ -238,7 +240,7 @@ combine_as_imports = true
|
||||
include_trailing_comma = true
|
||||
line_length = 88
|
||||
known_first_party = "superset, apache-superset-core, apache-superset-extensions-cli"
|
||||
known_third_party = "alembic, apispec, backoff, celery, click, colorama, cron_descriptor, croniter, cryptography, dateutil, deprecation, flask, flask_appbuilder, flask_babel, flask_caching, flask_compress, flask_jwt_extended, flask_login, flask_migrate, flask_sqlalchemy, flask_talisman, flask_testing, flask_wtf, freezegun, geohash, geopy, holidays, humanize, isodate, jinja2, jwt, markdown, markupsafe, marshmallow, marshmallow-union, msgpack, nh3, numpy, pandas, parameterized, parsedatetime, pgsanity, polyline, prison, progress, pyarrow, sqlalchemy_bigquery, pyhive, pyparsing, pytest, pytest_mock, pytz, redis, requests, selenium, setuptools, shillelagh, simplejson, slack, sqlalchemy, sqlalchemy_utils, typing_extensions, urllib3, werkzeug, wtforms, wtforms_json, yaml"
|
||||
known_third_party = "alembic, apispec, backoff, celery, click, colorama, cron_descriptor, croniter, cryptography, dateutil, deprecation, flask, flask_appbuilder, flask_babel, flask_caching, flask_compress, flask_jwt_extended, flask_login, flask_migrate, flask_sqlalchemy, flask_talisman, flask_testing, flask_wtf, freezegun, geohash, geopy, holidays, humanize, isodate, jinja2, jwt, markdown, markupsafe, marshmallow, marshmallow-union, msgpack, nh3, numpy, pandas, parameterized, parsedatetime, pgsanity, polyline, prison, progress, pyarrow, sqlalchemy_bigquery, pyhive, pyparsing, pytest, pytest_mock, pytz, redis, requests, selenium, setuptools, shillelagh, simplejson, slack, sqlalchemy, sqlalchemy_utils, syntaqlite, typing_extensions, urllib3, werkzeug, wtforms, wtforms_json, yaml"
|
||||
multi_line_output = 3
|
||||
order_by_type = false
|
||||
|
||||
@@ -372,6 +374,7 @@ unfixable = []
|
||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"superset/mcp_service/app.py" = ["S608", "E501"] # LLM instruction text: SQL examples (S608) and long lines in multiline string (E501)
|
||||
"scripts/*" = ["TID251"]
|
||||
"setup.py" = ["TID251"]
|
||||
"superset/config.py" = ["TID251"]
|
||||
|
||||
@@ -120,7 +120,7 @@ flask==2.3.3
|
||||
# flask-session
|
||||
# flask-sqlalchemy
|
||||
# flask-wtf
|
||||
flask-appbuilder==5.2.0
|
||||
flask-appbuilder==5.2.1
|
||||
# via
|
||||
# apache-superset (pyproject.toml)
|
||||
# apache-superset-core
|
||||
|
||||
@@ -259,7 +259,7 @@ flask==2.3.3
|
||||
# flask-sqlalchemy
|
||||
# flask-testing
|
||||
# flask-wtf
|
||||
flask-appbuilder==5.2.0
|
||||
flask-appbuilder==5.2.1
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -992,6 +992,8 @@ starlette==0.49.1
|
||||
# via mcp
|
||||
statsd==4.0.1
|
||||
# via apache-superset
|
||||
syntaqlite==0.1.0
|
||||
# via apache-superset
|
||||
tabulate==0.9.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
|
||||
[project]
|
||||
name = "apache-superset-core"
|
||||
version = "0.1.0rc1"
|
||||
version = "0.1.0rc2"
|
||||
description = "Core Python package for building Apache Superset backend extensions and integrations"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Apache Software Foundation", email = "dev@superset.apache.org" },
|
||||
]
|
||||
license = { file="LICENSE.txt" }
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE.txt"]
|
||||
requires-python = ">=3.10"
|
||||
keywords = ["superset", "apache", "analytics", "business-intelligence", "extensions", "visualization"]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Environment :: Web Environment",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
|
||||
@@ -23,14 +23,14 @@ readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Apache Software Foundation", email = "dev@superset.apache.org" },
|
||||
]
|
||||
license = { file="LICENSE.txt" }
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE.txt"]
|
||||
requires-python = ">=3.10"
|
||||
keywords = ["superset", "apache", "cli", "extensions", "analytics", "business-intelligence", "development-tools"]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* 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 { selectResultsTab } from './sqllab.helper';
|
||||
|
||||
describe.skip('SqlLab datasource panel', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/sqllab');
|
||||
});
|
||||
|
||||
// TODO the test below is flaky, and has been disabled for the time being
|
||||
// (notice the `it.skip`)
|
||||
it('creates a table preview when a database, schema, and table are selected', () => {
|
||||
cy.intercept('**/superset/table/**').as('tableMetadata');
|
||||
|
||||
// it should have dropdowns to select database, schema, and table
|
||||
cy.get('.sql-toolbar .Select').should('have.length', 3);
|
||||
|
||||
cy.get('.sql-toolbar .table-schema').should('not.exist');
|
||||
cy.get('[data-test="filterable-table-container"]').should('not.exist');
|
||||
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(0) // database select
|
||||
.within(() => {
|
||||
// note: we have to set force: true because the input is invisible / cypress throws
|
||||
cy.get('input').type('main{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(1) // schema select
|
||||
.within(() => {
|
||||
cy.get('input').type('main{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(2) // table select
|
||||
.within(() => {
|
||||
cy.get('input').type('birth_names{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.wait('@tableMetadata');
|
||||
|
||||
cy.get('.sql-toolbar .table-schema').should('have.length', 1);
|
||||
selectResultsTab().should('have.length', 1);
|
||||
|
||||
// add another table and check for added schema + preview
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(2)
|
||||
.within(() => {
|
||||
cy.get('input').type('logs{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.wait('@tableMetadata');
|
||||
|
||||
cy.get('.sql-toolbar .table-schema').should('have.length', 2);
|
||||
selectResultsTab().should('have.length', 2);
|
||||
});
|
||||
});
|
||||
@@ -1,192 +0,0 @@
|
||||
/**
|
||||
* 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 { nanoid } from 'nanoid';
|
||||
import { selectResultsTab, assertSQLLabResultsAreEqual } from './sqllab.helper';
|
||||
|
||||
function parseClockStr(node: JQuery) {
|
||||
return Number.parseFloat(node.text().replace(/:/g, ''));
|
||||
}
|
||||
|
||||
describe('SqlLab query panel', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/sqllab');
|
||||
});
|
||||
|
||||
it.skip('supports entering and running a query', () => {
|
||||
// row limit has to be < ~10 for us to be able to determine how many rows
|
||||
// are fetched below (because React _Virtualized_ does not render all rows)
|
||||
let clockTime = 0;
|
||||
|
||||
cy.intercept({
|
||||
method: 'POST',
|
||||
url: '**/api/v1/sqllab/execute/',
|
||||
}).as('mockSQLResponse');
|
||||
|
||||
cy.get('.TableSelector .Select:eq(0)').click();
|
||||
cy.get('.TableSelector .Select:eq(0) input[type=text]').focus();
|
||||
cy.focused().type('{enter}');
|
||||
|
||||
cy.get('#brace-editor textarea').focus();
|
||||
cy.focused().clear();
|
||||
cy.focused().type(`{selectall}{backspace}SELECT 1`);
|
||||
|
||||
cy.get('#js-sql-toolbar button:eq(0)').eq(0).click();
|
||||
|
||||
// wait for 300 milliseconds
|
||||
cy.wait(300);
|
||||
|
||||
// started timer
|
||||
cy.get('.sql-toolbar .label-success').then(node => {
|
||||
clockTime = parseClockStr(node);
|
||||
// should be longer than 0.2s
|
||||
expect(clockTime).greaterThan(0.2);
|
||||
});
|
||||
|
||||
cy.wait('@mockSQLResponse');
|
||||
|
||||
// timer is increasing
|
||||
cy.get('.sql-toolbar .label-success').then(node => {
|
||||
const newClockTime = parseClockStr(node);
|
||||
expect(newClockTime).greaterThan(0.9);
|
||||
clockTime = newClockTime;
|
||||
});
|
||||
|
||||
// rerun the query
|
||||
cy.get('#js-sql-toolbar button:eq(0)').eq(0).click();
|
||||
|
||||
// should restart the timer
|
||||
cy.get('.sql-toolbar .label-success').contains('00:00:00');
|
||||
cy.wait('@mockSQLResponse');
|
||||
cy.get('.sql-toolbar .label-success').then(node => {
|
||||
expect(parseClockStr(node)).greaterThan(0.9);
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('successfully saves a query', () => {
|
||||
cy.intercept('**/api/v1/database/**/tables/**').as('getTables');
|
||||
|
||||
const query =
|
||||
'SELECT ds, gender, name, num FROM main.birth_names ORDER BY name LIMIT 3';
|
||||
const savedQueryTitle = `CYPRESS TEST QUERY ${nanoid()}`;
|
||||
|
||||
// we will assert that the results of the query we save, and the saved query are the same
|
||||
let initialResultsTable: HTMLElement | null = null;
|
||||
let savedQueryResultsTable = null;
|
||||
|
||||
cy.get('#brace-editor textarea').clear({ force: true });
|
||||
cy.get('#brace-editor textarea').type(`{selectall}{backspace}${query}`, {
|
||||
force: true,
|
||||
});
|
||||
cy.get('#brace-editor textarea').focus(); // focus => blur is required for updating the query that is to be saved
|
||||
cy.focused().blur();
|
||||
|
||||
// ctrl + r also runs query
|
||||
cy.get('#brace-editor textarea').type('{ctrl}r', { force: true });
|
||||
|
||||
cy.wait('@sqlLabQuery');
|
||||
|
||||
// Save results to check against below
|
||||
selectResultsTab().then(resultsA => {
|
||||
initialResultsTable = resultsA[0];
|
||||
});
|
||||
|
||||
cy.get('#js-sql-toolbar button')
|
||||
.eq(1) // save query
|
||||
.click();
|
||||
|
||||
// Enter name + save into modal
|
||||
cy.get('.modal-sm input').clear({ force: true });
|
||||
cy.get('.modal-sm input').type(`{selectall}{backspace}${savedQueryTitle}`, {
|
||||
force: true,
|
||||
});
|
||||
|
||||
cy.get('.modal-sm .modal-body button')
|
||||
.eq(0) // save
|
||||
.click();
|
||||
|
||||
// first row contains most recent link, follow back to SqlLab
|
||||
cy.get('table tr:first-child a[href*="savedQueryId"').click();
|
||||
|
||||
// will timeout without explicitly waiting here
|
||||
cy.wait(['@getSavedQuery', '@getTables']);
|
||||
|
||||
// run the saved query
|
||||
cy.get('#js-sql-toolbar button')
|
||||
.eq(0) // run query
|
||||
.click();
|
||||
|
||||
cy.wait('@sqlLabQuery');
|
||||
|
||||
// assert the results of the saved query match the initial results
|
||||
selectResultsTab().then(resultsB => {
|
||||
savedQueryResultsTable = resultsB[0];
|
||||
|
||||
assertSQLLabResultsAreEqual(initialResultsTable, savedQueryResultsTable);
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('Create a chart from a query', () => {
|
||||
cy.intercept('**/api/v1/sqllab/execute/').as('queryFinished');
|
||||
cy.intercept('**/api/v1/explore/**').as('explore');
|
||||
cy.intercept('**/api/v1/chart/**').as('chart');
|
||||
cy.intercept('**/tabstateview/**').as('tabstateview');
|
||||
|
||||
// cypress doesn't handle opening a new tab, override window.open to open in the same tab
|
||||
cy.window().then(win => {
|
||||
cy.stub(win, 'open', url => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
win.location.href = url;
|
||||
});
|
||||
});
|
||||
cy.wait('@tabstateview');
|
||||
|
||||
const query = 'SELECT gender, name FROM birth_names';
|
||||
|
||||
cy.get('.ace_text-input').focus();
|
||||
cy.focused().clear({ force: true });
|
||||
cy.focused().type(`{selectall}{backspace}${query}`, { force: true });
|
||||
cy.get('.sql-toolbar button').contains('Run').click();
|
||||
cy.wait('@queryFinished');
|
||||
|
||||
cy.get(
|
||||
'.SouthPane .ant-tabs-content > .ant-tabs-tabpane-active > div button:first',
|
||||
{ timeout: 10000 },
|
||||
).click();
|
||||
|
||||
cy.wait('@explore');
|
||||
cy.get('[data-test="datasource-control"] .title-select').contains(query);
|
||||
cy.get('.column-option-label').first().contains('gender');
|
||||
cy.get('.column-option-label').last().contains('name');
|
||||
|
||||
cy.get(
|
||||
'[data-test="all_columns"] [data-test="dnd-labels-container"] > div:first-child',
|
||||
).contains('gender');
|
||||
cy.get(
|
||||
'[data-test="all_columns"] [data-test="dnd-labels-container"] > div:nth-child(2)',
|
||||
).contains('name');
|
||||
|
||||
cy.wait('@chart');
|
||||
cy.get('[data-test="slice-container"] table > thead th')
|
||||
.first()
|
||||
.contains('gender');
|
||||
cy.get('[data-test="slice-container"] table > thead th')
|
||||
.last()
|
||||
.contains('name');
|
||||
});
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export const selectResultsTab = () =>
|
||||
cy.get('.SouthPane .ReactVirtualized__Table', { timeout: 10000 });
|
||||
|
||||
// this function asserts that the result set for two SQL lab table results are equal
|
||||
export const assertSQLLabResultsAreEqual = (resultsA, resultsB) => {
|
||||
const [headerA, bodyWrapperA] = resultsA.childNodes;
|
||||
const bodyA = bodyWrapperA.childNodes[0];
|
||||
|
||||
const [headerB, bodyWrapperB] = resultsB.childNodes;
|
||||
const bodyB = bodyWrapperB.childNodes[0];
|
||||
|
||||
expect(headerA.childNodes.length).to.equal(headerB.childNodes.length);
|
||||
expect(bodyA.childNodes.length).to.equal(bodyB.childNodes.length);
|
||||
|
||||
bodyA.childNodes.forEach((rowA, rowIndex) => {
|
||||
const rowB = bodyB.childNodes[rowIndex];
|
||||
|
||||
rowA.childNodes.forEach((cellA, columnIndex) => {
|
||||
const cellB = rowB.childNodes[columnIndex];
|
||||
expect(cellA.innerText).to.equal(cellB.innerText);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,113 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
describe('SqlLab query tabs', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/sqllab');
|
||||
});
|
||||
|
||||
const tablistSelector = '[data-test="sql-editor-tabs"] > [role="tablist"]';
|
||||
const tabSelector = `${tablistSelector} [role="tab"]:not([type="button"])`;
|
||||
|
||||
it('allows you to create and close a tab', () => {
|
||||
cy.get(tabSelector).then(tabs => {
|
||||
const initialTabCount = tabs.length;
|
||||
const initialUntitledCount = Math.max(
|
||||
0,
|
||||
...tabs
|
||||
.map(
|
||||
(i, tabItem) =>
|
||||
Number(tabItem.textContent?.match(/Untitled Query (\d+)/)?.[1]) ||
|
||||
0,
|
||||
)
|
||||
.toArray(),
|
||||
);
|
||||
|
||||
// add two new tabs
|
||||
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||
|
||||
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 2}`);
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 2);
|
||||
|
||||
// close the tabs
|
||||
cy.get(`${tabSelector}:last [data-test="dropdown-trigger"]`).click({
|
||||
force: true,
|
||||
});
|
||||
cy.get('[data-test="close-tab-menu-option"]').click();
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||
|
||||
cy.get(`${tablistSelector} [aria-label="remove"]:last`).click();
|
||||
cy.get(tabSelector).should('have.length', initialTabCount);
|
||||
});
|
||||
});
|
||||
|
||||
it('opens a new tab by a button and a shortcut', () => {
|
||||
const editorContent = '.ace_editor .ace_content';
|
||||
const editorInput = '.ace_editor textarea';
|
||||
const queryLimitSelector = '#js-sql-toolbar .limitDropdown';
|
||||
cy.get(tabSelector).then(tabs => {
|
||||
const initialTabCount = tabs.length;
|
||||
const initialUntitledCount = Math.max(
|
||||
0,
|
||||
...tabs
|
||||
.map(
|
||||
(i, tabItem) =>
|
||||
Number(tabItem.textContent?.match(/Untitled Query (\d+)/)?.[1]) ||
|
||||
0,
|
||||
)
|
||||
.toArray(),
|
||||
);
|
||||
|
||||
// configure some editor settings
|
||||
cy.get(editorInput).type('some random query string', { force: true });
|
||||
cy.get(queryLimitSelector).parent().click({ force: true });
|
||||
cy.get('.ant-dropdown-menu')
|
||||
.last()
|
||||
.find('.ant-dropdown-menu-item')
|
||||
.first()
|
||||
.click({ force: true });
|
||||
|
||||
// open a new tab by a button
|
||||
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||
cy.get(editorContent).contains('SELECT ...');
|
||||
cy.get(queryLimitSelector).contains('10');
|
||||
|
||||
// close the tab
|
||||
cy.get(`${tabSelector}:last [data-test="dropdown-trigger"]`).click({
|
||||
force: true,
|
||||
});
|
||||
cy.get(`${tablistSelector} [aria-label="remove"]:last`).click({
|
||||
force: true,
|
||||
});
|
||||
cy.get(tabSelector).should('have.length', initialTabCount);
|
||||
|
||||
// open a new tab by a shortcut
|
||||
cy.get('body').type('{ctrl}t');
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||
cy.get(editorContent).contains('SELECT ...');
|
||||
cy.get(queryLimitSelector).contains('10');
|
||||
});
|
||||
});
|
||||
});
|
||||
1592
superset-frontend/package-lock.json
generated
@@ -128,17 +128,17 @@
|
||||
"@superset-ui/legacy-plugin-chart-chord": "file:./plugins/legacy-plugin-chart-chord",
|
||||
"@superset-ui/legacy-plugin-chart-country-map": "file:./plugins/legacy-plugin-chart-country-map",
|
||||
"@superset-ui/legacy-plugin-chart-horizon": "file:./plugins/legacy-plugin-chart-horizon",
|
||||
"@superset-ui/legacy-plugin-chart-map-box": "file:./plugins/legacy-plugin-chart-map-box",
|
||||
"@superset-ui/legacy-plugin-chart-paired-t-test": "file:./plugins/legacy-plugin-chart-paired-t-test",
|
||||
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "file:./plugins/legacy-plugin-chart-parallel-coordinates",
|
||||
"@superset-ui/legacy-plugin-chart-partition": "file:./plugins/legacy-plugin-chart-partition",
|
||||
"@superset-ui/legacy-plugin-chart-rose": "file:./plugins/legacy-plugin-chart-rose",
|
||||
"@superset-ui/legacy-plugin-chart-world-map": "file:./plugins/legacy-plugin-chart-world-map",
|
||||
"@superset-ui/legacy-preset-chart-deckgl": "file:./plugins/legacy-preset-chart-deckgl",
|
||||
"@superset-ui/preset-chart-deckgl": "file:./plugins/preset-chart-deckgl",
|
||||
"@superset-ui/legacy-preset-chart-nvd3": "file:./plugins/legacy-preset-chart-nvd3",
|
||||
"@superset-ui/plugin-chart-ag-grid-table": "file:./plugins/plugin-chart-ag-grid-table",
|
||||
"@superset-ui/plugin-chart-cartodiagram": "file:./plugins/plugin-chart-cartodiagram",
|
||||
"@superset-ui/plugin-chart-echarts": "file:./plugins/plugin-chart-echarts",
|
||||
"@superset-ui/plugin-chart-point-cluster-map": "file:./plugins/plugin-chart-point-cluster-map",
|
||||
"@superset-ui/plugin-chart-handlebars": "file:./plugins/plugin-chart-handlebars",
|
||||
"@superset-ui/plugin-chart-pivot-table": "file:./plugins/plugin-chart-pivot-table",
|
||||
"@superset-ui/plugin-chart-table": "file:./plugins/plugin-chart-table",
|
||||
@@ -168,8 +168,8 @@
|
||||
"echarts": "^5.6.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"fs-extra": "^11.3.4",
|
||||
"fuse.js": "^7.1.0",
|
||||
"geolib": "^3.3.4",
|
||||
"fuse.js": "^7.3.0",
|
||||
"geolib": "^3.3.14",
|
||||
"geostyler": "^18.3.1",
|
||||
"geostyler-data": "^1.1.0",
|
||||
"geostyler-openlayers-parser": "^5.4.1",
|
||||
@@ -184,7 +184,7 @@
|
||||
"json-stringify-pretty-compact": "^2.0.0",
|
||||
"lodash": "^4.18.1",
|
||||
"mapbox-gl": "^3.20.0",
|
||||
"markdown-to-jsx": "^9.7.13",
|
||||
"markdown-to-jsx": "^9.7.15",
|
||||
"match-sorter": "^8.2.0",
|
||||
"memoize-one": "^5.2.1",
|
||||
"mousetrap": "^1.6.5",
|
||||
@@ -223,7 +223,7 @@
|
||||
"redux-undo": "^1.0.0-beta9-9-7",
|
||||
"rison": "^0.1.1",
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
"simple-zstd": "^2.1.0",
|
||||
"simple-zstd": "^1.4.2",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"tinycolor2": "^1.4.2",
|
||||
"urijs": "^1.19.8",
|
||||
@@ -270,8 +270,8 @@
|
||||
"@storybook/test": "^8.6.15",
|
||||
"@storybook/test-runner": "^0.17.0",
|
||||
"@svgr/webpack": "^8.1.0",
|
||||
"@swc/core": "^1.15.21",
|
||||
"@swc/plugin-emotion": "^14.7.0",
|
||||
"@swc/core": "^1.15.24",
|
||||
"@swc/plugin-emotion": "^14.8.0",
|
||||
"@swc/plugin-transform-imports": "^12.5.0",
|
||||
"@testing-library/dom": "^8.20.1",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
@@ -284,7 +284,7 @@
|
||||
"@types/js-levenshtein": "^1.1.3",
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
"@types/mousetrap": "^1.6.15",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/react": "^17.0.83",
|
||||
"@types/react-dom": "^17.0.26",
|
||||
"@types/react-loadable": "^5.5.11",
|
||||
@@ -301,11 +301,11 @@
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"babel-jest": "^30.0.2",
|
||||
"babel-loader": "^10.1.0",
|
||||
"babel-loader": "^10.1.1",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.3",
|
||||
"babel-plugin-jsx-remove-data-test-id": "^3.0.0",
|
||||
"babel-plugin-lodash": "^3.3.4",
|
||||
"baseline-browser-mapping": "^2.10.13",
|
||||
"baseline-browser-mapping": "^2.10.16",
|
||||
"cheerio": "1.2.0",
|
||||
"concurrently": "^9.2.1",
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
@@ -340,14 +340,14 @@
|
||||
"jest-html-reporter": "^4.4.0",
|
||||
"jest-websocket-mock": "^2.5.0",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"jsdom": "^29.0.1",
|
||||
"jsdom": "^29.0.2",
|
||||
"lerna": "^9.0.4",
|
||||
"lightningcss": "^1.32.0",
|
||||
"mini-css-extract-plugin": "^2.10.2",
|
||||
"open-cli": "^9.0.0",
|
||||
"oxlint": "^1.56.0",
|
||||
"po2json": "^0.4.5",
|
||||
"prettier": "3.8.1",
|
||||
"prettier": "3.8.3",
|
||||
"prettier-plugin-packagejson": "^3.0.2",
|
||||
"process": "^0.11.10",
|
||||
"react-refresh": "^0.18.0",
|
||||
@@ -367,8 +367,8 @@
|
||||
"typescript": "5.4.5",
|
||||
"unzipper": "^0.12.3",
|
||||
"vm-browserify": "^1.1.2",
|
||||
"wait-on": "^9.0.4",
|
||||
"webpack": "^5.105.4",
|
||||
"wait-on": "^9.0.5",
|
||||
"webpack": "^5.106.0",
|
||||
"webpack-bundle-analyzer": "^5.3.0",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"webpack-dev-server": "^5.2.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apache-superset/core",
|
||||
"version": "0.1.0-rc1",
|
||||
"version": "0.1.0-rc2",
|
||||
"description": "This package contains UI elements, APIs, and utility functions used by Superset.",
|
||||
"sideEffects": false,
|
||||
"main": "lib/index.js",
|
||||
@@ -70,8 +70,8 @@
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.28.6",
|
||||
"@babel/core": "^7.29.0",
|
||||
|
||||
@@ -21,7 +21,11 @@ import { styled, css } from '@apache-superset/core/theme';
|
||||
export const ControlSubSectionHeader = styled.div`
|
||||
${({ theme }) => css`
|
||||
font-weight: ${theme.fontWeightStrong};
|
||||
margin-top: ${theme.sizeUnit * 3}px;
|
||||
margin-bottom: ${theme.sizeUnit}px;
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: ${theme.colorTextSecondary};
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"d3-time": "^3.1.0",
|
||||
"d3-time-format": "^4.1.0",
|
||||
"dayjs": "^1.11.20",
|
||||
"dompurify": "^3.3.3",
|
||||
"dompurify": "^3.4.0",
|
||||
"fetch-retry": "^6.0.0",
|
||||
"handlebars": "^4.7.9",
|
||||
"jed": "^1.1.1",
|
||||
@@ -76,7 +76,7 @@
|
||||
"@types/d3-time-format": "^4.0.3",
|
||||
"@types/jquery": "^3.5.33",
|
||||
"@types/lodash": "^4.17.24",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/prop-types": "^15.7.15",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@types/react-table": "^7.7.20",
|
||||
@@ -85,7 +85,7 @@
|
||||
"fetch-mock": "^12.6.0",
|
||||
"jest-mock-console": "^2.0.0",
|
||||
"resize-observer-polyfill": "1.5.1",
|
||||
"timezone-mock": "1.4.0"
|
||||
"timezone-mock": "^1.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@emotion/cache": "^11.4.0",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PureComponent, ReactNode } from 'react';
|
||||
import { memo, ReactNode } from 'react';
|
||||
|
||||
import { isDefined } from '../utils';
|
||||
|
||||
@@ -29,7 +29,7 @@ type Props = {
|
||||
contentWidth?: number;
|
||||
contentHeight?: number;
|
||||
height: number;
|
||||
renderContent: ({
|
||||
renderContent?: ({
|
||||
height,
|
||||
width,
|
||||
}: {
|
||||
@@ -39,36 +39,35 @@ type Props = {
|
||||
width: number;
|
||||
};
|
||||
|
||||
export default class ChartFrame extends PureComponent<Props, {}> {
|
||||
static defaultProps = {
|
||||
renderContent() {},
|
||||
};
|
||||
function ChartFrame({
|
||||
contentWidth,
|
||||
contentHeight,
|
||||
width,
|
||||
height,
|
||||
renderContent = () => null,
|
||||
}: Props) {
|
||||
const overflowX = checkNumber(contentWidth) && contentWidth > width;
|
||||
const overflowY = checkNumber(contentHeight) && contentHeight > height;
|
||||
|
||||
render() {
|
||||
const { contentWidth, contentHeight, width, height, renderContent } =
|
||||
this.props;
|
||||
|
||||
const overflowX = checkNumber(contentWidth) && contentWidth > width;
|
||||
const overflowY = checkNumber(contentHeight) && contentHeight > height;
|
||||
|
||||
if (overflowX || overflowY) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height,
|
||||
overflowX: overflowX ? 'auto' : 'hidden',
|
||||
overflowY: overflowY ? 'auto' : 'hidden',
|
||||
width,
|
||||
}}
|
||||
>
|
||||
{renderContent({
|
||||
height: Math.max(contentHeight ?? 0, height),
|
||||
width: Math.max(contentWidth ?? 0, width),
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return renderContent({ height, width });
|
||||
if (overflowX || overflowY) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height,
|
||||
overflowX: overflowX ? 'auto' : 'hidden',
|
||||
overflowY: overflowY ? 'auto' : 'hidden',
|
||||
width,
|
||||
}}
|
||||
>
|
||||
{renderContent({
|
||||
height: Math.max(contentHeight ?? 0, height),
|
||||
width: Math.max(contentWidth ?? 0, width),
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <>{renderContent({ height, width })}</>;
|
||||
}
|
||||
|
||||
export default memo(ChartFrame);
|
||||
|
||||
@@ -17,26 +17,19 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { CSSProperties, ReactNode, PureComponent } from 'react';
|
||||
import { CSSProperties, ReactNode, memo, useMemo } from 'react';
|
||||
import { ParentSize } from '@visx/responsive';
|
||||
|
||||
const defaultProps = {
|
||||
className: '',
|
||||
height: 'auto' as number | string,
|
||||
position: 'top',
|
||||
width: 'auto' as number | string,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
className: string;
|
||||
className?: string;
|
||||
debounceTime?: number;
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
legendJustifyContent?: 'center' | 'flex-start' | 'flex-end';
|
||||
position: 'top' | 'left' | 'bottom' | 'right';
|
||||
position?: 'top' | 'left' | 'bottom' | 'right';
|
||||
renderChart: (dim: { width: number; height: number }) => ReactNode;
|
||||
renderLegend?: (params: { direction: string }) => ReactNode;
|
||||
} & Readonly<typeof defaultProps>;
|
||||
};
|
||||
|
||||
const LEGEND_STYLE_BASE: CSSProperties = {
|
||||
display: 'flex',
|
||||
@@ -52,95 +45,101 @@ const CHART_STYLE_BASE: CSSProperties = {
|
||||
position: 'relative',
|
||||
};
|
||||
|
||||
class WithLegend extends PureComponent<Props, {}> {
|
||||
static defaultProps = defaultProps;
|
||||
|
||||
getContainerDirection(): CSSProperties['flexDirection'] {
|
||||
const { position } = this.props;
|
||||
|
||||
if (position === 'left') {
|
||||
return 'row';
|
||||
}
|
||||
if (position === 'right') {
|
||||
return 'row-reverse';
|
||||
}
|
||||
if (position === 'bottom') {
|
||||
return 'column-reverse';
|
||||
}
|
||||
|
||||
return 'column';
|
||||
function getContainerDirection(
|
||||
position: Props['position'],
|
||||
): CSSProperties['flexDirection'] {
|
||||
if (position === 'left') {
|
||||
return 'row';
|
||||
}
|
||||
if (position === 'right') {
|
||||
return 'row-reverse';
|
||||
}
|
||||
if (position === 'bottom') {
|
||||
return 'column-reverse';
|
||||
}
|
||||
|
||||
getLegendJustifyContent() {
|
||||
const { legendJustifyContent, position } = this.props;
|
||||
if (legendJustifyContent) {
|
||||
return legendJustifyContent;
|
||||
}
|
||||
|
||||
if (position === 'left' || position === 'right') {
|
||||
return 'flex-start';
|
||||
}
|
||||
|
||||
return 'flex-end';
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
className,
|
||||
debounceTime,
|
||||
width,
|
||||
height,
|
||||
position,
|
||||
renderChart,
|
||||
renderLegend,
|
||||
} = this.props;
|
||||
|
||||
const isHorizontal = position === 'left' || position === 'right';
|
||||
|
||||
const style: CSSProperties = {
|
||||
display: 'flex',
|
||||
flexDirection: this.getContainerDirection(),
|
||||
height,
|
||||
width,
|
||||
};
|
||||
|
||||
const chartStyle: CSSProperties = { ...CHART_STYLE_BASE };
|
||||
if (isHorizontal) {
|
||||
chartStyle.width = 0;
|
||||
} else {
|
||||
chartStyle.height = 0;
|
||||
}
|
||||
|
||||
const legendDirection = isHorizontal ? 'column' : 'row';
|
||||
const legendStyle: CSSProperties = {
|
||||
...LEGEND_STYLE_BASE,
|
||||
flexDirection: legendDirection,
|
||||
justifyContent: this.getLegendJustifyContent(),
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`with-legend ${className}`} style={style}>
|
||||
{renderLegend && (
|
||||
<div className="legend-container" style={legendStyle}>
|
||||
{renderLegend({
|
||||
// Pass flexDirection for @vx/legend to arrange legend items
|
||||
direction: legendDirection,
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div className="main-container" style={chartStyle}>
|
||||
<ParentSize debounceTime={debounceTime}>
|
||||
{(parent: { width: number; height: number }) =>
|
||||
parent.width > 0 && parent.height > 0
|
||||
? // Only render when necessary
|
||||
renderChart(parent)
|
||||
: null
|
||||
}
|
||||
</ParentSize>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return 'column';
|
||||
}
|
||||
|
||||
export default WithLegend;
|
||||
function getLegendJustifyContent(
|
||||
legendJustifyContent: Props['legendJustifyContent'],
|
||||
position: Props['position'],
|
||||
) {
|
||||
if (legendJustifyContent) {
|
||||
return legendJustifyContent;
|
||||
}
|
||||
|
||||
if (position === 'left' || position === 'right') {
|
||||
return 'flex-start';
|
||||
}
|
||||
|
||||
return 'flex-end';
|
||||
}
|
||||
|
||||
function WithLegend({
|
||||
className = '',
|
||||
debounceTime,
|
||||
width = 'auto',
|
||||
height = 'auto',
|
||||
legendJustifyContent,
|
||||
position = 'top',
|
||||
renderChart,
|
||||
renderLegend,
|
||||
}: Props) {
|
||||
const isHorizontal = position === 'left' || position === 'right';
|
||||
|
||||
const style: CSSProperties = useMemo(
|
||||
() => ({
|
||||
display: 'flex',
|
||||
flexDirection: getContainerDirection(position),
|
||||
height,
|
||||
width,
|
||||
}),
|
||||
[position, height, width],
|
||||
);
|
||||
|
||||
const chartStyle: CSSProperties = useMemo(() => {
|
||||
const baseStyle = { ...CHART_STYLE_BASE };
|
||||
if (isHorizontal) {
|
||||
baseStyle.width = 0;
|
||||
} else {
|
||||
baseStyle.height = 0;
|
||||
}
|
||||
return baseStyle;
|
||||
}, [isHorizontal]);
|
||||
|
||||
const legendDirection = isHorizontal ? 'column' : 'row';
|
||||
const legendStyle: CSSProperties = useMemo(
|
||||
() => ({
|
||||
...LEGEND_STYLE_BASE,
|
||||
flexDirection: legendDirection,
|
||||
justifyContent: getLegendJustifyContent(legendJustifyContent, position),
|
||||
}),
|
||||
[legendDirection, legendJustifyContent, position],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={`with-legend ${className}`} style={style}>
|
||||
{renderLegend && (
|
||||
<div className="legend-container" style={legendStyle}>
|
||||
{renderLegend({
|
||||
// Pass flexDirection for @vx/legend to arrange legend items
|
||||
direction: legendDirection,
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div className="main-container" style={chartStyle}>
|
||||
<ParentSize debounceTime={debounceTime}>
|
||||
{(parent: { width: number; height: number }) =>
|
||||
parent.width > 0 && parent.height > 0
|
||||
? // Only render when necessary
|
||||
renderChart(parent)
|
||||
: null
|
||||
}
|
||||
</ParentSize>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default memo(WithLegend);
|
||||
|
||||
@@ -17,31 +17,21 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PureComponent, ReactNode } from 'react';
|
||||
|
||||
const defaultProps = {
|
||||
className: '',
|
||||
};
|
||||
import { memo, ReactNode } from 'react';
|
||||
|
||||
type Props = {
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
} & Readonly<typeof defaultProps>;
|
||||
};
|
||||
|
||||
const CONTAINER_STYLE = { padding: 8 };
|
||||
|
||||
class TooltipFrame extends PureComponent<Props, {}> {
|
||||
static defaultProps = defaultProps;
|
||||
|
||||
render() {
|
||||
const { className, children } = this.props;
|
||||
|
||||
return (
|
||||
<div className={className} style={CONTAINER_STYLE}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
function TooltipFrame({ className = '', children }: Props) {
|
||||
return (
|
||||
<div className={className} style={CONTAINER_STYLE}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default TooltipFrame;
|
||||
export default memo(TooltipFrame);
|
||||
|
||||
@@ -41,6 +41,7 @@ export enum VizType {
|
||||
LegacyBubble = 'bubble',
|
||||
Line = 'echarts_timeseries_line',
|
||||
MapBox = 'mapbox',
|
||||
PointClusterMap = 'point_cluster_map',
|
||||
MixedTimeseries = 'mixed_timeseries',
|
||||
PairedTTest = 'paired_ttest',
|
||||
ParallelCoordinates = 'para',
|
||||
|
||||
@@ -319,6 +319,11 @@ export function AsyncAceEditor(
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* Style bracket matching to blend with theme */
|
||||
.ace_editor .ace_bracket {
|
||||
border-color: ${token.colorPrimaryBorderHover} !important;
|
||||
}
|
||||
|
||||
/* Adjust cursor color */
|
||||
.ace_editor .ace_cursor {
|
||||
color: ${token.colorPrimaryText} !important;
|
||||
|
||||
@@ -33,20 +33,22 @@ import type { PlaceholderProps } from './types';
|
||||
function DefaultPlaceholder({
|
||||
width,
|
||||
height,
|
||||
showLoadingForImport = false,
|
||||
showLoadingForImport = true,
|
||||
placeholderStyle: style,
|
||||
}: PlaceholderProps) {
|
||||
return (
|
||||
// since `width` defaults to 100%, we can display the placeholder once
|
||||
// height is specified.
|
||||
(height && (
|
||||
if (showLoadingForImport) {
|
||||
return (
|
||||
<div key="async-asm-placeholder" style={{ width, height, ...style }}>
|
||||
{showLoadingForImport && <Loading position="floating" />}
|
||||
<Loading position="floating" size="s" />
|
||||
</div>
|
||||
)) ||
|
||||
// `|| null` is for in case of height=0.
|
||||
null
|
||||
);
|
||||
);
|
||||
}
|
||||
if (height) {
|
||||
return (
|
||||
<div key="async-asm-placeholder" style={{ width, height, ...style }} />
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { render, screen } from '../../spec';
|
||||
import { render, screen, fireEvent } from '../../spec';
|
||||
import CodeSyntaxHighlighter from './index';
|
||||
|
||||
// Simple mock that just returns the content
|
||||
@@ -153,4 +153,44 @@ describe('CodeSyntaxHighlighter', () => {
|
||||
|
||||
expect(screen.getByText('SELECT * FROM users;')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('shows copy button by default', () => {
|
||||
render(
|
||||
<CodeSyntaxHighlighter language="sql">SELECT 1;</CodeSyntaxHighlighter>,
|
||||
);
|
||||
|
||||
expect(screen.getByTitle('Copy to clipboard')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('hides copy button when showCopyButton is false', () => {
|
||||
render(
|
||||
<CodeSyntaxHighlighter language="sql" showCopyButton={false}>
|
||||
SELECT 1;
|
||||
</CodeSyntaxHighlighter>,
|
||||
);
|
||||
|
||||
expect(screen.queryByTitle('Copy to clipboard')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('copy button does not throw when clipboard API is unavailable', () => {
|
||||
const originalClipboard = navigator.clipboard;
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: undefined,
|
||||
configurable: true,
|
||||
});
|
||||
document.execCommand = jest.fn().mockReturnValue(true);
|
||||
|
||||
render(
|
||||
<CodeSyntaxHighlighter language="sql">SELECT 1;</CodeSyntaxHighlighter>,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
fireEvent.click(screen.getByTitle('Copy to clipboard')),
|
||||
).not.toThrow();
|
||||
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: originalClipboard,
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import SyntaxHighlighterBase from 'react-syntax-highlighter/dist/cjs/light';
|
||||
import github from 'react-syntax-highlighter/dist/cjs/styles/hljs/github';
|
||||
import tomorrow from 'react-syntax-highlighter/dist/cjs/styles/hljs/tomorrow-night';
|
||||
import { isThemeDark, useTheme } from '@apache-superset/core/theme';
|
||||
import { css, isThemeDark, useTheme } from '@apache-superset/core/theme';
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import copyTextToClipboard from '../../utils/copy';
|
||||
import { Icons } from '../Icons';
|
||||
|
||||
export type SupportedLanguage = 'sql' | 'htmlbars' | 'markdown' | 'json';
|
||||
|
||||
@@ -31,6 +34,7 @@ export interface CodeSyntaxHighlighterProps {
|
||||
showLineNumbers?: boolean;
|
||||
wrapLines?: boolean;
|
||||
style?: any; // Override theme style if needed
|
||||
showCopyButton?: boolean;
|
||||
}
|
||||
|
||||
// Track which languages have been registered to avoid duplicate registrations
|
||||
@@ -76,11 +80,14 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
showLineNumbers = false,
|
||||
wrapLines = true,
|
||||
style: overrideStyle,
|
||||
showCopyButton = true,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const [isLanguageReady, setIsLanguageReady] = useState(
|
||||
registeredLanguages.has(language),
|
||||
);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const copyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const loadLanguage = async () => {
|
||||
@@ -93,6 +100,21 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
loadLanguage();
|
||||
}, [language]);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const handleCopy = useCallback(() => {
|
||||
copyTextToClipboard(() => Promise.resolve(children)).then(() => {
|
||||
if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current);
|
||||
setCopied(true);
|
||||
copyTimeoutRef.current = setTimeout(() => setCopied(false), 1500);
|
||||
});
|
||||
}, [children]);
|
||||
|
||||
const isDark = isThemeDark(theme);
|
||||
const themeStyle = overrideStyle || (isDark ? tomorrow : github);
|
||||
|
||||
@@ -104,32 +126,79 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
...customStyle,
|
||||
};
|
||||
|
||||
const copyButton = showCopyButton && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
handleCopy();
|
||||
}}
|
||||
title={copied ? t('Copied!') : t('Copy to clipboard')}
|
||||
css={css`
|
||||
position: absolute;
|
||||
top: ${theme.sizeUnit}px;
|
||||
right: ${theme.sizeUnit}px;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: ${theme.sizeUnit}px;
|
||||
color: ${copied ? theme.colorSuccess : theme.colorTextSecondary};
|
||||
line-height: 1;
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
&:hover {
|
||||
color: ${copied ? theme.colorSuccess : theme.colorText};
|
||||
background: ${theme.colorBgTextHover};
|
||||
}
|
||||
`}
|
||||
>
|
||||
{copied ? (
|
||||
<Icons.CheckOutlined style={{ fontSize: theme.fontSizeSM }} />
|
||||
) : (
|
||||
<Icons.CopyOutlined style={{ fontSize: theme.fontSizeSM }} />
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
|
||||
// Show a simple pre-formatted text while language is loading
|
||||
if (!isLanguageReady) {
|
||||
return (
|
||||
<pre
|
||||
style={{
|
||||
...defaultCustomStyle,
|
||||
fontFamily: 'monospace',
|
||||
whiteSpace: 'pre-wrap',
|
||||
margin: 0,
|
||||
}}
|
||||
<div
|
||||
css={css`
|
||||
position: relative;
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</pre>
|
||||
{copyButton}
|
||||
<pre
|
||||
style={{
|
||||
...defaultCustomStyle,
|
||||
fontFamily: 'monospace',
|
||||
whiteSpace: 'pre-wrap',
|
||||
margin: 0,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SyntaxHighlighterBase
|
||||
language={language}
|
||||
style={themeStyle}
|
||||
customStyle={defaultCustomStyle}
|
||||
showLineNumbers={showLineNumbers}
|
||||
wrapLines={wrapLines}
|
||||
<div
|
||||
css={css`
|
||||
position: relative;
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</SyntaxHighlighterBase>
|
||||
{copyButton}
|
||||
<SyntaxHighlighterBase
|
||||
language={language}
|
||||
style={themeStyle}
|
||||
customStyle={defaultCustomStyle}
|
||||
showLineNumbers={showLineNumbers}
|
||||
wrapLines={wrapLines}
|
||||
>
|
||||
{children}
|
||||
</SyntaxHighlighterBase>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<svg viewBox="0 0 119 78" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="17" y="1" width="86" height="62" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="21" y="5" width="78" height="14" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="21" y="23" width="38" height="36" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="63" y="37" width="36" height="22" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="63" y="23" width="36" height="10" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M16 55.2892C6.07439 57.7013 0 60.9397 0 64.5C0 71.9559 26.6391 78 59.5 78C92.3609 78 119 71.9559 119 64.5C119 61.0609 113.332 57.9221 104 55.5383V60C104 62.2092 102.209 64 100 64H20C17.7909 64 16 62.2092 16 60V55.2892Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
<path d="M99.3193 1H20.6639C19.0349 1 17.7143 2.32057 17.7143 3.94958V59.0084C17.7143 60.6374 19.0349 61.958 20.6639 61.958H99.3193C100.948 61.958 102.269 60.6374 102.269 59.0084V3.94958C102.269 2.32057 100.948 1 99.3193 1Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M95.3866 4.93277H24.5966C22.9676 4.93277 21.647 6.25335 21.647 7.88235V15.7479C21.647 17.3769 22.9676 18.6975 24.5966 18.6975H95.3866C97.0156 18.6975 98.3361 17.3769 98.3361 15.7479V7.88235C98.3361 6.25335 97.0156 4.93277 95.3866 4.93277Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M56.0588 22.6303H24.5966C22.9676 22.6303 21.647 23.9508 21.647 25.5798V55.0756C21.647 56.7046 22.9676 58.0252 24.5966 58.0252H56.0588C57.6878 58.0252 59.0084 56.7046 59.0084 55.0756V25.5798C59.0084 23.9508 57.6878 22.6303 56.0588 22.6303Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M95.3865 36.395H65.8907C64.2617 36.395 62.9412 37.7155 62.9412 39.3445V55.0756C62.9412 56.7046 64.2617 58.0252 65.8907 58.0252H95.3865C97.0155 58.0252 98.3361 56.7046 98.3361 55.0756V39.3445C98.3361 37.7155 97.0155 36.395 95.3865 36.395Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M95.3865 22.6303H65.8907C64.2617 22.6303 62.9412 23.9508 62.9412 25.5798V29.5126C62.9412 31.1416 64.2617 32.4622 65.8907 32.4622H95.3865C97.0155 32.4622 98.3361 31.1416 98.3361 29.5126V25.5798C98.3361 23.9508 97.0155 22.6303 95.3865 22.6303Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M17.2227 59.0086C17.2228 60.9091 18.7637 62.45 20.6641 62.45H99.3193C101.22 62.45 102.761 60.9091 102.761 59.0086V53.9891L103.374 54.1453C107.981 55.3221 111.718 56.6931 114.315 58.2137C116.877 59.7134 118.491 61.4572 118.491 63.4324C118.491 64.5056 118.01 65.513 117.177 66.4373C116.346 67.3587 115.143 68.2232 113.635 69.032C110.618 70.6501 106.286 72.0925 100.975 73.2977C90.343 75.7099 75.6797 77.1971 59.5 77.1971C43.3203 77.1971 28.657 75.7099 18.0254 73.2977C12.7137 72.0925 8.38162 70.6501 5.36523 69.032C3.85742 68.2232 2.65424 67.3587 1.82324 66.4373C0.989641 65.513 0.508789 64.5056 0.508789 63.4324C0.508977 61.389 2.23587 59.5926 4.96484 58.0535C7.73449 56.4916 11.717 55.0896 16.6152 53.8992L17.2227 53.7518V59.0086Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -17,6 +17,6 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<svg viewBox="0 0 119 76" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M83.1952 1.36598L103 24V62C103 64.2091 101.209 66 99 66H20C17.7909 66 16 64.2091 16 62V24L35.8048 1.36598C36.5643 0.497921 37.6616 0 38.8151 0H80.1849C81.3384 0 82.4357 0.497922 83.1952 1.36598ZM101 26V62C101 63.1046 100.105 64 99 64H20C18.8954 64 18 63.1046 18 62V26H35.25C37.8734 26 40 28.1266 40 30.75C40 34.4779 43.0221 37.5 46.75 37.5H72.25C75.9779 37.5 79 34.4779 79 30.75C79 28.1266 81.1266 26 83.75 26H101ZM100.342 24L81.6901 2.68299C81.3103 2.24896 80.7617 2 80.1849 2H38.8151C38.2383 2 37.6897 2.24896 37.3099 2.68299L18.6575 24H35.25C38.9779 24 42 27.0221 42 30.75C42 33.3734 44.1266 35.5 46.75 35.5H72.25C74.8734 35.5 77 33.3734 77 30.75C77 27.0221 80.0221 24 83.75 24H100.342Z" fill="currentColor"/>
|
||||
<path d="M16 53.2891C6.07439 55.7012 0 58.9396 0 62.4999C0 69.9557 26.6391 75.9999 59.5 75.9999C92.3609 75.9999 119 69.9557 119 62.4999C119 58.9396 112.926 55.7012 103 53.2891V61.9999C103 64.209 101.209 65.9999 99 65.9999H20C17.7909 65.9999 16 64.209 16 61.9999V53.2891Z" fill="currentColor" stroke="currentColor" fill-opacity="0.25" />
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M82.7969 1.34302L102.269 23.5966V60.958C102.269 63.13 100.508 64.8908 98.3361 64.8908H20.6639C18.4919 64.8908 16.7311 63.13 16.7311 60.958V23.5966L36.203 1.34302C36.9498 0.489553 38.0286 0 39.1627 0H79.8372C80.9713 0 82.0502 0.489554 82.7969 1.34302ZM100.303 25.563V60.958C100.303 62.044 99.4225 62.9244 98.3361 62.9244H20.6639C19.5778 62.9244 18.6975 62.044 18.6975 60.958V25.563H35.6575C38.2369 25.563 40.3277 27.6539 40.3277 30.2332C40.3277 33.8984 43.299 36.8698 46.9643 36.8698H72.0357C75.7009 36.8698 78.6723 33.8984 78.6723 30.2332C78.6723 27.6539 80.7631 25.563 83.3424 25.563H100.303ZM99.6556 23.5966L81.3171 2.6379C80.9437 2.21116 80.4043 1.96639 79.8372 1.96639H39.1627C38.5956 1.96639 38.0562 2.21116 37.6828 2.6379L19.3439 23.5966H35.6575C39.3228 23.5966 42.2941 26.568 42.2941 30.2332C42.2941 32.8125 44.385 34.9034 46.9643 34.9034H72.0357C74.615 34.9034 76.7059 32.8125 76.7059 30.2332C76.7059 26.568 79.6772 23.5966 83.3424 23.5966H99.6556Z" fill="currentColor"/>
|
||||
<path d="M102.385 51.9159C107.283 53.1063 111.266 54.5083 114.035 56.0702C116.764 57.6093 118.491 59.4058 118.491 61.4492C118.491 62.5223 118.01 63.5298 117.177 64.454C116.346 65.3754 115.143 66.2399 113.635 67.0488C110.618 68.6668 106.286 70.1092 100.975 71.3144C90.343 73.7266 75.6797 75.2138 59.5 75.2138C43.3203 75.2138 28.657 73.7266 18.0254 71.3144C12.7137 70.1092 8.38162 68.6668 5.36523 67.0488C3.85743 66.2399 2.65424 65.3754 1.82324 64.454C0.989642 63.5298 0.508789 62.5223 0.508789 61.4492C0.508976 59.4057 2.23587 57.6093 4.96484 56.0702C7.73449 54.5083 11.717 53.1063 16.6152 51.9159L17.2227 51.7685V60.9579C17.2227 62.8584 18.7636 64.3993 20.6641 64.3993H98.3359C100.236 64.3993 101.777 62.8584 101.777 60.9579V51.7685L102.385 51.9159Z" fill="currentColor" stroke="currentColor" fill-opacity="0.25" />
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -17,6 +17,6 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<svg viewBox="0 0 119 78" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M59.2123 1.55857C59.4575 0.81382 60.5425 0.813801 60.7878 1.55857L67.5616 22.1322C67.9434 23.292 69.0328 24.0653 70.249 24.0653L92.1695 24.0653C92.9982 24.0653 93.2777 25.0719 92.6607 25.5143L74.9266 38.2295C73.9348 38.9406 73.5131 40.2085 73.8958 41.3707L80.6696 61.9444C80.8987 62.6402 80.076 63.3262 79.3906 62.8348L61.6566 50.1196C60.6679 49.4107 59.3321 49.4107 58.3434 50.1196L40.6094 62.8348C39.924 63.3262 39.1013 62.6402 39.3304 61.9444L46.1042 41.3707C46.4869 40.2085 46.0652 38.9406 45.0734 38.2295L27.3393 25.5143C26.7223 25.0719 27.0018 24.0653 27.8305 24.0653L49.751 24.0653C50.9672 24.0653 52.0566 23.292 52.4384 22.1322L59.2123 1.55857Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M41.6782 51.616C17.5239 53.3343 0 58.4528 0 64.5C0 71.9558 26.6391 78 59.5 78C92.3609 78 119 71.9558 119 64.5C119 58.5387 101.97 53.4798 78.3466 51.6913L81.6194 61.6317C82.1664 63.2928 80.2398 64.6741 78.808 63.6475L61.1757 51.0053C60.619 51.0018 60.0604 51 59.5 51C59.2765 51 59.0534 51.0003 58.8305 51.0008L41.192 63.6475C39.7602 64.6741 37.8337 63.2928 38.3806 61.6317L41.6782 51.616Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
<path d="M59.2172 1.54918C59.4582 0.816949 60.525 0.81693 60.7662 1.54918L67.4261 21.777C67.8015 22.9173 68.8726 23.6776 70.0684 23.6776H91.6205C92.4352 23.6776 92.71 24.6673 92.1034 25.1023L74.6673 37.6038C73.6922 38.3029 73.2776 39.5495 73.6539 40.6922L80.3138 60.9201C80.5391 61.6042 79.7302 62.2787 79.0563 61.7956L61.6204 49.2941C60.6483 48.5971 59.3349 48.5971 58.3629 49.2941L40.9269 61.7956C40.253 62.2787 39.4441 61.6042 39.6694 60.9201L46.3294 40.6922C46.7056 39.5495 46.291 38.3029 45.3159 37.6038L27.8798 25.1023C27.2732 24.6673 27.548 23.6776 28.3628 23.6776H49.9149C51.1106 23.6776 52.1817 22.9173 52.5571 21.777L59.2172 1.54918Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M59.5 49.6685C60.052 49.6685 60.6021 49.6699 61.1504 49.6733L61.3066 49.6743L61.4336 49.7651L78.7695 62.1948C79.8103 62.9411 81.1618 61.9247 80.7803 60.7661L77.5625 50.9927L77.333 50.2935L78.0674 50.3491C89.7005 51.2299 99.7327 52.9176 106.87 55.1284C110.435 56.2328 113.307 57.4759 115.298 58.8335C117.27 60.1787 118.491 61.7173 118.491 63.4331C118.491 64.5061 118.01 65.5129 117.177 66.437C116.346 67.3584 115.143 68.2239 113.635 69.0327C110.618 70.6507 106.286 72.0922 100.975 73.2974C90.343 75.7096 75.6797 77.1978 59.5 77.1978C43.3203 77.1978 28.657 75.7096 18.0254 73.2974C12.7139 72.0922 8.3816 70.6507 5.36523 69.0327C3.85739 68.2239 2.65424 67.3584 1.82324 66.437C0.989783 65.5129 0.508887 64.5061 0.508789 63.4331C0.508789 61.6928 1.7644 60.135 3.78906 58.7749C5.83338 57.4017 8.78191 56.1452 12.4404 55.0327C19.7642 52.8057 30.0482 51.1211 41.9424 50.2749L42.6738 50.2231L42.4443 50.9194L39.2021 60.7661C38.8207 61.9247 40.1722 62.9409 41.2129 62.1948L58.5557 49.7612L58.6836 49.6694L58.8408 49.6685C59.0602 49.668 59.2799 49.6685 59.5 49.6685Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -115,6 +115,7 @@ import {
|
||||
PlusSquareOutlined,
|
||||
PlusOutlined,
|
||||
ProfileOutlined,
|
||||
PushpinFilled,
|
||||
PushpinOutlined,
|
||||
QuestionCircleOutlined,
|
||||
ReloadOutlined,
|
||||
@@ -270,6 +271,7 @@ const AntdIcons = {
|
||||
PlusSquareOutlined,
|
||||
PlusOutlined,
|
||||
ProfileOutlined,
|
||||
PushpinFilled,
|
||||
PushpinOutlined,
|
||||
ReloadOutlined,
|
||||
QuestionCircleOutlined,
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
waitFor,
|
||||
within,
|
||||
} from '@superset-ui/core/spec';
|
||||
import { formatNumber } from '@superset-ui/core';
|
||||
import { Select } from '.';
|
||||
|
||||
type Option = {
|
||||
@@ -85,8 +86,10 @@ const getElementsByClassName = (className: string) =>
|
||||
const getSelect = () =>
|
||||
screen.getByRole('combobox', { name: new RegExp(ARIA_LABEL, 'i') });
|
||||
|
||||
const selectAllButtonText = (length: number) => `Select all (${length})`;
|
||||
const deselectAllButtonText = (length: number) => `Clear (${length})`;
|
||||
const selectAllButtonText = (length: number) =>
|
||||
`Select all (${formatNumber('SMART_NUMBER', length)})`;
|
||||
const deselectAllButtonText = (length: number) =>
|
||||
`Clear (${formatNumber('SMART_NUMBER', length)})`;
|
||||
|
||||
const findSelectOption = (text: string) =>
|
||||
waitFor(() =>
|
||||
@@ -811,6 +814,62 @@ test('Maintains stable maxTagCount to prevent click target disappearing in oneLi
|
||||
expect(withinSelector.getByText('+ 2 ...')).toBeVisible();
|
||||
});
|
||||
|
||||
test('dropdown width matches input width after tags collapse in oneLine mode', async () => {
|
||||
render(
|
||||
<div style={{ width: '300px' }}>
|
||||
<Select
|
||||
{...defaultProps}
|
||||
value={[OPTIONS[0], OPTIONS[1], OPTIONS[2]]}
|
||||
mode="multiple"
|
||||
oneLine
|
||||
/>
|
||||
</div>,
|
||||
);
|
||||
|
||||
await open();
|
||||
|
||||
// Wait for RAF to complete and tags to collapse
|
||||
await waitFor(() => {
|
||||
const withinSelector = within(
|
||||
getElementByClassName('.ant-select-selector'),
|
||||
);
|
||||
expect(
|
||||
withinSelector.queryByText(OPTIONS[0].label),
|
||||
).not.toBeInTheDocument();
|
||||
expect(withinSelector.getByText('+ 3 ...')).toBeVisible();
|
||||
});
|
||||
|
||||
const selectElement = document.querySelector('.ant-select') as HTMLElement;
|
||||
expect(selectElement).toBeInTheDocument();
|
||||
|
||||
// Mock the select element's width since JSDOM doesn't perform real layout
|
||||
jest.spyOn(selectElement, 'getBoundingClientRect').mockReturnValue({
|
||||
width: 300,
|
||||
height: 32,
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 300,
|
||||
bottom: 32,
|
||||
x: 0,
|
||||
y: 0,
|
||||
toJSON: () => ({}),
|
||||
} as DOMRect);
|
||||
|
||||
// Close and reopen to trigger width measurement with mocked value
|
||||
await type('{esc}');
|
||||
await open();
|
||||
|
||||
const dropdown = document.querySelector(
|
||||
'.ant-select-dropdown',
|
||||
) as HTMLElement;
|
||||
expect(dropdown).toBeInTheDocument();
|
||||
|
||||
// Verify the dropdown has inline width matching the mocked select width
|
||||
await waitFor(() => {
|
||||
expect(parseInt(dropdown.style.width, 10)).toBe(300);
|
||||
});
|
||||
});
|
||||
|
||||
test('does not render "Select all" when there are 0 or 1 options', async () => {
|
||||
const { rerender } = render(
|
||||
<Select {...defaultProps} options={[]} mode="multiple" allowNewOptions />,
|
||||
@@ -915,6 +974,17 @@ test('"Select all" does not affect disabled options', async () => {
|
||||
expect(await findSelectValue()).not.toHaveTextContent(options[1].label);
|
||||
});
|
||||
|
||||
test('abbreviates large numbers in bulk action buttons', async () => {
|
||||
const manyOptions = Array.from({ length: 1500 }, (_, i) => ({
|
||||
label: `Option ${i}`,
|
||||
value: i,
|
||||
}));
|
||||
render(<Select {...defaultProps} mode="multiple" options={manyOptions} />);
|
||||
await open();
|
||||
// SMART_NUMBER format uses lowercase 'k' for thousands (d3-format)
|
||||
expect(await screen.findByText('Select all (1.5k)')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('dropdown takes full width of the select input for multi select', async () => {
|
||||
render(
|
||||
<div style={{ width: '400px' }}>
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
} from 'react';
|
||||
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import { ensureIsArray, usePrevious } from '@superset-ui/core';
|
||||
import { ensureIsArray, formatNumber, usePrevious } from '@superset-ui/core';
|
||||
import { Constants } from '@superset-ui/core/components';
|
||||
import {
|
||||
LabeledValue as AntdLabeledValue,
|
||||
@@ -149,6 +149,8 @@ const Select = forwardRef(
|
||||
// Prevent maxTagCount change during click events to avoid click target disappearing
|
||||
const [stableMaxTagCount, setStableMaxTagCount] = useState(maxTagCount);
|
||||
const isOpeningRef = useRef(false);
|
||||
const selectContainerRef = useRef<HTMLDivElement>(null);
|
||||
const [dropdownWidth, setDropdownWidth] = useState<number | true>(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (oneLine) {
|
||||
@@ -159,12 +161,23 @@ const Select = forwardRef(
|
||||
requestAnimationFrame(() => {
|
||||
setStableMaxTagCount(0);
|
||||
isOpeningRef.current = false;
|
||||
|
||||
// Measure collapsed width and update dropdown width
|
||||
const selectElement =
|
||||
selectContainerRef.current?.querySelector('.ant-select');
|
||||
if (selectElement) {
|
||||
const { width } = selectElement.getBoundingClientRect();
|
||||
if (width > 0) {
|
||||
setDropdownWidth(width);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!isDropdownVisible) {
|
||||
// When closing, immediately show the first tag
|
||||
setStableMaxTagCount(1);
|
||||
setDropdownWidth(true); // Reset to default when closing
|
||||
isOpeningRef.current = false;
|
||||
}
|
||||
return;
|
||||
@@ -494,7 +507,7 @@ const Select = forwardRef(
|
||||
|
||||
const bulkSelectComponent = useMemo(
|
||||
() => (
|
||||
<StyledBulkActionsContainer justify="center">
|
||||
<StyledBulkActionsContainer justify="space-between">
|
||||
<Button
|
||||
type="link"
|
||||
buttonStyle="link"
|
||||
@@ -506,7 +519,7 @@ const Select = forwardRef(
|
||||
handleSelectAll();
|
||||
}}
|
||||
>
|
||||
{`${t('Select all')} (${bulkSelectCounts.selectable})`}
|
||||
{`${t('Select all')} (${formatNumber('SMART_NUMBER', bulkSelectCounts.selectable)})`}
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
@@ -523,7 +536,7 @@ const Select = forwardRef(
|
||||
handleDeselectAll();
|
||||
}}
|
||||
>
|
||||
{`${t('Clear')} (${bulkSelectCounts.deselectable})`}
|
||||
{`${t('Clear')} (${formatNumber('SMART_NUMBER', bulkSelectCounts.deselectable)})`}
|
||||
</Button>
|
||||
</StyledBulkActionsContainer>
|
||||
),
|
||||
@@ -717,7 +730,11 @@ const Select = forwardRef(
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledContainer className={className} headerPosition={headerPosition}>
|
||||
<StyledContainer
|
||||
ref={selectContainerRef}
|
||||
className={className}
|
||||
headerPosition={headerPosition}
|
||||
>
|
||||
{header && (
|
||||
<StyledHeader headerPosition={headerPosition}>{header}</StyledHeader>
|
||||
)}
|
||||
@@ -777,7 +794,7 @@ const Select = forwardRef(
|
||||
options={visibleOptions}
|
||||
optionRender={option => <Space>{option.label || option.value}</Space>}
|
||||
oneLine={oneLine}
|
||||
popupMatchSelectWidth
|
||||
popupMatchSelectWidth={oneLine ? dropdownWidth : true}
|
||||
css={props.css}
|
||||
dropdownAlign={DROPDOWN_ALIGN_BOTTOM}
|
||||
{...props}
|
||||
|
||||
@@ -140,11 +140,17 @@ export const StyledErrorMessage = styled.div`
|
||||
|
||||
export const StyledBulkActionsContainer = styled(Flex)`
|
||||
${({ theme }) => `
|
||||
padding: ${theme.sizeUnit}px;
|
||||
padding: ${theme.sizeUnit}px 0;
|
||||
border-top: 1px solid ${theme.colorSplit};
|
||||
gap: ${theme.sizeUnit * 2}px;
|
||||
& .superset-button {
|
||||
font-family: inherit;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
& .superset-button:first-of-type {
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
& .superset-button:last-of-type {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -158,11 +158,13 @@ test('passes all props through to AgGridReact', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
// onGridReady and onFirstDataRendered are intercepted by the component to expose
|
||||
// the grid API on the container element; the wrapped function is passed instead.
|
||||
expect(AgGridReact).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
rowData: mockRowData,
|
||||
columnDefs: mockColumnDefs,
|
||||
onGridReady,
|
||||
onGridReady: expect.any(Function),
|
||||
onCellClicked,
|
||||
pagination: true,
|
||||
paginationPageSize: 10,
|
||||
@@ -171,6 +173,47 @@ test('passes all props through to AgGridReact', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('onGridReady wrapper calls user callback and exposes api on container', () => {
|
||||
const onGridReady = jest.fn();
|
||||
|
||||
render(
|
||||
<ThemedAgGridReact
|
||||
rowData={mockRowData}
|
||||
columnDefs={mockColumnDefs}
|
||||
onGridReady={onGridReady}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Retrieve the wrapped handler that was passed to AgGridReact
|
||||
const lastCall = (AgGridReact as jest.Mock).mock.calls.at(-1)[0];
|
||||
const wrappedOnGridReady = lastCall.onGridReady as Function;
|
||||
|
||||
const mockApi = { setGridOption: jest.fn() };
|
||||
wrappedOnGridReady({ api: mockApi });
|
||||
|
||||
// The user-provided callback must be forwarded
|
||||
expect(onGridReady).toHaveBeenCalledWith({ api: mockApi });
|
||||
});
|
||||
|
||||
test('onFirstDataRendered wrapper calls user callback', () => {
|
||||
const onFirstDataRendered = jest.fn();
|
||||
|
||||
render(
|
||||
<ThemedAgGridReact
|
||||
rowData={mockRowData}
|
||||
columnDefs={mockColumnDefs}
|
||||
onFirstDataRendered={onFirstDataRendered}
|
||||
/>,
|
||||
);
|
||||
|
||||
const lastCall = (AgGridReact as jest.Mock).mock.calls.at(-1)[0];
|
||||
const wrappedOnFirstDataRendered = lastCall.onFirstDataRendered as Function;
|
||||
|
||||
wrappedOnFirstDataRendered({ firstRow: 0 });
|
||||
|
||||
expect(onFirstDataRendered).toHaveBeenCalledWith({ firstRow: 0 });
|
||||
});
|
||||
|
||||
test('applies custom theme colors from Superset theme', () => {
|
||||
const customTheme = {
|
||||
...supersetTheme,
|
||||
|
||||
@@ -16,19 +16,28 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { useMemo, forwardRef } from 'react';
|
||||
import { useMemo, useRef, useCallback, forwardRef } from 'react';
|
||||
import { css } from '@emotion/react';
|
||||
import { AgGridReact, type AgGridReactProps } from 'ag-grid-react';
|
||||
import {
|
||||
themeQuartz,
|
||||
colorSchemeDark,
|
||||
colorSchemeLight,
|
||||
type GridApi,
|
||||
type GridReadyEvent,
|
||||
type FirstDataRenderedEvent,
|
||||
} from 'ag-grid-community';
|
||||
import { useTheme, useThemeMode } from '@apache-superset/core/theme';
|
||||
|
||||
// Note: With ag-grid v34's new theming API, CSS files are injected automatically
|
||||
// Do NOT import 'ag-grid-community/styles/ag-grid.css' or theme CSS files
|
||||
|
||||
// Extends HTMLDivElement with ag-grid state attached to the container for downloadAsImage.
|
||||
export interface AgGridContainerElement extends HTMLDivElement {
|
||||
_agGridApi?: GridApi;
|
||||
_agGridFirstDataRendered?: boolean;
|
||||
}
|
||||
|
||||
export interface ThemedAgGridReactProps extends AgGridReactProps {
|
||||
/**
|
||||
* Optional theme parameter overrides to customize specific ag-grid theme values.
|
||||
@@ -71,9 +80,13 @@ export interface ThemedAgGridReactProps extends AgGridReactProps {
|
||||
export const ThemedAgGridReact = forwardRef<
|
||||
AgGridReact,
|
||||
ThemedAgGridReactProps
|
||||
>(function ThemedAgGridReact({ themeOverrides, ...props }, ref) {
|
||||
>(function ThemedAgGridReact(
|
||||
{ themeOverrides, onGridReady, onFirstDataRendered, ...props },
|
||||
ref,
|
||||
) {
|
||||
const theme = useTheme();
|
||||
const isDarkMode = useThemeMode();
|
||||
const containerRef = useRef<AgGridContainerElement>(null);
|
||||
|
||||
// Get the appropriate ag-grid theme based on dark/light mode
|
||||
const agGridTheme = useMemo(() => {
|
||||
@@ -140,8 +153,32 @@ export const ThemedAgGridReact = forwardRef<
|
||||
return baseTheme.withParams(finalParams);
|
||||
}, [theme, isDarkMode, themeOverrides]);
|
||||
|
||||
// Expose gridApi and first-data-rendered flag on the container for downloadAsImage.
|
||||
const handleGridReady = useCallback(
|
||||
(event: GridReadyEvent) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current._agGridFirstDataRendered = false;
|
||||
containerRef.current._agGridApi = event.api;
|
||||
}
|
||||
onGridReady?.(event);
|
||||
},
|
||||
[onGridReady],
|
||||
);
|
||||
|
||||
// Mark the container once rows are painted so downloadAsImage can gate on readiness.
|
||||
const handleFirstDataRendered = useCallback(
|
||||
(event: FirstDataRenderedEvent) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current._agGridFirstDataRendered = true;
|
||||
}
|
||||
onFirstDataRendered?.(event);
|
||||
},
|
||||
[onFirstDataRendered],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
css={css`
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -151,7 +188,13 @@ export const ThemedAgGridReact = forwardRef<
|
||||
`}
|
||||
data-themed-ag-grid="true"
|
||||
>
|
||||
<AgGridReact ref={ref} theme={agGridTheme} {...props} />
|
||||
<AgGridReact
|
||||
ref={ref}
|
||||
theme={agGridTheme}
|
||||
onGridReady={handleGridReady}
|
||||
onFirstDataRendered={handleFirstDataRendered}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -171,6 +214,7 @@ export type {
|
||||
CellClassParams,
|
||||
IMenuActionParams,
|
||||
IHeaderParams,
|
||||
SelectionChangedEvent,
|
||||
SortModelItem,
|
||||
ValueFormatterParams,
|
||||
ValueGetterParams,
|
||||
|
||||
@@ -201,6 +201,7 @@ export * from './Result';
|
||||
export {
|
||||
ThemedAgGridReact,
|
||||
type ThemedAgGridReactProps,
|
||||
type AgGridContainerElement,
|
||||
setupAGGridModules,
|
||||
defaultModules,
|
||||
} from './ThemedAgGridReact';
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const isSafari = (): boolean => {
|
||||
const { userAgent } = navigator;
|
||||
return Boolean(userAgent && /^((?!chrome|android).)*safari/i.test(userAgent));
|
||||
};
|
||||
|
||||
// Use the new Clipboard API if the browser supports it
|
||||
const copyTextWithClipboardApi = async (getText: () => Promise<string>) => {
|
||||
// Safari (WebKit) does not support delayed generation of clipboard.
|
||||
// This means that writing to the clipboard, from the moment the user
|
||||
// interacts with the app, must be instantaneous.
|
||||
// However, neither writeText nor write accepts a Promise, so
|
||||
// we need to create a ClipboardItem that accepts said Promise to
|
||||
// delay the text generation, as needed.
|
||||
// Source: https://bugs.webkit.org/show_bug.cgi?id=222262P
|
||||
if (isSafari()) {
|
||||
try {
|
||||
const clipboardItem = new ClipboardItem({
|
||||
'text/plain': getText(),
|
||||
});
|
||||
await navigator.clipboard.write([clipboardItem]);
|
||||
} catch {
|
||||
// Fallback to default clipboard API implementation
|
||||
const text = await getText();
|
||||
await navigator.clipboard.writeText(text);
|
||||
}
|
||||
} else {
|
||||
// For Blink, the above method won't work, but we can use the
|
||||
// default (intended) API, since the delayed generation of the
|
||||
// clipboard is now supported.
|
||||
// Source: https://bugs.chromium.org/p/chromium/issues/detail?id=1014310
|
||||
const text = await getText();
|
||||
await navigator.clipboard.writeText(text);
|
||||
}
|
||||
};
|
||||
|
||||
const copyTextToClipboard = (getText: () => Promise<string>) =>
|
||||
copyTextWithClipboardApi(getText)
|
||||
// If the Clipboard API is not supported, fallback to the older method.
|
||||
.catch(() =>
|
||||
getText().then(
|
||||
text =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
const selection: Selection | null = document.getSelection();
|
||||
if (selection) {
|
||||
selection.removeAllRanges();
|
||||
const range = document.createRange();
|
||||
const span = document.createElement('span');
|
||||
span.textContent = text;
|
||||
span.style.position = 'fixed';
|
||||
span.style.top = '0';
|
||||
span.style.clip = 'rect(0, 0, 0, 0)';
|
||||
span.style.whiteSpace = 'pre';
|
||||
|
||||
document.body.appendChild(span);
|
||||
range.selectNode(span);
|
||||
selection.addRange(range);
|
||||
|
||||
try {
|
||||
if (!document.execCommand('copy')) {
|
||||
reject();
|
||||
}
|
||||
} catch (err) {
|
||||
reject();
|
||||
}
|
||||
|
||||
document.body.removeChild(span);
|
||||
if (selection.removeRange) {
|
||||
selection.removeRange(range);
|
||||
} else {
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
}
|
||||
|
||||
resolve();
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
export default copyTextToClipboard;
|
||||
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
export { default as convertKeysToCamelCase } from './convertKeysToCamelCase';
|
||||
export { default as copyTextToClipboard } from './copy';
|
||||
export { default as ensureIsArray } from './ensureIsArray';
|
||||
export { default as ensureIsInt } from './ensureIsInt';
|
||||
export { default as isDefined } from './isDefined';
|
||||
|
||||
@@ -109,10 +109,10 @@ test('should handle custom range with relative dates (now)', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['5 days ago'],
|
||||
['4 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'5 days ago',
|
||||
'4 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -218,10 +218,10 @@ test('should handle null timeRangeFilter', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['2 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'3 days ago',
|
||||
'2 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -304,10 +304,10 @@ test('should handle custom range with DATEADD function and relative start date',
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['2 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'3 days ago',
|
||||
'2 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -362,10 +362,10 @@ test('should handle custom range with specific date and relative end date', () =
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['8 days ago'],
|
||||
['9 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'8 days ago',
|
||||
'9 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -390,10 +390,10 @@ test('should handle custom range with specific date and specific end date', () =
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['1 days ago'],
|
||||
['2 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'1 days ago',
|
||||
'2 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -474,7 +474,7 @@ test('should handle custom range with previous calendar week', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['1 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-05T00:06:00Z',
|
||||
@@ -482,7 +482,7 @@ test('should handle custom range with previous calendar week', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['1 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-04T16:06:00-08:00',
|
||||
@@ -507,7 +507,7 @@ test('should handle custom range with previous calendar month', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['7 days ago'],
|
||||
['5 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-05T00:06:00Z',
|
||||
@@ -515,7 +515,7 @@ test('should handle custom range with previous calendar month', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['7 days ago'],
|
||||
['5 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-04T16:06:00-08:00',
|
||||
@@ -541,7 +541,7 @@ test('should handle custom range with previous calendar year', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['8 days ago'],
|
||||
['6 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-05T00:06:00Z',
|
||||
@@ -549,7 +549,7 @@ test('should handle custom range with previous calendar year', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['8 days ago'],
|
||||
['6 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-04T16:06:00-08:00',
|
||||
@@ -760,10 +760,10 @@ test('should handle future custom shift with different format', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days after'],
|
||||
['4 days after'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'3 days after',
|
||||
'4 days after',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -771,7 +771,7 @@ test('should handle future custom shift with different format', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['4 days after'],
|
||||
['5 days after'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -850,10 +850,10 @@ test('should handle custom range with relative dates (hour)', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['2 days ago'],
|
||||
['4 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'2 days ago',
|
||||
'4 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
import { parseDttmToDate } from '@superset-ui/core';
|
||||
import timezoneMock from 'timezone-mock';
|
||||
|
||||
// NOW will be set at midnight 2024-06-03 and transforme dfrom local timezone to UTC
|
||||
// NOW will be set at midnight 2024-06-03 and transformed from local timezone to UTC
|
||||
const NOW_IN_UTC = '2024-06-03T00:00:00Z';
|
||||
const NOW_UTC_IN_EUROPE = '2024-06-02T22:00:00Z'; // Same as 2024-06-03T00:00:00+02:00
|
||||
const NOW_UTC_IN_PACIFIC = '2024-06-03T08:00:00Z'; // Same as 2024-06-03T00:00:00-08:00
|
||||
@@ -69,9 +69,9 @@ test('should return the current date for "today"', () => {
|
||||
'today',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest('today', NOW_IN_UTC, 'UTC', new Date('2024-06-02T00:00:00Z'));
|
||||
runTimezoneTest('today', NOW_IN_UTC, 'UTC', new Date('2024-06-03T00:00:00Z'));
|
||||
runTimezoneTest(
|
||||
'today',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -125,13 +125,13 @@ test('should return yesterday date for "Last day"', () => {
|
||||
'Last day',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-31T22:00:00Z'),
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-01T00:00:00Z'),
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
@@ -147,13 +147,13 @@ test('should return the date one week ago for "Last week"', () => {
|
||||
'Last week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-25T22:00:00Z'),
|
||||
new Date('2024-05-26T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-26T00:00:00Z'),
|
||||
new Date('2024-05-27T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
@@ -169,13 +169,13 @@ test('should return the date one month ago for "Last month"', () => {
|
||||
'Last month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-01T22:00:00Z'),
|
||||
new Date('2024-05-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last month',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-02T00:00:00Z'),
|
||||
new Date('2024-05-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last month',
|
||||
@@ -191,13 +191,13 @@ test('should return the date three months ago for "Last quarter"', () => {
|
||||
'Last quarter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-03-01T22:00:00Z'),
|
||||
new Date('2024-03-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-03-02T00:00:00Z'),
|
||||
new Date('2024-03-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
@@ -213,13 +213,13 @@ test('should return the date one year ago for "Last year"', () => {
|
||||
'Last year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-06-01T22:00:00Z'),
|
||||
new Date('2023-06-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2023-06-02T00:00:00Z'),
|
||||
new Date('2023-06-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
@@ -235,19 +235,19 @@ test('should return the date for "previous calendar week"', () => {
|
||||
'previous calendar week',
|
||||
'2024-06-04T22:00:00Z',
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-27T16:00:00Z'),
|
||||
new Date('2024-05-26T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
'2024-06-05T00:00:00Z',
|
||||
'UTC',
|
||||
new Date('2024-05-27T20:00:00Z'),
|
||||
new Date('2024-05-27T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
'2024-06-05T08:00:00Z',
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-05-27T12:00:00Z'),
|
||||
new Date('2024-05-27T08:00:00Z'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -257,19 +257,19 @@ test('should return the date for "previous calendar month"', () => {
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-01T10:00:00Z'),
|
||||
new Date('2024-04-30T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-01T16:00:00Z'),
|
||||
new Date('2024-05-01T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-05-01T16:00:00Z'),
|
||||
new Date('2024-05-01T08:00:00Z'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -279,19 +279,19 @@ test('should return the date for "previous calendar year"', () => {
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-01-01T16:00:00Z'),
|
||||
new Date('2022-12-31T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2023-01-01T20:00:00Z'),
|
||||
new Date('2023-01-01T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2023-01-01T12:00:00Z'),
|
||||
new Date('2023-01-01T08:00:00Z'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -301,13 +301,13 @@ test('should return the date for "1 day ago"', () => {
|
||||
'1 day ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-31T22:00:00Z'),
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 day ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-01T00:00:00Z'),
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 day ago',
|
||||
@@ -323,13 +323,13 @@ test('should return the date for "1 week ago"', () => {
|
||||
'1 week ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-25T22:00:00Z'),
|
||||
new Date('2024-05-26T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 week ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-26T00:00:00Z'),
|
||||
new Date('2024-05-27T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 week ago',
|
||||
@@ -345,13 +345,13 @@ test('should return the date for "1 month ago"', () => {
|
||||
'1 month ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-01T22:00:00Z'),
|
||||
new Date('2024-05-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 month ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-02T00:00:00Z'),
|
||||
new Date('2024-05-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 month ago',
|
||||
@@ -367,13 +367,13 @@ test('should return the date for "1 year ago"', () => {
|
||||
'1 year ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-06-01T22:00:00Z'),
|
||||
new Date('2023-06-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 year ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2023-06-02T00:00:00Z'),
|
||||
new Date('2023-06-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 year ago',
|
||||
@@ -389,13 +389,13 @@ test('should return the date for "2024-03-09"', () => {
|
||||
'2024-03-09',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-03-07T22:00:00.000Z'),
|
||||
new Date('2024-03-08T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-09',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-03-08T00:00:00.000Z'),
|
||||
new Date('2024-03-09T00:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-09',
|
||||
@@ -411,14 +411,14 @@ test('should return the current date for "Last day" with isEndDate true', () =>
|
||||
'Last day',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -436,14 +436,14 @@ test('should return the current date for "Last week" with isEndDate true', () =>
|
||||
'Last week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -461,14 +461,14 @@ test('should return the current date for "Last quarter" with isEndDate true', ()
|
||||
'Last quarter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -486,14 +486,14 @@ test('should return the current date for "Last year" with isEndDate true', () =>
|
||||
'Last year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -511,21 +511,21 @@ test('should return the date for "previous calendar week" with isEndDate true',
|
||||
'previous calendar week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-03T16:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-03T20:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-06-03T12:00:00Z'),
|
||||
new Date('2024-06-03T08:00:00Z'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -536,21 +536,21 @@ test('should return the date for "previous calendar month" with isEndDate true',
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T16:00:00Z'),
|
||||
new Date('2024-05-31T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-01T20:00:00Z'),
|
||||
new Date('2024-06-01T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-06-01T12:00:00Z'),
|
||||
new Date('2024-06-01T08:00:00Z'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -561,21 +561,21 @@ test('should return the date for "previous calendar year" with isEndDate true',
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-01-01T16:00:00Z'),
|
||||
new Date('2023-12-31T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-01-01T20:00:00Z'),
|
||||
new Date('2024-01-01T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-01-01T12:00:00Z'),
|
||||
new Date('2024-01-01T08:00:00Z'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -586,9 +586,9 @@ test('should return the date for "2024" with parts.length === 1', () => {
|
||||
'2024',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-12-30T22:00:00.000Z'),
|
||||
new Date('2023-12-31T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest('2024', NOW_IN_UTC, 'UTC', new Date('2023-12-31T00:00:00Z'));
|
||||
runTimezoneTest('2024', NOW_IN_UTC, 'UTC', new Date('2024-01-01T00:00:00Z'));
|
||||
runTimezoneTest(
|
||||
'2024',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -603,13 +603,13 @@ test('should return the date for "2024-03" with parts.length === 2', () => {
|
||||
'2024-03',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-02-28T22:00:00.000Z'),
|
||||
new Date('2024-02-29T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-02-29T00:00:00Z'),
|
||||
new Date('2024-03-01T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03',
|
||||
@@ -625,13 +625,13 @@ test('should return the date for "2024-03-06" with parts.length === 3', () => {
|
||||
'2024-03-06',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-03-04T22:00:00.000Z'),
|
||||
new Date('2024-03-05T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-03-05T00:00:00.000Z'),
|
||||
new Date('2024-03-06T00:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
@@ -643,7 +643,7 @@ test('should return the date for "2024-03-06" with parts.length === 3', () => {
|
||||
|
||||
test('should return the date for "2024-03-06" with computingShifts true', () => {
|
||||
jest.useFakeTimers();
|
||||
const expectedDate = new Date('2024-03-05T22:00:00Z');
|
||||
const expectedDate = new Date('2024-03-06T22:00:00Z');
|
||||
expectedDate.setHours(-expectedDate.getTimezoneOffset() / 60, 0, 0, 0);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
@@ -657,7 +657,7 @@ test('should return the date for "2024-03-06" with computingShifts true', () =>
|
||||
|
||||
test('should return the date for "2024-03-06" with computingShifts true and isEndDate true', () => {
|
||||
jest.useFakeTimers();
|
||||
const expectedDate = new Date('2024-03-05T22:00:00Z');
|
||||
const expectedDate = new Date('2024-03-06T22:00:00Z');
|
||||
expectedDate.setHours(-expectedDate.getTimezoneOffset() / 60, 0, 0, 0);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* 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 { copyTextToClipboard } from '@superset-ui/core';
|
||||
|
||||
const SAFARI_UA =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15';
|
||||
const CHROME_UA =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
||||
|
||||
const makeGetText = (text: string) => () => Promise.resolve(text);
|
||||
|
||||
const globalWithClipboardItem = global as unknown as {
|
||||
ClipboardItem?: unknown;
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
delete globalWithClipboardItem.ClipboardItem;
|
||||
});
|
||||
|
||||
test('uses Clipboard API writeText on non-Safari browsers', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: CHROME_UA,
|
||||
configurable: true,
|
||||
});
|
||||
const writeText = jest.fn().mockResolvedValue(undefined);
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: { writeText },
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
await copyTextToClipboard(makeGetText('hello'));
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith('hello');
|
||||
});
|
||||
|
||||
test('uses ClipboardItem API on Safari browsers', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: SAFARI_UA,
|
||||
configurable: true,
|
||||
});
|
||||
const write = jest.fn().mockResolvedValue(undefined);
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: { write },
|
||||
configurable: true,
|
||||
});
|
||||
const MockClipboardItem = jest.fn().mockImplementation(data => ({ data }));
|
||||
globalWithClipboardItem.ClipboardItem = MockClipboardItem;
|
||||
|
||||
await copyTextToClipboard(makeGetText('safari text'));
|
||||
|
||||
expect(MockClipboardItem).toHaveBeenCalled();
|
||||
expect(write).toHaveBeenCalledWith([expect.anything()]);
|
||||
});
|
||||
|
||||
test('falls back to writeText on Safari when ClipboardItem write fails', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: SAFARI_UA,
|
||||
configurable: true,
|
||||
});
|
||||
const writeText = jest.fn().mockResolvedValue(undefined);
|
||||
const write = jest.fn().mockRejectedValue(new Error('not supported'));
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: { write, writeText },
|
||||
configurable: true,
|
||||
});
|
||||
const MockClipboardItem = jest.fn().mockImplementation(data => ({ data }));
|
||||
globalWithClipboardItem.ClipboardItem = MockClipboardItem;
|
||||
|
||||
await copyTextToClipboard(makeGetText('fallback text'));
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith('fallback text');
|
||||
});
|
||||
|
||||
function mockExecCommand(impl: (cmd: string) => boolean) {
|
||||
Object.defineProperty(document, 'execCommand', {
|
||||
value: jest.fn().mockImplementation(impl),
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
|
||||
function setupFallbackMocks(options: { selection: Partial<Selection> | null }) {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: CHROME_UA,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: jest.fn().mockRejectedValue(new Error('not allowed')),
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const mockRange = { selectNode: jest.fn() };
|
||||
const mockSpan = {
|
||||
style: {} as CSSStyleDeclaration,
|
||||
textContent: '',
|
||||
} as unknown as HTMLSpanElement;
|
||||
|
||||
jest
|
||||
.spyOn(document, 'getSelection')
|
||||
.mockReturnValue(options.selection as Selection | null);
|
||||
jest
|
||||
.spyOn(document, 'createRange')
|
||||
.mockReturnValue(mockRange as unknown as Range);
|
||||
jest.spyOn(document, 'createElement').mockReturnValue(mockSpan);
|
||||
jest.spyOn(document.body, 'appendChild').mockImplementation(() => mockSpan);
|
||||
jest.spyOn(document.body, 'removeChild').mockImplementation(() => mockSpan);
|
||||
|
||||
return { mockRange, mockSpan };
|
||||
}
|
||||
|
||||
test('falls back to execCommand copy when Clipboard API is unavailable', async () => {
|
||||
const removeRange = jest.fn();
|
||||
const { mockRange } = setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges: jest.fn(),
|
||||
addRange: jest.fn(),
|
||||
removeRange,
|
||||
},
|
||||
});
|
||||
mockExecCommand(cmd => cmd === 'copy');
|
||||
|
||||
await copyTextToClipboard(makeGetText('exec text'));
|
||||
|
||||
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
||||
expect(removeRange).toHaveBeenCalledWith(mockRange);
|
||||
});
|
||||
|
||||
test('falls back to removeAllRanges when removeRange is not available', async () => {
|
||||
const removeAllRanges = jest.fn();
|
||||
setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges,
|
||||
addRange: jest.fn(),
|
||||
removeRange: undefined,
|
||||
},
|
||||
});
|
||||
mockExecCommand(cmd => cmd === 'copy');
|
||||
|
||||
await copyTextToClipboard(makeGetText('no removeRange'));
|
||||
|
||||
expect(removeAllRanges).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('rejects when execCommand returns false', async () => {
|
||||
setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges: jest.fn(),
|
||||
addRange: jest.fn(),
|
||||
removeRange: jest.fn(),
|
||||
},
|
||||
});
|
||||
mockExecCommand(() => false);
|
||||
|
||||
await expect(
|
||||
copyTextToClipboard(makeGetText('fail')),
|
||||
).rejects.toBeUndefined();
|
||||
});
|
||||
|
||||
test('rejects when execCommand throws', async () => {
|
||||
setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges: jest.fn(),
|
||||
addRange: jest.fn(),
|
||||
removeRange: jest.fn(),
|
||||
},
|
||||
});
|
||||
Object.defineProperty(document, 'execCommand', {
|
||||
value: jest.fn().mockImplementation(() => {
|
||||
throw new Error('execCommand error');
|
||||
}),
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
await expect(
|
||||
copyTextToClipboard(makeGetText('throw')),
|
||||
).rejects.toBeUndefined();
|
||||
});
|
||||
|
||||
test('resolves without copying when getSelection returns null', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: CHROME_UA,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: jest.fn().mockRejectedValue(new Error('not allowed')),
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
jest.spyOn(document, 'getSelection').mockReturnValue(null);
|
||||
|
||||
await expect(
|
||||
copyTextToClipboard(makeGetText('no selection')),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
@@ -94,6 +94,7 @@ export default defineConfig({
|
||||
name: 'chromium',
|
||||
testIgnore: [
|
||||
'**/tests/auth/**/*.spec.ts',
|
||||
'**/tests/sqllab/**/*.spec.ts',
|
||||
...(process.env.INCLUDE_EXPERIMENTAL ? [] : ['**/experimental/**']),
|
||||
],
|
||||
use: {
|
||||
@@ -103,6 +104,22 @@ export default defineConfig({
|
||||
storageState: 'playwright/.auth/user.json',
|
||||
},
|
||||
},
|
||||
{
|
||||
// SQL Lab needs its own project because tab state is stored server-side
|
||||
// per user (/tabstateview/*). All workers share the same auth user, so
|
||||
// parallel workers mutating tabs would cause nondeterministic tab counts
|
||||
// and cross-worker tab deletions. Other test suites (dataset, dashboard,
|
||||
// chart) don't need this because they create/delete isolated resources
|
||||
// via API with unique names — no shared mutable state between tests.
|
||||
name: 'chromium-sqllab',
|
||||
testMatch: '**/tests/sqllab/**/*.spec.ts',
|
||||
fullyParallel: false,
|
||||
use: {
|
||||
browserName: 'chromium',
|
||||
testIdAttribute: 'data-test',
|
||||
storageState: 'playwright/.auth/user.json',
|
||||
},
|
||||
},
|
||||
{
|
||||
// Separate project for unauthenticated tests (login, signup, etc.)
|
||||
// These tests use beforeEach for per-test navigation - no global auth
|
||||
|
||||
85
superset-frontend/playwright/components/core/AgGrid.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* 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 { Locator, Page } from '@playwright/test';
|
||||
|
||||
const AG_GRID_SELECTORS = {
|
||||
ROOT: '[role="grid"]',
|
||||
HEADER_ROW: '.ag-header-row',
|
||||
HEADER_CELL: '.ag-header-cell',
|
||||
BODY_ROW: '.ag-row',
|
||||
CELL: '.ag-cell',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* AG Grid component wrapper for Playwright.
|
||||
* Used by FilterableTable/GridTable in SQL Lab results and elsewhere.
|
||||
*/
|
||||
export class AgGrid {
|
||||
readonly page: Page;
|
||||
private readonly locator: Locator;
|
||||
|
||||
constructor(page: Page, locator: Locator) {
|
||||
this.page = page;
|
||||
this.locator = locator;
|
||||
}
|
||||
|
||||
get element(): Locator {
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the grid to render with data rows
|
||||
*/
|
||||
async waitForRows(options?: { timeout?: number }): Promise<void> {
|
||||
await this.locator
|
||||
.locator(AG_GRID_SELECTORS.BODY_ROW)
|
||||
.first()
|
||||
.waitFor({ state: 'visible', ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header cell texts
|
||||
*/
|
||||
async getHeaderTexts(): Promise<string[]> {
|
||||
return this.locator
|
||||
.locator(AG_GRID_SELECTORS.HEADER_CELL)
|
||||
.allTextContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of visible data rows
|
||||
*/
|
||||
async getRowCount(): Promise<number> {
|
||||
return this.locator.locator(AG_GRID_SELECTORS.BODY_ROW).count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell text at a specific row and column index (0-based)
|
||||
*/
|
||||
async getCellText(row: number, col: number): Promise<string> {
|
||||
const text = await this.locator
|
||||
.locator(AG_GRID_SELECTORS.BODY_ROW)
|
||||
.nth(row)
|
||||
.locator(AG_GRID_SELECTORS.CELL)
|
||||
.nth(col)
|
||||
.textContent();
|
||||
return text?.trim() ?? '';
|
||||
}
|
||||
}
|
||||
46
superset-frontend/playwright/components/core/EditableTabs.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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 { Tabs } from './Tabs';
|
||||
|
||||
/**
|
||||
* EditableTabs component for Ant Design editable-card tabs.
|
||||
*
|
||||
* Mirrors the Superset EditableTabs component (type="editable-card")
|
||||
* which adds add/remove tab functionality to the base Tabs component.
|
||||
*
|
||||
* The add button (.ant-tabs-nav-add) is only rendered when
|
||||
* type="editable-card". If the host component switches to type="card"
|
||||
* (e.g., SQL Lab empty state), use the host page object for that case.
|
||||
*/
|
||||
export class EditableTabs extends Tabs {
|
||||
/**
|
||||
* Clicks the add-tab button rendered by antd in editable-card mode.
|
||||
*/
|
||||
async addTab(): Promise<void> {
|
||||
await this.element.getByRole('button', { name: 'Add tab' }).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks the remove button on the last tab.
|
||||
*/
|
||||
async removeLastTab(): Promise<void> {
|
||||
await this.nav.locator('.ant-tabs-tab-remove').last().click();
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class Modal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a footer button by text content (private helper)
|
||||
* Gets a footer button by text content
|
||||
* @param buttonText - The text content of the button
|
||||
*/
|
||||
private getFooterButton(buttonText: string): Locator {
|
||||
@@ -80,7 +80,7 @@ export class Modal {
|
||||
* @param buttonText - The text content of the button to click
|
||||
* @param options - Optional click options
|
||||
*/
|
||||
protected async clickFooterButton(
|
||||
async clickFooterButton(
|
||||
buttonText: string,
|
||||
options?: { timeout?: number; force?: boolean; delay?: number },
|
||||
): Promise<void> {
|
||||
|
||||
53
superset-frontend/playwright/components/core/Popover.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 { Locator, Page } from '@playwright/test';
|
||||
import { Button } from './Button';
|
||||
|
||||
/**
|
||||
* Ant Design Popover component.
|
||||
*/
|
||||
export class Popover {
|
||||
readonly page: Page;
|
||||
private readonly locator: Locator;
|
||||
|
||||
constructor(page: Page, locator?: Locator) {
|
||||
this.page = page;
|
||||
this.locator = locator ?? page.locator('.ant-popover-content');
|
||||
}
|
||||
|
||||
get element(): Locator {
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
async waitForVisible(options?: { timeout?: number }): Promise<void> {
|
||||
await this.locator.waitFor({ state: 'visible', ...options });
|
||||
}
|
||||
|
||||
async waitForHidden(options?: { timeout?: number }): Promise<void> {
|
||||
await this.locator.waitFor({ state: 'hidden', ...options });
|
||||
}
|
||||
|
||||
getButton(name: string): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.locator.getByRole('button', { name, exact: true }),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { TIMEOUT } from '../../utils/constants';
|
||||
|
||||
/**
|
||||
* Ant Design Select component selectors
|
||||
@@ -87,7 +88,7 @@ export class Select {
|
||||
await this.page
|
||||
.locator(`${SELECT_SELECTORS.DROPDOWN}:not(.ant-select-dropdown-hidden)`)
|
||||
.last()
|
||||
.waitFor({ state: 'hidden', timeout: 5000 })
|
||||
.waitFor({ state: 'hidden', timeout: TIMEOUT.UI_TRANSITION })
|
||||
.catch(error => {
|
||||
// Only ignore TimeoutError (dropdown may already be closed); re-throw others
|
||||
if (!(error instanceof Error) || error.name !== 'TimeoutError') {
|
||||
|
||||
@@ -21,6 +21,10 @@ import { Locator, Page } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Tabs component for Ant Design tab navigation.
|
||||
*
|
||||
* Expects the locator to point to the `.ant-tabs` wrapper element
|
||||
* (not the inner tablist) so that `nav` can scope to the outer tab bar
|
||||
* and exclude nested/inner tabs (e.g. Results / Query history in SQL Lab).
|
||||
*/
|
||||
export class Tabs {
|
||||
readonly page: Page;
|
||||
@@ -28,23 +32,54 @@ export class Tabs {
|
||||
|
||||
constructor(page: Page, locator?: Locator) {
|
||||
this.page = page;
|
||||
// Default to the tablist role if no specific locator provided
|
||||
this.locator = locator ?? page.getByRole('tablist');
|
||||
this.locator = locator ?? page.locator('.ant-tabs').first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tablist element locator
|
||||
* The root element locator for this tabs component.
|
||||
*/
|
||||
get element(): Locator {
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a tab by name, scoped to this tablist's container
|
||||
* The tab navigation bar for this component.
|
||||
* Scoped to the first `.ant-tabs-nav` descendant so that queries
|
||||
* only hit this component's tabs, never nested/inner tab bars.
|
||||
*/
|
||||
protected get nav(): Locator {
|
||||
return this.locator.locator('.ant-tabs-nav').first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of tabs.
|
||||
* Counts `.ant-tabs-tab` wrappers in the nav bar — one per physical tab,
|
||||
* regardless of inner role="tab" elements (btn, remove button, etc.).
|
||||
*/
|
||||
async getTabCount(): Promise<number> {
|
||||
return this.nav.locator('.ant-tabs-tab').count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text content of all tabs.
|
||||
*/
|
||||
async getTabNames(): Promise<string[]> {
|
||||
return this.nav.locator('.ant-tabs-tab-btn').allTextContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a tab button by name, scoped to this component's nav bar.
|
||||
* Anchored at start (^) with negative lookahead (?!\d) to prevent
|
||||
* partial matches: "Query" won't match "Query 1", and "Query 1"
|
||||
* won't match "Query 10". Trailing icon text (e.g. " circle-solid")
|
||||
* is allowed since (?!\d) permits non-digit suffixes.
|
||||
* @param tabName - The name/label of the tab
|
||||
*/
|
||||
getTab(tabName: string): Locator {
|
||||
return this.locator.getByRole('tab', { name: tabName });
|
||||
const escaped = tabName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
return this.nav
|
||||
.locator('.ant-tabs-tab-btn')
|
||||
.filter({ hasText: new RegExp(`^${escaped}(?!\\d)`) });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,6 +98,16 @@ export class Tabs {
|
||||
return this.page.getByRole('tabpanel', { name: tabName });
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the currently active tab.
|
||||
*/
|
||||
async getActiveTabName(): Promise<string> {
|
||||
const text = await this.nav
|
||||
.locator('.ant-tabs-tab-active .ant-tabs-tab-btn')
|
||||
.textContent();
|
||||
return text?.trim() ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tab is selected
|
||||
* @param tabName - The name/label of the tab
|
||||
|
||||
@@ -19,12 +19,15 @@
|
||||
|
||||
// Core Playwright Components for Superset
|
||||
export { AceEditor } from './AceEditor';
|
||||
export { AgGrid } from './AgGrid';
|
||||
export { Button } from './Button';
|
||||
export { Checkbox } from './Checkbox';
|
||||
export { EditableTabs } from './EditableTabs';
|
||||
export { Form } from './Form';
|
||||
export { Input } from './Input';
|
||||
export { Menu } from './Menu';
|
||||
export { Modal } from './Modal';
|
||||
export { Popover } from './Popover';
|
||||
export { Select } from './Select';
|
||||
export { Table } from './Table';
|
||||
export { Tabs } from './Tabs';
|
||||
|
||||
@@ -40,8 +40,11 @@ export class EditDatasetModal extends Modal {
|
||||
// Use getByRole with specific name to target Edit Dataset dialog
|
||||
// The dialog has aria-labelledby that resolves to "edit Edit Dataset"
|
||||
this.specificLocator = page.getByRole('dialog', { name: /edit.*dataset/i });
|
||||
// Scope tabs to modal's tablist to avoid matching tablists elsewhere on page
|
||||
this.tabs = new Tabs(page, this.specificLocator.getByRole('tablist'));
|
||||
// Scope tabs to modal dialog so nav getter finds .ant-tabs-nav as descendant
|
||||
this.tabs = new Tabs(
|
||||
page,
|
||||
this.specificLocator.locator('.ant-tabs').first(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,41 +16,28 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import getPointsFromPolygon from '../../src/utils/getPointsFromPolygon';
|
||||
|
||||
describe('getPointsFromPolygon', () => {
|
||||
test('handle original input', () => {
|
||||
expect(
|
||||
getPointsFromPolygon({
|
||||
polygon: [
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
],
|
||||
}),
|
||||
).toEqual([
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
]);
|
||||
});
|
||||
test('handle geojson features', () => {
|
||||
expect(
|
||||
getPointsFromPolygon({
|
||||
polygon: {
|
||||
type: 'Feature',
|
||||
geometry: {
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual([
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
]);
|
||||
});
|
||||
});
|
||||
import { Page } from '@playwright/test';
|
||||
import { Input, Modal } from '../core';
|
||||
|
||||
/**
|
||||
* Save Dataset modal in SQL Lab.
|
||||
* Appears when clicking "Save dataset" after running a query.
|
||||
*/
|
||||
export class SaveDatasetModal extends Modal {
|
||||
constructor(page: Page) {
|
||||
super(page, '[data-test="Save or Overwrite Dataset-modal"] .ant-modal');
|
||||
}
|
||||
|
||||
private get nameInput(): Input {
|
||||
return new Input(
|
||||
this.page,
|
||||
this.body.locator('input[placeholder="Dataset name"]'),
|
||||
);
|
||||
}
|
||||
|
||||
async fillName(name: string): Promise<void> {
|
||||
await this.nameInput.clear();
|
||||
await this.nameInput.fill(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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 { Page } from '@playwright/test';
|
||||
import { Input, Modal } from '../core';
|
||||
|
||||
/**
|
||||
* Save Query modal in SQL Lab.
|
||||
* Appears when clicking the Save button in the SQL editor toolbar.
|
||||
*/
|
||||
export class SaveQueryModal extends Modal {
|
||||
constructor(page: Page) {
|
||||
super(page, '.save-query-modal');
|
||||
}
|
||||
|
||||
private get nameInput(): Input {
|
||||
return new Input(
|
||||
this.page,
|
||||
this.body.locator('input[type="text"]').first(),
|
||||
);
|
||||
}
|
||||
|
||||
async fillName(name: string): Promise<void> {
|
||||
await this.nameInput.clear();
|
||||
await this.nameInput.fill(name);
|
||||
}
|
||||
}
|
||||
@@ -24,3 +24,5 @@ export { DeleteConfirmationModal } from './DeleteConfirmationModal';
|
||||
export { DuplicateDatasetModal } from './DuplicateDatasetModal';
|
||||
export { EditDatasetModal } from './EditDatasetModal';
|
||||
export { ImportDatasetModal } from './ImportDatasetModal';
|
||||
export { SaveDatasetModal } from './SaveDatasetModal';
|
||||
export { SaveQueryModal } from './SaveQueryModal';
|
||||
|
||||
@@ -61,6 +61,22 @@ export function expectStatusOneOf<T extends ResponseLike>(
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the resource ID from a JSON response body.
|
||||
* Handles both `{ result: { id } }` and `{ id }` shapes.
|
||||
* @param response - Playwright Response or APIResponse object
|
||||
* @returns The extracted numeric ID
|
||||
*/
|
||||
export async function extractIdFromResponse(
|
||||
response: ResponseLike,
|
||||
): Promise<number> {
|
||||
const body = await response.json();
|
||||
const id: number = body.result?.id ?? body.id;
|
||||
expect(typeof id, 'Response body must contain a numeric id').toBe('number');
|
||||
expect(Number.isNaN(id), 'Response id must not be NaN').toBe(false);
|
||||
return id;
|
||||
}
|
||||
|
||||
interface ExportZipOptions {
|
||||
/** Directory name containing resource yaml files (e.g. 'charts', 'datasets') */
|
||||
resourceDir: string;
|
||||
|
||||
47
superset-frontend/playwright/helpers/api/savedQuery.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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 { Page, APIResponse } from '@playwright/test';
|
||||
import { apiGet, apiDelete, ApiRequestOptions } from './requests';
|
||||
|
||||
const ENDPOINTS = {
|
||||
SAVED_QUERY: 'api/v1/saved_query/',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* GET request to fetch a saved query's details
|
||||
*/
|
||||
export async function apiGetSavedQuery(
|
||||
page: Page,
|
||||
savedQueryId: number,
|
||||
options?: ApiRequestOptions,
|
||||
): Promise<APIResponse> {
|
||||
return apiGet(page, `${ENDPOINTS.SAVED_QUERY}${savedQueryId}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE request to remove a saved query
|
||||
*/
|
||||
export async function apiDeleteSavedQuery(
|
||||
page: Page,
|
||||
savedQueryId: number,
|
||||
options?: ApiRequestOptions,
|
||||
): Promise<APIResponse> {
|
||||
return apiDelete(page, `${ENDPOINTS.SAVED_QUERY}${savedQueryId}`, options);
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import { apiDeleteDashboard } from '../api/dashboard';
|
||||
import { apiDeleteDataset } from '../api/dataset';
|
||||
import { apiDeleteTheme } from '../api/theme';
|
||||
import { apiDeleteDatabase } from '../api/database';
|
||||
import { apiDeleteSavedQuery } from '../api/savedQuery';
|
||||
|
||||
/**
|
||||
* Test asset tracker for automatic cleanup after each test.
|
||||
@@ -34,6 +35,7 @@ export interface TestAssets {
|
||||
trackDataset(id: number): void;
|
||||
trackTheme(id: number): void;
|
||||
trackDatabase(id: number): void;
|
||||
trackSavedQuery(id: number): void;
|
||||
}
|
||||
|
||||
const EXPECTED_CLEANUP_STATUSES = new Set([200, 202, 204, 404]);
|
||||
@@ -46,6 +48,7 @@ export const test = base.extend<{ testAssets: TestAssets }>({
|
||||
const datasetIds = new Set<number>();
|
||||
const themeIds = new Set<number>();
|
||||
const databaseIds = new Set<number>();
|
||||
const savedQueryIds = new Set<number>();
|
||||
|
||||
await use({
|
||||
trackDashboard: id => dashboardIds.add(id),
|
||||
@@ -53,9 +56,29 @@ export const test = base.extend<{ testAssets: TestAssets }>({
|
||||
trackDataset: id => datasetIds.add(id),
|
||||
trackTheme: id => themeIds.add(id),
|
||||
trackDatabase: id => databaseIds.add(id),
|
||||
trackSavedQuery: id => savedQueryIds.add(id),
|
||||
});
|
||||
|
||||
// Cleanup order: dashboards → charts → datasets → themes → databases (respects FK dependencies)
|
||||
// Cleanup order: saved queries → dashboards → charts → datasets → themes → databases (respects FK dependencies)
|
||||
// Saved queries have no FK dependents, so they can be cleaned up first
|
||||
await Promise.all(
|
||||
[...savedQueryIds].map(id =>
|
||||
apiDeleteSavedQuery(page, id, { failOnStatusCode: false })
|
||||
.then(response => {
|
||||
if (!EXPECTED_CLEANUP_STATUSES.has(response.status())) {
|
||||
console.warn(
|
||||
`[testAssets] Unexpected status ${response.status()} cleaning up saved query ${id}`,
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn(
|
||||
`[testAssets] Failed to cleanup saved query ${id}:`,
|
||||
error,
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
// Use failOnStatusCode: false to avoid throwing on 404 (resource already deleted by test)
|
||||
// Warn on unexpected status codes (401/403/500) that may indicate leaked state
|
||||
await Promise.all(
|
||||
|
||||
@@ -50,7 +50,9 @@ export class AuthPage {
|
||||
* Navigate to the login page
|
||||
*/
|
||||
async goto(): Promise<void> {
|
||||
await this.page.goto(URL.LOGIN);
|
||||
// Use domcontentloaded — the login form is server-rendered and ready before
|
||||
// all assets load. The default 'load' event may never fire with HMR WebSocket.
|
||||
await this.page.goto(URL.LOGIN, { waitUntil: 'domcontentloaded' });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
371
superset-frontend/playwright/pages/SqlLabPage.ts
Normal file
@@ -0,0 +1,371 @@
|
||||
/**
|
||||
* 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 { Page, Locator, Response } from '@playwright/test';
|
||||
import { AceEditor } from '../components/core/AceEditor';
|
||||
import { AgGrid } from '../components/core/AgGrid';
|
||||
import { Button } from '../components/core/Button';
|
||||
import { EditableTabs } from '../components/core/EditableTabs';
|
||||
import { Popover } from '../components/core/Popover';
|
||||
import { Select } from '../components/core/Select';
|
||||
import { waitForPost } from '../helpers/api/intercepts';
|
||||
import { URL } from '../utils/urls';
|
||||
import { TIMEOUT } from '../utils/constants';
|
||||
|
||||
/**
|
||||
* Page object for SQL Lab.
|
||||
*
|
||||
* Selectors verified against source code — see plan for line references.
|
||||
*/
|
||||
export class SqlLabPage {
|
||||
private readonly page: Page;
|
||||
private readonly editorTabs: EditableTabs;
|
||||
|
||||
private static readonly SELECTORS = {
|
||||
SQL_EDITOR_TABS: '[data-test="sql-editor-tabs"]',
|
||||
ADD_TAB_ICON: '[data-test="add-tab-icon"]',
|
||||
RUN_QUERY_BUTTON: '[data-test="run-query-action"]',
|
||||
SOUTH_PANE: '[data-test="south-pane"]',
|
||||
EXPLORE_RESULTS_BUTTON: '[data-test="explore-results-button"]',
|
||||
SAVE_BUTTON: 'button[aria-label="Save"]',
|
||||
ACE_EDITOR: '.ace_editor',
|
||||
LEFT_BAR: '[data-test="sql-editor-left-bar"]',
|
||||
DATABASE_SELECTOR: '[data-test="DatabaseSelector"]',
|
||||
LIMIT_DROPDOWN: '.limitDropdown',
|
||||
SAVE_DATASET_BUTTON: 'button[aria-label="Save dataset"]',
|
||||
} as const;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
this.editorTabs = new EditableTabs(
|
||||
page,
|
||||
page.locator(SqlLabPage.SELECTORS.SQL_EDITOR_TABS),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Navigation ──
|
||||
|
||||
async goto(): Promise<void> {
|
||||
await this.page.goto(URL.SQLLAB, { waitUntil: 'domcontentloaded' });
|
||||
}
|
||||
|
||||
async waitForPageLoad(options?: { timeout?: number }): Promise<void> {
|
||||
// SQL Lab with dev server can be slow on first load (webpack HMR + React hydration)
|
||||
const timeout = options?.timeout ?? TIMEOUT.QUERY_EXECUTION;
|
||||
await this.editorTabs.element.waitFor({ state: 'visible', timeout });
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to SQL Lab and wait until the editor is ready.
|
||||
* Convenience method combining goto + waitForPageLoad + ensureEditorReady.
|
||||
*/
|
||||
async gotoAndReady(): Promise<void> {
|
||||
await this.goto();
|
||||
await this.waitForPageLoad();
|
||||
await this.ensureEditorReady();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures at least one query editor tab exists. Creates one if SQL Lab
|
||||
* is in the empty state ("Add a new tab to create SQL Query").
|
||||
* Waits for the ace editor to be ready before returning.
|
||||
*
|
||||
* Uses a two-stage check to handle three states correctly:
|
||||
* 1. Empty state (CI): type="card" with 0 queryEditors, no editor → create tab
|
||||
* 2. Loading after reload: real tabs exist, editor hasn't mounted yet → just wait
|
||||
* 3. Normal: tabs + editor present → ready immediately
|
||||
*
|
||||
* Stage 1 checks editor presence (catches empty + loading).
|
||||
* Stage 2 checks the Ant Design tabs type to distinguish real tabs
|
||||
* (type="editable-card") from the empty state (type="card"). The React
|
||||
* source (TabbedSqlEditors) sets type based on queryEditors.length,
|
||||
* so this directly reflects whether persisted tabs exist.
|
||||
*/
|
||||
async ensureEditorReady(): Promise<void> {
|
||||
// Page-global check: are there ANY editors in the DOM (any tab)?
|
||||
const anyEditor = this.page.locator(SqlLabPage.SELECTORS.ACE_EDITOR);
|
||||
let tabSyncPromise: Promise<Response> | null = null;
|
||||
|
||||
if ((await anyEditor.count()) === 0) {
|
||||
// No editor visible. Check if real query editors exist (editable-card)
|
||||
// or if this is the empty state (card type, 0 queryEditors).
|
||||
// type="editable-card" → queryEditors.length > 0 (even 1 real tab).
|
||||
// type="card" → queryEditors.length === 0 (true empty state).
|
||||
const isEditableCard = await this.editorTabs.element.evaluate(el =>
|
||||
el.classList.contains('ant-tabs-editable-card'),
|
||||
);
|
||||
if (!isEditableCard) {
|
||||
// Register before clicking — EditorAutoSync POSTs the new tab
|
||||
// within its 5 s interval, so capture it before any await.
|
||||
tabSyncPromise = waitForPost(this.page, /tabstateview\/?$/, {
|
||||
timeout: 10_000,
|
||||
});
|
||||
// True empty state — click add-tab icon (works in card mode)
|
||||
await this.editorTabs.element
|
||||
.locator(SqlLabPage.SELECTORS.ADD_TAB_ICON)
|
||||
.first()
|
||||
.click();
|
||||
}
|
||||
// If editable-card: real tabs exist, editor is still mounting — just wait
|
||||
}
|
||||
|
||||
// Wait for the editor in the ACTIVE panel, not page-global .first().
|
||||
// In persisted multi-tab sessions, .first() can resolve to a hidden
|
||||
// inactive editor. activePanel scopes to the visible tab panel.
|
||||
await this.activePanel
|
||||
.locator(SqlLabPage.SELECTORS.ACE_EDITOR)
|
||||
.waitFor({ state: 'visible' });
|
||||
await this.editor.waitForReady();
|
||||
|
||||
// If we created the initial tab, wait for its backend sync to complete.
|
||||
// This prevents later waitForPost calls from accidentally matching
|
||||
// this tab's creation POST instead of a subsequent tab's.
|
||||
if (tabSyncPromise) {
|
||||
await tabSyncPromise;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Active Tab Panel ──
|
||||
|
||||
/**
|
||||
* Gets the active tab panel. Ant Design keeps inactive tab panels mounted
|
||||
* but sets aria-hidden="true" on them. Using :not([aria-hidden="true"])
|
||||
* is more reliable than :visible during tab-switch animations where both
|
||||
* panels may briefly have non-zero dimensions.
|
||||
*/
|
||||
private get activePanel(): Locator {
|
||||
return this.page
|
||||
.locator('[role="tabpanel"]:not([aria-hidden="true"])')
|
||||
.filter({ has: this.page.locator(SqlLabPage.SELECTORS.ACE_EDITOR) });
|
||||
}
|
||||
|
||||
// ── Elements ──
|
||||
|
||||
get editor(): AceEditor {
|
||||
return new AceEditor(
|
||||
this.page,
|
||||
this.activePanel.locator(SqlLabPage.SELECTORS.ACE_EDITOR),
|
||||
);
|
||||
}
|
||||
|
||||
get resultsGrid(): AgGrid {
|
||||
return new AgGrid(
|
||||
this.page,
|
||||
this.activePanel
|
||||
.locator(SqlLabPage.SELECTORS.SOUTH_PANE)
|
||||
.locator('[role="grid"]'),
|
||||
);
|
||||
}
|
||||
|
||||
get resultsPane(): Locator {
|
||||
return this.activePanel.locator(SqlLabPage.SELECTORS.SOUTH_PANE);
|
||||
}
|
||||
|
||||
get errorAlert(): Locator {
|
||||
return this.resultsPane.locator('.ant-alert-error');
|
||||
}
|
||||
|
||||
get databaseSelector(): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.page.locator(
|
||||
`${SqlLabPage.SELECTORS.LEFT_BAR} ${SqlLabPage.SELECTORS.DATABASE_SELECTOR}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
get runQueryButton(): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.activePanel.locator(SqlLabPage.SELECTORS.RUN_QUERY_BUTTON),
|
||||
);
|
||||
}
|
||||
|
||||
get saveButton(): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.activePanel.locator(SqlLabPage.SELECTORS.SAVE_BUTTON),
|
||||
);
|
||||
}
|
||||
|
||||
get saveDatasetButton(): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.activePanel.locator(SqlLabPage.SELECTORS.SAVE_DATASET_BUTTON),
|
||||
);
|
||||
}
|
||||
|
||||
get createChartButton(): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.activePanel.locator(SqlLabPage.SELECTORS.EXPLORE_RESULTS_BUTTON),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Editor Convenience ──
|
||||
|
||||
async setQuery(sql: string): Promise<void> {
|
||||
await this.editor.setText(sql);
|
||||
}
|
||||
|
||||
async getQuery(): Promise<string> {
|
||||
return this.editor.getText();
|
||||
}
|
||||
|
||||
// ── Tab Management ──
|
||||
|
||||
async getTabCount(): Promise<number> {
|
||||
return this.editorTabs.getTabCount();
|
||||
}
|
||||
|
||||
async getTabNames(): Promise<string[]> {
|
||||
return this.editorTabs.getTabNames();
|
||||
}
|
||||
|
||||
async getActiveTabName(): Promise<string> {
|
||||
return this.editorTabs.getActiveTabName();
|
||||
}
|
||||
|
||||
async addTab(): Promise<void> {
|
||||
await this.editorTabs.addTab();
|
||||
}
|
||||
|
||||
async addTabByShortcut(): Promise<void> {
|
||||
const modifier = process.platform === 'win32' ? 'Control+q' : 'Control+t';
|
||||
await this.page.keyboard.press(modifier);
|
||||
}
|
||||
|
||||
async closeLastTab(): Promise<void> {
|
||||
const countBefore = await this.getTabCount();
|
||||
await this.editorTabs.removeLastTab();
|
||||
// Wait for tab count to decrease
|
||||
await this.page.waitForFunction(
|
||||
([selector, expected]) => {
|
||||
const container = document.querySelector(selector);
|
||||
if (!container) return false;
|
||||
const nav = container.querySelector(':scope > .ant-tabs-nav');
|
||||
if (!nav) return false;
|
||||
return nav.querySelectorAll('.ant-tabs-tab').length === expected;
|
||||
},
|
||||
[SqlLabPage.SELECTORS.SQL_EDITOR_TABS, countBefore - 1] as const,
|
||||
{ timeout: TIMEOUT.UI_TRANSITION },
|
||||
);
|
||||
}
|
||||
|
||||
getTab(name: string): Locator {
|
||||
return this.editorTabs.getTab(name);
|
||||
}
|
||||
|
||||
// ── Database Selection (Left Sidebar) ──
|
||||
|
||||
async selectDatabase(dbName: string): Promise<void> {
|
||||
await this.databaseSelector.click();
|
||||
|
||||
const popover = new Popover(this.page);
|
||||
await popover.waitForVisible();
|
||||
|
||||
// Target the .ant-select wrapper (not the combobox input) because the
|
||||
// selection-item overlay intercepts pointer events on the input.
|
||||
const dbSelect = popover.element
|
||||
.locator(SqlLabPage.SELECTORS.DATABASE_SELECTOR)
|
||||
.locator('.ant-select')
|
||||
.first();
|
||||
const select = new Select(this.page, dbSelect);
|
||||
await select.selectOption(dbName);
|
||||
|
||||
await popover.getButton('Select').click();
|
||||
await popover
|
||||
.waitForHidden({ timeout: TIMEOUT.UI_TRANSITION })
|
||||
.catch(error => {
|
||||
if (!(error instanceof Error) || error.name !== 'TimeoutError') {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── Query Execution ──
|
||||
|
||||
/**
|
||||
* Sets SQL, runs the query, and waits for the API response.
|
||||
* Also observes the QueryStatusBar (.ant-steps) loading indicator to
|
||||
* confirm the UI entered the execution cycle — this unmounts the old
|
||||
* results grid, so waitForQueryResults() can trust that any grid it
|
||||
* finds afterward contains data from THIS execution.
|
||||
*/
|
||||
async executeQuery(sql: string): Promise<Response> {
|
||||
await this.setQuery(sql);
|
||||
const responsePromise = waitForPost(this.page, 'api/v1/sqllab/execute/', {
|
||||
timeout: TIMEOUT.QUERY_EXECUTION,
|
||||
});
|
||||
// Start observing the loading indicator BEFORE clicking Run so we
|
||||
// catch it even for fast queries. QueryStatusBar (.ant-steps) appears
|
||||
// when SQL Lab enters the running state and unmounts the results grid.
|
||||
const loadingStarted = this.resultsPane
|
||||
.locator('.ant-steps')
|
||||
.waitFor({ state: 'visible', timeout: TIMEOUT.QUERY_EXECUTION });
|
||||
await this.runQueryButton.click();
|
||||
const [, response] = await Promise.all([loadingStarted, responsePromise]);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for fresh query results to render in the AG Grid.
|
||||
* Waits for the QueryStatusBar to disappear first, proving the execution
|
||||
* cycle completed and React rendered the post-query grid.
|
||||
* @param expectHeader - A column header that must be visible before returning.
|
||||
* @param options.timeout - How long to wait (default: TIMEOUT.QUERY_EXECUTION)
|
||||
*/
|
||||
async waitForQueryResults(
|
||||
expectHeader: string,
|
||||
options?: { timeout?: number },
|
||||
): Promise<void> {
|
||||
const timeout = options?.timeout ?? TIMEOUT.QUERY_EXECUTION;
|
||||
// Wait for QueryStatusBar to disappear — proves the loading → ready
|
||||
// transition completed. If already hidden (fast query finished before
|
||||
// this call), resolves immediately since executeQuery() already observed
|
||||
// the loading state appear.
|
||||
await this.resultsPane
|
||||
.locator('.ant-steps')
|
||||
.waitFor({ state: 'hidden', timeout });
|
||||
const grid = this.resultsGrid.element;
|
||||
await grid.waitFor({ state: 'visible', timeout });
|
||||
await grid
|
||||
.locator('.ag-header-cell', { hasText: expectHeader })
|
||||
.first()
|
||||
.waitFor({ state: 'visible', timeout });
|
||||
}
|
||||
|
||||
// ── Row Limit ──
|
||||
|
||||
async getRowLimit(): Promise<string> {
|
||||
const text = await this.activePanel
|
||||
.locator(SqlLabPage.SELECTORS.LIMIT_DROPDOWN)
|
||||
.textContent();
|
||||
return text?.trim() ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the row limit via the Limit dropdown in the active panel.
|
||||
* @param limit - The menu item label to select (e.g., "10", "100")
|
||||
*/
|
||||
async setRowLimit(limit: string): Promise<void> {
|
||||
await this.activePanel.locator(SqlLabPage.SELECTORS.LIMIT_DROPDOWN).click();
|
||||
await this.page.getByRole('menuitem', { name: limit, exact: true }).click();
|
||||
}
|
||||
}
|
||||
@@ -44,25 +44,18 @@ test.beforeEach(async ({ page }) => {
|
||||
test('should redirect to login with incorrect username and password', async ({
|
||||
page,
|
||||
}) => {
|
||||
// Setup request interception before login attempt
|
||||
const loginRequestPromise = authPage.waitForLoginRequest();
|
||||
// The form submission is async (SupersetClient.postForm uses ensureAuth)
|
||||
// so listen for the page reload before triggering the login
|
||||
await Promise.all([
|
||||
page.waitForEvent('load', { timeout: TIMEOUT.PAGE_LOAD }),
|
||||
authPage.loginWithCredentials('wronguser', 'wrongpassword'),
|
||||
]);
|
||||
|
||||
// Attempt login with incorrect credentials (both username and password invalid)
|
||||
await authPage.loginWithCredentials('wronguser', 'wrongpassword');
|
||||
|
||||
// Wait for login request and verify response
|
||||
const loginResponse = await loginRequestPromise;
|
||||
// Failed login returns 401 Unauthorized or 302 redirect to login
|
||||
expect([401, 302]).toContain(loginResponse.status());
|
||||
|
||||
// Wait for redirect to complete before checking URL
|
||||
await page.waitForURL(url => url.pathname.endsWith(URL.LOGIN), {
|
||||
timeout: TIMEOUT.PAGE_LOAD,
|
||||
});
|
||||
// After the reload, wait for the React login form to render
|
||||
await authPage.waitForLoginForm();
|
||||
|
||||
// Verify we stay on login page
|
||||
const currentUrl = await authPage.getCurrentUrl();
|
||||
expect(currentUrl).toContain(URL.LOGIN);
|
||||
expect(page.url()).toContain(URL.LOGIN);
|
||||
|
||||
// Verify error message is shown
|
||||
const hasError = await authPage.hasLoginError();
|
||||
@@ -70,16 +63,12 @@ test('should redirect to login with incorrect username and password', async ({
|
||||
});
|
||||
|
||||
test('should login with correct username and password', async ({ page }) => {
|
||||
// Setup request interception before login attempt
|
||||
const loginRequestPromise = authPage.waitForLoginRequest();
|
||||
|
||||
// Login with correct credentials
|
||||
await authPage.loginWithCredentials(adminUsername, adminPassword);
|
||||
|
||||
// Wait for login request and verify response
|
||||
const loginResponse = await loginRequestPromise;
|
||||
// Successful login returns 302 redirect
|
||||
expect(loginResponse.status()).toBe(302);
|
||||
// Use waitForLoginSuccess (proven in global-setup) — guards against race
|
||||
// conditions with cookie check before falling back to response interception
|
||||
await authPage.waitForLoginSuccess({ timeout: TIMEOUT.PAGE_LOAD });
|
||||
|
||||
// Wait for successful redirect to welcome page
|
||||
await page.waitForURL(url => url.pathname.endsWith(URL.WELCOME), {
|
||||
|
||||
315
superset-frontend/playwright/tests/sqllab/sqllab.spec.ts
Normal file
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SQL Lab E2E tests — sequential via chromium-sqllab project.
|
||||
*
|
||||
* Tab state is stored server-side per user (/tabstateview/*), and all workers
|
||||
* share the same authenticated user. Parallel workers adding/removing tabs
|
||||
* would cause nondeterministic tab counts and cross-worker deletions.
|
||||
* See playwright.config.ts chromium-sqllab project for details.
|
||||
*/
|
||||
|
||||
import { test, expect } from '../../helpers/fixtures/testAssets';
|
||||
import { SqlLabPage } from '../../pages/SqlLabPage';
|
||||
import { ExplorePage } from '../../pages/ExplorePage';
|
||||
import { Input } from '../../components/core';
|
||||
import { SaveQueryModal } from '../../components/modals/SaveQueryModal';
|
||||
import { SaveDatasetModal } from '../../components/modals/SaveDatasetModal';
|
||||
import { waitForPost } from '../../helpers/api/intercepts';
|
||||
import {
|
||||
expectStatus,
|
||||
extractIdFromResponse,
|
||||
} from '../../helpers/api/assertions';
|
||||
import { apiGetSavedQuery } from '../../helpers/api/savedQuery';
|
||||
import { TIMEOUT } from '../../utils/constants';
|
||||
import { URL } from '../../utils/urls';
|
||||
|
||||
let sqlLabPage: SqlLabPage;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
test.setTimeout(TIMEOUT.SLOW_TEST);
|
||||
sqlLabPage = new SqlLabPage(page);
|
||||
await sqlLabPage.gotoAndReady();
|
||||
});
|
||||
|
||||
// ── Query Execution ──
|
||||
|
||||
test('executes a simple SELECT query and displays results', async () => {
|
||||
await expect(sqlLabPage.databaseSelector.element).toBeVisible();
|
||||
|
||||
const response = await sqlLabPage.executeQuery('SELECT 1 AS test_col');
|
||||
expectStatus(response, 200);
|
||||
|
||||
await sqlLabPage.waitForQueryResults('test_col');
|
||||
const headers = await sqlLabPage.resultsGrid.getHeaderTexts();
|
||||
expect(headers.some(h => h.includes('test_col'))).toBe(true);
|
||||
});
|
||||
|
||||
test('shows error message for invalid SQL', async () => {
|
||||
const invalidTable = 'a_table_that_does_not_exist_xyz_pw';
|
||||
await sqlLabPage.executeQuery(`SELECT * FROM ${invalidTable}`);
|
||||
|
||||
const { errorAlert } = sqlLabPage;
|
||||
await expect(errorAlert).toBeVisible({ timeout: TIMEOUT.QUERY_EXECUTION });
|
||||
// Assert the error references the specific table name, proving this query
|
||||
// triggered the failure — not a stale error from a prior test or session.
|
||||
await expect(errorAlert).toContainText(invalidTable);
|
||||
});
|
||||
|
||||
test('re-runs a query and refreshes results', async () => {
|
||||
const firstResponse = await sqlLabPage.executeQuery('SELECT 1 AS first_col');
|
||||
expectStatus(firstResponse, 200);
|
||||
await sqlLabPage.waitForQueryResults('first_col');
|
||||
|
||||
const firstHeaders = await sqlLabPage.resultsGrid.getHeaderTexts();
|
||||
expect(firstHeaders.some(h => h.includes('first_col'))).toBe(true);
|
||||
|
||||
const secondResponse = await sqlLabPage.executeQuery(
|
||||
'SELECT 2 AS second_col',
|
||||
);
|
||||
expectStatus(secondResponse, 200);
|
||||
await sqlLabPage.waitForQueryResults('second_col');
|
||||
|
||||
const secondHeaders = await sqlLabPage.resultsGrid.getHeaderTexts();
|
||||
expect(secondHeaders.some(h => h.includes('second_col'))).toBe(true);
|
||||
expect(secondHeaders.some(h => h.includes('first_col'))).toBe(false);
|
||||
});
|
||||
|
||||
// ── Tabs ──
|
||||
|
||||
test('creates a new tab via button', async () => {
|
||||
const initialTabCount = await sqlLabPage.getTabCount();
|
||||
|
||||
await sqlLabPage.addTab();
|
||||
await sqlLabPage.editor.waitForReady();
|
||||
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount + 1);
|
||||
|
||||
const defaultContent = await sqlLabPage.getQuery();
|
||||
expect(defaultContent).toContain('SELECT');
|
||||
|
||||
await sqlLabPage.closeLastTab();
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount);
|
||||
});
|
||||
|
||||
test('closes a tab via close button', async () => {
|
||||
const initialTabCount = await sqlLabPage.getTabCount();
|
||||
|
||||
await sqlLabPage.addTab();
|
||||
await sqlLabPage.editor.waitForReady();
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount + 1);
|
||||
|
||||
await sqlLabPage.closeLastTab();
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount);
|
||||
});
|
||||
|
||||
test('preserves query state when switching tabs', async () => {
|
||||
const tabOneSql = `SELECT 'tab_one_${Date.now()}'`;
|
||||
const tabTwoSql = `SELECT 'tab_two_${Date.now()}'`;
|
||||
|
||||
const firstTabName = await sqlLabPage.getActiveTabName();
|
||||
|
||||
await sqlLabPage.setQuery(tabOneSql);
|
||||
|
||||
await sqlLabPage.addTab();
|
||||
await sqlLabPage.editor.waitForReady();
|
||||
const secondTabName = await sqlLabPage.getActiveTabName();
|
||||
await sqlLabPage.setQuery(tabTwoSql);
|
||||
|
||||
// Use positional selection — tab names can collide in CI (both tabs may be
|
||||
// named "Untitled Query 1" depending on server-side tab state from prior tests).
|
||||
// Content assertions use toPass() because the editor hydrates asynchronously
|
||||
// after the tab switch — the Ace editor mounts first, then Redux populates it.
|
||||
await sqlLabPage.getTab(firstTabName).first().click();
|
||||
await sqlLabPage.editor.waitForReady();
|
||||
await expect(async () => {
|
||||
expect(await sqlLabPage.getQuery()).toContain('tab_one_');
|
||||
}).toPass({ timeout: TIMEOUT.UI_TRANSITION });
|
||||
|
||||
await sqlLabPage.getTab(secondTabName).last().click();
|
||||
await sqlLabPage.editor.waitForReady();
|
||||
await expect(async () => {
|
||||
expect(await sqlLabPage.getQuery()).toContain('tab_two_');
|
||||
}).toPass({ timeout: TIMEOUT.UI_TRANSITION });
|
||||
|
||||
await sqlLabPage.closeLastTab();
|
||||
});
|
||||
|
||||
test('should open new tab by keyboard shortcut with correct defaults', async ({
|
||||
page,
|
||||
}) => {
|
||||
const initialTabCount = await sqlLabPage.getTabCount();
|
||||
|
||||
await sqlLabPage.setQuery('some random query string');
|
||||
|
||||
// Register before addTabByShortcut — EditorAutoSync POSTs the new tab
|
||||
// within its 5 s interval, so the POST can fire before any later line.
|
||||
const tabStatePromise = waitForPost(page, /tabstateview\/?$/);
|
||||
|
||||
await sqlLabPage.addTabByShortcut();
|
||||
await sqlLabPage.editor.waitForReady();
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount + 1);
|
||||
|
||||
// Verify new tab has default SQL (not carried over from previous tab)
|
||||
const defaultContent = await sqlLabPage.getQuery();
|
||||
expect(defaultContent).toContain('SELECT');
|
||||
|
||||
// Wait for the auto-sync POST that persists the new tab to the backend
|
||||
await tabStatePromise;
|
||||
|
||||
await page.reload();
|
||||
await sqlLabPage.waitForPageLoad();
|
||||
await sqlLabPage.ensureEditorReady();
|
||||
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount + 1);
|
||||
|
||||
await sqlLabPage.closeLastTab();
|
||||
expect(await sqlLabPage.getTabCount()).toBe(initialTabCount);
|
||||
});
|
||||
|
||||
// ── Save and Share ──
|
||||
|
||||
test('saves a query and loads it from saved queries', async ({
|
||||
page,
|
||||
testAssets,
|
||||
}) => {
|
||||
const queryText = 'SELECT 1 AS saved_test_col';
|
||||
const savedQueryTitle = `pw_test_saved_query_${Date.now()}`;
|
||||
|
||||
await expect(sqlLabPage.databaseSelector.element).toBeVisible();
|
||||
|
||||
const executeResponse = await sqlLabPage.executeQuery(queryText);
|
||||
expectStatus(executeResponse, 200);
|
||||
await sqlLabPage.waitForQueryResults('saved_test_col');
|
||||
|
||||
await sqlLabPage.saveButton.click();
|
||||
const saveModal = new SaveQueryModal(page);
|
||||
await saveModal.waitForReady();
|
||||
|
||||
await saveModal.fillName(savedQueryTitle);
|
||||
|
||||
const savePromise = waitForPost(page, 'api/v1/saved_query/', {
|
||||
timeout: TIMEOUT.API_RESPONSE,
|
||||
});
|
||||
await saveModal.clickFooterButton('Save');
|
||||
const saveResponse = await savePromise;
|
||||
expectStatus(saveResponse, 201);
|
||||
|
||||
const savedQueryId = await extractIdFromResponse(saveResponse);
|
||||
testAssets.trackSavedQuery(savedQueryId);
|
||||
|
||||
await saveModal.waitForHidden();
|
||||
|
||||
const getResponse = await apiGetSavedQuery(page, savedQueryId);
|
||||
const savedQuery = (await getResponse.json()).result;
|
||||
expect(savedQuery.sql).toContain('saved_test_col');
|
||||
expect(savedQuery.label).toBe(savedQueryTitle);
|
||||
|
||||
// Navigate through the Saved Queries list UI (not deep-link) to verify
|
||||
// the query appears in the list and can be loaded from there.
|
||||
await page.goto(URL.SAVED_QUERIES_LIST, { waitUntil: 'domcontentloaded' });
|
||||
await page.locator('.ant-table').waitFor({
|
||||
state: 'visible',
|
||||
timeout: TIMEOUT.PAGE_LOAD,
|
||||
});
|
||||
|
||||
// Search for the saved query by its unique name
|
||||
const searchInput = new Input(page, 'input[data-test="filters-search"]');
|
||||
await searchInput.fill(savedQueryTitle);
|
||||
|
||||
// Wait for the filtered row to appear in the table
|
||||
const queryLink = page.getByRole('link', { name: savedQueryTitle });
|
||||
await queryLink.waitFor({ state: 'visible', timeout: TIMEOUT.API_RESPONSE });
|
||||
|
||||
// Navigate to SQL Lab with the saved query ID. The list-view React Router
|
||||
// <Link> uses makeUrl() which double-prefixes with basename in CI, causing
|
||||
// the click to silently fail. Direct navigation tests the loading path
|
||||
// reliably — the list search above already proves the query appears in the UI.
|
||||
await page.goto(`${URL.SQLLAB}?savedQueryId=${savedQueryId}`);
|
||||
await sqlLabPage.waitForPageLoad();
|
||||
await sqlLabPage.ensureEditorReady();
|
||||
|
||||
const loadedSql = await sqlLabPage.getQuery();
|
||||
expect(loadedSql).toContain('saved_test_col');
|
||||
});
|
||||
|
||||
test('creates a dataset from query results', async ({ page, testAssets }) => {
|
||||
await sqlLabPage.selectDatabase('examples');
|
||||
|
||||
const executeResponse = await sqlLabPage.executeQuery(
|
||||
'SELECT 1 AS ds_test_col',
|
||||
);
|
||||
expectStatus(executeResponse, 200);
|
||||
await sqlLabPage.waitForQueryResults('ds_test_col');
|
||||
|
||||
await sqlLabPage.saveDatasetButton.click();
|
||||
|
||||
const saveDatasetModal = new SaveDatasetModal(page);
|
||||
await saveDatasetModal.waitForReady();
|
||||
|
||||
const datasetName = `pw_test_dataset_${Date.now()}`;
|
||||
await saveDatasetModal.fillName(datasetName);
|
||||
|
||||
const datasetCreatePromise = waitForPost(page, 'api/v1/dataset/', {
|
||||
timeout: TIMEOUT.API_RESPONSE,
|
||||
});
|
||||
const newPagePromise = page.context().waitForEvent('page', {
|
||||
timeout: TIMEOUT.API_RESPONSE,
|
||||
});
|
||||
|
||||
await saveDatasetModal.clickFooterButton('Save & Explore');
|
||||
|
||||
const createResponse = await datasetCreatePromise;
|
||||
const datasetId = await extractIdFromResponse(createResponse);
|
||||
testAssets.trackDataset(datasetId);
|
||||
|
||||
const newPage = await newPagePromise;
|
||||
|
||||
const explorePage = new ExplorePage(newPage);
|
||||
await explorePage.waitForPageLoad({ timeout: TIMEOUT.PAGE_LOAD });
|
||||
|
||||
const loadedDatasetName = await explorePage.getDatasetName();
|
||||
expect(loadedDatasetName).toContain(datasetName);
|
||||
|
||||
await newPage.close();
|
||||
});
|
||||
|
||||
// ── Create Chart ──
|
||||
|
||||
test('should navigate to Explore from SQL Lab query results', async ({
|
||||
page,
|
||||
}) => {
|
||||
await sqlLabPage.selectDatabase('examples');
|
||||
|
||||
const query = 'SELECT gender, name FROM birth_names';
|
||||
const executeResponse = await sqlLabPage.executeQuery(query);
|
||||
expectStatus(executeResponse, 200);
|
||||
|
||||
await sqlLabPage.waitForQueryResults('gender');
|
||||
|
||||
await expect(sqlLabPage.createChartButton.element).toBeEnabled();
|
||||
await sqlLabPage.createChartButton.click();
|
||||
|
||||
const explorePage = new ExplorePage(page);
|
||||
await explorePage.waitForPageLoad({ timeout: TIMEOUT.PAGE_LOAD });
|
||||
|
||||
const datasetName = await explorePage.getDatasetName();
|
||||
expect(datasetName).toContain(query);
|
||||
});
|
||||
@@ -58,4 +58,20 @@ export const TIMEOUT = {
|
||||
* File import/upload operations (upload + server processing)
|
||||
*/
|
||||
FILE_IMPORT: 30000, // 30s for file import operations
|
||||
|
||||
/**
|
||||
* UI transition timeout (tab close, popover dismiss, dropdown close)
|
||||
*/
|
||||
UI_TRANSITION: 5000, // 5s ceiling for Ant Design animations (~300-500ms actual)
|
||||
|
||||
/**
|
||||
* SQL query execution (query → backend processing → results)
|
||||
*/
|
||||
QUERY_EXECUTION: 15000, // 15s for SQL queries that may take longer than default expect timeout
|
||||
|
||||
/**
|
||||
* Extended test timeout for multi-step tests (page load + query execution + assertions).
|
||||
* Use with test.setTimeout() when the default 30s test timeout is insufficient.
|
||||
*/
|
||||
SLOW_TEST: 60000, // 60s for tests that chain multiple slow operations
|
||||
} as const;
|
||||
|
||||
@@ -33,6 +33,7 @@ export const URL = {
|
||||
DASHBOARD_LIST: 'dashboard/list/',
|
||||
DATASET_LIST: 'tablemodelview/list',
|
||||
LOGIN: 'login/',
|
||||
SAVED_QUERIES_LIST: 'savedqueryview/list/',
|
||||
SQLLAB: 'sqllab',
|
||||
WELCOME: 'superset/welcome/',
|
||||
} as const;
|
||||
|
||||