Compare commits
189 Commits
dark-mode
...
python-run
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64977bffa6 | ||
|
|
25dddd8f32 | ||
|
|
ee806be8b7 | ||
|
|
0ea6e387c0 | ||
|
|
f6f128b87d | ||
|
|
8cb9ca883d | ||
|
|
384d0b5d3b | ||
|
|
1561702bdb | ||
|
|
4d0eef7217 | ||
|
|
cc6827ae8c | ||
|
|
08dffba554 | ||
|
|
18b59c1b4d | ||
|
|
d56be957f0 | ||
|
|
6631ed5389 | ||
|
|
16c4a16025 | ||
|
|
2219786d93 | ||
|
|
93052b8a8e | ||
|
|
e01cbfc87e | ||
|
|
899d6edb3c | ||
|
|
5705ba7f81 | ||
|
|
0261a15e7b | ||
|
|
02cec9f38d | ||
|
|
8fa9204d57 | ||
|
|
88229c321e | ||
|
|
4d0d576c13 | ||
|
|
7e4dfde94f | ||
|
|
85fc7cb3fd | ||
|
|
16dc5bece0 | ||
|
|
3f15dcd0ad | ||
|
|
6e17e96bf0 | ||
|
|
59dc6a1376 | ||
|
|
4614a37972 | ||
|
|
648039ca1a | ||
|
|
2804f26f4b | ||
|
|
158b78fb25 | ||
|
|
9b82a4d92d | ||
|
|
5fb41fd3b1 | ||
|
|
db70faad90 | ||
|
|
dddf9d679c | ||
|
|
c6c0bf73dd | ||
|
|
c5da59566e | ||
|
|
f914bf8714 | ||
|
|
448e9c8278 | ||
|
|
0ac7bce92b | ||
|
|
ccd8a11ee7 | ||
|
|
5164a08b2a | ||
|
|
e50317d86d | ||
|
|
3800f7452a | ||
|
|
f89073a6bd | ||
|
|
d848a88e64 | ||
|
|
356025f41b | ||
|
|
a0c2ebd9e9 | ||
|
|
c9bc786c60 | ||
|
|
1f024e148d | ||
|
|
7c8a53c4d5 | ||
|
|
bc28d50013 | ||
|
|
d0af14f90d | ||
|
|
6afcf2aed5 | ||
|
|
99d7d54af3 | ||
|
|
1610538386 | ||
|
|
1d94009c3d | ||
|
|
b8360b6da3 | ||
|
|
cb13bdc086 | ||
|
|
1704f14bda | ||
|
|
593ecfb952 | ||
|
|
611220c5e0 | ||
|
|
b77f570c57 | ||
|
|
8ba64b7bcd | ||
|
|
e1dcfdab2e | ||
|
|
5c9b282361 | ||
|
|
cf5c7bd4c3 | ||
|
|
46adff882f | ||
|
|
87923e1e1d | ||
|
|
5bd544baf5 | ||
|
|
f8d410f858 | ||
|
|
cfa62e4b8b | ||
|
|
fa2820320e | ||
|
|
33070f6e06 | ||
|
|
f43c6462d8 | ||
|
|
8f4ccdf2ba | ||
|
|
788bf01ea9 | ||
|
|
c4de2725e3 | ||
|
|
cd0965a299 | ||
|
|
95452f41d3 | ||
|
|
b323ecd565 | ||
|
|
b2939990fc | ||
|
|
c63dff0d7b | ||
|
|
521eed05c5 | ||
|
|
e88afceba9 | ||
|
|
ac2003368e | ||
|
|
1d2fc06b60 | ||
|
|
581c1e7a38 | ||
|
|
17a61a81c8 | ||
|
|
1d699a5fae | ||
|
|
277d1fdaff | ||
|
|
82b3ba1fcc | ||
|
|
dd7845cc83 | ||
|
|
7e7ed1ac9f | ||
|
|
19387d8d29 | ||
|
|
7ac8feb49b | ||
|
|
4447e2c6bc | ||
|
|
8434b23764 | ||
|
|
be72407fc8 | ||
|
|
e530911305 | ||
|
|
ca9ba3390d | ||
|
|
a947f3cb94 | ||
|
|
33de954fcf | ||
|
|
db79c64d3d | ||
|
|
3e646a69f3 | ||
|
|
d6c15aab01 | ||
|
|
34c224b5f2 | ||
|
|
568443a99c | ||
|
|
5fe1efe15b | ||
|
|
894176cf26 | ||
|
|
c28f66c961 | ||
|
|
85e6e7f779 | ||
|
|
d44a2cab66 | ||
|
|
e349faa741 | ||
|
|
817af7b71d | ||
|
|
e8cd58b376 | ||
|
|
62d7beec2b | ||
|
|
c2ec56beed | ||
|
|
5274867997 | ||
|
|
b5a9d7457f | ||
|
|
12f4387864 | ||
|
|
6b5e3bd646 | ||
|
|
b7c4063dd9 | ||
|
|
49fcc4a40f | ||
|
|
7fb62b782b | ||
|
|
f393237eb9 | ||
|
|
48376d3f63 | ||
|
|
a67c48a036 | ||
|
|
8c3d77473a | ||
|
|
9f029dbb2f | ||
|
|
1adaaae66e | ||
|
|
21956d6ab7 | ||
|
|
fd94a0b0cb | ||
|
|
7b6fbd6374 | ||
|
|
eeecd9a10a | ||
|
|
685424df74 | ||
|
|
c4af9c415b | ||
|
|
ca66414190 | ||
|
|
855e846d0a | ||
|
|
270086315f | ||
|
|
16ea0dc141 | ||
|
|
94b9737f0b | ||
|
|
4448933543 | ||
|
|
a9e0afd420 | ||
|
|
d018b4a1bc | ||
|
|
92011484de | ||
|
|
c10fd5cd5b | ||
|
|
564556d706 | ||
|
|
5e55ecd75c | ||
|
|
0a33f82baf | ||
|
|
7ecdc2f757 | ||
|
|
0bf1ac867f | ||
|
|
cbdc23a7bf | ||
|
|
c59e9de090 | ||
|
|
9668ebe98c | ||
|
|
3c2d46151b | ||
|
|
1cacd1f510 | ||
|
|
a8074ca04b | ||
|
|
28014961c3 | ||
|
|
ec5b20af0c | ||
|
|
ab68e21cf7 | ||
|
|
821c0f624b | ||
|
|
7423aaf572 | ||
|
|
03f68f0a2c | ||
|
|
e8f125c19b | ||
|
|
21c5271879 | ||
|
|
45d701fd6b | ||
|
|
7c1152e9d0 | ||
|
|
ab20852102 | ||
|
|
137bc61a42 | ||
|
|
f567aeece1 | ||
|
|
e60e38682b | ||
|
|
84efc79be4 | ||
|
|
8de8d13eb6 | ||
|
|
a52d58a3e2 | ||
|
|
f34cb3d5c3 | ||
|
|
d8571ccabe | ||
|
|
19f279610b | ||
|
|
5647233576 | ||
|
|
14481bcf2f | ||
|
|
bbccbb4842 | ||
|
|
4b99060f46 | ||
|
|
3903af487f | ||
|
|
0fb061b839 | ||
|
|
ab9e7bbcb8 |
@@ -173,6 +173,7 @@
|
||||
metabase.driver.sql-jdbc.execute/execute-prepared-statement!
|
||||
metabase.notification.models/create-notification!
|
||||
metabase.pulse.send/send-pulse!
|
||||
metabase-enterprise.transforms-python.python-runner-test/execute!
|
||||
;; Safe in tests, where we typically use a private, temporary index per thread.
|
||||
metabase.search.core/reindex!
|
||||
metabase.util/run-count!
|
||||
@@ -418,6 +419,7 @@
|
||||
metabase-enterprise.transforms.api-test/with-transform-tags clojure.core/let
|
||||
metabase-enterprise.transforms.api-test/with-worker-runs clojure.core/let
|
||||
metabase-enterprise.transforms.test-util/with-transform-cleanup! clojure.core/let
|
||||
metabase-enterprise.transforms.execute/with-transform-lifecycle clojure.core/let
|
||||
metabase.actions.test-util/with-actions clojure.core/let
|
||||
metabase.api.common/let-404 clojure.core/let
|
||||
metabase.app-db.custom-migrations.util/with-temp-scheduler! clojure.core/fn
|
||||
@@ -519,6 +521,7 @@
|
||||
metabase-enterprise.cache.config-test/with-temp-persist-models hooks.common/with-seven-bindings
|
||||
metabase-enterprise.semantic-search.db.connection/with-migrate-tx hooks.common/let-one-with-optional-value
|
||||
metabase-enterprise.serialization.test-util/with-temp-dpc hooks.toucan2.tools.with-temp/with-temp
|
||||
metabase-enterprise.transforms-python.drivers-test/with-test-table hooks.common/with-two-bindings
|
||||
metabase.api.common.internal-test/with-jetty-server hooks.common/with-one-binding
|
||||
metabase.api.macros/defendpoint hooks.metabase.api.macros/defendpoint
|
||||
metabase.app-db.schema-migrations-test.impl/test-migrations hooks.metabase.app-db.schema-migrations-test.impl/test-migrations
|
||||
@@ -621,10 +624,11 @@
|
||||
metabase.test/with-non-admin-groups-no-root-collection-perms hooks.common/do*
|
||||
metabase.test/with-persistence-enabled! hooks.metabase.model-persistence.test-util/with-persistence-enabled!
|
||||
metabase.test/with-prometheus-system! hooks.common/with-two-bindings
|
||||
metabase.test/with-random-premium-token! hooks.common/with-one-binding
|
||||
metabase.test/with-temp hooks.toucan2.tools.with-temp/with-temp
|
||||
metabase.test/with-temp-file hooks.metabase.test.util/with-temp-file
|
||||
metabase.test/with-temporary-setting-values hooks.metabase.test.util/with-temporary-setting-values
|
||||
metabase.users.api-test/with-temp-user-email! hooks.common/with-one-binding
|
||||
metabase.users.api-test/with-temp-user-email! hooks.common/with-one-binding
|
||||
metabase.util.i18n/deferred-trs hooks.metabase.util.i18n/deferred-trs
|
||||
metabase.util.i18n/deferred-tru hooks.metabase.util.i18n/deferred-tru
|
||||
metabase.util.i18n/trs hooks.metabase.util.i18n/trs
|
||||
@@ -832,7 +836,16 @@
|
||||
performance-sensitive
|
||||
{:linters
|
||||
{:discouraged-var
|
||||
{clojure.core/update-keys {:message "Use metabase.util.performance/update-keys"}}}}
|
||||
{clojure.core/every? {:message "Use metabase.util.performance/every?"}
|
||||
clojure.core/mapv {:message "Use metabase.util.performance/mapv"}
|
||||
clojure.core/run! {:message "Use metabase.util.performance/run!"}
|
||||
clojure.core/select-keys {:message "Use metabase.util.performance/select-keys"}
|
||||
clojure.core/some {:message "Use metabase.util.performance/some"}
|
||||
clojure.core/update-keys {:message "Use metabase.util.performance/update-keys"}
|
||||
clojure.walk/keywordize-keys {:message "Use metabase.util.performance/keywordize-keys"}
|
||||
clojure.walk/postwalk {:message "Use metabase.util.performance/postwalk"}
|
||||
clojure.walk/prewalk {:message "Use metabase.util.performance/prewalk"}
|
||||
clojure.walk/walk {:message "Use metabase.util.performance/walk"}}}}
|
||||
|
||||
qp-and-driver-source-namespaces
|
||||
{:linters
|
||||
|
||||
@@ -428,6 +428,11 @@
|
||||
:api #{metabase.database-routing.core}
|
||||
:uses #{premium-features}}
|
||||
|
||||
dependencies
|
||||
{:team "Querying"
|
||||
:api #{metabase.premium-features.core}
|
||||
:uses #{premium-features}}
|
||||
|
||||
driver
|
||||
{:team "Drivers"
|
||||
:api #{metabase.driver
|
||||
@@ -502,6 +507,7 @@
|
||||
metabase.embedding.init
|
||||
metabase.embedding.jwt
|
||||
metabase.embedding.settings
|
||||
metabase.embedding.util
|
||||
metabase.embedding.validation}
|
||||
:uses #{analytics
|
||||
api
|
||||
@@ -555,6 +561,11 @@
|
||||
models
|
||||
util}}
|
||||
|
||||
graph
|
||||
{:team "Querying"
|
||||
:api #{metabase.graph.core}
|
||||
:uses #{util}}
|
||||
|
||||
indexed-entities
|
||||
{:team "UX West"
|
||||
:api #{metabase.indexed-entities.api
|
||||
@@ -724,6 +735,7 @@
|
||||
metabase.native-query-snippets.core}
|
||||
:uses #{api
|
||||
collections
|
||||
events
|
||||
lib
|
||||
models
|
||||
permissions
|
||||
@@ -893,6 +905,19 @@
|
||||
enterprise/advanced-permissions
|
||||
enterprise/sandbox}}
|
||||
|
||||
python-runner
|
||||
{:team "Workflows"
|
||||
:api #{metabase.python-runner.api
|
||||
metabase.python-runner.core
|
||||
metabase.python-runner.init}
|
||||
:uses #{api
|
||||
driver
|
||||
models
|
||||
query-processor
|
||||
request
|
||||
util
|
||||
enterprise/transforms}}
|
||||
|
||||
queries
|
||||
{:team "Querying"
|
||||
:api #{metabase.queries.api
|
||||
@@ -938,6 +963,7 @@
|
||||
:uses #{api
|
||||
legacy-mbql
|
||||
lib
|
||||
lib-be
|
||||
models
|
||||
permissions
|
||||
query-processor
|
||||
@@ -1020,6 +1046,7 @@
|
||||
metabase.request.schema}
|
||||
:uses #{api
|
||||
config
|
||||
embedding
|
||||
permissions ; FIXME
|
||||
session
|
||||
settings
|
||||
@@ -1225,6 +1252,7 @@
|
||||
events
|
||||
lib
|
||||
models
|
||||
premium-features
|
||||
query-processor
|
||||
settings
|
||||
task
|
||||
@@ -1333,9 +1361,11 @@
|
||||
users
|
||||
{:team "UX West"
|
||||
:api #{metabase.users.api
|
||||
metabase.users.core
|
||||
metabase.users.init
|
||||
metabase.users.models.user
|
||||
metabase.users.models.user-parameter-value}
|
||||
metabase.users.models.user-parameter-value
|
||||
metabase.users.schema}
|
||||
:uses #{analytics
|
||||
api
|
||||
appearance
|
||||
@@ -1470,6 +1500,7 @@
|
||||
driver
|
||||
legacy-mbql
|
||||
lib
|
||||
lib-be
|
||||
models
|
||||
queries
|
||||
query-permissions
|
||||
@@ -1698,6 +1729,29 @@
|
||||
warehouse-schema
|
||||
warehouses}}
|
||||
|
||||
enterprise/dependencies
|
||||
{:team "Querying"
|
||||
:api #{metabase-enterprise.dependencies.api
|
||||
metabase-enterprise.dependencies.core
|
||||
metabase-enterprise.dependencies.init}
|
||||
:uses #{analyze
|
||||
api
|
||||
app-db
|
||||
collections
|
||||
config
|
||||
driver
|
||||
events
|
||||
graph
|
||||
lib
|
||||
lib-be
|
||||
models
|
||||
native-query-snippets
|
||||
premium-features
|
||||
queries
|
||||
query-processor
|
||||
task
|
||||
util}}
|
||||
|
||||
enterprise/documents
|
||||
{:team "UX West"
|
||||
:api #{metabase-enterprise.documents.api
|
||||
@@ -1813,10 +1867,13 @@
|
||||
pulse
|
||||
query-processor
|
||||
request
|
||||
search
|
||||
server
|
||||
settings
|
||||
store-api
|
||||
sync
|
||||
system
|
||||
task
|
||||
users
|
||||
util
|
||||
warehouse-schema
|
||||
@@ -1978,6 +2035,7 @@
|
||||
:api #{metabase-enterprise.transforms.api
|
||||
metabase-enterprise.transforms.core
|
||||
metabase-enterprise.transforms.init
|
||||
metabase-enterprise.transforms.instrumentation
|
||||
metabase-enterprise.transforms.util}
|
||||
:uses #{analytics
|
||||
api
|
||||
@@ -2003,6 +2061,7 @@
|
||||
enterprise/transforms-python
|
||||
{:team "Querying"
|
||||
:api #{metabase-enterprise.transforms-python.api
|
||||
metabase-enterprise.transforms-python.execute
|
||||
metabase-enterprise.transforms-python.init
|
||||
metabase-enterprise.transforms-python.settings}
|
||||
:uses #{api
|
||||
|
||||
@@ -232,7 +232,6 @@
|
||||
metabase.test.data/$ids [[:inner 0]]
|
||||
metabase.test.data/dataset [[:inner 0]]
|
||||
metabase.test.data/mbql-query [[:inner 0]]
|
||||
metabase.test.data/native-query [[:block 0]]
|
||||
metabase.test.data/query [[:block 1]]
|
||||
metabase.test.data/run-mbql-query [[:inner 0]]
|
||||
metabase.test.data/with-empty-h2-app-db! [[:block 0]]
|
||||
@@ -253,7 +252,6 @@
|
||||
metabase.test/format-rows-by [[:default]]
|
||||
metabase.test/let-url [[:block 1]]
|
||||
metabase.test/mbql-query [[:inner 0]]
|
||||
metabase.test/native-query [[:block 0]]
|
||||
metabase.test/query [[:block 1]]
|
||||
metabase.test/run-mbql-query [[:inner 0]]
|
||||
metabase.test/test-driver [[:inner 0]]
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -3,7 +3,7 @@
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> If that is your first contribution to Metabase, please sign the [Contributor License Agreement](https://docs.google.com/a/metabase.com/forms/d/1oV38o7b9ONFSwuzwmERRMi9SYrhYeOrkbmNaq9pOJ_E/viewform) (unless it's a tiny documentation change). Also, if you're attempting to fix a translation issue, please submit your changes to our [Crowdin project](https://crowdin.com/project/metabase-i18n) instead of opening a PR.
|
||||
> If that is your first contribution to Metabase, please sign the [Contributor License Agreement](https://docs.google.com/a/metabase.com/forms/d/1oV38o7b9ONFSwuzwmERRMi9SYrhYeOrkbmNaq9pOJ_E/viewform). Also, if you're attempting to fix a translation issue, please submit your changes to our [Crowdin project](https://crowdin.com/project/metabase-i18n) instead of opening a PR.
|
||||
|
||||
Closes https://github.com/metabase/metabase/issues/[issue_number]
|
||||
|
||||
|
||||
36
.github/actions/cleanup-python-runner/action.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Cleanup Python Runner
|
||||
description: Cleanup python-runner services and upload logs as artifacts
|
||||
|
||||
inputs:
|
||||
upload-logs:
|
||||
description: 'Whether to upload logs (typically on failure)'
|
||||
required: false
|
||||
default: 'false'
|
||||
logs-artifact-suffix:
|
||||
description: 'The unique name of the .zip artifact containing the logs'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Cleanup python-runner services
|
||||
if: always()
|
||||
run: |
|
||||
echo "Stopping python-runner services..."
|
||||
if [ -d "python-runner" ]; then
|
||||
cd python-runner
|
||||
make stop || echo "WARNING: Failed to stop python runner"
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
- name: Upload python-runner logs
|
||||
if: ${{inputs.upload-logs == 'true' && inputs.logs-artifact-suffix != ''}}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: python-runner-logs-${{inputs.logs-artifact-suffix}}
|
||||
path: |
|
||||
python-runner.out.log
|
||||
python-runner.err.log
|
||||
retention-days: 1
|
||||
if-no-files-found: warn
|
||||
27
.github/actions/setup-python-runner/action.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Setup Python Runner
|
||||
description: Setup python-runner for tests
|
||||
inputs:
|
||||
metabase-automation-token:
|
||||
description: Token for accessing the python-runner repository
|
||||
required: true
|
||||
python-runner-version:
|
||||
description: Git tag or commit of the python-runner repository to checkout
|
||||
required: false
|
||||
default: 'v0.0.1'
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Clone and setup python-runner
|
||||
run: |
|
||||
echo "Cloning python-runner repository..."
|
||||
git clone --depth 1 --branch ${{ inputs.python-runner-version }} \
|
||||
https://${{ inputs.metabase-automation-token }}@github.com/metabase/python-runner-container.git python-runner
|
||||
|
||||
echo "Starting python-runner..."
|
||||
cd python-runner
|
||||
make run-ci 1> ../python-runner.out.log 2> ../python-runner.err.log
|
||||
make logs 1>> ../python-runner.out.log 2>> ../python-runner.err.log &
|
||||
cd ..
|
||||
shell: bash
|
||||
env:
|
||||
METABASE_AUTOMATION_USER_TOKEN: ${{ inputs.metabase-automation-token }}
|
||||
30
.github/scripts/setup-python-runner.sh
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Parse command line arguments
|
||||
SKIP_START=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--skip-start)
|
||||
SKIP_START=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--skip-start]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Cloning python-runner repository..."
|
||||
git clone --depth 1 https://${METABASE_AUTOMATION_USER_TOKEN}@github.com/metabase/python-runner-container.git python-runner
|
||||
|
||||
if [ "$SKIP_START" = false ]; then
|
||||
echo "Starting python-runner..."
|
||||
cd python-runner
|
||||
make run-ci 1> ../python-runner.out.log 2> ../python-runner.err.log
|
||||
make logs 1>> ../python-runner.out.log 2>> ../python-runner.err.log &
|
||||
cd ..
|
||||
fi
|
||||
20
.github/workflows/app-db.yml
vendored
@@ -35,21 +35,21 @@ jobs:
|
||||
build-static-viz: false
|
||||
test-args: >-
|
||||
:only '"enterprise/backend/test"'
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
- name: EE App DB Tests (Part 1)
|
||||
build-static-viz: true
|
||||
test-args: >-
|
||||
:only '"test"'
|
||||
:partition/total 2
|
||||
:partition/index 0
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
- name: EE App DB Tests (Part 2)
|
||||
build-static-viz: true
|
||||
test-args: >-
|
||||
:only '"test"'
|
||||
:partition/total 2
|
||||
:partition/index 1
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
|
||||
services:
|
||||
mysql:
|
||||
@@ -147,21 +147,21 @@ jobs:
|
||||
build-static-viz: false
|
||||
test-args: >-
|
||||
:only '"enterprise/backend/test"'
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
- name: EE App DB Tests (Part 1)
|
||||
build-static-viz: true
|
||||
test-args: >-
|
||||
:only '"test"'
|
||||
:partition/total 2
|
||||
:partition/index 0
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
- name: EE App DB Tests (Part 2)
|
||||
build-static-viz: true
|
||||
test-args: >-
|
||||
:only '"test"'
|
||||
:partition/total 2
|
||||
:partition/index 1
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
|
||||
services:
|
||||
mysql:
|
||||
@@ -259,11 +259,13 @@ jobs:
|
||||
build-static-viz: false
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
exclude-tag: ':mb/transforms-python-test'
|
||||
- name: Enterprise Tests
|
||||
build-static-viz: false
|
||||
test-args: >-
|
||||
:only '"enterprise/backend/test"'
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
- name: EE App DB Tests (Part 1)
|
||||
build-static-viz: true
|
||||
test-args: >-
|
||||
@@ -271,14 +273,14 @@ jobs:
|
||||
:exclude-tags [:mb/driver-tests]
|
||||
:partition/total 2
|
||||
:partition/index 0
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
- name: EE App DB Tests (Part 2)
|
||||
build-static-viz: true
|
||||
test-args: >-
|
||||
:only '"test"'
|
||||
:partition/total 2
|
||||
:partition/index 1
|
||||
exclude-tag: ':mb/driver-tests'
|
||||
exclude-tag: ':mb/driver-tests :mb/transforms-python-test'
|
||||
name: "${{ matrix.version.name }} ${{ matrix.job.name }}"
|
||||
env:
|
||||
# Only run old migrations tests on pushes to master or release branches. All other branches should skip tests
|
||||
|
||||
233
.github/workflows/drivers.yml
vendored
@@ -6,6 +6,10 @@ on:
|
||||
skip:
|
||||
type: boolean
|
||||
default: false
|
||||
python-runner-version:
|
||||
type: string
|
||||
default: 'v0.0.1'
|
||||
description: 'Git tag or commit of python-runner repository to use'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-drivers
|
||||
@@ -90,6 +94,7 @@ jobs:
|
||||
junit-name: 'be-tests-athena-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -106,6 +111,19 @@ jobs:
|
||||
if: ${{ !inputs.skip }}
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
# DS 2025-09-26 temporarily disabled while we diagnose flakes
|
||||
# - name: Transforms Python Tests
|
||||
# test-args: >-
|
||||
# :only-tags [:mb/transforms-python-test]
|
||||
# needs-python-runner: true
|
||||
env:
|
||||
CI: 'true'
|
||||
DRIVERS: bigquery-cloud-sdk
|
||||
@@ -116,15 +134,21 @@ jobs:
|
||||
MB_BIGQUERY_TEST_REFRESH_TOKEN: ${{ secrets.MB_BIGQUERY_TEST_REFRESH_TOKEN }}
|
||||
MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON }}
|
||||
MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON_ROUTING: ${{ secrets.MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON_ROUTING }}
|
||||
name: BigQuery
|
||||
name: BigQuery ${{ matrix.job.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test BigQuery Cloud SDK driver
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: 'be-tests-bigquery-cloud-sdk-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
test-args: ${{ matrix.job.test-args }}
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -136,11 +160,29 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: ${{ always() && matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-clickhouse-ee:
|
||||
if: ${{ !inputs.skip }}
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Transforms Python Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/transforms-python-test]
|
||||
needs-python-runner: true
|
||||
env:
|
||||
CI: 'true'
|
||||
DRIVERS: clickhouse
|
||||
@@ -148,9 +190,15 @@ jobs:
|
||||
MB_CLICKHOUSE_TEST_PORT: 8123
|
||||
MB_CLICKHOUSE_TEST_OLD_PORT: 8124
|
||||
MB_CLICKHOUSE_TEST_NGINX_PORT: 8127
|
||||
name: Clickhouse
|
||||
name: Clickhouse ${{ matrix.job.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Add ClickHouse TLS instance to /etc/hosts
|
||||
run: |
|
||||
sudo echo "127.0.0.1 server.clickhouseconnect.test" | sudo tee -a /etc/hosts
|
||||
@@ -167,11 +215,11 @@ jobs:
|
||||
clickhouse_cluster_node2
|
||||
nginx
|
||||
- name: Test Clickhouse driver
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: 'be-tests-clickhouse-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
test-args: ${{ matrix.job.test-args }}
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -183,6 +231,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: ${{ always() && matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-druid-ee:
|
||||
needs: determine-driver-skips
|
||||
@@ -208,6 +262,7 @@ jobs:
|
||||
junit-name: 'be-tests-druid-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -244,6 +299,7 @@ jobs:
|
||||
junit-name: 'be-tests-druid-jdbc-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -280,6 +336,7 @@ jobs:
|
||||
junit-name: 'be-tests-databricks-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -317,6 +374,7 @@ jobs:
|
||||
junit-name: 'be-tests-databricks-multi-catalog-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -338,12 +396,19 @@ jobs:
|
||||
name: H2
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test H2 driver
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: 'be-tests-h2'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -355,6 +420,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: always()
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-mysql-mariadb:
|
||||
if: ${{ !inputs.skip }}
|
||||
@@ -388,6 +459,11 @@ jobs:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
exclude-tag: ':mb/transforms-python-test'
|
||||
- name: Transforms Python Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/transforms-python-test]
|
||||
needs-python-runner: true
|
||||
|
||||
services:
|
||||
mysql:
|
||||
@@ -442,7 +518,14 @@ jobs:
|
||||
name: "${{ matrix.version.name }} ${{ matrix.job.name }}"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test ${{ matrix.version.name }}
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: ${{ matrix.version.junit-name }}
|
||||
@@ -460,6 +543,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: always()
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-mongo:
|
||||
needs: determine-driver-skips
|
||||
@@ -476,6 +565,15 @@ jobs:
|
||||
- name: MongoDB Latest
|
||||
junit-name: be-tests-mongo-latest-ee
|
||||
image: mongo:latest
|
||||
job:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:exclude-tags '[:mongo-sharded-cluster-tests :mb/transforms-python-test]'
|
||||
:only-tags [:mb/driver-tests]
|
||||
- name: Transforms Python Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/transforms-python-test]
|
||||
needs-python-runner: true
|
||||
env:
|
||||
CI: 'true'
|
||||
DRIVERS: mongo
|
||||
@@ -489,16 +587,21 @@ jobs:
|
||||
env:
|
||||
MONGO_INITDB_ROOT_USERNAME: metabase
|
||||
MONGO_INITDB_ROOT_PASSWORD: metasample123
|
||||
name: ${{ matrix.version.name }}
|
||||
name: ${{ matrix.version.name }} ${{ matrix.job.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test ${{ matrix.version.name }}
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: ${{ matrix.version.junit-name }}
|
||||
test-args: >-
|
||||
:exclude-tags [:mongo-sharded-cluster-tests]
|
||||
:only-tags [:mb/driver-tests]
|
||||
test-args: ${{ matrix.job.test-args }}
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -510,6 +613,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: ${{ always() && matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-mongo-ssl:
|
||||
needs: determine-driver-skips
|
||||
@@ -562,7 +671,7 @@ jobs:
|
||||
with:
|
||||
junit-name: ${{ matrix.version.junit-name }}
|
||||
test-args: >-
|
||||
:exclude-tags [:mongo-sharded-cluster-tests]
|
||||
:exclude-tags '[:mongo-sharded-cluster-tests :mb/transforms-python-test]'
|
||||
:only-tags [:mb/driver-tests]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
@@ -670,6 +779,7 @@ jobs:
|
||||
junit-name: ${{ matrix.version.junit-name }}
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -704,6 +814,11 @@ jobs:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
exclude-tag: ':mb/transforms-python-test'
|
||||
- name: Transforms Python Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/transforms-python-test]
|
||||
needs-python-runner: true
|
||||
name: "${{ matrix.version.name }} ${{ matrix.job.name }}"
|
||||
env:
|
||||
# Only run old migrations tests on pushes to master or release branches. All other branches should skip tests
|
||||
@@ -745,7 +860,14 @@ jobs:
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test ${{ matrix.version.name }} (${{ matrix.job.name }})
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: 'be-tests-${{ matrix.version.junit-name }}'
|
||||
@@ -763,6 +885,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: always()
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-presto-jdbc-ee:
|
||||
needs: determine-driver-skips
|
||||
@@ -821,6 +949,7 @@ jobs:
|
||||
junit-name: 'be-tests-presto-jdbc-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -850,8 +979,14 @@ jobs:
|
||||
skip: false
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/upload-tests]
|
||||
:exclude-tags '[:mb/upload-tests :mb/transforms-python-test]'
|
||||
:fail-fast? true
|
||||
- name: Redshift Transforms Python Tests
|
||||
skip: false
|
||||
test-args: >-
|
||||
:only-tags [:mb/transforms-python-test]
|
||||
:fail-fast? true
|
||||
needs-python-runner: true
|
||||
|
||||
env:
|
||||
CI: 'true'
|
||||
@@ -864,7 +999,14 @@ jobs:
|
||||
name: ${{ matrix.job.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test ${{ matrix.job.name }}
|
||||
id: test-driver
|
||||
if: ${{ !matrix.job.skip }}
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
@@ -882,11 +1024,30 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: ${{ always() && matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-snowflake-ee:
|
||||
if: ${{ !inputs.skip }}
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
# DS 2025-09-26 temporarily disabled while we diagnose flakes
|
||||
# - name: Transforms Python Tests
|
||||
# test-args: >-
|
||||
# :only-tags [:mb/transforms-python-test]
|
||||
# needs-python-runner: true
|
||||
env:
|
||||
CI: 'true'
|
||||
DRIVERS: snowflake
|
||||
@@ -905,15 +1066,21 @@ jobs:
|
||||
MB_SNOWFLAKE_TEST_RSA_ROLE_TEST_CUSTOM_USER: RSA_ROLE_TEST_CUSTOM_USER
|
||||
MB_SNOWFLAKE_TEST_RSA_ROLE_TEST_ROLE: RSA_ROLE_TEST_ROLE
|
||||
MB_SNOWFLAKE_TEST_RSA_ROLE_TEST_DB: RSA_ROLE_TEST_DB
|
||||
name: Snowflake
|
||||
name: Snowflake ${{ matrix.job.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test Snowflake driver
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: 'be-tests-snowflake-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
test-args: ${{ matrix.job.test-args }}
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -925,6 +1092,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: ${{ always() && matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
be-tests-sparksql-ee:
|
||||
needs: determine-driver-skips
|
||||
@@ -948,6 +1121,7 @@ jobs:
|
||||
junit-name: 'be-tests-sparksql-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -977,6 +1151,7 @@ jobs:
|
||||
junit-name: 'be-tests-sqlite-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -1004,6 +1179,15 @@ jobs:
|
||||
- name: SQL Server 2022
|
||||
junit-name: be-tests-sqlserver-2022-ee
|
||||
image: mcr.microsoft.com/mssql/server:2022-latest
|
||||
job:
|
||||
- name: Driver Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Transforms Python Tests
|
||||
test-args: >-
|
||||
:only-tags [:mb/transforms-python-test]
|
||||
needs-python-runner: true
|
||||
env:
|
||||
CI: 'true'
|
||||
DRIVERS: sqlserver
|
||||
@@ -1019,15 +1203,21 @@ jobs:
|
||||
ACCEPT_EULA: Y
|
||||
SA_PASSWORD: 'P@ssw0rd'
|
||||
MSSQL_MEMORY_LIMIT_MB: 1024
|
||||
name: ${{ matrix.version.name }}
|
||||
name: ${{ matrix.version.name }} ${{ matrix.job.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup python-runner
|
||||
if: ${{ matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
- name: Test ${{ matrix.version.name }}
|
||||
id: test-driver
|
||||
uses: ./.github/actions/test-driver
|
||||
with:
|
||||
junit-name: ${{ matrix.version.junit-name }}
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
test-args: ${{ matrix.job.test-args }}
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
@@ -1039,6 +1229,12 @@ jobs:
|
||||
aws-secret-access-key: ${{ secrets.AWS_TEST_RESULTS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
trunk-api-token: ${{ secrets.TRUNK_API_TOKEN }}
|
||||
- name: Cleanup python-runner
|
||||
if: ${{ always() && matrix.job.needs-python-runner == true }}
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: ${{ steps.test-driver.outcome == 'failure' }}
|
||||
logs-artifact-suffix: ${{ matrix.job.name }} ${{ matrix.version.name }}
|
||||
|
||||
# TODO(dpsutton, 2025-08-20): Re-enable starburst when we figure out why it randomly dies in CI
|
||||
# be-tests-starburst-ee:
|
||||
@@ -1136,6 +1332,7 @@ jobs:
|
||||
junit-name: 'be-tests-vertica-ee'
|
||||
test-args: >-
|
||||
:only-tags [:mb/driver-tests]
|
||||
:exclude-tags [:mb/transforms-python-test]
|
||||
- name: Upload Test Results
|
||||
uses: ./.github/actions/upload-test-results
|
||||
if: always()
|
||||
|
||||
20
.github/workflows/e2e-test.yml
vendored
@@ -28,6 +28,11 @@ on:
|
||||
split_index: # index of the chunk
|
||||
required: false
|
||||
type: number
|
||||
python-runner-version:
|
||||
type: string
|
||||
default: 'v0.0.1'
|
||||
description: 'Git tag or commit of python-runner repository to use'
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
e2e-tests:
|
||||
@@ -60,6 +65,15 @@ jobs:
|
||||
CYPRESS_IS_EMBEDDING_SDK: "${{ inputs.name == 'embedding-sdk' }}"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
|
||||
- name: Setup python-runner
|
||||
uses: ./.github/actions/setup-python-runner
|
||||
with:
|
||||
metabase-automation-token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
|
||||
python-runner-version: ${{ inputs.python-runner-version }}
|
||||
|
||||
- name: Prepare Docker containers
|
||||
uses: ./.github/actions/e2e-prepare-containers
|
||||
@@ -238,3 +252,9 @@ jobs:
|
||||
const summary = formatSummary(results);
|
||||
|
||||
await core.summary.addRaw(summary).write();
|
||||
|
||||
- name: Cleanup python-runner
|
||||
if: always()
|
||||
uses: ./.github/actions/cleanup-python-runner
|
||||
with:
|
||||
upload-logs: false
|
||||
|
||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
@@ -29,7 +29,8 @@
|
||||
- Use the linter as a way to know that you are adhering to conventions in place in the codebase
|
||||
- **Lint Changes:** `./bin/mage kondo-updated HEAD`
|
||||
- **Format:** `./bin/mage cljfmt-files [path]`
|
||||
- **Test file:** `clojure -X:dev:test :only namespace/test-name`
|
||||
- **Run a test:** `./bin-mage run-tests namespace/test-name`
|
||||
- **Run all tests in a namespace:** `./bin-mage run-tests namespace`
|
||||
- **Check Code Readability** `./bin/mage -check-readable` with optional line-number
|
||||
- Run this after every change to Clojure code, only accept readable code
|
||||
- **Evaluating Clojure Code** `./bin/mage -repl '<code>'`
|
||||
|
||||
41
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
[Metabase](https://www.metabase.com) is the easy, open-source way for everyone in your company to ask questions and learn from data.
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://github.com/metabase/metabase/releases)
|
||||
[](https://codecov.io/gh/metabase/metabase)
|
||||
@@ -12,28 +12,29 @@
|
||||
|
||||
The easiest way to get started with Metabase is to sign up for a free trial of [Metabase Cloud](https://store.metabase.com/checkout). You get support, backups, upgrades, an SMTP server, SSL certificate, SoC2 Type 2 security auditing, and more (plus your money goes toward improving Metabase). Check out our quick overview of [cloud vs self-hosting](https://www.metabase.com/docs/latest/cloud/cloud-vs-self-hosting). If you need to, you can always switch to [self-hosting](https://www.metabase.com/docs/latest/installation-and-operation/installing-metabase) Metabase at any time (or vice versa).
|
||||
|
||||
## Features
|
||||
## Key Features
|
||||
|
||||
- [Set up in five minutes](https://www.metabase.com/docs/latest/setting-up-metabase.html) (we're not kidding).
|
||||
- [Set up in five minutes](https://www.metabase.com/docs/latest/configuring-metabase/setting-up-metabase) (we're not kidding).
|
||||
- Let anyone on your team [ask questions](https://www.metabase.com/docs/latest/questions/introduction) without knowing SQL.
|
||||
- Use the [SQL editor](https://www.metabase.com/docs/latest/questions/native-editor/writing-sql) for more complex queries.
|
||||
- Build handsome, interactive [dashboards](https://www.metabase.com/docs/latest/users-guide/07-dashboards.html) with filters, auto-refresh, fullscreen, and custom click behavior.
|
||||
- Build handsome, interactive [dashboards](https://www.metabase.com/docs/latest/dashboards/introduction) with filters, auto-refresh, fullscreen, and custom click behavior.
|
||||
- Create [models](https://www.metabase.com/learn/metabase-basics/getting-started/models) that clean up, annotate, and/or combine raw tables.
|
||||
- Define canonical [segments and metrics](https://www.metabase.com/docs/latest/administration-guide/07-segments-and-metrics.html) for your team to use.
|
||||
- Send data to Slack or email on a schedule with [dashboard subscriptions](https://www.metabase.com/docs/latest/users-guide/dashboard-subscriptions).
|
||||
- Set up [alerts](https://www.metabase.com/docs/latest/users-guide/15-alerts.html) to have Metabase notify you when your data changes.
|
||||
- [Embed charts and dashboards](https://www.metabase.com/docs/latest/administration-guide/13-embedding.html) in your app, or even [your entire Metabase](https://www.metabase.com/docs/latest/enterprise-guide/full-app-embedding.html).
|
||||
- Define canonical [segments and metrics](https://www.metabase.com/docs/latest/data-modeling/metrics) for your team to use.
|
||||
- Send data to Slack or email on a schedule with [dashboard subscriptions](https://www.metabase.com/docs/latest/dashboards/subscriptions).
|
||||
- Set up [alerts](https://www.metabase.com/docs/latest/questions/alerts) to have Metabase notify you when your data changes.
|
||||
- [Embed charts and dashboards](https://www.metabase.com/docs/latest/embedding/introduction) in your app, or even [your entire Metabase](https://www.metabase.com/docs/latest/embedding/interactive-embedding).
|
||||
- Build with the [Embedded Analytics SDK for React](https://www.metabase.com/docs/latest/embedding/sdk/introduction) to embed standalone components with custom styling that matches your app's design.
|
||||
|
||||
Take a [tour of Metabase](https://www.metabase.com/learn/getting-started/tour-of-metabase).
|
||||
Take a [tour of Metabase](https://www.metabase.com/learn/metabase-basics/overview/tour-of-metabase).
|
||||
|
||||
## Supported databases
|
||||
|
||||
- [Officially supported databases](./docs/databases/connecting.md#connecting-to-supported-databases)
|
||||
- [Community drivers](./docs/developers-guide/partner-and-community-drivers.md)
|
||||
- [Community drivers](./docs/developers-guide/community-drivers.md)
|
||||
|
||||
## Installation
|
||||
|
||||
Metabase can be run just about anywhere. Check out our [Installation Guides](https://www.metabase.com/docs/latest/operations-guide/installing-metabase).
|
||||
Metabase can be run just about anywhere. Check out our [Installation Guides](https://www.metabase.com/docs/latest/installation-and-operation/installing-metabase).
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -43,7 +44,7 @@ In order to spin up a development environment, you need to start the front end a
|
||||
|
||||
### Frontend quick setup
|
||||
|
||||
The following command will install the Javascript dependencies:
|
||||
The following command will install the JavaScript dependencies:
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
@@ -63,7 +64,7 @@ yarn build-hot
|
||||
|
||||
### Backend quick setup
|
||||
|
||||
In order to run the backend, you'll need to build the drivers first, and then start the backend:
|
||||
To run the backend, you'll need to build the drivers first, and then start the backend:
|
||||
|
||||
```bash
|
||||
./bin/build-drivers.sh
|
||||
@@ -78,13 +79,13 @@ We want Metabase to be available in as many languages as possible. See which tra
|
||||
|
||||
## Extending Metabase
|
||||
|
||||
Hit our Query API from Javascript to integrate analytics. Metabase enables your application to:
|
||||
Hit our Query API from JavaScript to integrate analytics. Metabase enables your application to:
|
||||
|
||||
- Build moderation interfaces.
|
||||
- Export subsets of your users to third party marketing automation software.
|
||||
- Provide a custom customer lookup application for the people in your company.
|
||||
|
||||
Check out our guide, [Working with the Metabase API](https://www.metabase.com/learn/administration/metabase-api).
|
||||
Check out our guide, [Working with the Metabase API](https://www.metabase.com/learn/metabase-basics/administration/administration-and-operation/metabase-api).
|
||||
|
||||
## Security Disclosure
|
||||
|
||||
@@ -98,6 +99,14 @@ See [LICENSE.txt](./LICENSE.txt) for details.
|
||||
|
||||
Unless otherwise noted, all files © 2025 Metabase, Inc.
|
||||
|
||||
## [Metabase Experts](https://www.metabase.com/partners/)
|
||||
## Community
|
||||
|
||||
- [Discourse](https://discourse.metabase.com/)
|
||||
- [Twitter](https://x.com/metabase)
|
||||
- [LinkedIn](https://www.linkedin.com/company/metabase/)
|
||||
- [YouTube](https://www.youtube.com/@metabasedata)
|
||||
- [Reddit](https://www.reddit.com/r/Metabase/)
|
||||
|
||||
## Metabase Experts
|
||||
|
||||
If you’d like more technical resources to set up your data stack with Metabase, connect with a [Metabase Expert](https://www.metabase.com/partners/?utm_source=readme&utm_medium=metabase-expetrs&utm_campaign=readme).
|
||||
|
||||
23
bb.edn
@@ -1,4 +1,4 @@
|
||||
{:min-bb-version "1.12.197"
|
||||
{:min-bb-version "1.12.208"
|
||||
;; we put path as bin, and everything is in the ./mage subdirectory,
|
||||
;; so the namespaces are mage.cli, mage.format, etc.
|
||||
:paths ["mage" "test" "bin/lint-migrations-file/src"]
|
||||
@@ -161,7 +161,7 @@
|
||||
:task (stats-repl/connect (cli/parse! (current-task)))}
|
||||
|
||||
notify
|
||||
{:doc "Send notification for a comment (that already exists"
|
||||
{:doc "Send notification for a comment (that already exists)"
|
||||
:requires [[mage.be-dev :refer [nrepl-eval]]]
|
||||
:options [["-c" "--comment-id ID" "Notify about this comment id"]
|
||||
["-p" "--port PORT" "Port to use for the task, defaults to value in .nrepl-port"]]
|
||||
@@ -172,6 +172,25 @@
|
||||
(nrepl-eval "metabase-enterprise.comments.core" code (:port opts))
|
||||
(nrepl-eval "metabase-enterprise.comments.core" code)))}
|
||||
|
||||
run-tests
|
||||
{:doc "Run a tests (or a single test) against nrepl server"
|
||||
:requires [[clojure.string :as str]
|
||||
[mage.be-dev :refer [nrepl-eval]]]
|
||||
:arg-schema [:tuple [:string {:name "NS/TEST" :desc "or just NS"}]]
|
||||
:options [["-p" "--port PORT" "Port to use for the task, defaults to value in .nrepl-port"]]
|
||||
:task (let [{:keys [options]
|
||||
[test] :arguments} (cli/parse! (current-task))
|
||||
test (if (or (str/starts-with? test "test/")
|
||||
(str/starts-with? test "enterprise/"))
|
||||
;; paths should come in as strings
|
||||
(format "\"%s\"" test)
|
||||
;; ns or var should be a symbol
|
||||
(str "'" test))
|
||||
code (format
|
||||
"(do ((requiring-resolve 'dev.reload/reload!)) (find-and-run-tests-repl {:only %s}))"
|
||||
test)]
|
||||
(nrepl-eval "mb.hawk.core" (str code) (:port options)))}
|
||||
|
||||
ls {:doc "List all mage public and private tasks"
|
||||
:examples [["./bin/mage ls" "List all tasks"]]
|
||||
:requires [[mage.util :as u]]
|
||||
|
||||
4
deps.edn
@@ -90,7 +90,7 @@
|
||||
:git/sha "4998a1fdd9d3713d7034d04509e9212204773bf2"
|
||||
:git/url "https://github.com/eerohele/pp"}
|
||||
;; TODO: replace back to normal artifact
|
||||
io.github.metabase/macaw {:mvn/version "0.2.27"} ; Parse native SQL queries
|
||||
io.github.metabase/macaw {:mvn/version "0.2.28"} ; Parse native SQL queries
|
||||
io.github.resilience4j/resilience4j-retry ^:antq/exclude ; 2.x do not support Java 8
|
||||
{:mvn/version "1.7.1"} ; Support for retrying operations
|
||||
io.prometheus/simpleclient_hotspot {:mvn/version "0.16.0"} ; prometheus jvm collector
|
||||
@@ -198,6 +198,8 @@
|
||||
org.eclipse.jetty.ee9/jetty-ee9-servlet
|
||||
org.eclipse.jetty.ee9.websocket/jetty-ee9-websocket-jetty-server]}
|
||||
slingshot/slingshot {:mvn/version "0.12.2"} ; enhanced throw/catch, used by other deps
|
||||
software.amazon.awssdk/s3 {:mvn/version "2.33.0"} ; AWS SDK v2 for S3
|
||||
software.amazon.awssdk/sts {:mvn/version "2.33.0"} ; Required for S3 client to use service account
|
||||
stencil/stencil {:mvn/version "0.5.0"} ; Mustache templates for Clojure
|
||||
user-agent/user-agent {:mvn/version "0.1.1"} ; User-Agent string parser, for Login History page & elsewhere
|
||||
weavejester/dependency {:mvn/version "1.0.0"} ; Dependency graphs and topological sorting
|
||||
|
||||
151
dev/src/dev/reload.clj
Normal file
@@ -0,0 +1,151 @@
|
||||
(ns dev.reload
|
||||
(:require
|
||||
[clojure.java.shell :as shell]
|
||||
[clojure.string :as str]
|
||||
[metabase.util :as u])
|
||||
(:import
|
||||
(java.io File)
|
||||
(java.nio.file Files LinkOption Paths)))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(defonce *reload-timestamps (atom {}))
|
||||
|
||||
(defn system-classpath
|
||||
"Returns a sequence of File paths from the 'java.class.path' system
|
||||
property."
|
||||
[]
|
||||
(into [] (comp (filter #(not (str/ends-with? % ".jar")))
|
||||
(map #(File. ^String %))
|
||||
(filter #(.isDirectory ^File %))
|
||||
(map #(.getCanonicalPath ^File %)))
|
||||
(.split (System/getProperty "java.class.path")
|
||||
(System/getProperty "path.separator"))))
|
||||
|
||||
(defn find-classpath-root
|
||||
"Finds the classpath directory that contains the given file path.
|
||||
Returns the portion of the path to strip, or nil if not found."
|
||||
[classpath file-path]
|
||||
(let [canonical-file (try
|
||||
(.getCanonicalPath (File. ^String file-path))
|
||||
(catch Exception _ file-path))]
|
||||
(->> classpath
|
||||
(filter #(str/starts-with? canonical-file %))
|
||||
(sort-by count >) ; Longest match first
|
||||
first)))
|
||||
|
||||
(defn git-changed-files
|
||||
"Returns a set of changed/added/untracked files from git status."
|
||||
[]
|
||||
(let [{:keys [exit out]} (shell/sh "git" "status" "--porcelain")]
|
||||
(if (and (zero? exit)
|
||||
(not (str/blank? out)))
|
||||
(->> (str/split-lines out)
|
||||
(map #(str/trim (subs % 3))) ; Remove status prefix (e.g., "M ", "A ", "??")
|
||||
(filter #(str/ends-with? % ".clj"))
|
||||
set)
|
||||
#{})))
|
||||
|
||||
(defn file-last-modified
|
||||
"Returns the last modified time of a file in milliseconds."
|
||||
[file-path]
|
||||
(try
|
||||
(-> (Paths/get file-path (into-array String []))
|
||||
(Files/getLastModifiedTime (into-array LinkOption []))
|
||||
(.toMillis))
|
||||
(catch Exception _ nil)))
|
||||
|
||||
(defn relpath->ns
|
||||
"foo/bar_baz.clj -> foo.bar-baz"
|
||||
[relpath]
|
||||
(-> relpath
|
||||
(str/replace #"\.clj$" "")
|
||||
(str/replace #"/" ".")
|
||||
(str/replace #"_" "-")
|
||||
symbol))
|
||||
|
||||
(defn file-path->namespace
|
||||
"Converts a file path to a namespace symbol using classpath information.
|
||||
Example: enterprise/backend/src/foo/bar/baz.clj -> foo.bar.baz"
|
||||
[file-path classpath]
|
||||
(when (and file-path (re-find #".cljc?$" file-path))
|
||||
(when-let [root (find-classpath-root classpath file-path)]
|
||||
(let [canonical-file (try
|
||||
(.getCanonicalPath (File. ^String file-path))
|
||||
(catch Exception _ file-path))
|
||||
relative-path (subs canonical-file (inc (count root)))]
|
||||
(relpath->ns relative-path)))))
|
||||
|
||||
(defn loaded-namespaces
|
||||
"Returns a set of all currently loaded namespace symbols."
|
||||
[]
|
||||
(set (map ns-name (all-ns))))
|
||||
|
||||
(defn needs-reload?
|
||||
"Checks if a file needs reloading based on its last modified time."
|
||||
[file-path ns-sym]
|
||||
(let [last-reload (get @*reload-timestamps ns-sym)
|
||||
last-modified (file-last-modified file-path)]
|
||||
(or (nil? last-reload)
|
||||
(nil? last-modified)
|
||||
(> last-modified last-reload))))
|
||||
|
||||
(defn changed-namespaces []
|
||||
(let [changed-files (git-changed-files)
|
||||
loaded-ns (loaded-namespaces)
|
||||
classpath-dirs (system-classpath)
|
||||
candidates (->> changed-files
|
||||
(map (fn [f] {:file f :ns (file-path->namespace f classpath-dirs)}))
|
||||
(filter :ns)
|
||||
(filter #(loaded-ns (:ns %))))
|
||||
to-reload (filter #(needs-reload? (:file %) (:ns %)) candidates)
|
||||
skipped (remove #(needs-reload? (:file %) (:ns %)) candidates)]
|
||||
{:to-reload to-reload
|
||||
:skipped skipped}))
|
||||
|
||||
(defn reload-namespaces!
|
||||
[to-reload]
|
||||
(->> (for [{:keys [_file ns]} to-reload]
|
||||
(try
|
||||
(require ns :reload)
|
||||
(swap! *reload-timestamps assoc ns (System/currentTimeMillis))
|
||||
[:reloaded ns]
|
||||
(catch Exception e
|
||||
[:failed {:ns ns :error (.getMessage e)}])))
|
||||
(u/group-by first second)))
|
||||
|
||||
(defn reload!
|
||||
"Reloads all changed files from git that are already loaded as namespaces
|
||||
and have been modified since last reload.
|
||||
Returns a map with :reloaded, :skipped, and :failed keys."
|
||||
[]
|
||||
(let [{:keys [to-reload
|
||||
skipped]} (changed-namespaces)
|
||||
_ (println (format "Reloading %s namespaces (%s skipped):" (count to-reload) (count skipped)))
|
||||
{:keys [reloaded
|
||||
failed]
|
||||
:as res} (reload-namespaces! to-reload)]
|
||||
(doseq [ns reloaded]
|
||||
(println " ✓" ns))
|
||||
(doseq [{:keys [ns error]} failed]
|
||||
(println " ✗" ns ":" error))
|
||||
(assoc res :skipped skipped)))
|
||||
|
||||
(defn clear-reload-history!
|
||||
"Clears the reload timestamp history, forcing all files to reload next time."
|
||||
[]
|
||||
(reset! *reload-timestamps {})
|
||||
(println "Reload history cleared."))
|
||||
|
||||
(defn show-classpath
|
||||
"Shows all classpath directories for debugging."
|
||||
[]
|
||||
(println "\n=== Classpath Directories ===")
|
||||
(run! #(println (.getCanonicalPath ^File %)) (sort (system-classpath))))
|
||||
|
||||
(comment
|
||||
(show-classpath) ; to see what's in your classpath
|
||||
(clear-reload-history!) ; if you want to force reload everything
|
||||
(changed-namespaces)
|
||||
(reload!))
|
||||
@@ -61,7 +61,7 @@ Once one or more people have started to work on a feature, it should be marked [
|
||||
|
||||
### E) Verification and merging
|
||||
|
||||
All PRs that involve more than an insignificant change should be reviewed. See our [Code Review Process](./developers-guide/code-reviews.md).
|
||||
All PRs that involve more than an insignificant change should be reviewed. See our [Code Review Process](https://www.metabase.com/docs/master/developers-guide/code-reviews).
|
||||
|
||||
If all goes well, the feature gets coded up, verified and then the pull request gets merged! High-fives all around.
|
||||
|
||||
@@ -95,7 +95,7 @@ By our definition, "Bugs" are situations where the program doesn't do what it wa
|
||||
|
||||
There are a lot of docs, which means keeping them up to date is hard. If you notice inconsistencies, errors, or outdated information, please help us keep them current!
|
||||
|
||||
Note that **we cannot accept translations for documentation at this time**. We support [in-app translations](./configuring-metabase/localization.md), and only support languages that have 100% coverage. But 1) the in-app text is orders of magnitude shorter than our docs, 2) it changes at a slower pace, and 3) we have a lot of people help out. We may consider supporting docs in multiple languages in the future, but for now we need to focus our resources on improving our existing documentation (and expanding it to include all of the new features we're adding).
|
||||
Note that **we cannot accept translations for documentation at this time**. We support [in-app translations](https://www.metabase.com/docs/master/configuring-metabase/localization), and only support languages that have 100% coverage. But 1) the in-app text is orders of magnitude shorter than our docs, 2) it changes at a slower pace, and 3) we have a lot of people help out. We may consider supporting docs in multiple languages in the future, but for now we need to focus our resources on improving our existing documentation (and expanding it to include all of the new features we're adding).
|
||||
|
||||
### Working on features
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 129 KiB |
@@ -53,7 +53,7 @@ Some tips:
|
||||
Hover over Metabot's response to:
|
||||
|
||||
- Copy the response.
|
||||
- Give thumbs-up/thumbs-down feedback on responses. If you downvote a response, you can optionally contribute a bug report to help us improve Metabot.
|
||||
- Give thumbs-up/thumbs-down [feedback on responses](#giving-feedback-on-metabot-responses). If you upvote a response, you can optionally add some feedback. If you downvote a response, you can optionally contribute a bug report to help us improve Metabot.
|
||||
- Re-run the prompt with Metabot. This is useful if you've updated the chart or just want to have Metabot take another pass (since AI responses aren't deterministic, Metabot may give a different response on another run).
|
||||
|
||||
## Analyze charts with Metabot
|
||||
@@ -68,7 +68,7 @@ You can also ask Metabot to tell you about specific tables in your database.
|
||||
|
||||
## How Metabot uses the query builder
|
||||
|
||||
When you ask Metabot to create a chart from natural language, it first looks for existing questions that might answer your request. If it finds a relevant question, it'll point you to that instead of creating something new. Otherwise, Metabot will use the [query builder](../questions/query-builder/editor.md) to create a new chart for you.
|
||||
When you ask Metabot to create a chart from natural language, it first looks for existing questions that might answer your request. If it finds a relevant question, it'll point you to that instead of creating something new. Otherwise, Metabot will use the [query builder](../questions/query-builder/editor.md) to create a new chart for you.
|
||||
|
||||
Keep in mind that Metabot is still learning the query builder. Metabot can only handle basic query builder operations, and it lacks access to the library of [custom expressions](../questions/query-builder/expressions-list.md). Metabot is also limited to single-level aggregation and grouping, so if you need more complex analysis, you can take over and refine the query yourself, or switch to the SQL editor.
|
||||
|
||||
@@ -83,7 +83,7 @@ To have Metabot generate SQL for you:
|
||||
3. Type cmd+b on Mac, ctrl+b on Windows, to open up the [chat sidebar](#the-metabot-chat-sidebar).
|
||||
4. Ask it to "Write a SQL query that..." and type your prompt.
|
||||
|
||||
Metabot will generate the SQL for you, but it won't run the query. This gives you a chance to inspect the code before running it. The native editor is designed to be read-only (so don't worry about Metabot dropping any tables), but you should still check the query to make sure it targets the data you want.
|
||||
Metabot will generate the SQL for you, but it won't run the query. This gives you a chance to inspect the code before running it.
|
||||
|
||||
If you don't specify a specific table in a natural language question, Metabot will only check the first 100 tables in the currently selected database. If your question pertains to tables other than those first 100 tables, Metabot may hallucinate the tables it needs, and the query will fail.
|
||||
|
||||
@@ -98,3 +98,19 @@ When you get an error in a SQL query, you can click the **Have Metabot fix it**
|
||||
If Metabot creates a query or takes you to a new item but you want to return to the previous screen, you can navigate using your browser's back button.
|
||||
|
||||
You can also save any chart that Metabot creates to a dashboard or collection.
|
||||
|
||||
## Giving feedback on Metabot responses
|
||||
|
||||
When you hover over Metabot's responses, you'll see options to give feedback.
|
||||
|
||||
Thumbs up are just as helpful as thumbs down. If you give a thumbs down, you can optionally provide more details about the issue and set an issue type:
|
||||
|
||||
- UI bug
|
||||
- Took incorrect actions
|
||||
- Overall refusal
|
||||
- Did not follow request
|
||||
- Not factually correct
|
||||
- Incomplete response
|
||||
- Other
|
||||
|
||||
> When you submit feedback, the form you send may contain sensitive data from your conversation.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Metabot settings
|
||||
title: Metabot AI settings
|
||||
summary: Configure Metabot settings, including which collections Metabot can access, and learn tips for improving Metabot's performance through data modeling and metadata.
|
||||
---
|
||||
|
||||
# Metabot settings
|
||||
# Metabot AI settings
|
||||
|
||||
{% include beta-blockquote.html
|
||||
message="For now, <a href='https://www.metabase.com/features/metabot-ai'>Metabot</a> is only available as an add-on for Pro and Enterprise plans on Metabase Cloud."
|
||||
@@ -13,21 +13,26 @@ _Settings > Admin settings > AI_
|
||||
|
||||
This page covers admin settings for Metabase's AI assistant, [Metabot](./metabot.md).
|
||||
|
||||
## Configure Metabot
|
||||
|
||||
To help Metabot focus on the data you care about most, select the collection containing the models and metrics you'd like it to work with.
|
||||
|
||||
## Pick a collection for Metabot to have access to
|
||||
|
||||

|
||||
|
||||
To select a collection for Metabot:
|
||||
## Verified content
|
||||
|
||||
Admins on Pro and Enterprise plans can tell Metabot to only work with [models](../data-modeling/models.md) and [metrics](../data-modeling/metrics.md) that have been [verified](../exploration-and-organization/content-verification.md).
|
||||
|
||||
Restricting Metabot to verified models and metrics (and only models and metrics) can help Metabot produce more reliable answers, since you know someone has at least vetted the data Metabot can use.
|
||||
|
||||
## When embedding Metabot, you can pick a collection for Metabot to have access to
|
||||
|
||||
When embedding Metabot in your app, you can select a collection for Metabot:
|
||||
|
||||
1. Go to **Settings** > **Admin settings** > **AI**.
|
||||
2. Click the **Collection** dropdown.
|
||||
3. Select the collection that contains the models and metrics you want Metabot to use.
|
||||
2. Click **Embedded Metabot**.
|
||||
3. In the **Collection Embedded Metabot can use** section, click **Pick a collection**.
|
||||
4. Select the collection that contains the models and metrics you want Metabot to use.
|
||||
|
||||
Metabot will use the models and metrics in that collection to help answer questions and generate queries. You can change this collection at any time.
|
||||
Metabot will use the models and metrics in that collection to help answer questions and generate queries. You can change this collection at any time. To give Metabot access to all collections, you can set the collection to the root collection, called "Our Analytics" (the default).
|
||||
|
||||
Alternatively (or additionally), you can restrict Metabot to [verified content](#verified-content).
|
||||
|
||||
## Tips for making the most of Metabot
|
||||
|
||||
@@ -66,7 +71,7 @@ Metabase will try to set semantic types automatically, but you should confirm th
|
||||
|
||||
### Curate prompt suggestions
|
||||
|
||||
When you select a collection for Metabot to "learn", Metabot will suggest a series of prompts based on the content it finds in that collection. These give people a feel for the kinds of things people can ask Metabot to do.
|
||||
When you select a collection for Metabot to "learn", Metabot will suggest a series of prompts based on the content it finds in that collection. These prompts just give people a feel for the kinds of things people can ask Metabot to do.
|
||||
|
||||
Admins can run these generated prompts to test the answers, or trash the individual prompts if they're not useful or misleading. You can also regenerate all the prompts with a click.
|
||||
|
||||
@@ -86,6 +91,16 @@ Under the hood, Metabase powers Metabot with a variety of generative models. For
|
||||
|
||||
To get the best results, we (the Metabase team) use internal benchmarks to determine which AI models Metabot should use for different tasks. And we are constantly iterating on performance, so Metabot will continue to improve over time.
|
||||
|
||||
## We don't collect or store the prompts you send to Metabot
|
||||
## Unless you submit feedback, we don't collect or store the prompts you send to Metabot
|
||||
|
||||
We've intentionally limited what Metabot can do. Metabot lacks access to API keys, and it can't create assets, write data, or send data outside of your Metabase. Your questions and conversations remain private to your Metabase. We do collect some metadata to gauge and improve usage, but we don't train Metabot on your prompts or your data—because we can't see them!
|
||||
We've intentionally limited what Metabot can do. Metabot lacks access to API keys, and it can't create assets, write data, or send your data outside of your Metabase. Your questions and conversations remain private to your Metabase (unless you [submit feedback](./metabot.md#giving-feedback-on-metabot-responses)). We do collect some metadata to gauge and improve usage.
|
||||
|
||||
### What Metabot can see
|
||||
|
||||
Metabot has access to your Metabase metadata and some data values to help answer your questions:
|
||||
|
||||
- **Table, Question, Model, Dashboard, and Metric metadata**: Metabot can see the structure and configuration of your content
|
||||
- **Sample field values**: When you ask questions like "Filter everyone from Wisconsin," Metabot might check the values in the state field to understand how the data is stored (like "WI" vs "Wisconsin"). See [syncs](../databases/sync-scan.md).
|
||||
- **Timeseries data**: For chart analysis, Metabot might see the timeseries data used to draw certain visualizations, depending on the chart type.
|
||||
|
||||
When you [submit feedback](./metabot.md#giving-feedback-on-metabot-responses), however, the form you send may contain sensitive data from your conversation.
|
||||
|
||||
1378
docs/api.html
@@ -80,6 +80,7 @@ Here's what you need to know when syncing Google Sheets:
|
||||
- **Special character replacement**. Some characters just don't play nice with databases (like "?"). When we find these in column names, we'll replace them with "x" to keep things running smoothly.
|
||||
- **Renamed files will create new tables**. If you rename files in your folder or tabs in your sheets, we'll treat them as brand new tables and import them fresh.
|
||||
- **New columns sync automatically**. Adding new columns to your sheets? No problem — they'll show up in Metabase as expected.
|
||||
- **Renaming sheet columns will create new table columns**. If you rename a column in a spreadsheet, Metabase will create a new column with the new name in the synced table. The original column will remain in the table but it'll become empty. You'll be able to hide the old column in Table Metadata settings.
|
||||
- **Empty sheets won't import**. We won't import completely empty sheets or sheets that only have column headers. There needs to be some actual data in there.
|
||||
- **Google Sheets must have unique names**. If files in the synced Google Drive folder (and its subfolders) have the same name (e.g., one sheet is in the root folder, another sheet in a subfolder), the sheets might not sync properly.
|
||||
|
||||
|
||||
@@ -122,11 +122,12 @@ If you have databases connected to Metabase that are set to **Use default** poli
|
||||
To set a caching policy for a dashboard, you must have [curate access](../permissions/collections.md#curate-access) to the dashboard's collection.
|
||||
|
||||
1. Go to your dashboard.
|
||||
2. Click on the **info** icon.
|
||||
3. Click **Caching policy**.
|
||||
4. Select the [caching invalidation policy](#cache-invalidation-policies).
|
||||
5. Optional: turn on [refresh cache automatically](#refresh-cache-automatically).
|
||||
6. Save your changes.
|
||||
2. Click on the **three dots** icon in the top-right corner of the dashboard and choose **Edit settings**.
|
||||
3. By default, each question will use the database default caching settings. Click the current caching policy to change it.
|
||||
4. Select the new [caching policy](#cache-invalidation-policies).
|
||||
5. Optional: turn on [refresh cache automatically](#refresh-cache-automatically)
|
||||
6. Optional: to clear the cache for all questions on a dashboard, click **Clear cache for this dashboard** at the bottom of the setting sidebar.
|
||||
7. Save your changes.
|
||||
|
||||
### Question caching policy
|
||||
|
||||
|
||||
@@ -137,8 +137,6 @@ config:
|
||||
embedding-app-origins-interactive: null
|
||||
embedding-app-origins-sdk: ''
|
||||
embedding-homepage: hidden
|
||||
embedding-hub-production-embed-snippet-created: false
|
||||
embedding-hub-test-embed-snippet-created: false
|
||||
embedding-secret-key: null
|
||||
enable-embedding-interactive: false
|
||||
enable-embedding-sdk: false
|
||||
@@ -190,6 +188,7 @@ config:
|
||||
ldap-security: none
|
||||
ldap-sync-user-attributes: true
|
||||
ldap-sync-user-attributes-blacklist: userPassword,dn,distinguishedName
|
||||
ldap-timeout-seconds: 15.0
|
||||
ldap-user-base: null
|
||||
ldap-user-filter: (&(objectClass=inetOrgPerson)(|(uid={login})(mail={login})))
|
||||
ldap-user-provisioning-enabled: true
|
||||
|
||||
@@ -585,24 +585,6 @@ Allow Metabase SDK access to these space delimited origins.
|
||||
|
||||
Embedding homepage status, indicating if it's visible, hidden or has been dismissed.
|
||||
|
||||
### `MB_EMBEDDING_HUB_PRODUCTION_EMBED_SNIPPET_CREATED`
|
||||
|
||||
- Type: boolean
|
||||
- Default: `false`
|
||||
- [Exported as](../installation-and-operation/serialization.md): `embedding-hub-production-embed-snippet-created`.
|
||||
- [Configuration file name](./config-file.md): `embedding-hub-production-embed-snippet-created`
|
||||
|
||||
Indicates if a production embed snippet has been created for tracking in the embedding hub.
|
||||
|
||||
### `MB_EMBEDDING_HUB_TEST_EMBED_SNIPPET_CREATED`
|
||||
|
||||
- Type: boolean
|
||||
- Default: `false`
|
||||
- [Exported as](../installation-and-operation/serialization.md): `embedding-hub-test-embed-snippet-created`.
|
||||
- [Configuration file name](./config-file.md): `embedding-hub-test-embed-snippet-created`
|
||||
|
||||
Indicates if a test embed snippet has been created for tracking in the embedding hub.
|
||||
|
||||
### `MB_EMBEDDING_SECRET_KEY`
|
||||
|
||||
- Type: string
|
||||
@@ -1076,6 +1058,14 @@ Should we sync user attributes when someone logs in via LDAP?
|
||||
|
||||
Comma-separated list of user attributes to skip syncing for LDAP users.
|
||||
|
||||
### `MB_LDAP_TIMEOUT_SECONDS`
|
||||
|
||||
- Type: double
|
||||
- Default: `15.0`
|
||||
- [Configuration file name](./config-file.md): `ldap-timeout-seconds`
|
||||
|
||||
Maximum time, in seconds, to wait for LDAP server before falling back to local authentication.
|
||||
|
||||
### `MB_LDAP_USER_BASE`
|
||||
|
||||
- Type: string
|
||||
|
||||
@@ -19,7 +19,7 @@ To manage upload settings, admins can hit cmd/ctrl + K and search for "Settings
|
||||
- [PostgreSQL](../databases/connections/postgresql.md)
|
||||
- [MySQL](../databases/connections/mysql.md)
|
||||
- [Redshift](../databases/connections/redshift.md)
|
||||
- [ClickHouse](../databases/connections/clickhouse.md)
|
||||
- [ClickHouse](../databases/connections/clickhouse.md) (only supported on ClickHouse Cloud)
|
||||
|
||||
## Setting up uploads
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ Anyone can build a community driver. These are the currently known third-party d
|
||||
| [Neo4j](https://github.com/StronkMan/metabase-neo4j-driver) |  |  |
|
||||
| [Netsuite SuiteAnalytics Connect](https://github.com/ericcj/metabase-netsuite-driver) |  |  |
|
||||
| [Peaka](https://github.com/peakacom/metabase-driver) |  |  |
|
||||
| [SPARQL](https://github.com/jhisse/metabase-sparql-driver) |  |  |
|
||||
| [Teradata](https://github.com/swisscom-bigdata/metabase-teradata-driver) |  |  |
|
||||
|
||||
If you don't see a driver for your database, try looking in the comments of the [issue related to the database](https://github.com/metabase/metabase/labels/Database%2F). You might also find more drivers by searching on GitHub for "Metabase driver".
|
||||
|
||||
@@ -7,7 +7,7 @@ title: Development environment
|
||||
The Metabase application has two basic components:
|
||||
|
||||
1. A backend written in Clojure which contains a REST API as well as all the relevant code for talking to databases and processing queries.
|
||||
2. A frontend written as a Javascript single-page application which provides the web UI.
|
||||
2. A frontend written as a JavaScript single-page application which provides the web UI.
|
||||
|
||||
Both components are built and assembled together into a single JAR file. In the directory where you run the JAR, you can create a JAR file (if Metabase hasn't already created it) and add drivers in there (the drivers are also JARs).
|
||||
|
||||
@@ -147,6 +147,17 @@ You can also start a REPL another way (e.g., through your editor) and then call:
|
||||
To start the server (at `localhost:3000`). This will also set up or migrate your application database. To actually
|
||||
use Metabase, don't forget to start the frontend as well (e.g. with `yarn build-hot`).
|
||||
|
||||
### Multiple Instances
|
||||
|
||||
By default Rspack runs the development server on port `8088`. You can run multiple instances of Metabase on the same machine by specifying a different port for each instance.
|
||||
|
||||
Frontend:
|
||||
- If you are running the frontend with `yarn build-hot`, set the `MB_FRONTEND_DEV_PORT` environment variable: `MB_FRONTEND_DEV_PORT=8089 MB_EDITION=ee yarn build-hot`
|
||||
- If you are building the frontend statically with `yarn build`, there is nothing different to do
|
||||
|
||||
Backend:
|
||||
- Set the `MB_JETTY_PORT` environment variable and `MB_FRONTEND_DEV_PORT` to the same one as for the frontend.
|
||||
|
||||
### The application database
|
||||
|
||||
By default, Metabase uses H2 for its application database, but we recommend using Postgres. This is configured with
|
||||
|
||||
@@ -20,7 +20,24 @@ title: Driver interface changelog
|
||||
- Added `metabase.driver/rename-tables!*` multimethod for atomic table renaming operations. Takes a map of {from-table to-table}
|
||||
pairs that has been topologically sorted.
|
||||
|
||||
- Added the driver multi-methods `metabase.driver/schema-exists?` and `metabase.driver/create-schema-if-needed!` which should be implemented by drivers that support `:schemas` and `:transforms/table`.
|
||||
- Added `metabase.driver/rename-table!` multimethod for table renaming operations. Takes a single from-table to-table pair.
|
||||
Fallbacks to singleton call to `rename-tables!*` if available.
|
||||
|
||||
- Added the driver multi-methods `metabase.driver/schema-exists?` and `metabase.driver/create-schema-if-needed!`
|
||||
which should be implemented by drivers that support `:schemas` and `:transforms/table`.
|
||||
|
||||
- Added `metabase.driver/type->database-type` multimethod that returns the database type for a given Metabase
|
||||
type (from the type hierarchy) as a HoneySQL spec. This method handles general Metabase base types.
|
||||
|
||||
- Added driver multimethods driver/native-result-metadata, driver/validate-native-query-fields, driver.sql/resolve-field, driver.sql.normalize-unquoted-name, driver.sql.normalize/reserved-literal, driver.sql.references/find-used-fields, driver.sql.references/find-returned-fields, and driver.sql.references/field-references-impl for use with the :dependencies/native feature.
|
||||
|
||||
- Added `metabase.driver/insert-from-source!` multimethod that abstracts data insertion from various sources
|
||||
into existing tables. This multimethod dispatches on both the driver and the data source type
|
||||
(`:rows` or `:jsonl-file`). It allows drivers to optimize based on the data source type and returns the number
|
||||
of rows inserted. Default implementations are provided for both `:rows` and `:jsonl-file` source types.
|
||||
|
||||
- Added `metabase.driver/insert-col->val` multimethod to parse values for insertion based on driver, data source type
|
||||
and column definition. Drivers should implement this when their insertion mechanism needs values converted to proper types.
|
||||
|
||||
- `metabase.driver/humanize-connection-error-message` now takes a list of all messages in the exception chain,
|
||||
instead of just the top-level message as a string.
|
||||
|
||||
BIN
docs/documents/images/document-layout.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
docs/documents/images/document-with-comment.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
@@ -7,6 +7,8 @@ summary: Create documents to combine text and charts for long-form analysis. Add
|
||||
|
||||
{% include plans-blockquote.html feature="Documents" %}
|
||||
|
||||

|
||||
|
||||
Documents let you tell a story with your data by combining text, charts, and other content.
|
||||
|
||||
## Create a document
|
||||
@@ -34,13 +36,15 @@ You can add [questions](../questions/start.md) and [models](../data-modeling/mod
|
||||
|
||||
### Adding a chart copies it to the document
|
||||
|
||||
When you add a chart from a collection, Metabase creates a copy in the document. The original question remains in the collection.
|
||||
When you add a chart from a collection, Metabase creates a copy in the document. The original question remains in the collection. Changes to one copy won't affect the other; they're independent.
|
||||
|
||||
If however, you delete the document's copy, that copy is permanently deleted. It can't be recovered from the [trash](../exploration-and-organization/delete-and-restore.md).
|
||||
|
||||
### Charts generated by Metabot only exist in the document
|
||||
|
||||
If Metabot generates a chart, Metabase saves that question to the document itself. If you delete it, it's gone forever. You won't be able to recover the question from the trash.
|
||||
If [Metabot](../ai/metabot.md) generates a chart, Metabase saves that question to the document itself. If you delete it, it's gone forever. You won't be able to recover the question from the trash.
|
||||
|
||||
### Editing charts
|
||||
## Editing charts
|
||||
|
||||
To edit a chart, click the **three-dot** menu in the chart's upper right. You can:
|
||||
|
||||
@@ -50,6 +54,22 @@ To edit a chart, click the **three-dot** menu in the chart's upper right. You ca
|
||||
|
||||
Edits only affect the chart in the document. If you added the chart from a collection, Metabase will have created a copy of the chart. Any changes made to the chart in the document won't affect the original question.
|
||||
|
||||
## Arranging charts
|
||||
|
||||

|
||||
|
||||
To rearrange charts, simply click and hold on the chart and drag it to where you want it in the document.
|
||||
|
||||
You can put up to three charts side by side (more than three charts side-by-side gets crowded). To resize charts, you can click on the edges to adjust their size.
|
||||
|
||||
When there are multiple charts in the same row, you can resize them horizontally by clicking between the charts and sliding left or right to resize.
|
||||
|
||||
To resize a chart's height, click the bottom of the chart and resize the chart up or down.
|
||||
|
||||
For now, you can only put charts side-by-side (not text elements).
|
||||
|
||||
After arranging your charts, save your changes!
|
||||
|
||||
## Formatting text
|
||||
|
||||
Documents support Markdown syntax for:
|
||||
@@ -67,16 +87,27 @@ If you paste a link into a document, Metabase will turn it into a clickable link
|
||||
|
||||
## Commenting on documents
|
||||
|
||||
To comment on a document, click the chat bubble next to the section you want to comment on.
|
||||
To comment on a text element, click the chat bubble next to the section. You can only comment on whole sections; you can't highlight text to comment on.
|
||||
|
||||
You can comment on whole sections like charts, headings, or text blocks. You can't highlight portions of text to comment on.
|
||||
To comment on a chart:
|
||||
|
||||
1. Hover over the chart.
|
||||
2. Click the three-dot menu.
|
||||
3. Select **Comment**.
|
||||
|
||||
You can:
|
||||
|
||||
- React to comments with emojis (which are like pictures masquerading as words). For example, this is a gondola: 🚠.
|
||||
- Mention other items or people in your Metabase (type `@` and then search for who/what you want to mention).
|
||||
- Link to a comment. Click the **three-dot** menu and select **Copy link**.
|
||||
- Resolve comments. Resolved comments appear in a separate tab.
|
||||
|
||||
### Comment notifications
|
||||
|
||||
If someone mentions you in a thread, or responds to a comment in a thread you're in, Metabase will send you an email to let you know.
|
||||
|
||||
Currently, there's no central place to view all of your threads and mentions, and no way to disable email notifications for comments.
|
||||
|
||||
### Deleting comments
|
||||
|
||||
If you never want to see a comment again:
|
||||
@@ -86,7 +117,7 @@ If you never want to see a comment again:
|
||||
3. Click on the **three-dot** menu.
|
||||
4. Select **Delete**.
|
||||
|
||||
This deletion is permanent. You'll never see that comment again.
|
||||
This deletion is permanent.
|
||||
|
||||
## Printing documents
|
||||
|
||||
@@ -101,7 +132,6 @@ Documents and dashboards both have their use cases.
|
||||
Documents work best for:
|
||||
|
||||
- Telling a story with data
|
||||
- Point-in-time analysis
|
||||
- Opening analysis for comments
|
||||
- Exploratory analysis
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ summary: Getting started with Embedded Analytics JS for embedding Metabase entit
|
||||
|
||||
Embedded analytics JS lets you embed Metabase entities like questions, dashboards, or even the query builder into your own application using customizable components.
|
||||
|
||||
{% include shared/in-page-promo-embedding-workshop.html %}
|
||||
|
||||
Embedded Analytics JS is a JavaScript library built on top of Metabase's [Embedded Analytics React SDK](./sdk/introduction.md). But it does not require using React or setting up full SDK embedding.
|
||||
Unlike with [interactive embedding](./interactive-embedding.md), where you embed the entire Metabase app in an iframe, Embedded Analytics JS lets you choose from a set of predefined components like a single chart, a dashboard with optional drill-through, or query builder, and customize those components.
|
||||
|
||||
@@ -23,20 +25,25 @@ Currently you can choose to embed:
|
||||
|
||||
## Quickstart
|
||||
|
||||
You can also follow the setup guide directly in Metabase in **Admin > Embedding > Setup guide**. We're recording the steps here for convenience.
|
||||
|
||||
### 1. Enable Embedded Analytics JS
|
||||
|
||||
1. In Metabase, go to **Admin Settings > Embedding > Modular embedding**.
|
||||
1. In Metabase, go to **Admin > Embedding > Modular embedding**.
|
||||
2. Toggle on **Embedded Analytics JS**.
|
||||
3. Under **Cross-Origin Resource Sharing (CORS)**, add the URLs of the websites where you want to embed Metabase (such as `https://*.example.com`). For testing embeds, you can use `localhost` which is always included in CORS policy.
|
||||
|
||||
### 2. Create a new embed
|
||||
|
||||
1. In Metabase, go to **Admin Settings > Embedding > Quick start** and select **Create embed**. Note that this will only be visible to admins.
|
||||
1. In Metabase, go to **Admin > Embedding > Setup guide > Embed in your code**, and select **Try it out** next to **Embedded analytics JS**.
|
||||
|
||||
If you're planning to embed an existing question or dashboard, you can instead go straight to that question or dashboard, click on the **Share** button, and choose **Embedded Analytics JS**.
|
||||
|
||||
2. Choose the _type_ of entity to embed:
|
||||
- Dashboard
|
||||
- Question
|
||||
- Exploration (which will embed the Metabase query builder)
|
||||
- Browser
|
||||
- Dashboard
|
||||
- Question
|
||||
- Exploration (which will embed the Metabase query builder)
|
||||
- Browser
|
||||
3. Next, select the entity you want to embed. For browser, pick the collection you want people to start from.
|
||||
|
||||
Once you've selected what you want to embed, click Next to customize your embed.
|
||||
@@ -109,13 +116,13 @@ Note the `defer` attribute and the reference to your Metabase URL in the script
|
||||
|
||||
If you're embedding multiple entities on the same page, you only need to include the `<script>` tags once globally.
|
||||
|
||||
You can also generate the code snippet for Embedded Analytics JS interactively in Metabase through **Admin Settings > Embedding > Setup guide > Create embed**. Check out the [Quickstart](#quickstart).
|
||||
You can also generate the code snippet for Embedded Analytics JS interactively in Metabase through **Admin > Embedding > Setup guide > Embed in your code**. Check out the [quickstart](#quickstart).
|
||||
|
||||
## Customizing embeds
|
||||
|
||||
The exact customization options you see will depend on what type of entity you're embedding.
|
||||
|
||||
When you're creating a new embed using **Admin Settings > Embedding > Setup guide > Create embed**, you'll see the following customization options in the interactive creation flow. These options correspond to parameters in [components](#components).
|
||||
When you're creating a new embed using **Admin > Embedding > Setup guide > Embed in your code**, you'll see the following customization options in the interactive creation flow. These options correspond to parameters in [components](#components).
|
||||
|
||||
- **Allow people to drill through on data points**: determines whether people can interact with the chart (or charts on a dashboard). Interactivity includes [drilling down](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) to individual records from aggregated questions, filtering on click, zooming in, etc. Disabling drill-through for an embedded _question_ also disables people's ability to add filters and summaries.
|
||||
|
||||
@@ -141,6 +148,8 @@ To define the configuration that applies to every embed on the page, use the `de
|
||||
|
||||
- `apiKey: mb_YourAPIKey` (optional, for development only) - another way to preview embeds locally using an API key.
|
||||
|
||||
- `fetchRequestToken: () => Promise<{ jwt: string }>` (optional) - you can customize how the SDK fetches the refresh token for JWT authentication by specifying the `fetchRequestToken` function. See [customizing JWT authentication](./sdk/authentication.md#customizing-jwt-authentication).
|
||||
|
||||
### Theming
|
||||
|
||||
You can specify colors, fonts, spacing, and other appearance options using the `theme` parameter in your embed configuration.
|
||||
@@ -360,7 +369,7 @@ To render a question (chart).
|
||||
|
||||
To render a collection browser so people can navigate a collection and open dashboards or questions.
|
||||
|
||||
```html
|
||||
```html
|
||||
<metabase-browser initial-collection="14" read-only="false"></metabase-browser>
|
||||
```
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 207 KiB |
@@ -4,6 +4,8 @@ title: "Interactive embedding quickstart"
|
||||
|
||||
# Interactive embedding quickstart
|
||||
|
||||
> If you are just starting out with Metabase embedding, consider using [Embedded Analytics JS](./embedded-analytics-js.md) - an improved, more customizable option for embedding interactive Metabase elements. Interactive embedding remains fully supported.
|
||||
|
||||
You'll embed the full Metabase application in your app. Once logged in, people can view a Metabase dashboard in your web app, and be able to use the full Metabase application to explore their data, and only their data.
|
||||
|
||||
{% include shared/in-page-promo-embedding-workshop.html %}
|
||||
@@ -27,9 +29,9 @@ You could also use the dashboard's [Entity ID](../installation-and-operation/ser
|
||||
|
||||
### Enable interactive embedding
|
||||
|
||||
In Metabase, click on the **gear** icon in the upper right and go to **Admin settings** > **Settings** > **Embedding**. Look for **Interactive Embedding** and click on the **Enabled** toggle.
|
||||
In Metabase, click on the **gear** icon in the upper right and go to **Admin > Embedding > Interactive Embedding** and toggle on **Enable interactive embedding**.
|
||||
|
||||
Click on the **Configure** button under **Interactive Embedding**. Under **Authorized origins**, add the URL of the website or web app where you want to embed Metabase. If you're running your app locally, you can add localhost and specify the port number, e.g. `http://localhost:8080`.
|
||||
Under **Authorized origins**, add the URL of the website or web app where you want to embed Metabase. If you're running your app locally, you can add localhost and specify the port number, e.g. `http://localhost:8080`.
|
||||
|
||||
#### SameSite configuration
|
||||
|
||||
@@ -39,7 +41,7 @@ If you're embedding Metabase in a different domain, you may need to [set the ses
|
||||
|
||||
#### Enable authentication with JWT
|
||||
|
||||
While still in the Admin panel's **Settings** section, click on **Authentication**.
|
||||
While still in the **Interactive embedding** section, click on **Authentication** under **Related settings**.
|
||||
|
||||
On the card that says **JWT**, click the **Setup** button (you may have to scroll down to view the JWT card).
|
||||
|
||||
@@ -167,7 +169,7 @@ In Metabase, click the **gear** icon and go to **Admin settings** > **People** >
|
||||
|
||||
You'll map this string in the `groups` key to a Metabase group, so that when the person signs in via SSO, Metabase automatically assigns them to the appropriate Metabase group.
|
||||
|
||||
In Metabase's admin section, go to **Settings** > **Authentication**. Scroll to the **JWT** card and click **Edit**.
|
||||
In Metabase's admin section, go to **Authentication > JWT** and click **Edit**.
|
||||
|
||||
In the **Group schema** section, toggle on **Synchronize group memberships**. If the names of groups in the `groups` array match Metabase group names exactly (e.g. both are `"Customer Acme"`), then the groups will be mapped automatically.
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ redirect_from:
|
||||
|
||||
{% include shared/in-page-promo-embedding-workshop.html %}
|
||||
|
||||
**Interactive embedding** is what you want if you want to offer [multi-tenant, self-service analytics](https://www.metabase.com/learn/metabase-basics/embedding/multi-tenant-self-service-analytics).
|
||||
**Interactive embedding** lets you embed the entire Metabase app in an iframe. Interactive embedding integrates your [permissions](../permissions/introduction.md) and [SSO](../people-and-groups/start.md#authentication) to give people the right level of access to [query](../questions/query-builder/editor.md) and [drill-down](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) into your data.
|
||||
|
||||
Interactive embedding is the only type of embedding that integrates with your [permissions](../permissions/introduction.md) and [SSO](../people-and-groups/start.md#authentication) to give people the right level of access to [query](https://www.metabase.com/glossary/query-builder) and [drill-down](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) into your data.
|
||||
> If you are just starting out with Metabase embedding, consider using [Embedded Analytics JS](./embedded-analytics-js.md) instead of interactive embedding - it's an improved, more customizable option for embedding interactive Metabase elements. Interactive embedding remains fully supported.
|
||||
|
||||
## Interactive embedding demo
|
||||
|
||||
@@ -38,10 +38,9 @@ If you have your app running locally, and you're using the Pro Cloud version, or
|
||||
|
||||
## Enabling interactive embedding in Metabase
|
||||
|
||||
1. Go to **Settings** > **Admin settings** > **Embedding**.
|
||||
2. Click **Enable**.
|
||||
3. Click **Interactive embedding**.
|
||||
4. Under **Authorized origins**, add the URL of the website or web app where you want to embed Metabase (such as `https://*.example.com`).
|
||||
1. Go to **Admin > Embedding > Interactive**.
|
||||
2. Click **Enable interactive embedding**.
|
||||
3. Under **Authorized origins**, add the URL of the website or web app where you want to embed Metabase (such as `https://*.example.com`).
|
||||
|
||||
## Setting up embedding on your website
|
||||
|
||||
@@ -129,7 +128,7 @@ Note that your interactive embed must be compatible with Safari to run on _any_
|
||||
|
||||
If you want to embed Metabase in another domain (say, if Metabase is hosted at `metabase.yourcompany.com`, but you want to embed Metabase at `yourcompany.github.io`), you can tell Metabase to set the session cookie's SameSite value to "none".
|
||||
|
||||
You can set session cookie's SameSite value in **Admin settings** > **Embedding** > **Interactive embedding** > **SameSite cookie setting**.
|
||||
You can set session cookie's SameSite value in **Admin settings** > **Embedding** > **Interactive** > **SameSite cookie setting**.
|
||||
|
||||
SameSite values include:
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ description: Customize the UI components in your interactive Metabase embed by a
|
||||
|
||||
To change the interface of your interactive embed, you can add parameters to the end of your embedding URL. If you want to change the colors or fonts in your embed, see [Customizing appearance](../configuring-metabase/appearance.md).
|
||||
|
||||
> If you are just starting out with Metabase embedding, consider using [Embedded Analytics JS](./embedded-analytics-js.md) instead of interactive embedding - it's an improved, more customizable option for embedding interactive Metabase elements. Interactive embedding remains fully supported.
|
||||
|
||||
For example, you can disable Metabase's [top nav bar](#top_nav) and [side nav menu](#side_nav) like this:
|
||||
|
||||
```
|
||||
|
||||
@@ -12,23 +12,11 @@ Here are the different ways you can embed Metabase.
|
||||
|
||||
{% include shared/in-page-promo-embedding-workshop.html %}
|
||||
|
||||
## Embedded analytics SDK with React
|
||||
|
||||
With the [Embedded analytics SDK](./sdk/introduction.md), you can embed individual Metabase components with React (like standalone charts, dashboards, the query builder, and more). You can manage access and interactivity per component, and you have advanced customization for seamless styling.
|
||||
|
||||
**When to use the Embedded analytics SDK**: you want the most control over how you embed Metabase in your React app.
|
||||
|
||||
## Embedded analytics JS
|
||||
|
||||
With [Embedded analytics JS](./embedded-analytics-js.md), you can embed individual Metabase components in your web app with JavaScript — no React required. Choose from dashboards, questions, or the query builder, and configure per‑component options like drill‑through, parameters, downloads, and theming.
|
||||
With [Embedded analytics JS](./embedded-analytics-js.md), you can embed individual Metabase components in your web app with JavaScript — no React required. Choose from dashboards, questions, or the query builder, and configure per‑component options like drill‑through, parameters, downloads, and theming. Embedded Analytics JS integrates with [SSO](securing-embeds.md) and [data permissions](../permissions/embedding.md).
|
||||
|
||||
**When to use Embedded analytics JS**: you’re not using React (or want a drop‑in script) and want to embed Metabase components with per‑component controls and theming.
|
||||
|
||||
## Interactive embedding
|
||||
|
||||
Interactive embedding is the only kind of embedding that [integrates with SSO and data permissions](./interactive-embedding.md) to enable true self-service access to the underlying data.
|
||||
|
||||
**When to use interactive embedding**: you want to [offer multi-tenant, self-service analytics](https://www.metabase.com/blog/why-full-app-embedding). With interactive embedding, people can create their own questions, dashboards, models, and more, with row and column security policies determining which data they can access.
|
||||
**When to use Embedded analytics JS**: You want to [offer multi-tenant, self-service analytics](https://www.metabase.com/blog/why-full-app-embedding), you’re not using React (or want a drop‑in script) and want to embed Metabase components with per‑component controls and theming.
|
||||
|
||||
## Static embedding
|
||||
|
||||
@@ -42,31 +30,40 @@ If you'd like to share your data with the good people of the internet, admins ca
|
||||
|
||||
**When to use public links and embeds**: public links and embeds are good for one-off charts and dashboards. Admins can use them when you just need to show someone a chart or dashboard without giving people access to your Metabase. And you don't care who sees the data; you want to make those stats available to everyone.
|
||||
|
||||
## Interactive embedding
|
||||
|
||||
[Interactive embedding](./interactive-embedding.md) allows you to embed the entire Metabase app in an iframe, and integrate Metabase SSO with your app's authentication.
|
||||
|
||||
## Comparison of embedding types
|
||||
|
||||
| Action | [SDK](./sdk/introduction.md) | [JS](./embedded-analytics-js.md) | [Interactive](./interactive-embedding.md) | [Static](./static-embedding.md) | [Public](../embedding/public-links.md) |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -------------------------------- | ----------------------------------------- | ------------------------------- | -------------------------------------- |
|
||||
| Display charts and dashboards | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Display interactive [filter widgets](https://www.metabase.com/glossary/filter-widget) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Export results\* | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Restrict data with [locked filters](./static-embedding-parameters.md#restricting-data-in-a-static-embed-with-locked-parameters) | ❌ | ❌ | ❌ | ✅ | ❌ |
|
||||
| Restrict data with [row and column security](../permissions/row-and-column-security.md) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Use the [drill-through menu](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Self-serve via [query builder](https://www.metabase.com/glossary/query-builder) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| View usage of embeds with [usage analytics](../usage-and-performance-tools/usage-analytics.md) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| [Actions on dashboards](../dashboards/actions.md) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Embed individual Metabase components | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Manage access and interactivity per component | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Action | [React SDK](./sdk/introduction.md) | [JS](./embedded-analytics-js.md) | [Interactive](./interactive-embedding.md) | [Static](./static-embedding.md) | [Public](../embedding/public-links.md) |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | -------------------------------- | ----------------------------------------- | ------------------------------- | -------------------------------------- |
|
||||
| Display charts and dashboards | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Display interactive [filter widgets](https://www.metabase.com/glossary/filter-widget) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Export results\* | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Restrict data with [locked filters](./static-embedding-parameters.md#restricting-data-in-a-static-embed-with-locked-parameters) | ❌ | ❌ | ❌ | ✅ | ❌ |
|
||||
| [Data segregation](../permissions/embedding.md) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Use the [drill-through menu](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Self-serve via [query builder](../questions/query-builder/editor.md) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| [Basic appearance customization](../configuring-metabase/appearance.md)\*\* | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| [Advanced theming](./sdk/appearance.md) | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| View usage of embeds with [usage analytics](../usage-and-performance-tools/usage-analytics.md) | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Embed individual Metabase components | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Manage access and interactivity per component | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Custom layouts | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||
| Customize behavior with [plugins](./sdk/plugins.md) | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||
|
||||
\* Each embedding type allows data downloads by default, but only [Pro and Enterprise](https://www.metabase.com/pricing/) plans can disable data downloads.
|
||||
|
||||
\*\* Requires a [Pro and Enterprise](https://www.metabase.com/pricing/) plan for any embedding type.
|
||||
|
||||
### Embedded analytics SDK vs JS
|
||||
|
||||
When deciding between the Embedded analytics SDK and Embedded analytics JS: if your app uses React, you should use the SDK. Otherwise, use the JS library. The JS library uses the SDK under the hood, but you can have more control with React and the SDK.
|
||||
|
||||
## Switching from static to interactive embedding
|
||||
## Switching from static embedding to Embedded Analytics JS
|
||||
|
||||
[Interactive embedding](./interactive-embedding.md) requires authentication via single sign-on (SSO), so you'll need to set that up both in your Metabase and in your application's server. Check out our [Interactive embedding quick start](../embedding/interactive-embedding-quick-start-guide.md).
|
||||
[Embedded Analytics JS](./embedded-analytics-js.md) requires authentication via single sign-on (SSO), so you'll need to set that up both in your Metabase and in your application's server. Check out our [Modular embedding authentication](../embedding/sdk/authentication.md).
|
||||
|
||||
## Further reading
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ You can simulate drill-through on a public dashboard by setting up a [custom cli
|
||||
6. Optional: pass a filter value from the primary dashboard to the destination dashboard by adding a query parameter to the end of the destination URL:
|
||||
|
||||
```
|
||||
{%raw%}
|
||||
{% raw %}
|
||||
/public/dashboard/?child_filter_name={{parent_column_name}}
|
||||
{%endraw%}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
For example, if you have a primary public dashboard that displays **Invoices** data, you can pass the **Plan** name (on click) to a destination public dashboard that displays **Accounts** data:
|
||||
|
||||
@@ -24,9 +24,11 @@ You can check out a [demo of the AI chat component](https://embedded-analytics-s
|
||||
```typescript
|
||||
{% include_file "{{ dirname }}/snippets/questions/ai-question.tsx" %}
|
||||
```
|
||||
|
||||
## API reference
|
||||
|
||||
- [Component](./api/MetabotQuestion.html)
|
||||
- [Props](./api/MetabotQuestionProps.html)
|
||||
|
||||
## Setting up AI chat
|
||||
|
||||
@@ -40,3 +42,11 @@ To configure your embedded AI chat in your Metabase:
|
||||
When embedding the Metabot component in your app, you should specify a collection that embedded Metabot is allowed to use for creating queries. Embedded Metabot will only have access to that collection.
|
||||
|
||||
For tips and more, see [Metabot settings](../../ai/settings.md).
|
||||
|
||||
## Layout
|
||||
|
||||
Use the `layout` prop to specify which layout to use for the Metabot component:
|
||||
|
||||
- `auto` (default): Metabot uses the `stacked` layout on mobile screens, and a `sidebar` layout on larger screens.
|
||||
- `stacked`: the question visualization stacks on top of the chat interface.
|
||||
- `sidebar`: the question visualization appears to the left of the chat interface, which is on a sidebar on the right.
|
||||
|
||||
@@ -89,7 +89,7 @@ You can add some middleware in your backend to handle cross-domain requests.
|
||||
|
||||
## Customizing JWT authentication
|
||||
|
||||
You can customize how the SDK fetches the refresh token by specifying the `fetchRefreshToken` function with the `defineMetabaseAuthConfig` function:
|
||||
You can customize how the SDK fetches the request token by specifying the `fetchRequestToken` function with the `defineMetabaseAuthConfig` function:
|
||||
|
||||
```typescript
|
||||
{% include_file "{{ dirname }}/snippets/authentication/auth-config-jwt.tsx" snippet="example" %}
|
||||
|
||||
@@ -36,7 +36,9 @@ To use the SDK, you'll need to enable the SDK in Metabase, and install the SDK i
|
||||
|
||||
### Enable the SDK in Metabase
|
||||
|
||||
Enable the Embedded analytics SDK by going to **Admin settings > Settings > Embedding**. Toggle on the SDK, and hit **Configure**. Enter the origins for your website or app where you want to allow SDK embedding, separated by a space. Localhost is automatically included.
|
||||
1. Enable the Embedded analytics SDK by going to **Admin settings > Embedding > Modular**.
|
||||
2. Toggle on **SDK for React**.
|
||||
3. In **Cross-Origin Resource Sharing (CORS)**, enter the origins for your website or app where you want to allow SDK embedding, separated by a space. Localhost is automatically included.
|
||||
|
||||
### Install the SDK in your React application
|
||||
|
||||
|
||||
@@ -98,11 +98,11 @@ To enable SSO with JWT when self-hosting, you'll need to [activate your license]
|
||||
|
||||
## Enable embedding in Metabase
|
||||
|
||||
From any Metabase page, click on the **gear** icon in the upper right and select **Admin Settings** > **Settings** > **Embedding**.
|
||||
From any Metabase page, click on the **gear** icon in the upper right and select **Admin Settings** > **Embedding**.
|
||||
|
||||
Turn on:
|
||||
|
||||
- Embedded analytics SDK
|
||||
- Embedded analytics SDK (it's in in the **Modular** section)
|
||||
- Static embedding
|
||||
|
||||
Otherwise, this whole thing is hopeless.
|
||||
|
||||
@@ -36,11 +36,11 @@ To embed a dashboard in your app using the SDK, you'll need to:
|
||||
|
||||
## 1. Enable the SDK in Metabase
|
||||
|
||||
In Metabase, click on the gear icon in the upper right and navigate to **Admin Settings > Settings > Embedding** and enable the Embedded analytics SDK.
|
||||
In Metabase, click on the gear icon in the upper right and navigate to **Admin Settings > Embedding > Modular** and enable the **SDK for React**.
|
||||
|
||||
## 2. Create an API key in Metabase
|
||||
|
||||
Still in the Admin's Settings tab, navigate to the **Authentication** section in the sidebar and click on the **API keys** tab. [Create a new API key](../../people-and-groups/api-keys.md).
|
||||
Still in the Admin console, go to **Settings > Authentication** and click on the **API keys** tab. [Create a new API key](../../people-and-groups/api-keys.md).
|
||||
|
||||
- Key name: "Embedded analytics SDK" (just to make the key easy to identify).
|
||||
- Group: select “Admin” (since this is only for local testing).
|
||||
|
||||
@@ -30,8 +30,7 @@ Metabase Cloud upgrades your instance automatically as new versions roll out. Bu
|
||||
|
||||
To manually pin your version of Metabase:
|
||||
|
||||
1. Go to **Admin settings > Settings > Embedding**.
|
||||
2. Go to the Embedded analytics SDK card.
|
||||
3. Scroll to **Version pinning** and click **Request version pinning**.
|
||||
1. Go to **Admin > Embedding > Modular**.
|
||||
2. Scroll to **Version pinning** and click **Request version pinning**.
|
||||
|
||||
This will open a mailto link to our support team.
|
||||
|
||||
@@ -10,25 +10,13 @@ redirect_from:
|
||||
|
||||
What is embedding, and how does it work?
|
||||
|
||||
## [Interactive embedding](./interactive-embedding.md)
|
||||
|
||||
The solution to self-service customer analytics: embed the full Metabase app in your app. Interactive embedding integrates with your data permissions to let people slice and dice data on their own using Metabase's query builder.
|
||||
|
||||
## [Interactive embedding quickstart](./interactive-embedding-quick-start-guide.md)
|
||||
|
||||
You'll embed the full Metabase application in your app. Once logged in, people can view a Metabase dashboard in your web app, and be able to use the full Metabase application to explore their data, and only their data.
|
||||
|
||||
## [Interactive UI components](./interactive-ui-components.md)
|
||||
|
||||
Customize the UI components in your interactive embed by adding parameters to the embedding URL.
|
||||
|
||||
## [Embedded analytics SDK](./sdk/introduction.md)
|
||||
|
||||
With the Embedded analytics SDK, you can embed individual Metabase components with React (like standalone charts, dashboards, the query builder, and more). You can manage access and interactivity per component, and you have advanced customization for seamless styling.
|
||||
|
||||
## [Embedded analytics JS](./embedded-analytics-js.md)
|
||||
|
||||
Embed dashboards, questions, or the query builder in your app with JavaScript (no React required). Built on the Embedded analytics SDK with per-component controls and theming.
|
||||
Embed dashboards, questions, or the query builder in your app with JavaScript (no React required). Built on the Embedded analytics SDK with per-component controls and theming. Integrate your app's auth with Metabase SSO.
|
||||
|
||||
## [Embedded analytics SDK quickstart](./sdk/quickstart.md)
|
||||
|
||||
@@ -42,6 +30,18 @@ Also known as Signed Embedding, Static embedding is a secure way to embed charts
|
||||
|
||||
You can pass parameters between Metabase and your website via the embedding URL to specify how Metabase items should look and behave inside the iframe on your website.
|
||||
|
||||
## [Interactive embedding](./interactive-embedding.md)
|
||||
|
||||
Interactive embedding allows you to embed full Metabase app in an iframe. Interactive embedding integrates with your data permissions to let people slice and dice data on their own using Metabase's query builder.
|
||||
|
||||
## [Interactive embedding quickstart](./interactive-embedding-quick-start-guide.md)
|
||||
|
||||
You'll embed the full Metabase application in your app. Once logged in, people can view a Metabase dashboard in your web app, and be able to use the full Metabase application to explore their data, and only their data.
|
||||
|
||||
## [Interactive UI components](./interactive-ui-components.md)
|
||||
|
||||
Customize the UI components in your interactive embed by adding parameters to the embedding URL.
|
||||
|
||||
## [Public embeds](./public-links.md)
|
||||
|
||||
Admins can also create unsecured public links or embeds of questions and dashboards.
|
||||
|
||||
@@ -12,7 +12,7 @@ Also known as: standalone embedding, or signed embedding.
|
||||
|
||||
In general, embedding works by displaying a Metabase URL inside an iframe in your website. A **static embed** (or signed embed) is an iframe that's loading a Metabase URL secured with a signed JSON Web Token (JWT). Metabase will only load the URL if the request supplies a JWT signed with the secret shared between your app and your Metabase. The JWT also includes a reference to the resource to load, e.g., the dashboard ID, and any values for locked parameters.
|
||||
|
||||
You can't use static embeds with [row and column security](../permissions/row-and-column-security.md), [drill-through](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through), and user-specific data isn't captured in [usage analytics](../usage-and-performance-tools/usage-analytics.md) because signed JWTs don't create user sessions (server-side sessions). For those features, check out [interactive embedding](./interactive-embedding.md).
|
||||
You can't use static embeds with [row and column security](../permissions/row-and-column-security.md), [drill-through](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through), and user-specific data isn't captured in [usage analytics](../usage-and-performance-tools/usage-analytics.md) because signed JWTs don't create user sessions (server-side sessions). For those features, check out [Embedded analytics JS](./embedded-analytics-js.md).
|
||||
|
||||
You can, however, restrict data in static embeds for specific people or groups by [locking parameters](./static-embedding-parameters.md#restricting-data-in-a-static-embed-with-locked-parameters).
|
||||
|
||||
@@ -34,12 +34,12 @@ your_metabase_embedding_url/your_signed_jwt?filter=true
|
||||
|
||||
The signed JWT is generated using your [Metabase secret key](#regenerating-the-static-embedding-secret-key). The secret key tells Metabase that the request for filtered data can be trusted, so it's safe to display the results at the new embedding URL. Note that this secret key is shared for all static embeds, so whoever has access to that key will have access to all embedded artifacts.
|
||||
|
||||
If you want to embed charts with additional interactive features, like [drill-down](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) and [self-service querying](../questions/query-builder/editor.md), see [Interactive embedding](./interactive-embedding.md).
|
||||
If you want to embed charts with additional interactive features, like [drill-down](https://www.metabase.com/learn/metabase-basics/querying-and-dashboards/questions/drill-through) and [self-service querying](../questions/query-builder/editor.md), see [Embedded analytics JS](./embedded-analytics-js.md).
|
||||
|
||||
## Turning on the embedding feature in Metabase
|
||||
|
||||
1. Go to **Settings** > **Admin settings** > **Embedding**.
|
||||
2. Toggle the **Enable embedding**.
|
||||
1. Go to **Settings** > **Admin settings** > **Embedding > Static**.
|
||||
2. Toggle **Enable static embedding**.
|
||||
|
||||
## Making a question or dashboard embeddable
|
||||
|
||||
@@ -127,7 +127,7 @@ If you change the [parameters](./static-embedding-parameters.md) of your embedde
|
||||
|
||||
## Disabling embedding for a question or dashboard
|
||||
|
||||
You can find a list of all static embeds of questions and dashboards from **Admin settings** > **Embedding** > **Static embedding** > **Manage**.
|
||||
You can find a list of all static embeds of questions and dashboards from **Admin settings** > **Embedding** > **Static**.
|
||||
|
||||
1. Visit the embeddable question or dashboard.
|
||||
2. Click on the **sharing icon** (square with an arrow pointing to the top right).
|
||||
@@ -164,9 +164,8 @@ The banner appears on static embeds created with Metabase's open-source version.
|
||||
|
||||
Your embedding secret key is used to sign JWTs for all of your [embedding URLs](#adding-the-embedding-url-to-your-website).
|
||||
|
||||
1. Go to **Settings** > **Admin settings** > **Embedding**.
|
||||
2. On the **Static embedding** card, click on **Manage**.
|
||||
3. Under **Regenerate secret key**, click **Regenerate key**.
|
||||
1. Go to **Admin** > **Embedding** > **Static embedding**.
|
||||
2. Under **Regenerate secret key**, click **Regenerate key**.
|
||||
|
||||
This key is shared across all static embeds. Whoever has access to this key could get access to all embedded artifacts, so keep this key secure. If you regenerate this key, you'll need to update your server code with the new key.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ summary: Upload a translation dictionary to translate questions and dashboards i
|
||||
|
||||
{% include plans-blockquote.html feature="Translation of embedded content" convert_pro_link_to_embbedding=true %}
|
||||
|
||||
For now, translations are only available for [static embeds](./static-embedding.md), not Interactive embedding or the Embedded analytics SDK.
|
||||
For now, translations are only available for [static embeds](./static-embedding.md), not Interactive embedding or the Embedded analytics JS/SDK.
|
||||
|
||||
You can upload a translation dictionary to translate strings both in Metabase content (like dashboard titles) and in the data itself (like column names and values).
|
||||
|
||||
@@ -21,6 +21,11 @@ The dictionary must be a CSV with these columns:
|
||||
|
||||
> Don't put any sensitive data in the dictionary, since anyone can see the dictionary—including viewers of public links.
|
||||
|
||||
To add a translation dictionary:
|
||||
|
||||
1. Go to **Admin > Embedding > Static**.
|
||||
2. Under **Translate embedded dashboards and question**, click **Upload translation dictionary**.
|
||||
|
||||
Uploading a new dictionary will replace the existing dictionary.
|
||||
|
||||
To remove a translation dictionary, upload a blank dictionary.
|
||||
@@ -64,9 +69,9 @@ Exact translations also apply to strings that use punctuation and special charac
|
||||
|
||||
Translations are case-insensitive. For example, if your translation dictionary has a translation:
|
||||
|
||||
| Language | String | Translation |
|
||||
| -------- | ----------- | ------------ |
|
||||
| pt-BR | Examples | Exemplos |
|
||||
| Language | String | Translation |
|
||||
| -------- | -------- | ----------- |
|
||||
| pt-BR | Examples | Exemplos |
|
||||
|
||||
`Examples`, `examples`, `EXAMPLES` would all be translated as `Exemplos`. That is, Metabase won't preserve the original case; it will output the exact translation string in the dictionary.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ You can use the command palette to:
|
||||
|
||||
So anytime you want to do or find anything in Metabase, just hit `cmd/ctrl + k` and start typing what you want to do.
|
||||
|
||||
> The command palette is currently unavailable in [interactive embedding](../embedding/interactive-embedding.md) contexts.
|
||||
> The command palette is currently unavailable in [Embedded analytics JS](../embedding/embedded-analytics-js.md) and [interactive embedding](../embedding/interactive-embedding.md) contexts.
|
||||
|
||||
## Advanced search
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ Metabase will only export the following entities:
|
||||
- Collections (but personal collections don't get exported unless explicitly specified them through [export options](#customize-what-gets-exported))
|
||||
- Dashboards
|
||||
- Saved questions
|
||||
- Transforms (including jobs)
|
||||
- Documents (without comments)
|
||||
- Actions
|
||||
- Models
|
||||
- Metrics
|
||||
@@ -61,7 +63,7 @@ Metabase will only export the following entities:
|
||||
- Events and timelines
|
||||
- Database connection strings (only if specified through [export options](#customize-what-gets-exported))
|
||||
|
||||
All other entities—including users, groups, permissions, alerts, subscriptions—won't get exported.
|
||||
All other entities—including users, groups, permissions, alerts, subscriptions, document comments—won't get exported.
|
||||
|
||||
Metabase will export its artifacts to a directory of YAML files. The export includes:
|
||||
|
||||
@@ -296,7 +298,7 @@ This ID refers to the collection where the question was saved. In a real export,
|
||||
|
||||
### Entity IDs work with embedding
|
||||
|
||||
Metabase supports working with [Entity IDs](#metabase-uses-entity-ids-to-identify-and-reference-metabase-items) for questions, dashboards, and collections in [Static Embedding](../embedding/static-embedding.md), [Interactive embedding](../embedding/interactive-embedding.md), and the [Embedded Analytics SDK](../embedding/sdk/introduction.md).
|
||||
Metabase supports working with [Entity IDs](#metabase-uses-entity-ids-to-identify-and-reference-metabase-items) for questions, dashboards, and collections in [Static Embedding](../embedding/static-embedding.md), [Embedded analytics JS](../embedding/embedded-analytics-js.md), [Interactive embedding](../embedding/interactive-embedding.md), and the [Embedded analytics SDK](../embedding/sdk/introduction.md).
|
||||
|
||||
A high-level workflow for using Entity IDs when embedding Metabase in your app would look something like:
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Account settings
|
||||
summary: Update your profile, change your password, view login history, manage notifications, and customize your Metabase experience.
|
||||
redirect_from:
|
||||
- /docs/latest/users-guide/account-settings
|
||||
---
|
||||
@@ -34,3 +35,5 @@ This isn't an in-Metabase setting, but just so you know: you can disable UI anim
|
||||
## Notifications
|
||||
|
||||
If you subscribe or are added to dashboard subscriptions or alerts, you’ll be able to manage those notifications here (as well as on the relevant question or dashboard themselves).
|
||||
|
||||
Metabase excludes notificatione for [comments](../documents/introduction.md#comment-notifications) from this page.
|
||||
|
||||
@@ -12,10 +12,14 @@ With database routing, an admin can build a question once using one database, an
|
||||
Database routing is useful for:
|
||||
|
||||
- Managing interactive embedding setups where each customer has their own database with identical schemas.
|
||||
|
||||
Database routing can't be used with static embedding, because database routing requires people who use the embedded questions and dashboards to have a Metabase account. Without a Metabase account, Metabase can't route the queries because it doesn't know who is viewing the embed.
|
||||
|
||||
- Switching between dev and prod data warehouses.
|
||||
- Changing the target data warehouse for certain teams.
|
||||
- Managing separate connections to the same data warehouse, with each connection having separate privileges. This connection management is akin to [connection impersonation](./impersonation.md) for databases that prevent the same connection from changing roles.
|
||||
|
||||
|
||||
## Database routing limitations
|
||||
|
||||
> Database routing is **not supported** on ClickHouse, Oracle, Spark SQL, and Vertica.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Row and column security
|
||||
summary: Control what data different groups can see by filtering rows and columns based on user attributes. Useful for multi-tenant analytics.
|
||||
redirect_from:
|
||||
- /docs/latest/enterprise-guide/data-sandboxes
|
||||
- /docs/latest/permissions/data-sandboxes
|
||||
@@ -46,10 +47,10 @@ Row and column security show specific data to each person based on their [user a
|
||||
|
||||
You can **restrict rows** by filtering a column using a [user attribute value](#choosing-user-attributes-for-row-and-column-security).
|
||||
|
||||
For example, you can filter the Accounts table for a group so that:
|
||||
For example, you can filter the Accounts table for a group so that the user attribute filters the table:
|
||||
|
||||
- A person with the user attribute value "Basic" will see rows where `Plan = "Basic"` (rows where the Plan column matches the value "Basic").
|
||||
- A person with the user attribute value "Premium" will see the rows where `Plan = "Premium"` (rows where the Plan column matches the value "Premium").
|
||||
- "Basic" will see rows where `Plan = "Basic"` (rows where the Plan column matches the value "Basic").
|
||||
- "Premium" will see the rows where `Plan = "Premium"` (rows where the Plan column matches the value "Premium").
|
||||
|
||||
### Custom row and column security: use a SQL question to create a custom "view" of a table
|
||||
|
||||
@@ -57,7 +58,7 @@ To **restrict rows _and_ columns**, you can use a SQL question to filter the tab
|
||||
|
||||
For example, say your original Accounts table includes the columns: `ID`, `Email`, `Plan`, and `Created At`. If you want to hide the Email column, you can create a "Restricted Accounts" SQL question with the columns: `ID`, `Plan`, and `Created At`.
|
||||
|
||||
You can use a question to filter tables to:
|
||||
You can use a question to:
|
||||
|
||||
- [Display an edited column instead of hiding the column](#displaying-edited-columns).
|
||||
- [Pass a user attribute to a SQL parameter](#restricting-rows-with-user-attributes-using-a-sql-variable).
|
||||
@@ -69,10 +70,10 @@ You can use a question to filter tables to:
|
||||
|
||||
Row security displays a filtered table, in place of an original table, to a specific group. How Metabase filters that table depends on the value in each person's user attribute.
|
||||
|
||||
For example, you can set up a row-level security so that:
|
||||
For example, you can set up a row-level security so that the user attribute `plan` shows different rows for different values:
|
||||
|
||||
- Someone with the user attribute with key of "plan" and a value of "Basic" will see a version of the Accounts table with a filter for `Plan = "Basic"` (that is, only the rows where the Plan column matches the value "Basic").
|
||||
- Someone with a "plan" user attribute set to "Premium" will see a different version of the Accounts table with the filter `Plan = "Premium"` applied.
|
||||
- "Basic" will see a version of the Accounts table with a filter for `Plan = "Basic"` (that is, only the rows where the Plan column matches the value "Basic").
|
||||
- "Premium" will see a different version of the Accounts table with the filter `Plan = "Premium"` applied.
|
||||
|
||||
## Choosing user attributes for row and column security
|
||||
|
||||
@@ -179,7 +180,7 @@ In steps 9-10 of the [row restriction setup](#restricting-rows-with-user-attribu
|
||||
WHERE plan = "Basic"
|
||||
```
|
||||
|
||||
Note that the parameters must be required for SQL questions used to create a custom views. E.g., you cannot use an optional parameter; the following won't work:
|
||||
Note that the parameters must be required for SQL questions used to create custom views. For example, you can't use an optional parameter; the following won't work:
|
||||
|
||||
```sql
|
||||
{%raw%}
|
||||
@@ -189,6 +190,42 @@ Note that the parameters must be required for SQL questions used to create a cus
|
||||
|
||||
Learn more about [SQL parameters](../questions/native-editor/sql-parameters.md)
|
||||
|
||||
### Advanced row-level security: filtering tables for people that have multiple IDs
|
||||
|
||||
For example, say have a table like this:
|
||||
|
||||
| User_ID | Value |
|
||||
|---------|-------|
|
||||
| 1 | 10 |
|
||||
| 1 | 50 |
|
||||
| 2 | 5 |
|
||||
| 2 | 50 |
|
||||
| 3 | 5 |
|
||||
| 3 | 5 |
|
||||
|
||||
If you want to give someone access to multiple user IDs (e.g., the person should see rows for both `User_ID` 1 and 2.), you can set up a user attribute, like `user_id` that can handle comma-separated values like "1,2".
|
||||
|
||||
1. Create a SQL question that parses the comma-separated string and filters the table:
|
||||
|
||||
```sql
|
||||
{%raw%}
|
||||
SELECT *
|
||||
FROM users_with_values
|
||||
WHERE user_id = ANY(STRING_TO_ARRAY(REGEXP_REPLACE(TRIM({{user_id}}), '\\s*,\\s*', ','), ','))
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
This query:
|
||||
|
||||
- Trims whitespace from the user attribute value
|
||||
- Replaces any spaces around commas with just commas
|
||||
- Converts the comma-separated string to an array
|
||||
- Filters rows where the user_id matches any value in the array
|
||||
|
||||
The `STRING_TO_ARRAY()` and `REGEXP_REPLACE()` functions are PostgreSQL-specific. To see which functions your database supports, see your database's documentation.
|
||||
|
||||
3. Set up the row and column security using this SQL question. See [setting up column security](#setting-up-column-security).
|
||||
|
||||
## Preventing row and column security permissions conflicts
|
||||
|
||||
Some Metabase permissions can conflict with row and column security to give more permissive or more restrictive data access than you intended.
|
||||
@@ -199,7 +236,7 @@ The Email column may get exposed to someone if:
|
||||
|
||||
- The person belongs to [multiple row and column security policies](#multiple-row-and-column-security-permissions).
|
||||
- Someone else in a non-secured group shares the Email column from:
|
||||
- A [SQL question](../questions/native-editor/writing-sql.md).
|
||||
- A [SQL question](../questions/native-editor/writing-sql.md)
|
||||
- A [public link](#public-sharing)
|
||||
- An [alert, or dashboard subscription](../permissions/notifications.md)
|
||||
|
||||
@@ -243,12 +280,13 @@ To prevent this from happening, you'll have to [disable public sharing](../embed
|
||||
|
||||
Metabase can only create row and column security using the group membership or user attributes of people who are logged in. Since public links don't require logins, Metabase won't have enough info to apply permissions.
|
||||
|
||||
## Limitations
|
||||
## Limitations of row and column security
|
||||
|
||||
Row and column security is limited to questions built with the [query builder](../questions/query-builder/editor.md).
|
||||
Some things to keep in mind when using row and column security.
|
||||
|
||||
### Groups with native query permissions (access to the SQL editor) can bypass row and column security
|
||||
|
||||
Row and column security is limited to the [query builder](../questions/query-builder/editor.md).
|
||||
You can't set up [native query persmissons](./data.md#create-queries-permissions) for groups with row and column security.
|
||||
|
||||
To enforce row-level permissions with the native query editor, check out [impersonation](./impersonation.md).
|
||||
@@ -263,6 +301,22 @@ Since Metabase can't parse SQL queries, the results of SQL questions will always
|
||||
|
||||
MongoDB only supports [row-level security](#row-level-security-filter-by-a-column-in-the-table). Row and column security permissions are unavailable for Apache Druid.
|
||||
|
||||
### Advanced data types require a workaround
|
||||
|
||||
If you're trying to set up row security on a column with an advanced data type (like enums or arrays), you'll need to convert that data to a basic type first. Options include:
|
||||
|
||||
#### Option 1: Use SQL to cast the advanced data type to a basic SQL type
|
||||
|
||||
Create a SQL question that casts the advanced data type column to a basic data type, then use that question for your row and column security setup.
|
||||
|
||||
#### Option 2: Create a database view
|
||||
|
||||
If you can't use SQL casting in Metabase, create a view in your database that converts the advanced data type to a basic type, then set up row and column security on that view instead of the original table. You'll also need to block the original table.
|
||||
|
||||
#### Option 3: Use transforms
|
||||
|
||||
Use a [transform](../data-modeling/transforms.md) to create a table that casts the advanced data type to a basic type. Then set up row and column security on the transformed table instead. You'll also need to block the original table.
|
||||
|
||||
## Further reading
|
||||
|
||||
- [Row and column security examples](./row-and-column-security-examples.md)
|
||||
|
||||
BIN
docs/questions/images/pin-type.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
@@ -21,7 +21,7 @@ When you select the **Map** visualization setting, Metabase will automatically t
|
||||
|
||||
## Pin map
|
||||
|
||||
Pin maps display pins for individual data points on the map. They work best for displaying unaggregated geographical data.
|
||||
Pin maps display markers or tiles for individual data points on the map. They work best for displaying small amounts of unaggregated geographical data.
|
||||
|
||||
### Pin map data shape
|
||||
|
||||
@@ -30,7 +30,7 @@ To build a pin map, you need a query that returns a result that has latitude and
|
||||

|
||||

|
||||
|
||||
Note that the tooltips will only be displayed when the map is sufficiently zoomed in using [**Draw box to filter**](#draw-box-to-filter).
|
||||
Note that the tooltips will only be displayed when using the [marker pin type](#choose-pin-type).
|
||||
|
||||
### Create a pin map
|
||||
|
||||
@@ -42,9 +42,22 @@ To create a pin map:
|
||||
|
||||
Otherwise, click on the **Gear** icon to go to visualization settings, choose **Map type: Pin map**, and pick columns that contain latitude and longitude coordinates.
|
||||
|
||||
### Pin maps display 2000 pins by default
|
||||
### Choose pin type
|
||||
|
||||
By default, pin maps will display 2000 pins even if there are more rows in your query results (this limit is the same for every chart displaying unaggregated data in Metabase). You can use the environment variable [`MB_UNAGGREGATED_QUERY_ROW_LIMIT`](../../configuring-metabase/environment-variables.md#mb_unaggregated_query_row_limit) to increase the number of data points rendered on charts based on unaggregated queries, but keep in mind that this setting will affect all charts—not just the pin maps—and it might significantly slow down your Metabase and your browser.
|
||||
Metabase can display individual data points on a map as markers or tiles (small squares).
|
||||
|
||||

|
||||
|
||||
Maps default to markers for results fewer then 1,000 rows, and to tiles for results with 1,000 rows or more.
|
||||
|
||||
To change the pin type:
|
||||
|
||||
1. While viewing the map, click the **gear** icon in the bottom left.
|
||||
2. In the visualization settings, choose the pin type in the **Pin type** dropdown.
|
||||
- **Markers**. Maps display up to 1,000 markers. If you choose the marker pin type for results with more than 1,000 rows, Metabase will still only display 1,000 markers. Maps default to markers for results fewer then 1,000 rows.
|
||||
- **Tiles**. Maps display up to 2,000 tiles. Maps default to tiles for results greater than 1,000 rows. Tooltips will not be displayed for tiles.
|
||||
|
||||
By default, maps can't display more than 2,000 individual unaggregated data points, regardless of the pin type. This limit is the same for every chart displaying unaggregated data in Metabase. To increase the number of data points rendered on charts based on unaggregated queries, you can use the environment variable [`MB_UNAGGREGATED_QUERY_ROW_LIMIT`](../../configuring-metabase/environment-variables.md#mb_unaggregated_query_row_limit). This setting will affect data points on _all_ charts—not just the pin maps—so increasing the limit too much could significantly slow down your Metabase and your browswer.
|
||||
|
||||
If you need to display a large number of geographical data points, consider using a grid map to display the distribution instead.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ To fix this problem you'll need answers to these questions:
|
||||
Once you have these answers, look for cases like these:
|
||||
|
||||
1. Your question or chart is comparing or sorting values with inconsistent or missing time zones. For example, if a flight's departure and arrival times are reported in local time, it can appear to arrive before it has left.
|
||||
2. Your question is aggregating timetsamps with different time zones: for example, the "daily" totals for your website's traffic include more than 24 hours worth of data because you are using the local dates from East Asia, Europe, and the Americas.
|
||||
2. Your question is aggregating timestamps with different time zones: for example, the "daily" totals for your website's traffic include more than 24 hours worth of data because you are using the local dates from East Asia, Europe, and the Americas.
|
||||
|
||||
Once you think you have identified a problem, drill down to understand exactly what time zone conversion is causing the underlying problem. For example, suppose you're looking at a time series with daily values; if your error is happening with weekly totals, you can:
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ if (!BASE_ENV.PREMIUM_EMBEDDING_TOKEN) {
|
||||
}
|
||||
|
||||
const BASE_SETUP_CONFIG = {
|
||||
"docker-up-command": "yarn docker:up",
|
||||
"docker-down-command": "yarn docker:down",
|
||||
"docker-up-command": "yarn docker:local-dist:up",
|
||||
"docker-down-command": "yarn docker:rm",
|
||||
"docker-env-example-path": ".env.docker.example",
|
||||
"docker-env-path": ".env.docker",
|
||||
defaultBranch: BRANCH_NAME,
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as path from "path";
|
||||
|
||||
import { E2E_TMP_FOLDER_PATH } from "../constants/e2e-tmp-folder-path";
|
||||
|
||||
const LOCAL_DIST_PATH = "./local-dist";
|
||||
const METABASE_FOLDER_PATH = "./metabase";
|
||||
|
||||
// See `docs/developers-guide/e2e-tests.md` for more info
|
||||
export function copyShoppyMetabaseAppDBDump(rootPath: string) {
|
||||
@@ -12,11 +12,11 @@ export function copyShoppyMetabaseAppDBDump(rootPath: string) {
|
||||
"db_dumps/shoppy_metabase_app_db_dump.sql",
|
||||
);
|
||||
|
||||
// The dump must be copied to the Shoppy's `local-dist` directory.
|
||||
// The dump must be copied to the Shoppy's `metabase` directory.
|
||||
// After that it will be used by the Shoppy's Docker container when it is built and started.
|
||||
const destinationPath = path.join(
|
||||
rootPath,
|
||||
LOCAL_DIST_PATH,
|
||||
METABASE_FOLDER_PATH,
|
||||
"metabase_dump.sql",
|
||||
);
|
||||
|
||||
|
||||
165
e2e/support/document-initial-data.ts
Normal file
@@ -0,0 +1,165 @@
|
||||
import {
|
||||
ORDERS_BY_YEAR_QUESTION_ID,
|
||||
ORDERS_COUNT_QUESTION_ID,
|
||||
ORDERS_QUESTION_ID,
|
||||
} from "e2e/support/cypress_sample_instance_data";
|
||||
|
||||
export const DOCUMENT_WITH_TWO_CARDS = {
|
||||
content: [
|
||||
{
|
||||
type: "paragraph",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Testing drag and drop functionality",
|
||||
},
|
||||
],
|
||||
attrs: {
|
||||
_id: "1",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "resizeNode",
|
||||
attrs: {
|
||||
height: 350,
|
||||
minHeight: 280,
|
||||
_id: "2",
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "cardEmbed",
|
||||
attrs: {
|
||||
id: ORDERS_QUESTION_ID,
|
||||
name: null,
|
||||
_id: "2a",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Some text between cards",
|
||||
},
|
||||
],
|
||||
attrs: {
|
||||
_id: "3",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "resizeNode",
|
||||
attrs: {
|
||||
height: 350,
|
||||
minHeight: 280,
|
||||
_id: "4",
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "cardEmbed",
|
||||
attrs: {
|
||||
id: ORDERS_COUNT_QUESTION_ID,
|
||||
name: null,
|
||||
_id: "4a",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
attrs: {
|
||||
_id: "5",
|
||||
},
|
||||
},
|
||||
],
|
||||
type: "doc",
|
||||
};
|
||||
|
||||
export const DOCUMENT_WITH_THREE_CARDS_AND_COLUMNS = {
|
||||
content: [
|
||||
{
|
||||
type: "paragraph",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Advanced drag and drop scenarios",
|
||||
},
|
||||
],
|
||||
attrs: {
|
||||
_id: "1",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "resizeNode",
|
||||
attrs: {
|
||||
height: 350,
|
||||
minHeight: 280,
|
||||
_id: "2",
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "flexContainer",
|
||||
attrs: {
|
||||
_id: "2a",
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "cardEmbed",
|
||||
attrs: {
|
||||
id: ORDERS_QUESTION_ID,
|
||||
name: null,
|
||||
_id: "2a1",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "cardEmbed",
|
||||
attrs: {
|
||||
id: ORDERS_COUNT_QUESTION_ID,
|
||||
name: null,
|
||||
_id: "2a2",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Standalone card below",
|
||||
},
|
||||
],
|
||||
attrs: {
|
||||
_id: "3",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "resizeNode",
|
||||
attrs: {
|
||||
height: 350,
|
||||
minHeight: 280,
|
||||
_id: "4",
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "cardEmbed",
|
||||
attrs: {
|
||||
id: ORDERS_BY_YEAR_QUESTION_ID,
|
||||
name: null,
|
||||
_id: "4a",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "paragraph",
|
||||
attrs: {
|
||||
_id: "5",
|
||||
},
|
||||
},
|
||||
],
|
||||
type: "doc",
|
||||
};
|
||||
@@ -38,4 +38,4 @@ export { getCurrentUser } from "./getCurrentUser";
|
||||
export { remapDisplayValueToFK } from "./remapDisplayValueToFK";
|
||||
export { updateComment } from "./updateComment";
|
||||
export { updateDashboardCards } from "./updateDashboardCards";
|
||||
export { updateSetting } from "./updateSetting";
|
||||
export { updateSetting, updateEnterpriseSetting } from "./updateSetting";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Settings } from "metabase-types/api";
|
||||
import type { EnterpriseSettings, Settings } from "metabase-types/api";
|
||||
|
||||
export const updateSetting = <
|
||||
TKey extends keyof Settings,
|
||||
@@ -9,3 +9,13 @@ export const updateSetting = <
|
||||
): Cypress.Chainable<Cypress.Response<never>> => {
|
||||
return cy.request<never>("PUT", `/api/setting/${setting}`, { value });
|
||||
};
|
||||
|
||||
export const updateEnterpriseSetting = <
|
||||
TKey extends keyof EnterpriseSettings,
|
||||
TValue extends EnterpriseSettings[TKey],
|
||||
>(
|
||||
setting: TKey,
|
||||
value: TValue,
|
||||
): Cypress.Chainable<Cypress.Response<never>> => {
|
||||
return cy.request<never>("PUT", `/api/setting/${setting}`, { value });
|
||||
};
|
||||
|
||||
223
e2e/support/helpers/e2e-codemirror-helpers.ts
Normal file
@@ -0,0 +1,223 @@
|
||||
type TypeOptions = {
|
||||
delay?: number;
|
||||
focus?: boolean;
|
||||
allowFastSet?: boolean;
|
||||
};
|
||||
|
||||
export function codeMirrorHelpers<T extends object>(testId: string, extra: T) {
|
||||
const helpers = {
|
||||
get() {
|
||||
cy.findAllByTestId("loading-indicator").should("not.exist");
|
||||
return cy.get(`[data-testid=${testId}] .cm-content`);
|
||||
},
|
||||
focus() {
|
||||
helpers.get().should("be.visible").click("right");
|
||||
helpers.get().get(".cm-editor").should("have.class", "cm-focused");
|
||||
return helpers;
|
||||
},
|
||||
blur() {
|
||||
helpers.get().get(".cm-content").blur();
|
||||
return helpers;
|
||||
},
|
||||
selectAll() {
|
||||
const isMac = Cypress.platform === "darwin";
|
||||
const metaKey = isMac ? "Meta" : "Control";
|
||||
helpers.focus();
|
||||
cy.realPress([metaKey, "A"]);
|
||||
return helpers;
|
||||
},
|
||||
clear() {
|
||||
helpers.selectAll();
|
||||
cy.realPress(["Backspace"]);
|
||||
return helpers;
|
||||
},
|
||||
type(
|
||||
text: string,
|
||||
{ focus = true, delay = 10, allowFastSet = false }: TypeOptions = {},
|
||||
) {
|
||||
if (focus) {
|
||||
helpers.focus();
|
||||
}
|
||||
|
||||
if (allowFastSet) {
|
||||
// Enter the formula in one go
|
||||
// HACK: we do invoke("text") instead of type() because type() does not work on
|
||||
// CodeMirror elements in Cypress. realType() would work but some of the formulas
|
||||
// contain special characters that are not supported by realType().
|
||||
helpers.get().invoke("text", text);
|
||||
|
||||
// invoke("text") does not trigger the validator, so we need to trigger it manually
|
||||
// by typing something
|
||||
helpers.type(" {backspace}");
|
||||
|
||||
return helpers;
|
||||
}
|
||||
|
||||
const isMac = Cypress.platform === "darwin";
|
||||
const metaKey = isMac ? "Meta" : "Control";
|
||||
|
||||
const parts = text.replaceAll("{{", "{{}{{}").split(/(\{[^}]+\})/);
|
||||
|
||||
function insert(text: string) {
|
||||
cy.realType(text, { pressDelay: delay });
|
||||
}
|
||||
|
||||
// HACK: realType does not accept a lot of common escape sequences,
|
||||
// so we implement them manually here for the native editor.
|
||||
parts.forEach((part) => {
|
||||
switch (part.toLowerCase()) {
|
||||
case "":
|
||||
return;
|
||||
|
||||
case "{clear}":
|
||||
return helpers.clear();
|
||||
|
||||
case "{selectall}":
|
||||
return helpers.selectAll();
|
||||
|
||||
case "{leftarrow}":
|
||||
return cy.realPress(["ArrowLeft"]);
|
||||
|
||||
case "{rightarrow}":
|
||||
return cy.realPress(["ArrowRight"]);
|
||||
|
||||
case "{downarrow}":
|
||||
return cy.realPress(["ArrowDown"]);
|
||||
|
||||
case "{uparrow}":
|
||||
return cy.realPress(["ArrowUp"]);
|
||||
|
||||
case "{enter}":
|
||||
return cy.realPress(["Enter"]);
|
||||
|
||||
case "{home}":
|
||||
case "{movetostart}":
|
||||
return cy.realPress(["Home"]);
|
||||
|
||||
case "{end}":
|
||||
case "{movetoend}":
|
||||
return cy.realPress(["End"]);
|
||||
|
||||
case "{backspace}":
|
||||
return cy.realPress(["Backspace"]);
|
||||
|
||||
case "{tab}":
|
||||
return cy.realPress(["Tab"]);
|
||||
|
||||
case "{nextcompletion}":
|
||||
cy.wait(50);
|
||||
return cy.realPress([metaKey, "j"]);
|
||||
|
||||
case "{prevcompletion}":
|
||||
cy.wait(50);
|
||||
return cy.realPress([metaKey, "k"]);
|
||||
|
||||
case "{{}":
|
||||
return cy.realType("{");
|
||||
}
|
||||
|
||||
if (part.startsWith("{") && part.endsWith("}")) {
|
||||
// unknown escape sequence, let's try typing it
|
||||
insert("{");
|
||||
insert(part.slice(1));
|
||||
return;
|
||||
}
|
||||
|
||||
// realType does not support → arrow, so we replace it with ->, which the editor
|
||||
// expands into →
|
||||
const unexpanded = part.replaceAll(/→/g, "->");
|
||||
const alphabet =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^[]()-,.;_!@#$%&*+=/<>\" ':;\\\n{}";
|
||||
if (unexpanded.split("").some((char) => !alphabet.includes(char))) {
|
||||
throw new Error(
|
||||
`unknown character in codeMirrorHelpers.type in ${part}`,
|
||||
);
|
||||
}
|
||||
|
||||
insert(unexpanded);
|
||||
});
|
||||
|
||||
return helpers;
|
||||
},
|
||||
textbox() {
|
||||
return helpers.get().get("[role='textbox']");
|
||||
},
|
||||
value() {
|
||||
// Get the multiline text content of the editor
|
||||
return helpers
|
||||
.textbox()
|
||||
.get(".cm-line")
|
||||
.then((lines) => {
|
||||
const text: string[] = [];
|
||||
lines.each((_, line) => {
|
||||
const placeholder = line.querySelector(".cm-placeholder");
|
||||
if (placeholder) {
|
||||
return;
|
||||
}
|
||||
text.push(line.textContent ?? "");
|
||||
});
|
||||
return text.join("\n");
|
||||
});
|
||||
},
|
||||
completions() {
|
||||
return cy.get(".cm-tooltip-autocomplete").should("be.visible");
|
||||
},
|
||||
completion(label: string) {
|
||||
return cy.get(".cm-completionLabel").contains(label).parent();
|
||||
},
|
||||
acceptCompletion(key: "enter" | "tab" = "enter") {
|
||||
helpers.completions().should("be.visible");
|
||||
|
||||
// Avoid flakiness with CodeMirror not accepting the suggestion immediately
|
||||
cy.wait(300);
|
||||
helpers.type(`{${key}}`, { focus: false });
|
||||
},
|
||||
selectCompletion(name: string) {
|
||||
helpers.completions().should("be.visible");
|
||||
|
||||
// Avoid flakiness with CodeMirror not accepting the suggestion immediately
|
||||
cy.wait(300);
|
||||
helpers.completion(name).click();
|
||||
},
|
||||
paste(content: string) {
|
||||
helpers.textbox().then((el) => {
|
||||
const clipboardData = new DataTransfer();
|
||||
clipboardData.setData("text/plain", content);
|
||||
|
||||
const pasteEvent = new ClipboardEvent("paste", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
clipboardData,
|
||||
});
|
||||
|
||||
el[0].dispatchEvent(pasteEvent);
|
||||
});
|
||||
},
|
||||
...extra,
|
||||
};
|
||||
|
||||
return helpers;
|
||||
}
|
||||
|
||||
export function codeMirrorEditor() {
|
||||
return cy.get(".cm-content");
|
||||
}
|
||||
|
||||
export function codeMirrorValue() {
|
||||
// Get the multiline text content of the editor
|
||||
return codeMirrorEditor()
|
||||
.get("[role='textbox']")
|
||||
.get(".cm-line")
|
||||
.then((lines) => {
|
||||
const text: string[] = [];
|
||||
lines.each((_, line) => {
|
||||
text.push(line.textContent ?? "");
|
||||
});
|
||||
const value = text.join("\n");
|
||||
const placeholder = "SELECT * FROM TABLE_NAME";
|
||||
if (value === placeholder) {
|
||||
return "";
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
@@ -21,16 +21,22 @@ function getDocumentNodeButton({
|
||||
targetId,
|
||||
childTargetId,
|
||||
hasComments,
|
||||
isCardEmbedNode,
|
||||
}: {
|
||||
targetId: DocumentId;
|
||||
childTargetId: string;
|
||||
hasComments?: boolean;
|
||||
isCardEmbedNode?: boolean;
|
||||
}) {
|
||||
const threadUrl = `/document/${targetId}/comments/${childTargetId}${hasComments ? "" : "?new=true"}`;
|
||||
|
||||
return getDocumentNodeButtons().filter(
|
||||
(_, element) => element.getAttribute("href") === threadUrl,
|
||||
);
|
||||
if (isCardEmbedNode) {
|
||||
return cy.findByRole("button", { name: "Comments" });
|
||||
} else {
|
||||
return getDocumentNodeButtons().filter(
|
||||
(_, element) => element.getAttribute("href") === threadUrl,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getDocumentNodeButtons() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { popover } from "e2e/support/helpers/e2e-ui-elements-helpers";
|
||||
|
||||
import { codeMirrorHelpers } from "./e2e-codemirror-helpers";
|
||||
|
||||
export function expressionEditorWidget() {
|
||||
return cy.findByTestId("expression-editor");
|
||||
}
|
||||
@@ -8,9 +10,6 @@ export function expressionEditorTextfield() {
|
||||
return CustomExpressionEditor.get();
|
||||
}
|
||||
|
||||
const isMac = Cypress.platform === "darwin";
|
||||
const metaKey = isMac ? "Meta" : "Control";
|
||||
|
||||
export function enterCustomColumnDetails({
|
||||
formula,
|
||||
name,
|
||||
@@ -71,224 +70,43 @@ export function enterCustomColumnDetails({
|
||||
}
|
||||
}
|
||||
|
||||
export const CustomExpressionEditor = {
|
||||
get() {
|
||||
return cy.findByTestId("custom-expression-query-editor");
|
||||
},
|
||||
/**
|
||||
* @param {string} text the formula to type
|
||||
* @param {Object} options
|
||||
* @param {boolean} [options.focus]
|
||||
* true by default. Set to false to stop the helper from explicitly focussing the formula input.
|
||||
* @param {boolean} [options.allowFastSet]
|
||||
* true by default. However, if you need to examine the popover in the test, it should be set to false so the popover is not dismissed
|
||||
* Because CodeMirror uses a contenteditable div, and it is not possible to use cy.type() on it, we emulate .type with realPress.
|
||||
* This does not always work, since realPress() does not support all characters. Setting this to true will enable an escape hatch
|
||||
* that uses cy.invoke('text') under the hood, to allow for formulas that contain unsupported characters.
|
||||
* This has some other sideeffects however, so use it sparingly.
|
||||
*/
|
||||
type(
|
||||
text: string,
|
||||
{
|
||||
allowFastSet = false,
|
||||
focus = true,
|
||||
delay = 0,
|
||||
}: {
|
||||
focus?: boolean;
|
||||
allowFastSet?: boolean;
|
||||
delay?: number;
|
||||
} = {},
|
||||
) {
|
||||
if (focus) {
|
||||
CustomExpressionEditor.focus();
|
||||
}
|
||||
|
||||
if (allowFastSet) {
|
||||
// Enter the formula in one go
|
||||
// HACK: we do invoke("text") instead of type() because type() does not work on
|
||||
// CodeMirror elements in Cypress. realType() would work but some of the formulas
|
||||
// contain special characters that are not supported by realType().
|
||||
CustomExpressionEditor.get().findByRole("textbox").invoke("text", text);
|
||||
|
||||
// invoke("text") does not trigger the validator, so we need to trigger it manually
|
||||
// by typing something
|
||||
CustomExpressionEditor.type(" {backspace}");
|
||||
|
||||
export const CustomExpressionEditor = codeMirrorHelpers(
|
||||
"custom-expression-query-editor",
|
||||
{
|
||||
formatButton() {
|
||||
return cy.findByLabelText("Auto-format");
|
||||
},
|
||||
format() {
|
||||
CustomExpressionEditor.formatButton().should("be.visible");
|
||||
CustomExpressionEditor.formatButton().click();
|
||||
return CustomExpressionEditor;
|
||||
}
|
||||
|
||||
const parts = text.replaceAll("{{", "{{}{{}").split(/(\{[^}]+\})/);
|
||||
|
||||
parts.forEach((part) => {
|
||||
cy.wait(delay);
|
||||
switch (part.toLowerCase()) {
|
||||
case "":
|
||||
return;
|
||||
|
||||
case "{clear}":
|
||||
return CustomExpressionEditor.clear();
|
||||
|
||||
case "{selectall}":
|
||||
return CustomExpressionEditor.selectAll();
|
||||
|
||||
case "{leftarrow}":
|
||||
return cy.realPress(["ArrowLeft"]);
|
||||
|
||||
case "{rightarrow}":
|
||||
return cy.realPress(["ArrowRight"]);
|
||||
|
||||
case "{downarrow}":
|
||||
return cy.realPress(["ArrowDown"]);
|
||||
|
||||
case "{uparrow}":
|
||||
return cy.realPress(["ArrowUp"]);
|
||||
|
||||
case "{enter}":
|
||||
return cy.realPress(["Enter"]);
|
||||
|
||||
case "{home}":
|
||||
case "{movetostart}":
|
||||
return cy.realPress(["Home"]);
|
||||
|
||||
case "{end}":
|
||||
case "{movetoend}":
|
||||
return cy.realPress(["End"]);
|
||||
|
||||
case "{backspace}":
|
||||
return cy.realPress(["Backspace"]);
|
||||
|
||||
case "{tab}":
|
||||
return cy.realPress(["Tab"]);
|
||||
|
||||
case "{nextcompletion}":
|
||||
cy.wait(50);
|
||||
return cy.realPress([metaKey, "j"]);
|
||||
|
||||
case "{prevcompletion}":
|
||||
cy.wait(50);
|
||||
return cy.realPress([metaKey, "k"]);
|
||||
|
||||
case "{{}":
|
||||
return cy.realType("{");
|
||||
}
|
||||
|
||||
if (part.startsWith("{") && part.endsWith("}")) {
|
||||
// unknown escape sequence, let's try typing it
|
||||
throw new Error(
|
||||
`unknown escape sequence in CustomExpressionEditor.type: ${part}`,
|
||||
);
|
||||
}
|
||||
|
||||
// realType does not support → arrow, so we replace it with ->, which the editor
|
||||
// expands into →
|
||||
const unexpanded = part.replaceAll(/→/g, "->");
|
||||
|
||||
const alphabet =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^[]()-,.;_!@#$%&*+=/<>\" ':;\\\n";
|
||||
if (unexpanded.split("").some((char) => !alphabet.includes(char))) {
|
||||
throw new Error(
|
||||
`unknown character in CustomExpressionEditor.type in ${part}`,
|
||||
);
|
||||
}
|
||||
|
||||
cy.realType(unexpanded, { delay });
|
||||
});
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
focus() {
|
||||
CustomExpressionEditor.get().click("right");
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
blur() {
|
||||
// click outside the expression editor
|
||||
cy.findByTestId("expression-editor").click("bottomRight", { force: true });
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
formatButton() {
|
||||
return cy.findByLabelText("Auto-format");
|
||||
},
|
||||
format() {
|
||||
CustomExpressionEditor.formatButton().should("be.visible");
|
||||
CustomExpressionEditor.formatButton().click();
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
selectAll() {
|
||||
CustomExpressionEditor.focus();
|
||||
cy.realPress([metaKey, "A"]);
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
clear() {
|
||||
CustomExpressionEditor.selectAll();
|
||||
cy.realPress(["Backspace"]);
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
textbox() {
|
||||
return CustomExpressionEditor.get().get("[role='textbox']");
|
||||
},
|
||||
value() {
|
||||
// Get the multiline text content of the editor
|
||||
return CustomExpressionEditor.textbox()
|
||||
.get(".cm-line")
|
||||
.then((lines) => {
|
||||
const text: string[] = [];
|
||||
lines.each((_, line) => {
|
||||
text.push(line.textContent ?? "");
|
||||
});
|
||||
const value = text.join("\n");
|
||||
const placeholder = "Type your expression, press '[' for columns…";
|
||||
if (value === placeholder) {
|
||||
return "";
|
||||
}
|
||||
return value;
|
||||
},
|
||||
helpTextHeader() {
|
||||
return cy.findByTestId("expression-helper-popover-structure");
|
||||
},
|
||||
helpText() {
|
||||
return cy.findByTestId("expression-helper");
|
||||
},
|
||||
nameInput() {
|
||||
return cy.findByTestId("expression-name");
|
||||
},
|
||||
functionBrowser() {
|
||||
return cy.findByTestId("expression-editor-function-browser");
|
||||
},
|
||||
completions() {
|
||||
return cy.findByTestId("custom-expression-editor-suggestions");
|
||||
},
|
||||
completion(name: string) {
|
||||
return CustomExpressionEditor.completions()
|
||||
.findAllByRole("option")
|
||||
.contains(name)
|
||||
.first();
|
||||
},
|
||||
blur() {
|
||||
cy.findByTestId("expression-editor").click("bottomRight", {
|
||||
force: true,
|
||||
});
|
||||
return CustomExpressionEditor;
|
||||
},
|
||||
},
|
||||
completions() {
|
||||
return cy.findByTestId("custom-expression-editor-suggestions");
|
||||
},
|
||||
completion(name: string) {
|
||||
return CustomExpressionEditor.completions()
|
||||
.findAllByRole("option")
|
||||
.contains(name)
|
||||
.first();
|
||||
},
|
||||
acceptCompletion(key: "enter" | "tab" = "enter") {
|
||||
CustomExpressionEditor.completions().should("be.visible");
|
||||
|
||||
// Avoid flakiness with CodeMirror not accepting the suggestion immediately
|
||||
cy.wait(300);
|
||||
CustomExpressionEditor.type(`{${key}}`, { focus: false });
|
||||
},
|
||||
selectCompletion(name: string) {
|
||||
CustomExpressionEditor.completions().should("be.visible");
|
||||
|
||||
// Avoid flakiness with CodeMirror not accepting the suggestion immediately
|
||||
cy.wait(300);
|
||||
CustomExpressionEditor.completion(name).click();
|
||||
},
|
||||
helpTextHeader() {
|
||||
return cy.findByTestId("expression-helper-popover-structure");
|
||||
},
|
||||
helpText() {
|
||||
return cy.findByTestId("expression-helper");
|
||||
},
|
||||
paste(content: string) {
|
||||
CustomExpressionEditor.textbox().then((el) => {
|
||||
const clipboardData = new DataTransfer();
|
||||
clipboardData.setData("text/plain", content);
|
||||
|
||||
const pasteEvent = new ClipboardEvent("paste", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
clipboardData,
|
||||
});
|
||||
|
||||
el[0].dispatchEvent(pasteEvent);
|
||||
});
|
||||
},
|
||||
nameInput() {
|
||||
return cy.findByTestId("expression-name");
|
||||
},
|
||||
functionBrowser() {
|
||||
return cy.findByTestId("expression-editor-function-browser");
|
||||
},
|
||||
};
|
||||
);
|
||||
|
||||
@@ -37,10 +37,22 @@ export const documentMetabotSuggestionItem = (name: RegExp | string) =>
|
||||
export const commandSuggestionItem = (name: RegExp | string) =>
|
||||
commandSuggestionDialog().findByRole("option", { name });
|
||||
|
||||
export const getDocumentCard = (name: string) =>
|
||||
documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.contains('[data-testid="document-card-embed"]', name);
|
||||
export const getDocumentCard = (name: string, expectCardExists = true) => {
|
||||
const cardsResult = documentContent()
|
||||
.findAllByTestId("card-embed-title")
|
||||
.filter((index, el) => {
|
||||
// Filter elements based on custom logic, e.g., text content, class, etc.
|
||||
return el.innerText === name;
|
||||
})
|
||||
.should("have.length", expectCardExists ? 1 : 0);
|
||||
|
||||
return expectCardExists
|
||||
? cardsResult.closest('[data-testid="document-card-embed"]')
|
||||
: cardsResult;
|
||||
};
|
||||
|
||||
export const getDocumentCardResizeContainer = (name: string) =>
|
||||
getDocumentCard(name).closest('[data-type="resizeNode"]');
|
||||
|
||||
export const assertDocumentCardVizType = (name: string, type: string) =>
|
||||
getDocumentCard(name).find(`[data-viz-ui-name=${type}]`);
|
||||
@@ -102,3 +114,124 @@ const visitDocumentById = (id: DocumentId) => {
|
||||
|
||||
cy.wait(`@${alias}`);
|
||||
};
|
||||
|
||||
export function dragAndDropCardOnAnotherCard(
|
||||
sourceCardTitle: string,
|
||||
targetCardTitle: string,
|
||||
{
|
||||
side = "left",
|
||||
}: {
|
||||
side?: "left" | "right";
|
||||
} = {},
|
||||
) {
|
||||
// Perform drag and drop: drag sourceCard card onto targetCard
|
||||
getDocumentCard(sourceCardTitle)
|
||||
.should("exist")
|
||||
.then(($ordersCard) => {
|
||||
getDocumentCard(targetCardTitle)
|
||||
.should("exist")
|
||||
.then(($ordersCountCard) => {
|
||||
const sourceRect = $ordersCard[0].getBoundingClientRect();
|
||||
|
||||
// Start drag from center of Orders card
|
||||
getDocumentCard(sourceCardTitle).trigger("mousedown", {
|
||||
x: 10,
|
||||
y: 10,
|
||||
scrollBehavior: false,
|
||||
force: true,
|
||||
});
|
||||
const dataTransfer = new DataTransfer();
|
||||
getDocumentCard(sourceCardTitle).trigger("dragstart", {
|
||||
dataTransfer,
|
||||
clientX: sourceRect.left + 10,
|
||||
clientY: sourceRect.top + 10,
|
||||
scrollBehavior: false,
|
||||
force: true,
|
||||
});
|
||||
|
||||
const targetRect = $ordersCountCard[0].getBoundingClientRect();
|
||||
// Calculate position for target card side drop (20% from left or 20% from right based on 'side' param)
|
||||
const sideX =
|
||||
targetRect.left + targetRect.width * (side === "left" ? 0.2 : 0.8);
|
||||
const centerY = targetRect.top + 10;
|
||||
documentContent().trigger("mousemove", {
|
||||
clientX: sideX,
|
||||
clientY: centerY,
|
||||
scrollBehavior: false,
|
||||
});
|
||||
getDocumentCard(targetCardTitle).trigger("dragover", {
|
||||
clientX: sideX,
|
||||
clientY: centerY,
|
||||
scrollBehavior: false,
|
||||
force: true,
|
||||
});
|
||||
|
||||
getDocumentCard(sourceCardTitle).realMouseUp({
|
||||
scrollBehavior: false,
|
||||
});
|
||||
getDocumentCard(targetCardTitle).trigger("drop", {
|
||||
dataTransfer,
|
||||
clientX: sideX,
|
||||
clientY: centerY,
|
||||
scrollBehavior: false,
|
||||
force: true,
|
||||
});
|
||||
getDocumentCard(sourceCardTitle).trigger("dragend", {
|
||||
scrollBehavior: false,
|
||||
force: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function documentUndo() {
|
||||
const macOSX = Cypress.platform === "darwin";
|
||||
|
||||
documentContent()
|
||||
.get('[contenteditable="true"]')
|
||||
.click()
|
||||
.type(macOSX ? "{cmd+z}" : "{ctrl+z}", {
|
||||
scrollBehavior: false,
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
|
||||
export function getDragHandleForDocumentResizeNode(element: Cypress.Chainable) {
|
||||
return element.findByTestId("resize-node-drag-handle");
|
||||
}
|
||||
|
||||
export function documentDoDrag(
|
||||
_handle: Cypress.Chainable<JQuery<HTMLElement>>,
|
||||
diff: { x?: number; y?: number },
|
||||
) {
|
||||
_handle.then((handle) => {
|
||||
const { x: deltaX = 0, y: deltaY = 0 } = diff;
|
||||
|
||||
const rect = handle[0].getBoundingClientRect();
|
||||
|
||||
cy.log(`x: ${rect.x}, y: ${rect.y}, diff: ${diff}`);
|
||||
|
||||
cy.wrap(handle).trigger("mousedown", {
|
||||
button: 0,
|
||||
clientX: rect.x,
|
||||
clientY: rect.y,
|
||||
force: true,
|
||||
});
|
||||
cy.get("body")
|
||||
.trigger("mousemove", {
|
||||
button: 0,
|
||||
clientX: rect.x + deltaX,
|
||||
clientY: rect.y + deltaY,
|
||||
force: true,
|
||||
})
|
||||
.trigger("mouseup");
|
||||
});
|
||||
}
|
||||
|
||||
export function getFlexContainerForCard(name: string) {
|
||||
return getDocumentCard(name).closest('[data-type="flexContainer"]');
|
||||
}
|
||||
|
||||
export function getResizeHandlesForFlexContianer(element: Cypress.Chainable) {
|
||||
return element.findAllByTestId("flex-container-drag-handle");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ export interface BaseEmbedTestPageOptions {
|
||||
instanceUrl?: string;
|
||||
apiKey?: string;
|
||||
useExistingUserSession?: boolean;
|
||||
fetchRequestToken?: () => Promise<{ jwt: string }>;
|
||||
theme?: MetabaseTheme;
|
||||
preferredAuthMethod?: "jwt" | "saml";
|
||||
locale?: string;
|
||||
@@ -39,7 +40,7 @@ export interface BaseEmbedTestPageOptions {
|
||||
afterEmbed?: string;
|
||||
};
|
||||
|
||||
onVisitPage?(): void;
|
||||
onVisitPage?(win: Cypress.AUTWindow): void;
|
||||
}
|
||||
|
||||
export interface MetabaseElement {
|
||||
@@ -267,14 +268,7 @@ export const getNewEmbedConfigurationScript = ({
|
||||
useExistingUserSession,
|
||||
preferredAuthMethod,
|
||||
locale,
|
||||
}: {
|
||||
instanceUrl?: string;
|
||||
theme?: MetabaseTheme;
|
||||
apiKey?: string;
|
||||
useExistingUserSession?: boolean;
|
||||
preferredAuthMethod?: "jwt" | "saml";
|
||||
locale?: string;
|
||||
} = {}) => {
|
||||
}: BaseEmbedTestPageOptions["metabaseConfig"] = {}) => {
|
||||
const config = {
|
||||
instanceUrl,
|
||||
apiKey,
|
||||
|
||||
@@ -1,42 +1,6 @@
|
||||
import { codeMirrorHelpers } from "./e2e-codemirror-helpers";
|
||||
import { popover } from "./e2e-ui-elements-helpers";
|
||||
|
||||
function nativeEditor() {
|
||||
cy.findAllByTestId("loading-indicator").should("not.exist");
|
||||
return cy.get("[data-testid=native-query-editor] .cm-content");
|
||||
}
|
||||
|
||||
function focusNativeEditor() {
|
||||
nativeEditor().should("be.visible").click();
|
||||
|
||||
nativeEditor().get(".cm-editor").should("have.class", "cm-focused");
|
||||
|
||||
return nativeEditor();
|
||||
}
|
||||
|
||||
function blurNativeEditor() {
|
||||
nativeEditor().get(".cm-editor").blur();
|
||||
}
|
||||
|
||||
function nativeEditorCompletions() {
|
||||
return cy.get(".cm-tooltip-autocomplete").should("be.visible");
|
||||
}
|
||||
|
||||
function nativeEditorCompletion(label: string) {
|
||||
return cy.get(".cm-completionLabel").contains(label).parent();
|
||||
}
|
||||
|
||||
function nativeEditorSelectAll() {
|
||||
const isMac = Cypress.platform === "darwin";
|
||||
const metaKey = isMac ? "Meta" : "Control";
|
||||
focusNativeEditor().realPress([metaKey, "A"]);
|
||||
cy.get(".cm-selectionBackground").should("exist");
|
||||
}
|
||||
|
||||
function clearNativeEditor() {
|
||||
nativeEditorSelectAll();
|
||||
cy.realPress(["Backspace"]);
|
||||
}
|
||||
|
||||
export function nativeEditorDataSource() {
|
||||
return cy.findAllByTestId("gui-builder-data").first();
|
||||
}
|
||||
@@ -46,139 +10,7 @@ export function selectNativeEditorDataSource(name: string) {
|
||||
popover().findByText(name).click();
|
||||
}
|
||||
|
||||
type TypeOptions = {
|
||||
delay?: number;
|
||||
focus?: boolean;
|
||||
};
|
||||
|
||||
function nativeEditorType(
|
||||
text: string,
|
||||
{ delay = 10, focus = true }: TypeOptions = {},
|
||||
) {
|
||||
if (focus) {
|
||||
focusNativeEditor();
|
||||
}
|
||||
|
||||
const isMac = Cypress.platform === "darwin";
|
||||
const metaKey = isMac ? "Meta" : "Control";
|
||||
|
||||
const parts = text.replaceAll("{{", "{{}{{}").split(/(\{[^}]+\})/);
|
||||
|
||||
function type(text: string) {
|
||||
cy.realType(text, {
|
||||
pressDelay: delay,
|
||||
});
|
||||
}
|
||||
|
||||
// HACK: realType does not accept a lot of common escape sequences,
|
||||
// so we implement them manually here for the native editor.
|
||||
parts.forEach((part) => {
|
||||
switch (part.toLowerCase()) {
|
||||
case "":
|
||||
return;
|
||||
|
||||
case "{clear}":
|
||||
return clearNativeEditor();
|
||||
|
||||
case "{selectall}":
|
||||
return nativeEditorSelectAll();
|
||||
|
||||
case "{leftarrow}":
|
||||
return cy.realPress(["ArrowLeft"]);
|
||||
|
||||
case "{rightarrow}":
|
||||
return cy.realPress(["ArrowRight"]);
|
||||
|
||||
case "{downarrow}":
|
||||
return cy.realPress(["ArrowDown"]);
|
||||
|
||||
case "{uparrow}":
|
||||
return cy.realPress(["ArrowUp"]);
|
||||
|
||||
case "{enter}":
|
||||
return cy.realPress(["Enter"]);
|
||||
|
||||
case "{home}":
|
||||
case "{movetostart}":
|
||||
return cy.realPress(["Home"]);
|
||||
|
||||
case "{end}":
|
||||
case "{movetoend}":
|
||||
return cy.realPress(["End"]);
|
||||
|
||||
case "{backspace}":
|
||||
return cy.realPress(["Backspace"]);
|
||||
|
||||
case "{tab}":
|
||||
return cy.realPress(["Tab"]);
|
||||
|
||||
case "{nextcompletion}":
|
||||
cy.wait(50);
|
||||
return cy.realPress([metaKey, "j"]);
|
||||
|
||||
case "{prevcompletion}":
|
||||
cy.wait(50);
|
||||
return cy.realPress([metaKey, "k"]);
|
||||
|
||||
case "{{}":
|
||||
return cy.realType("{");
|
||||
}
|
||||
|
||||
if (part.startsWith("{") && part.endsWith("}")) {
|
||||
// unknown escape sequence, let's try typing it
|
||||
type("{");
|
||||
type(part.slice(1));
|
||||
return;
|
||||
}
|
||||
|
||||
type(part);
|
||||
});
|
||||
|
||||
return nativeEditor();
|
||||
}
|
||||
|
||||
export const NativeEditor = {
|
||||
get: nativeEditor,
|
||||
type(text: string, options: TypeOptions = {}) {
|
||||
nativeEditorType(text, options);
|
||||
return NativeEditor;
|
||||
},
|
||||
focus() {
|
||||
focusNativeEditor();
|
||||
return NativeEditor;
|
||||
},
|
||||
blur() {
|
||||
blurNativeEditor();
|
||||
return NativeEditor;
|
||||
},
|
||||
selectAll() {
|
||||
nativeEditorSelectAll();
|
||||
return NativeEditor;
|
||||
},
|
||||
clear() {
|
||||
clearNativeEditor();
|
||||
return NativeEditor;
|
||||
},
|
||||
textbox() {
|
||||
return NativeEditor.get().get("[role='textbox']");
|
||||
},
|
||||
value() {
|
||||
// Get the multiline text content of the editor
|
||||
return NativeEditor.textbox()
|
||||
.get(".cm-line")
|
||||
.then((lines) => {
|
||||
const text: string[] = [];
|
||||
lines.each((_, line) => {
|
||||
text.push(line.textContent ?? "");
|
||||
});
|
||||
const value = text.join("\n");
|
||||
const placeholder = "SELECT * FROM TABLE_NAME";
|
||||
if (value === placeholder) {
|
||||
return "";
|
||||
}
|
||||
return value;
|
||||
});
|
||||
},
|
||||
completions: nativeEditorCompletions,
|
||||
completion: nativeEditorCompletion,
|
||||
};
|
||||
export const NativeEditor = codeMirrorHelpers("native-query-editor", {
|
||||
dataSource: nativeEditorDataSource,
|
||||
selectDataSource: selectNativeEditorDataSource,
|
||||
});
|
||||
|
||||
3
e2e/support/helpers/e2e-python-helpers.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { codeMirrorHelpers } from "./e2e-codemirror-helpers";
|
||||
|
||||
export const PythonEditor = codeMirrorHelpers("python-editor", {});
|
||||
37
e2e/support/helpers/e2e-transform-helpers.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type {
|
||||
ListTransformRunsResponse,
|
||||
TransformId,
|
||||
TransformRun,
|
||||
} from "metabase-types/api";
|
||||
|
||||
export function visitTransform(transformId: TransformId) {
|
||||
cy.visit(`/admin/transforms/${transformId}`);
|
||||
}
|
||||
|
||||
const WAIT_TIMEOUT = 10000;
|
||||
const WAIT_INTERVAL = 100;
|
||||
|
||||
export function waitForTransformRuns(
|
||||
filter: (runs: TransformRun[]) => boolean,
|
||||
timeout = WAIT_TIMEOUT,
|
||||
): Cypress.Chainable {
|
||||
return cy
|
||||
.request<ListTransformRunsResponse>("GET", "/api/ee/transform/run")
|
||||
.then((response) => {
|
||||
if (filter(response.body.data)) {
|
||||
return cy.wrap(response);
|
||||
} else if (timeout > 0) {
|
||||
cy.wait(WAIT_INTERVAL);
|
||||
return waitForTransformRuns(filter, timeout - WAIT_INTERVAL);
|
||||
} else {
|
||||
throw new Error("Run retry timeout");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function waitForSucceededTransformRuns() {
|
||||
waitForTransformRuns(
|
||||
(runs) =>
|
||||
runs.length > 0 && runs.every((run) => run.status === "succeeded"),
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,29 @@ import {
|
||||
} from "e2e/support/helpers";
|
||||
import { enableJwtAuth } from "e2e/support/helpers/e2e-jwt-helpers";
|
||||
|
||||
export const mockAuthProviderAndJwtSignIn = (user = USERS.admin) => {
|
||||
export const getSignedJwtForUser = async ({
|
||||
user = USERS.admin,
|
||||
expiredInSeconds = 60 * 10, // 10 minutes expiration,
|
||||
}: {
|
||||
user?: { email: string; first_name: string; last_name: string };
|
||||
expiredInSeconds?: number;
|
||||
}) => {
|
||||
const secret = new TextEncoder().encode(JWT_SHARED_SECRET);
|
||||
|
||||
return new jose.SignJWT({
|
||||
email: user.email,
|
||||
first_name: user.first_name,
|
||||
last_name: user.last_name,
|
||||
exp: Math.round(Date.now() / 1000) + expiredInSeconds,
|
||||
})
|
||||
.setProtectedHeader({ alg: "HS256" })
|
||||
.sign(secret);
|
||||
};
|
||||
|
||||
export const mockAuthProviderAndJwtSignIn = (
|
||||
user = USERS.admin,
|
||||
{ jwt }: { jwt?: string } = {},
|
||||
) => {
|
||||
cy.intercept("GET", `${AUTH_PROVIDER_URL}**`, async (req) => {
|
||||
try {
|
||||
const url = new URL(req.url);
|
||||
@@ -26,15 +48,7 @@ export const mockAuthProviderAndJwtSignIn = (user = USERS.admin) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const secret = new TextEncoder().encode(JWT_SHARED_SECRET);
|
||||
const jwt = await new jose.SignJWT({
|
||||
email: user.email,
|
||||
first_name: user.first_name,
|
||||
last_name: user.last_name,
|
||||
exp: Math.round(Date.now() / 1000) + 60 * 10, // 10 minutes expiration
|
||||
})
|
||||
.setProtectedHeader({ alg: "HS256" })
|
||||
.sign(secret);
|
||||
jwt = jwt || (await getSignedJwtForUser({ user }));
|
||||
|
||||
req.reply({
|
||||
statusCode: 200,
|
||||
|
||||
@@ -6,6 +6,7 @@ export * from "./e2e-bi-basics-helpers";
|
||||
export * from "./e2e-boolean-helpers";
|
||||
export * from "./e2e-browser-helpers";
|
||||
export * from "./e2e-cloud-helpers";
|
||||
export * from "./e2e-codemirror-helpers";
|
||||
export * from "./e2e-collection-helpers";
|
||||
export * from "./e2e-command-palette-helpers";
|
||||
export * from "./e2e-comment-helpers";
|
||||
@@ -35,6 +36,7 @@ export * from "./e2e-native-editor-helpers";
|
||||
export * from "./e2e-notebook-helpers";
|
||||
export * from "./e2e-notification-helpers";
|
||||
export * from "./e2e-permissions-helpers";
|
||||
export * from "./e2e-python-helpers";
|
||||
export * from "./e2e-qa-databases-helpers";
|
||||
export * from "./e2e-relative-date-picker-helpers";
|
||||
export * from "./e2e-request-helpers";
|
||||
@@ -45,6 +47,7 @@ export * from "./e2e-slack-helpers";
|
||||
export * from "./e2e-snowplow-helpers";
|
||||
export * from "./e2e-table-metadata-helpers";
|
||||
export * from "./e2e-token-helpers";
|
||||
export * from "./e2e-transform-helpers";
|
||||
export * from "./e2e-ui-elements-helpers";
|
||||
export * from "./e2e-ui-elements-overflow-helpers";
|
||||
export * from "./e2e-upload-helpers";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
EditableDashboard,
|
||||
InteractiveDashboard,
|
||||
InteractiveQuestion,
|
||||
} from "@metabase/embedding-sdk-react";
|
||||
|
||||
const { H } = cy;
|
||||
@@ -26,6 +27,30 @@ describe("scenarios > embedding-sdk > dashboard-click-behavior", () => {
|
||||
semantic_type: "type/URL",
|
||||
});
|
||||
|
||||
// Create a question with custom column that returns a url as a string
|
||||
H.createQuestion({
|
||||
name: "Orders with URL Expression",
|
||||
query: {
|
||||
"source-table": ORDERS_ID,
|
||||
expressions: {
|
||||
// NOTE: this is a question, so it won't have semantic_type set as url, we'll need a model for that
|
||||
url_column: [
|
||||
"concat",
|
||||
"https://example.org/",
|
||||
["field", ORDERS.ID, { "base-type": "type/BigInteger" }],
|
||||
],
|
||||
},
|
||||
fields: [
|
||||
["field", ORDERS.ID, { "base-type": "type/BigInteger" }],
|
||||
["expression", "url_column", { "base-type": "type/Text" }],
|
||||
["field", ORDERS.PRODUCT_ID, null],
|
||||
],
|
||||
limit: 5,
|
||||
},
|
||||
}).then(({ body: question }) => {
|
||||
cy.wrap(question.id).as("questionId");
|
||||
});
|
||||
|
||||
H.createDashboardWithQuestions({
|
||||
dashboardName: "Orders in a dashboard",
|
||||
questions: [
|
||||
@@ -60,7 +85,7 @@ describe("scenarios > embedding-sdk > dashboard-click-behavior", () => {
|
||||
],
|
||||
cards: [
|
||||
{
|
||||
size_x: 12,
|
||||
size_x: 24,
|
||||
col: 0,
|
||||
visualization_settings: {
|
||||
column_settings: {
|
||||
@@ -77,7 +102,7 @@ describe("scenarios > embedding-sdk > dashboard-click-behavior", () => {
|
||||
},
|
||||
{
|
||||
size_x: 12,
|
||||
col: 12,
|
||||
col: 0,
|
||||
visualization_settings: {
|
||||
click_behavior: {
|
||||
type: "link",
|
||||
@@ -193,4 +218,123 @@ describe("scenarios > embedding-sdk > dashboard-click-behavior", () => {
|
||||
cy.findByTestId("visualization-root").should("be.visible");
|
||||
});
|
||||
});
|
||||
|
||||
it("columns that return a string url should be rendered as a link", () => {
|
||||
cy.get<string>("@questionId").then((questionId) => {
|
||||
mountSdkContent(<InteractiveQuestion questionId={questionId} />);
|
||||
});
|
||||
|
||||
cy.intercept("GET", "/api/card/*").as("getCard");
|
||||
cy.wait("@getCard");
|
||||
|
||||
cy.findByRole("link", { name: "https://example.org/448" })
|
||||
.should("have.length", 1)
|
||||
.should("have.attr", "href", "https://example.org/448");
|
||||
});
|
||||
|
||||
it("columns that have 'type/URL' semantic type should be rendered as a link", () => {
|
||||
cy.signIn("admin");
|
||||
|
||||
cy.get<string>("@questionId").then((questionId) => {
|
||||
// Convert question to model
|
||||
cy.request("GET", `/api/card/${questionId}`)
|
||||
.then((response) => {
|
||||
const questionData = response.body;
|
||||
return cy.request("PUT", `/api/card/${questionId}`, {
|
||||
...questionData,
|
||||
type: "model",
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
// re-fetch it as model
|
||||
return cy.request("GET", `/api/card/${questionId}`);
|
||||
})
|
||||
.then((modelResponse) => {
|
||||
// Update model column semantic type for url_column to type/URL
|
||||
|
||||
const modelData = modelResponse.body;
|
||||
const updatedMetadata = modelData.result_metadata.map((col: any) => {
|
||||
if (col.name === "url_column") {
|
||||
return { ...col, semantic_type: "type/URL" };
|
||||
}
|
||||
return col;
|
||||
});
|
||||
|
||||
return cy.request("PUT", `/api/card/${questionId}`, {
|
||||
...modelData,
|
||||
result_metadata: updatedMetadata,
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
// Create dashboard with the model
|
||||
H.createDashboardWithQuestions({
|
||||
dashboardName: "URL Dashboard",
|
||||
questions: [
|
||||
{
|
||||
name: "Orders with URLs",
|
||||
query: {
|
||||
"source-table": `card__${questionId}`,
|
||||
limit: 5,
|
||||
},
|
||||
},
|
||||
],
|
||||
}).then(({ dashboard }) => {
|
||||
mountSdkContent(
|
||||
<InteractiveDashboard dashboardId={dashboard.id} />,
|
||||
);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
H.getDashboardCard(0)
|
||||
.findByRole("link", {
|
||||
name: "https://example.org/448",
|
||||
})
|
||||
.should("have.attr", "href", "https://example.org/448");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("columns that have 'Display as Link' should be rendered as a link and use the custom rendering", () => {
|
||||
cy.signIn("admin");
|
||||
cy.intercept("GET", "/api/card/*").as("getCard");
|
||||
|
||||
cy.get<string>("@questionId").then((questionId) => {
|
||||
H.createDashboardWithQuestions({
|
||||
dashboardName: "URL Dashboard",
|
||||
questions: [
|
||||
{
|
||||
name: "Orders with URLs",
|
||||
query: {
|
||||
"source-table": `card__${questionId}`,
|
||||
limit: 5,
|
||||
},
|
||||
},
|
||||
],
|
||||
cards: [
|
||||
{
|
||||
visualization_settings: {
|
||||
column_settings: {
|
||||
[JSON.stringify(["name", "ID"])]: {
|
||||
view_as: "link",
|
||||
link_text: "Link to {{ID}}",
|
||||
link_url: "https://example.org/{{ID}}",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}).then(({ dashboard }) => {
|
||||
mountSdkContent(<EditableDashboard dashboardId={dashboard.id} />);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
H.getDashboardCard(0)
|
||||
.findByRole("link", {
|
||||
name: "Link to 448",
|
||||
})
|
||||
.should("have.attr", "href", "https://example.org/448");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ describe("scenarios > embedding-sdk > incompatibility-with-instance-banner", ()
|
||||
mockAuthProviderAndJwtSignIn();
|
||||
});
|
||||
|
||||
describe("when the SDK is incompatible with an instance", () => {
|
||||
describe("when the SDK bundle is incompatible with an instance", () => {
|
||||
it("should show an error with a close button", () => {
|
||||
cy.mount(
|
||||
<MetabaseProvider authConfig={DEFAULT_SDK_AUTH_PROVIDER_CONFIG}>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
const { H } = cy;
|
||||
import { InteractiveQuestion } from "@metabase/embedding-sdk-react";
|
||||
|
||||
import { getSdkRoot } from "e2e/support/helpers/e2e-embedding-sdk-helpers";
|
||||
import { mountSdkContent } from "e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-helpers";
|
||||
import { signInAsAdminAndEnableEmbeddingSdk } from "e2e/support/helpers/embedding-sdk-testing";
|
||||
import { mockAuthProviderAndJwtSignIn } from "e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers";
|
||||
|
||||
describe("scenarios > embedding-sdk > interactive-question", () => {
|
||||
beforeEach(() => {
|
||||
signInAsAdminAndEnableEmbeddingSdk();
|
||||
|
||||
H.createNativeQuestion(
|
||||
{
|
||||
name: "SQL Orders",
|
||||
native: { query: "select * from ORDERS limit 5" },
|
||||
},
|
||||
{
|
||||
wrapId: true,
|
||||
idAlias: "sqlQuestionId",
|
||||
},
|
||||
);
|
||||
cy.signOut();
|
||||
|
||||
mockAuthProviderAndJwtSignIn();
|
||||
});
|
||||
|
||||
it("should be able to drill SQL question (EMB-273)", () => {
|
||||
cy.get("@sqlQuestionId").then((sqlQuestionId) => {
|
||||
mountSdkContent(
|
||||
<InteractiveQuestion questionId={sqlQuestionId} withParameters />,
|
||||
);
|
||||
});
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByText("SQL Orders").should("be.visible");
|
||||
H.assertTableRowsCount(5);
|
||||
|
||||
// Drill down to "See these Orders"
|
||||
cy.get("[data-dataset-index=0] > [data-column-id='PRODUCT_ID']")
|
||||
.should("have.text", "14")
|
||||
.click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("Filter by this value").should("be.visible");
|
||||
cy.button(">").click();
|
||||
});
|
||||
H.assertTableRowsCount(4);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -171,4 +171,101 @@ describe("scenarios > embedding-sdk > metabot-question", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should show suggestion buttons when no messages exist", () => {
|
||||
setup(metabotResponse);
|
||||
mockSuggestedPrompts();
|
||||
|
||||
mountSdkContent(<MetabotQuestion />);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
// Verify suggestion buttons are visible
|
||||
cy.findAllByTestId("metabot-suggestion-button", { timeout: 10_000 })
|
||||
.should("have.length", 3)
|
||||
.should("be.visible");
|
||||
|
||||
// Verify suggestion texts are shown in order
|
||||
cy.findAllByTestId("metabot-suggestion-button")
|
||||
.eq(0)
|
||||
.should("contain.text", "Show me total sales by product");
|
||||
|
||||
cy.findAllByTestId("metabot-suggestion-button")
|
||||
.eq(1)
|
||||
.should("contain.text", "What are the top performing products?");
|
||||
|
||||
cy.findAllByTestId("metabot-suggestion-button")
|
||||
.eq(2)
|
||||
.should("contain.text", "How many orders were placed last month?");
|
||||
|
||||
// Clicking on a suggestion should remove the suggestion buttons and add the user's message
|
||||
cy.findByText("Show me total sales by product").click();
|
||||
cy.findAllByTestId("metabot-suggestion-button").should("not.exist");
|
||||
cy.findAllByTestId("metabot-chat-message").should("have.length", 2);
|
||||
|
||||
cy.findAllByTestId("metabot-chat-message")
|
||||
.first()
|
||||
.should("contain.text", "Show me total sales by product");
|
||||
});
|
||||
});
|
||||
|
||||
it("should switch to stacked layout on small viewport", () => {
|
||||
setup(metabotResponse);
|
||||
mountSdkContent(<MetabotQuestion />);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
// On desktop, use the sidebar layout
|
||||
cy.findByTestId("metabot-question-container").should(
|
||||
"have.attr",
|
||||
"data-layout",
|
||||
"sidebar",
|
||||
);
|
||||
|
||||
// On mobile, use the stacked layout
|
||||
cy.viewport(400, 600);
|
||||
cy.findByTestId("metabot-overflow-button").should("be.visible");
|
||||
cy.findByTestId("metabot-question-container").should(
|
||||
"have.attr",
|
||||
"data-layout",
|
||||
"stacked",
|
||||
);
|
||||
|
||||
// On desktop, use the sidebar layout
|
||||
cy.viewport(1200, 800);
|
||||
cy.findByTestId("metabot-overflow-button").should("not.be.visible");
|
||||
cy.findByTestId("metabot-question-container").should(
|
||||
"have.attr",
|
||||
"data-layout",
|
||||
"sidebar",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const mockSuggestedPrompts = () => {
|
||||
cy.intercept(
|
||||
"GET",
|
||||
"/api/ee/metabot-v3/metabot/2/prompt-suggestions?limit=3&sample=true",
|
||||
{
|
||||
statusCode: 200,
|
||||
body: {
|
||||
prompts: [
|
||||
{
|
||||
id: 1,
|
||||
prompt: "Show me total sales by product",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
prompt: "What are the top performing products?",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
prompt: "How many orders were placed last month?",
|
||||
},
|
||||
],
|
||||
limit: 3,
|
||||
offset: 0,
|
||||
total: 3,
|
||||
},
|
||||
},
|
||||
).as("suggestedPrompts");
|
||||
};
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
import { CollectionBrowser } from "@metabase/embedding-sdk-react";
|
||||
import {
|
||||
CollectionBrowser,
|
||||
InteractiveQuestion,
|
||||
MetabaseProvider,
|
||||
} from "@metabase/embedding-sdk-react";
|
||||
|
||||
import { mountSdkContent } from "e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-helpers";
|
||||
import { signInAsAdminAndEnableEmbeddingSdk } from "e2e/support/helpers/embedding-sdk-testing";
|
||||
import { USERS } from "e2e/support/cypress_data";
|
||||
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
|
||||
import { getSdkRoot } from "e2e/support/helpers/e2e-embedding-sdk-helpers";
|
||||
import {
|
||||
DEFAULT_SDK_AUTH_PROVIDER_CONFIG,
|
||||
mountSdkContent,
|
||||
} from "e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-helpers";
|
||||
import {
|
||||
getSignedJwtForUser,
|
||||
signInAsAdminAndEnableEmbeddingSdk,
|
||||
} from "e2e/support/helpers/embedding-sdk-testing";
|
||||
import { mockAuthProviderAndJwtSignIn } from "e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers";
|
||||
|
||||
describe("scenarios > embedding-sdk > requests", () => {
|
||||
@@ -23,5 +36,39 @@ describe("scenarios > embedding-sdk > requests", () => {
|
||||
expect(maxAgeHeader).to.equal("60");
|
||||
});
|
||||
});
|
||||
|
||||
it("properly performs session token refresh request when multiple data requests are triggered at the same time", () => {
|
||||
const expiredInSeconds = 60;
|
||||
cy.clock(Date.now());
|
||||
|
||||
cy.then(() => getSignedJwtForUser({ expiredInSeconds })).then((jwt) => {
|
||||
mockAuthProviderAndJwtSignIn(USERS.admin, { jwt });
|
||||
});
|
||||
|
||||
cy.mount(
|
||||
<MetabaseProvider authConfig={DEFAULT_SDK_AUTH_PROVIDER_CONFIG}>
|
||||
<InteractiveQuestion questionId={ORDERS_QUESTION_ID} />
|
||||
</MetabaseProvider>,
|
||||
);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByText("Orders").should("exist");
|
||||
|
||||
cy.findByText("Group").click();
|
||||
|
||||
cy.findByRole("dialog").should("be.visible");
|
||||
|
||||
cy.tick(1000 * (expiredInSeconds + 5));
|
||||
|
||||
cy.findByRole("dialog").contains(/^ID$/).click();
|
||||
cy.findByRole("dialog").findByTestId("badge-remove-button").click();
|
||||
|
||||
cy.wait("@jwtProvider");
|
||||
|
||||
cy.intercept("POST", "/api/dataset").as("dataset");
|
||||
// We ensure that both `dataset` requests are made after the token refresh request
|
||||
cy.get("@dataset.all").should("have.length", 2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useState } from "react";
|
||||
|
||||
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
|
||||
import {
|
||||
type NativeQuestionDetails,
|
||||
createNativeQuestion,
|
||||
tableInteractiveBody,
|
||||
} from "e2e/support/helpers";
|
||||
@@ -15,122 +16,281 @@ import { signInAsAdminAndEnableEmbeddingSdk } from "e2e/support/helpers/embeddin
|
||||
import { mockAuthProviderAndJwtSignIn } from "e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers";
|
||||
import { Box, Button } from "metabase/ui";
|
||||
import type { DatasetColumn } from "metabase-types/api";
|
||||
import { createMockParameter } from "metabase-types/api/mocks";
|
||||
|
||||
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
|
||||
|
||||
describe("scenarios > embedding-sdk > interactive-question > native", () => {
|
||||
beforeEach(() => {
|
||||
signInAsAdminAndEnableEmbeddingSdk();
|
||||
const setup = ({ question }: { question: NativeQuestionDetails }) => {
|
||||
signInAsAdminAndEnableEmbeddingSdk();
|
||||
|
||||
createNativeQuestion(
|
||||
{
|
||||
native: {
|
||||
query: "SELECT * FROM orders WHERE {{ID}}",
|
||||
"template-tags": {
|
||||
ID: {
|
||||
id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
|
||||
name: "ID",
|
||||
"display-name": "ID",
|
||||
type: "dimension",
|
||||
dimension: ["field", ORDERS.ID, null],
|
||||
"widget-type": "category",
|
||||
default: null,
|
||||
createNativeQuestion(question, { wrapId: true });
|
||||
|
||||
cy.signOut();
|
||||
mockAuthProviderAndJwtSignIn();
|
||||
};
|
||||
|
||||
const ensureParameterColumnValue = ({
|
||||
columnName,
|
||||
columnValue,
|
||||
}: {
|
||||
columnName: string;
|
||||
columnValue: string;
|
||||
}) => {
|
||||
tableInteractiveBody().within(() => {
|
||||
cy.get(`[data-column-id="${columnName}"]`).each((cell) => {
|
||||
cy.wrap(cell).should("have.text", columnValue);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describe("scenarios > embedding-sdk > interactive-question > native", () => {
|
||||
describe("common", () => {
|
||||
beforeEach(() => {
|
||||
setup({
|
||||
question: {
|
||||
native: {
|
||||
query: "SELECT * FROM orders WHERE {{ID}}",
|
||||
"template-tags": {
|
||||
ID: {
|
||||
id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
|
||||
name: "ID",
|
||||
"display-name": "ID",
|
||||
type: "dimension",
|
||||
dimension: ["field", ORDERS.ID, null],
|
||||
"widget-type": "category",
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ wrapId: true },
|
||||
);
|
||||
|
||||
cy.signOut();
|
||||
mockAuthProviderAndJwtSignIn();
|
||||
});
|
||||
|
||||
it("supports passing sql parameters to native questions", () => {
|
||||
mountInteractiveQuestion({ initialSqlParameters: { ID: ORDERS_ID } });
|
||||
|
||||
cy.wait("@cardQuery").then(({ response }) => {
|
||||
const { body } = response ?? {};
|
||||
|
||||
const rows = tableInteractiveBody().findAllByRole("row");
|
||||
|
||||
// There should be one row in the table
|
||||
rows.should("have.length", 1);
|
||||
|
||||
const idColumnIndex = body.data.cols.findIndex(
|
||||
(column: DatasetColumn) => column.name === "ID",
|
||||
);
|
||||
|
||||
// The first row should have the same ID column value as the initial SQL parameters
|
||||
// eslint-disable-next-line no-unsafe-element-filtering
|
||||
rows
|
||||
.findAllByTestId("cell-data")
|
||||
.eq(idColumnIndex)
|
||||
.should("have.text", String(ORDERS_ID));
|
||||
});
|
||||
});
|
||||
|
||||
it("should not crash when switching from new question to native question (metabase#60160)", () => {
|
||||
const TestComponent = ({
|
||||
nativeQuestionId,
|
||||
}: {
|
||||
nativeQuestionId: string | number;
|
||||
}) => {
|
||||
const [questionId, setQuestionId] = useState<string | number>("new");
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<InteractiveQuestion questionId={questionId} />
|
||||
|
||||
<Button onClick={() => setQuestionId(nativeQuestionId)}>
|
||||
use native question
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
cy.get<string>("@questionId").then((nativeQuestionId) => {
|
||||
mountSdkContent(<TestComponent nativeQuestionId={nativeQuestionId} />);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByText("Pick your starting data").should("be.visible");
|
||||
});
|
||||
});
|
||||
|
||||
cy.findByText("use native question").click();
|
||||
it("supports passing sql parameters to native questions", () => {
|
||||
mountInteractiveQuestion({ initialSqlParameters: { ID: ORDERS_ID } });
|
||||
|
||||
cy.wait("@cardQuery").then(({ response }) => {
|
||||
const { body } = response ?? {};
|
||||
|
||||
const rows = tableInteractiveBody().findAllByRole("row");
|
||||
|
||||
// There should be one row in the table
|
||||
rows.should("have.length", 1);
|
||||
|
||||
const idColumnIndex = body.data.cols.findIndex(
|
||||
(column: DatasetColumn) => column.name === "ID",
|
||||
);
|
||||
|
||||
// The first row should have the same ID column value as the initial SQL parameters
|
||||
// eslint-disable-next-line no-unsafe-element-filtering
|
||||
rows
|
||||
.findAllByTestId("cell-data")
|
||||
.eq(idColumnIndex)
|
||||
.should("have.text", String(ORDERS_ID));
|
||||
});
|
||||
});
|
||||
|
||||
it("should not crash when switching from new question to native question (metabase#60160)", () => {
|
||||
const TestComponent = ({
|
||||
nativeQuestionId,
|
||||
}: {
|
||||
nativeQuestionId: string | number;
|
||||
}) => {
|
||||
const [questionId, setQuestionId] = useState<string | number>("new");
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<InteractiveQuestion questionId={questionId} />
|
||||
|
||||
<Button onClick={() => setQuestionId(nativeQuestionId)}>
|
||||
use native question
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
cy.get<string>("@questionId").then((nativeQuestionId) => {
|
||||
mountSdkContent(<TestComponent nativeQuestionId={nativeQuestionId} />);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByText("Pick your starting data").should("be.visible");
|
||||
});
|
||||
|
||||
cy.findByText("use native question").click();
|
||||
|
||||
cy.log("should show native question table data");
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByText("Pick your starting data").should("not.exist");
|
||||
cy.findByText("test question").should("be.visible");
|
||||
cy.findByText("110.93").should("be.visible");
|
||||
});
|
||||
|
||||
cy.log("should not crash due to preview-query error");
|
||||
cy.on("uncaught:exception", (error) => {
|
||||
expect(
|
||||
error.message.includes(
|
||||
"preview-query cannot be called on native queries",
|
||||
),
|
||||
).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should not show filter/summarize/breakout buttons for native questions", () => {
|
||||
mountInteractiveQuestion({});
|
||||
|
||||
cy.log("should show native question table data");
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByText("Pick your starting data").should("not.exist");
|
||||
cy.log("should show native question data");
|
||||
cy.findByText("test question").should("be.visible");
|
||||
cy.findByText("110.93").should("be.visible");
|
||||
});
|
||||
|
||||
cy.log("should not crash due to preview-query error");
|
||||
cy.on("uncaught:exception", (error) => {
|
||||
expect(
|
||||
error.message.includes(
|
||||
"preview-query cannot be called on native queries",
|
||||
),
|
||||
).to.be.false;
|
||||
cy.log("should not show Filter button");
|
||||
cy.findByText("Filter").should("not.exist");
|
||||
|
||||
cy.log("should not show Summarize button");
|
||||
cy.findByText("Summarize").should("not.exist");
|
||||
|
||||
cy.log("should not show Group button");
|
||||
cy.findByText("Group").should("not.exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should not show filter/summarize/breakout buttons for native questions", () => {
|
||||
mountInteractiveQuestion({});
|
||||
describe("editable parameters for a native question", () => {
|
||||
beforeEach(() => {
|
||||
setup({
|
||||
question: {
|
||||
native: {
|
||||
query:
|
||||
"SELECT * FROM people WHERE state = {{State}} [[ and city = {{City}} ]] [[ and source = {{Source}} ]]",
|
||||
"template-tags": {
|
||||
State: {
|
||||
type: "text",
|
||||
name: "State",
|
||||
id: "1",
|
||||
"display-name": "State",
|
||||
},
|
||||
City: {
|
||||
type: "text",
|
||||
name: "City",
|
||||
id: "2",
|
||||
"display-name": "City",
|
||||
},
|
||||
Source: {
|
||||
type: "text",
|
||||
name: "Source",
|
||||
id: "3",
|
||||
"display-name": "Source",
|
||||
},
|
||||
},
|
||||
},
|
||||
parameters: [
|
||||
createMockParameter({
|
||||
id: "1",
|
||||
slug: "State",
|
||||
}),
|
||||
createMockParameter({
|
||||
id: "2",
|
||||
slug: "City",
|
||||
}),
|
||||
createMockParameter({
|
||||
id: "3",
|
||||
slug: "Source",
|
||||
}),
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.log("should show native question data");
|
||||
cy.findByText("test question").should("be.visible");
|
||||
it("does not show editable sql parameters controls for the default view", () => {
|
||||
mountInteractiveQuestion({
|
||||
initialSqlParameters: { State: "NY" },
|
||||
hiddenParameters: ["Source"],
|
||||
});
|
||||
|
||||
cy.log("should not show Filter button");
|
||||
cy.findByText("Filter").should("not.exist");
|
||||
cy.wait("@cardQuery");
|
||||
|
||||
cy.log("should not show Summarize button");
|
||||
cy.findByText("Summarize").should("not.exist");
|
||||
cy.findByTestId("parameter-widget").should("not.exist");
|
||||
cy.findByPlaceholderText("State").should("not.exist");
|
||||
cy.findByPlaceholderText("City").should("not.exist");
|
||||
cy.findByPlaceholderText("Source").should("not.exist");
|
||||
});
|
||||
|
||||
cy.log("should not show Group button");
|
||||
cy.findByText("Group").should("not.exist");
|
||||
describe("when `SqlParametersList` component is defined in a custom question layout", () => {
|
||||
it("allows to edit sql parameters", () => {
|
||||
mountInteractiveQuestion({
|
||||
hiddenParameters: ["Source"],
|
||||
children: (
|
||||
<>
|
||||
<InteractiveQuestion.Title />
|
||||
<InteractiveQuestion.SqlParametersList />
|
||||
<InteractiveQuestion.QuestionVisualization />
|
||||
</>
|
||||
),
|
||||
});
|
||||
|
||||
cy.wait("@cardQuery");
|
||||
|
||||
cy.findByPlaceholderText("State").should("exist");
|
||||
cy.findByPlaceholderText("City").should("exist");
|
||||
cy.findByPlaceholderText("Source").should("not.exist");
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByPlaceholderText("State").clear().type("NY{enter}");
|
||||
});
|
||||
|
||||
ensureParameterColumnValue({
|
||||
columnName: "STATE",
|
||||
columnValue: "NY",
|
||||
});
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByPlaceholderText("State").clear().type("AR{enter}");
|
||||
});
|
||||
|
||||
ensureParameterColumnValue({
|
||||
columnName: "STATE",
|
||||
columnValue: "AR",
|
||||
});
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByPlaceholderText("City").type("El Paso{enter}");
|
||||
});
|
||||
|
||||
ensureParameterColumnValue({
|
||||
columnName: "CITY",
|
||||
columnValue: "El Paso",
|
||||
});
|
||||
});
|
||||
|
||||
it("initializes sql parameters controls with initial values and keeps an initial value when changing other parameters", () => {
|
||||
mountInteractiveQuestion({
|
||||
initialSqlParameters: { State: "AR" },
|
||||
hiddenParameters: ["Source"],
|
||||
children: (
|
||||
<>
|
||||
<InteractiveQuestion.Title />
|
||||
<InteractiveQuestion.SqlParametersList />
|
||||
<InteractiveQuestion.QuestionVisualization />
|
||||
</>
|
||||
),
|
||||
});
|
||||
|
||||
cy.wait("@cardQuery");
|
||||
|
||||
ensureParameterColumnValue({
|
||||
columnName: "STATE",
|
||||
columnValue: "AR",
|
||||
});
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByPlaceholderText("City").type("El Paso{enter}");
|
||||
});
|
||||
|
||||
ensureParameterColumnValue({
|
||||
columnName: "CITY",
|
||||
columnValue: "El Paso",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,9 +4,11 @@ import {
|
||||
InteractiveDashboard,
|
||||
InteractiveQuestion,
|
||||
MetabaseProvider,
|
||||
type MetabaseTheme,
|
||||
StaticQuestion,
|
||||
defineMetabaseTheme,
|
||||
} from "@metabase/embedding-sdk-react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
|
||||
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
|
||||
@@ -132,6 +134,42 @@ describe("scenarios > embedding-sdk > styles", () => {
|
||||
.invoke("css", "color")
|
||||
.should("equal", "rgb(255, 0, 0)");
|
||||
});
|
||||
|
||||
it('should be able to reset theme colors by setting it to "undefined" (EMB-696)', () => {
|
||||
const THEME = defineMetabaseTheme({
|
||||
colors: {
|
||||
"text-primary": "#0000ff",
|
||||
},
|
||||
});
|
||||
function TestComponent() {
|
||||
const [theme, setTheme] = useState<MetabaseTheme | undefined>(
|
||||
undefined,
|
||||
);
|
||||
return (
|
||||
<MetabaseProvider
|
||||
authConfig={DEFAULT_SDK_AUTH_PROVIDER_CONFIG}
|
||||
theme={theme}
|
||||
>
|
||||
<button onClick={() => setTheme(THEME)}>Set theme</button>
|
||||
<button onClick={() => setTheme(undefined)}>Remove theme</button>
|
||||
<InteractiveQuestion questionId={ORDERS_QUESTION_ID} />
|
||||
</MetabaseProvider>
|
||||
);
|
||||
}
|
||||
cy.mount(<TestComponent />);
|
||||
|
||||
getSdkRoot().within(() => {
|
||||
cy.findByRole("button", { name: "Set theme" }).click();
|
||||
cy.findByText("Orders")
|
||||
.invoke("css", "color")
|
||||
.should("equal", "rgb(0, 0, 255)");
|
||||
cy.findByRole("button", { name: "Remove theme" }).click();
|
||||
cy.findByText("Orders")
|
||||
.invoke("css", "color")
|
||||
// --mb-color-text-primary
|
||||
.should("equal", "rgb(76, 87, 115)");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("style leaking", () => {
|
||||
|
||||
@@ -122,9 +122,9 @@ describe("admin > database > add", () => {
|
||||
.click({ force: true })
|
||||
.should("have.attr", "data-checked", "true");
|
||||
|
||||
cy.findByLabelText(
|
||||
cy.findByDisplayValue(
|
||||
"Never, I'll do this manually if I need to",
|
||||
).should("have.attr", "aria-selected", "true");
|
||||
).should("exist");
|
||||
|
||||
// make sure tooltips behave as expected
|
||||
cy.findByLabelText("Host")
|
||||
@@ -243,11 +243,9 @@ describe("admin > database > add", () => {
|
||||
"true",
|
||||
);
|
||||
|
||||
cy.findByLabelText("Never, I'll do this manually if I need to").should(
|
||||
"have.attr",
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
cy.findByDisplayValue(
|
||||
"Never, I'll do this manually if I need to",
|
||||
).should("exist");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -711,17 +709,15 @@ describe("scenarios > admin > databases > sample database", () => {
|
||||
});
|
||||
|
||||
// "lets you change the cache_field_values period"
|
||||
cy.findByLabelText("Never, I'll do this manually if I need to").should(
|
||||
"have.attr",
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
cy.findByDisplayValue("Never, I'll do this manually if I need to")
|
||||
.should("be.visible")
|
||||
.click();
|
||||
|
||||
cy.findByLabelText("Regularly, on a schedule")
|
||||
.click()
|
||||
.within(() => {
|
||||
cy.findByText("Daily").click();
|
||||
});
|
||||
H.popover().findByText("Regularly, on a schedule").click();
|
||||
cy.findAllByRole("button", { name: /Daily/ })
|
||||
.should("have.length", 2)
|
||||
.eq(1)
|
||||
.click();
|
||||
H.popover().findByText("Weekly").click();
|
||||
|
||||
cy.button("Save changes").click();
|
||||
@@ -735,7 +731,8 @@ describe("scenarios > admin > databases > sample database", () => {
|
||||
});
|
||||
|
||||
// "lets you change the cache_field_values to 'Only when adding a new filter widget'"
|
||||
cy.findByLabelText("Only when adding a new filter widget").click();
|
||||
cy.findByDisplayValue("Regularly, on a schedule").click();
|
||||
H.popover().findByText("Only when adding a new filter widget").click();
|
||||
cy.button("Save changes", { timeout: 10000 }).click();
|
||||
cy.wait("@databaseUpdate").then(({ response: { body } }) => {
|
||||
editDatabase();
|
||||
@@ -744,7 +741,8 @@ describe("scenarios > admin > databases > sample database", () => {
|
||||
});
|
||||
|
||||
// and back to never
|
||||
cy.findByLabelText("Never, I'll do this manually if I need to").click();
|
||||
cy.findByDisplayValue("Only when adding a new filter widget").click();
|
||||
H.popover().findByText("Never, I'll do this manually if I need to").click();
|
||||
cy.button("Save changes", { timeout: 10000 }).click();
|
||||
cy.wait("@databaseUpdate").then(({ response: { body } }) => {
|
||||
editDatabase();
|
||||
@@ -769,7 +767,8 @@ describe("scenarios > admin > databases > sample database", () => {
|
||||
});
|
||||
|
||||
editDatabase();
|
||||
cy.findByLabelText("Regularly, on a schedule").click();
|
||||
cy.findByDisplayValue("Never, I'll do this manually if I need to").click();
|
||||
H.popover().findByText("Regularly, on a schedule").click();
|
||||
cy.button("Save changes").click();
|
||||
cy.wait("@databaseUpdate").then(({ request: { body } }) => {
|
||||
expect(body.is_full_sync).to.equal(true);
|
||||
@@ -783,7 +782,8 @@ describe("scenarios > admin > databases > sample database", () => {
|
||||
});
|
||||
|
||||
editDatabase();
|
||||
cy.findByLabelText("Only when adding a new filter widget").click();
|
||||
cy.findByDisplayValue("Regularly, on a schedule").click();
|
||||
H.popover().findByText("Only when adding a new filter widget").click();
|
||||
cy.button("Save changes").click();
|
||||
cy.wait("@databaseUpdate").then(({ request: { body } }) => {
|
||||
expect(body.is_full_sync).to.equal(false);
|
||||
|
||||
@@ -1036,7 +1036,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
column: "New tax",
|
||||
values: ["2.07", "6.1", "2.9", "6.01", "7.03"],
|
||||
});
|
||||
verifyObjectDetailPreview({ index: 4, row: ["New tax", "2.07"] });
|
||||
verifyObjectDetailPreview({ rowNumber: 4, row: ["New tax", "2.07"] });
|
||||
|
||||
cy.log("verify viz");
|
||||
H.openOrdersTable();
|
||||
@@ -1429,7 +1429,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
column: "New tax",
|
||||
values: ["2.07", "6.1", "2.9", "6.01", "7.03"],
|
||||
});
|
||||
verifyObjectDetailPreview({ index: 4, row: ["New tax", "2.07"] });
|
||||
verifyObjectDetailPreview({ rowNumber: 4, row: ["New tax", "2.07"] });
|
||||
|
||||
cy.log("verify viz");
|
||||
H.openOrdersTable();
|
||||
@@ -1571,7 +1571,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["14", "123", "105", "94", "132"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 2,
|
||||
rowNumber: 2,
|
||||
row: ["Remapped Product ID", "14"],
|
||||
});
|
||||
|
||||
@@ -1669,7 +1669,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 4,
|
||||
rowNumber: 4,
|
||||
row: ["Rating", "December 31, 1969, 4:00 PM"],
|
||||
});
|
||||
|
||||
@@ -1718,7 +1718,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 4,
|
||||
rowNumber: 4,
|
||||
row: ["Rating", "December 31, 1969, 4:00 PM"],
|
||||
});
|
||||
|
||||
@@ -1989,8 +1989,8 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["2.07", "6.10", "2.90", "6.01", "7.03"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 4,
|
||||
row: ["Tax ($)", "$2.07"],
|
||||
rowNumber: 4,
|
||||
row: ["Tax ($)", "2.07"],
|
||||
});
|
||||
|
||||
cy.log("change currency");
|
||||
@@ -2009,8 +2009,8 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["2.07", "6.10", "2.90", "6.01", "7.03"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 4,
|
||||
row: ["Tax (CA$)", "CA$2.07"],
|
||||
rowNumber: 4,
|
||||
row: ["Tax (CA$)", "2.07"],
|
||||
});
|
||||
|
||||
cy.log("verify viz");
|
||||
@@ -2175,7 +2175,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["2.07", "6.1", "2.9", "6.01", "7.03"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 4,
|
||||
rowNumber: 4,
|
||||
row: ["Tax", "2.07"],
|
||||
});
|
||||
|
||||
@@ -2293,7 +2293,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
.should("be.visible");
|
||||
cy.get("@dataset.all").should("have.length", 0);
|
||||
verifyObjectDetailPreview({
|
||||
index: 4,
|
||||
rowNumber: 4,
|
||||
row: ["Tax", "2.07"],
|
||||
});
|
||||
|
||||
@@ -2509,7 +2509,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["14", "123", "105", "94", "132"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 2,
|
||||
rowNumber: 2,
|
||||
row: ["Product ID", "14"],
|
||||
});
|
||||
|
||||
@@ -2529,7 +2529,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
|
||||
cy.log("verify preview");
|
||||
verifyObjectDetailPreview({
|
||||
index: 2,
|
||||
rowNumber: 2,
|
||||
row: ["Product ID", "Awesome Concrete Shoes"],
|
||||
});
|
||||
verifyTablePreview({
|
||||
@@ -2670,7 +2670,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
cy.log("verify preview");
|
||||
FieldSection.getPreviewButton().click();
|
||||
verifyObjectDetailPreview({
|
||||
index: 2,
|
||||
rowNumber: 2,
|
||||
row: ["Product ID", "Awesome Concrete Shoes"],
|
||||
});
|
||||
verifyTablePreview({
|
||||
@@ -2755,7 +2755,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 3,
|
||||
rowNumber: 3,
|
||||
row: ["Rating", "Perfecto"],
|
||||
});
|
||||
|
||||
@@ -2846,6 +2846,10 @@ describe("scenarios > admin > datamodel", () => {
|
||||
'You can only use custom mapping for numerical fields with filtering set to "A list of all values"',
|
||||
);
|
||||
|
||||
cy.log("close popover by clicking on element inside panel");
|
||||
FieldSection.get().findByText("Field settings").click();
|
||||
|
||||
cy.log("open popover");
|
||||
FieldSection.getFilteringInput().click();
|
||||
H.popover().findByText("A list of all values").click();
|
||||
cy.wait("@updateField");
|
||||
@@ -2898,7 +2902,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 1,
|
||||
rowNumber: 1,
|
||||
row: ["User ID", "2023-10-07T01:34:35.462-07:00"],
|
||||
});
|
||||
|
||||
@@ -2952,7 +2956,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["10", "10"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 1,
|
||||
rowNumber: 1,
|
||||
row: ["Json → A", "10"],
|
||||
});
|
||||
|
||||
@@ -3107,7 +3111,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["200%", "300%", "200%", "600%", "500%"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 8,
|
||||
rowNumber: 8,
|
||||
row: ["Quantity", "200%"],
|
||||
});
|
||||
});
|
||||
@@ -3177,7 +3181,7 @@ describe("scenarios > admin > datamodel", () => {
|
||||
values: ["about 2", "about 3", "about 2", "about 6", "about 5"],
|
||||
});
|
||||
verifyObjectDetailPreview({
|
||||
index: 8,
|
||||
rowNumber: 8,
|
||||
row: ["Quantity", "about 2"],
|
||||
});
|
||||
|
||||
@@ -3865,31 +3869,28 @@ function verifyTablePreview({
|
||||
}
|
||||
|
||||
function verifyObjectDetailPreview({
|
||||
index,
|
||||
rowNumber,
|
||||
row,
|
||||
}: {
|
||||
index: number;
|
||||
rowNumber: number;
|
||||
row: [string, string];
|
||||
}) {
|
||||
const [label, value] = row;
|
||||
const labelIndex = index * 2;
|
||||
const valueIndex = labelIndex + 1;
|
||||
|
||||
PreviewSection.getPreviewTypeInput().findByText("Detail").click();
|
||||
cy.wait("@dataset");
|
||||
|
||||
cy.findAllByTestId("object-details-table-cell").should((elements) => {
|
||||
const index = [...elements].findIndex(
|
||||
(element) => element.textContent?.trim() === label,
|
||||
);
|
||||
expect(index).to.eq(labelIndex);
|
||||
});
|
||||
cy.findAllByTestId("column-name").then(($els) => {
|
||||
const foundRowIndex = $els
|
||||
.toArray()
|
||||
.findIndex((el) => el.textContent?.trim() === label);
|
||||
|
||||
cy.findAllByTestId("object-details-table-cell").should((elements) => {
|
||||
const index = [...elements].findIndex(
|
||||
(element) => element.textContent?.trim() === value,
|
||||
);
|
||||
expect(index).to.eq(valueIndex);
|
||||
expect(rowNumber).to.eq(foundRowIndex);
|
||||
|
||||
cy.findAllByTestId("value")
|
||||
.should("have.length.gte", foundRowIndex)
|
||||
.eq(foundRowIndex)
|
||||
.should("contain", value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const { H } = cy;
|
||||
|
||||
import dedent from "ts-dedent";
|
||||
|
||||
import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";
|
||||
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
|
||||
import type {
|
||||
CardType,
|
||||
ListTransformRunsResponse,
|
||||
PythonTransformTableAliases,
|
||||
TransformTagId,
|
||||
} from "metabase-types/api";
|
||||
|
||||
@@ -127,7 +129,7 @@ H.describeWithSnowplowEE("scenarios > admin > transforms", () => {
|
||||
it("should be able to use the data reference and snippets when writing a SQL transform", () => {
|
||||
H.createSnippet({
|
||||
name: "snippet1",
|
||||
content: "1",
|
||||
content: "'foo'",
|
||||
});
|
||||
|
||||
visitTransformListPage();
|
||||
@@ -175,12 +177,135 @@ H.describeWithSnowplowEE("scenarios > admin > transforms", () => {
|
||||
.click();
|
||||
|
||||
editorSidebar().should("not.exist");
|
||||
|
||||
cy.findByTestId("native-query-editor-action-buttons")
|
||||
.findByLabelText("Preview the query")
|
||||
.click();
|
||||
|
||||
H.modal().findByText("'foo'").should("be.visible");
|
||||
}
|
||||
|
||||
testDataReference();
|
||||
testSnippets();
|
||||
});
|
||||
|
||||
it(
|
||||
"should be possible to create and run a Python transform",
|
||||
{ tags: ["@transforms-python"] },
|
||||
() => {
|
||||
setPythonRunnerSettings();
|
||||
cy.log("create a new transform");
|
||||
visitTransformListPage();
|
||||
getTransformListPage().button("Create a transform").click();
|
||||
H.popover().findByText("Python script").click();
|
||||
|
||||
H.expectUnstructuredSnowplowEvent({
|
||||
event: "transform_create",
|
||||
event_detail: "python",
|
||||
triggered_from: "transform-page-create-menu",
|
||||
});
|
||||
|
||||
cy.findByTestId("python-data-picker")
|
||||
.findByText("Select a database")
|
||||
.click();
|
||||
|
||||
cy.log("Unsupported databases should be disabled");
|
||||
H.popover()
|
||||
.findByRole("option", { name: "Sample Database" })
|
||||
.should("have.attr", "aria-disabled", "true");
|
||||
|
||||
cy.log("Select database");
|
||||
H.popover().findByText(DB_NAME).click();
|
||||
|
||||
getPythonDataPicker().button("Select a table…").click();
|
||||
H.entityPickerModal().findByText("Animals").click();
|
||||
|
||||
getPythonDataPicker().within(() => {
|
||||
cy.findByText("Writable Postgres12 / Schema A").should("be.visible");
|
||||
cy.findByText("Animals").should("be.visible");
|
||||
cy.findByPlaceholderText("Enter alias").should(
|
||||
"have.value",
|
||||
"animals",
|
||||
);
|
||||
cy.findByPlaceholderText("Enter alias")
|
||||
.clear()
|
||||
.type("foo bar")
|
||||
.blur();
|
||||
cy.findByPlaceholderText("Enter alias").should(
|
||||
"have.value",
|
||||
"foo_bar",
|
||||
);
|
||||
});
|
||||
|
||||
H.PythonEditor.value()
|
||||
.should("contain", "def transform(foo_bar):")
|
||||
.should(
|
||||
"contain",
|
||||
'foo_bar: DataFrame containing the data from the "Writable Postgres12.Schema A.Animals" table',
|
||||
);
|
||||
|
||||
getPythonDataPicker().within(() => {
|
||||
cy.findByText("Add a table").click();
|
||||
cy.button("Select a table…").click();
|
||||
});
|
||||
|
||||
H.entityPickerModal().within(() => {
|
||||
cy.log("Selecting the same table should not be possible");
|
||||
cy.findByText("Animals")
|
||||
.parent()
|
||||
.parent()
|
||||
.parent()
|
||||
.should("have.attr", "data-disabled", "true");
|
||||
|
||||
cy.findByText("Schema B").click();
|
||||
cy.findByText("Animals").click();
|
||||
});
|
||||
|
||||
getPythonDataPicker().within(() => {
|
||||
cy.icon("refresh").click();
|
||||
cy.findAllByPlaceholderText("Enter alias")
|
||||
.first()
|
||||
.should("have.value", "animals_1")
|
||||
.clear()
|
||||
.type("foo bar")
|
||||
.blur()
|
||||
.should("have.value", "foo_bar");
|
||||
cy.findAllByPlaceholderText("Enter alias")
|
||||
.eq(1)
|
||||
.should("have.value", "animals")
|
||||
.clear()
|
||||
.type("foo bar")
|
||||
.blur()
|
||||
.should("have.value", "foo_bar_1");
|
||||
});
|
||||
|
||||
getQueryEditor().button("Save").click();
|
||||
|
||||
H.modal().within(() => {
|
||||
cy.findByLabelText("Name").clear().type("Python transform");
|
||||
cy.findByLabelText("Table name").clear().type("python_transform");
|
||||
cy.button("Save").click();
|
||||
});
|
||||
|
||||
H.expectUnstructuredSnowplowEvent({
|
||||
event: "transform_created",
|
||||
});
|
||||
|
||||
cy.log("run the transform and make sure its table can be queried");
|
||||
runTransformAndWaitForSuccess();
|
||||
H.expectUnstructuredSnowplowEvent({
|
||||
event: "transform_trigger_manual_run",
|
||||
triggered_from: "transform-page",
|
||||
});
|
||||
|
||||
getRunSection().should("contain", "Executing Python transform");
|
||||
|
||||
getTableLink().click();
|
||||
H.queryBuilderHeader().findByText(DB_NAME).should("be.visible");
|
||||
H.assertQueryBuilderRowCount(1);
|
||||
},
|
||||
);
|
||||
|
||||
it("should be able to create and run a transform from a question or a model", () => {
|
||||
function testCardSource({
|
||||
type,
|
||||
@@ -511,6 +636,114 @@ LIMIT
|
||||
});
|
||||
});
|
||||
|
||||
describe("filtering", () => {
|
||||
it("should be able to filter transforms", () => {
|
||||
createMbqlTransform({ visitTransform: true });
|
||||
runJobAndWaitForSuccess();
|
||||
|
||||
createSqlTransform({
|
||||
sourceQuery: `SELECT * FROM "${TARGET_SCHEMA}"."${SOURCE_TABLE}"`,
|
||||
targetTable: TARGET_TABLE_2,
|
||||
visitTransform: true,
|
||||
});
|
||||
getTagsInput().click();
|
||||
H.popover().findByText("hourly").click();
|
||||
H.undoToast().findByText("Transform tags updated").should("be.visible");
|
||||
|
||||
visitTransformListPage();
|
||||
|
||||
function testLastRunDateFilter() {
|
||||
cy.log("no filters");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
});
|
||||
|
||||
cy.log("last run at - add a filter");
|
||||
getLastRunDateFilterWidget().click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("Relative date range…").click();
|
||||
cy.findByText("Current").click();
|
||||
cy.findByText("Week").click();
|
||||
});
|
||||
|
||||
getLastRunDateFilterWidget().should("contain", "This week");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("not.exist");
|
||||
});
|
||||
|
||||
cy.log("last run at filter - remove filter");
|
||||
getLastRunDateFilterWidget().button("Remove filter").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
});
|
||||
}
|
||||
|
||||
function testLastRunStatusFilter() {
|
||||
cy.log("no filters");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
});
|
||||
|
||||
cy.log("last run status - add a filter");
|
||||
getLastRunStatusFilterWidget().click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("Success").click();
|
||||
cy.findByText("Add filter").click();
|
||||
});
|
||||
|
||||
getLastRunStatusFilterWidget().should("contain", "Success");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("not.exist");
|
||||
});
|
||||
|
||||
cy.log("last run status filter - remove filter");
|
||||
getLastRunStatusFilterWidget().button("Remove filter").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
});
|
||||
}
|
||||
|
||||
function testTagFilter() {
|
||||
cy.log("no filters");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
});
|
||||
|
||||
cy.log("tags - add a filter");
|
||||
getTagFilterWidget().click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("hourly").click();
|
||||
cy.findByText("daily").click();
|
||||
cy.button("Add filter").click();
|
||||
});
|
||||
|
||||
getTagFilterWidget().should("contain", "2 tags");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
cy.findByText("MBQL transform").should("not.exist");
|
||||
});
|
||||
|
||||
cy.log("last run status filter - remove filter");
|
||||
getTagFilterWidget().button("Remove filter").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
cy.findByText("SQL transform").should("be.visible");
|
||||
});
|
||||
}
|
||||
|
||||
testLastRunDateFilter();
|
||||
testLastRunStatusFilter();
|
||||
testTagFilter();
|
||||
});
|
||||
});
|
||||
|
||||
describe("name and description", () => {
|
||||
it("should be able to edit the name and description after creation", () => {
|
||||
createMbqlTransform({ visitTransform: true });
|
||||
@@ -566,7 +799,6 @@ LIMIT
|
||||
getTagsInput().type("New tag");
|
||||
H.popover().findByText("New tag").click();
|
||||
cy.wait("@createTag");
|
||||
H.popover().findByText("New tag").should("be.visible");
|
||||
H.undoToast().should("contain.text", "Transform tags updated");
|
||||
});
|
||||
|
||||
@@ -622,7 +854,6 @@ LIMIT
|
||||
getTagsInput().type("New tag");
|
||||
H.popover().findByText("New tag").click();
|
||||
cy.wait("@createTag");
|
||||
H.popover().findByText("New tag").should("be.visible");
|
||||
|
||||
cy.log("Navigate to transform B");
|
||||
getNavSidebar().findByText("Transforms").click();
|
||||
@@ -992,6 +1223,7 @@ LIMIT
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
database: WRITABLE_DB_ID,
|
||||
name: TARGET_TABLE,
|
||||
schema: TARGET_SCHEMA,
|
||||
},
|
||||
@@ -1105,6 +1337,7 @@ LIMIT
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
database: WRITABLE_DB_ID,
|
||||
name: TARGET_TABLE,
|
||||
schema: TARGET_SCHEMA,
|
||||
},
|
||||
@@ -1165,6 +1398,38 @@ LIMIT
|
||||
H.queryBuilderHeader().findByText(DB_NAME).should("be.visible");
|
||||
H.assertQueryBuilderRowCount(1);
|
||||
});
|
||||
|
||||
it("should be able to update a Python query", () => {
|
||||
setPythonRunnerSettings();
|
||||
cy.log("create a new transform");
|
||||
H.getTableId({ name: "Animals", databaseId: WRITABLE_DB_ID }).then(
|
||||
(id) => {
|
||||
createPythonTransform({
|
||||
body: dedent`
|
||||
import pandas as pd
|
||||
|
||||
def transform(foo):
|
||||
return pd.DataFrame([{"foo": 42 }])
|
||||
`,
|
||||
sourceTables: { foo: id },
|
||||
visitTransform: true,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
cy.log("update the query");
|
||||
getTransformPage().findByRole("link", { name: "Edit script" }).click();
|
||||
H.PythonEditor.type("{backspace}{backspace}{backspace} + 10 }])");
|
||||
|
||||
getQueryEditor().button("Save changes").click();
|
||||
cy.wait("@updateTransform");
|
||||
|
||||
cy.log("run the transform and make sure the query has changed");
|
||||
runTransformAndWaitForSuccess();
|
||||
getTableLink().click();
|
||||
H.queryBuilderHeader().findByText(DB_NAME).should("be.visible");
|
||||
H.assertQueryBuilderRowCount(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("runs", () => {
|
||||
@@ -1281,6 +1546,7 @@ LIMIT
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
database: WRITABLE_DB_ID,
|
||||
name: TARGET_TABLE,
|
||||
schema: TARGET_SCHEMA,
|
||||
},
|
||||
@@ -1347,7 +1613,7 @@ LIMIT
|
||||
"contain",
|
||||
"Last ran a few seconds ago successfully.",
|
||||
);
|
||||
getRunStatus().should(
|
||||
getRunSection().should(
|
||||
"contain",
|
||||
"This run succeeded before it had a chance to cancel.",
|
||||
);
|
||||
@@ -1391,6 +1657,136 @@ LIMIT
|
||||
H.main().findByText("Dependencies").should("not.exist");
|
||||
});
|
||||
});
|
||||
|
||||
describe("python > common library", () => {
|
||||
it(
|
||||
"should be possible to edit and save the common library",
|
||||
{ tags: ["@transforms-python"] },
|
||||
() => {
|
||||
visitCommonLibrary();
|
||||
|
||||
cy.log("updating the library should be possible");
|
||||
H.PythonEditor.clear().type(
|
||||
dedent`
|
||||
def useful_calculation(a, b):
|
||||
return a + b
|
||||
`,
|
||||
);
|
||||
getLibraryEditorHeader().findByText("Save").click();
|
||||
|
||||
cy.log("the contents should be saved properly");
|
||||
visitCommonLibrary();
|
||||
H.PythonEditor.value().should(
|
||||
"eq",
|
||||
dedent`
|
||||
def useful_calculation(a, b):
|
||||
return a + b
|
||||
`,
|
||||
);
|
||||
|
||||
cy.log("reverting the changes should be possible");
|
||||
H.PythonEditor.clear().type("# oops");
|
||||
getLibraryEditorHeader().findByText("Revert").click();
|
||||
H.PythonEditor.value().should(
|
||||
"eq",
|
||||
dedent`
|
||||
def useful_calculation(a, b):
|
||||
return a + b
|
||||
`,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should be possible to use the common library",
|
||||
{ tags: ["@transforms-python"] },
|
||||
() => {
|
||||
setPythonRunnerSettings();
|
||||
createPythonLibrary(
|
||||
"common.py",
|
||||
dedent`
|
||||
def useful_calculation(a, b):
|
||||
return a + b
|
||||
`,
|
||||
);
|
||||
|
||||
visitTransformListPage();
|
||||
getTransformListPage().button("Create a transform").click();
|
||||
H.popover().findByText("Python script").click();
|
||||
|
||||
H.PythonEditor.clear().type(
|
||||
dedent`
|
||||
import pandas as pd
|
||||
|
||||
def transform():
|
||||
return pd.DataFrame([{"foo": common.useful_calculation(1, 2)}])
|
||||
`,
|
||||
);
|
||||
|
||||
getQueryEditor().findByText("Import common library").click();
|
||||
H.PythonEditor.value().should("contain", "import common");
|
||||
|
||||
cy.findByTestId("python-data-picker")
|
||||
.findByText("Select a database")
|
||||
.click();
|
||||
|
||||
H.popover().findByText(DB_NAME).click();
|
||||
|
||||
cy.findByTestId("python-data-picker")
|
||||
.findByText("Select a table…")
|
||||
.click();
|
||||
|
||||
H.entityPickerModal().within(() => {
|
||||
cy.findByText("Schema a").click();
|
||||
cy.findByText("Animals").click();
|
||||
});
|
||||
|
||||
getQueryEditor().button("Save").click();
|
||||
|
||||
H.modal().within(() => {
|
||||
cy.findByLabelText("Name").clear().type("Python transform");
|
||||
cy.findByLabelText("Table name").clear().type("python_transform");
|
||||
cy.button("Save").click();
|
||||
});
|
||||
|
||||
runTransformAndWaitForSuccess();
|
||||
getTableLink().click();
|
||||
H.queryBuilderHeader()
|
||||
.findByText("Python Transform")
|
||||
.should("be.visible");
|
||||
H.assertQueryBuilderRowCount(1);
|
||||
cy.findByTestId("scalar-value").should("have.text", "3");
|
||||
H.expectUnstructuredSnowplowEvent({
|
||||
event: "transform_created",
|
||||
});
|
||||
|
||||
cy.log("update the common library and run the transform again");
|
||||
cy.go("back");
|
||||
createPythonLibrary(
|
||||
"common.py",
|
||||
dedent`
|
||||
def useful_calculation(a, b):
|
||||
return a + b + 40
|
||||
`,
|
||||
);
|
||||
runTransformAndWaitForSuccess();
|
||||
getTableLink().click();
|
||||
H.queryBuilderHeader()
|
||||
.findByText("Python Transform")
|
||||
.should("be.visible");
|
||||
H.assertQueryBuilderRowCount(1);
|
||||
cy.findByTestId("scalar-value").should("have.text", "43");
|
||||
},
|
||||
);
|
||||
|
||||
function visitCommonLibrary(path = "common.py") {
|
||||
cy.visit(`/admin/transforms/library/${path}`);
|
||||
}
|
||||
|
||||
function getLibraryEditorHeader() {
|
||||
return cy.findByTestId("library-editor-header");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("scenarios > admin > transforms > databases without :schemas", () => {
|
||||
@@ -1547,7 +1943,7 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
tag_ids: [tag.id],
|
||||
});
|
||||
});
|
||||
waitForRuns();
|
||||
H.waitForSucceededTransformRuns();
|
||||
visitRunListPage();
|
||||
getContentTable().within(() => {
|
||||
cy.findAllByText("MBQL transform").should("have.length.gte", 1);
|
||||
@@ -1628,6 +2024,11 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
event: "transform_job_trigger_manual_run",
|
||||
triggered_from: "job-page",
|
||||
});
|
||||
|
||||
getJobPage()
|
||||
.findByText("Last ran a few seconds ago successfully.")
|
||||
.should("be.visible");
|
||||
|
||||
getNavSidebar().findByText("Runs").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("MBQL transform").should("be.visible");
|
||||
@@ -1635,6 +2036,23 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
cy.findByText("Manual").should("be.visible");
|
||||
});
|
||||
});
|
||||
|
||||
it("should display the error message from a failed run", () => {
|
||||
H.createTransformTag({ name: "New tag" }).then(({ body: tag }) => {
|
||||
createSqlTransform({
|
||||
sourceQuery: "SELECT * FROM abc",
|
||||
tagIds: [tag.id],
|
||||
});
|
||||
H.createTransformJob(
|
||||
{ name: "New job", tag_ids: [tag.id] },
|
||||
{ visitTransformJob: true },
|
||||
);
|
||||
});
|
||||
runJobAndWaitForFailure();
|
||||
getJobPage().findByText("Last run failed a few seconds ago.");
|
||||
getRunErrorInfoButton().click();
|
||||
H.modal().should("contain.text", 'relation "abc" does not exist');
|
||||
});
|
||||
});
|
||||
|
||||
describe("deletion", () => {
|
||||
@@ -1689,13 +2107,11 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
it("should be able to filter jobs ", () => {
|
||||
cy.log("run hourly job so know that was recently run");
|
||||
visitJobListPage();
|
||||
|
||||
getContentTable().findByText("Hourly job").click();
|
||||
runJobAndWaitForSuccess();
|
||||
|
||||
visitJobListPage();
|
||||
|
||||
function testLastRunFilter() {
|
||||
function testLastRunDateFilter() {
|
||||
cy.log("no filters");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
@@ -1705,14 +2121,14 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
});
|
||||
|
||||
cy.log("last run at - add a filter");
|
||||
getLastRunAtFilterWidget().click();
|
||||
getLastRunDateFilterWidget().click();
|
||||
H.popover().findByText("Previous month").click();
|
||||
|
||||
getLastRunAtFilterWidget().should("contain", "Previous month");
|
||||
getLastRunDateFilterWidget().should("contain", "Previous month");
|
||||
getContentTable().should("not.exist");
|
||||
|
||||
cy.log("last run at filter - remove filter");
|
||||
getLastRunAtFilterWidget().button("Remove filter").click();
|
||||
getLastRunDateFilterWidget().button("Remove filter").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
cy.findByText("Daily job").should("be.visible");
|
||||
@@ -1721,7 +2137,42 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
});
|
||||
}
|
||||
|
||||
function testNextRunFilter() {
|
||||
function testLastRunStatusFilter() {
|
||||
cy.log("no filters");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
cy.findByText("Daily job").should("be.visible");
|
||||
cy.findByText("Weekly job").should("be.visible");
|
||||
cy.findByText("Monthly job").should("be.visible");
|
||||
});
|
||||
|
||||
cy.log("last run status - add a filter");
|
||||
getLastRunStatusFilterWidget().click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("In progress").click();
|
||||
cy.findByText("Success").click();
|
||||
cy.button("Add filter").click();
|
||||
});
|
||||
|
||||
getLastRunStatusFilterWidget().should("contain", "2 statuses");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
cy.findByText("Daily job").should("not.exist");
|
||||
cy.findByText("Weekly job").should("not.exist");
|
||||
cy.findByText("Monthly job").should("not.exist");
|
||||
});
|
||||
|
||||
cy.log("last run at filter - remove filter");
|
||||
getLastRunStatusFilterWidget().button("Remove filter").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
cy.findByText("Daily job").should("be.visible");
|
||||
cy.findByText("Weekly job").should("be.visible");
|
||||
cy.findByText("Monthly job").should("be.visible");
|
||||
});
|
||||
}
|
||||
|
||||
function testNextRunDateFilter() {
|
||||
cy.log("no filters");
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
@@ -1731,7 +2182,7 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
});
|
||||
|
||||
cy.log("next run - add a filter");
|
||||
getNextRunFilterWidget().click();
|
||||
getNextRunDateFilterWidget().click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("Fixed date range…").click();
|
||||
cy.findByLabelText("Start date").clear().type("12/10/2024");
|
||||
@@ -1739,14 +2190,14 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
cy.button("Apply").click();
|
||||
});
|
||||
|
||||
getNextRunFilterWidget().should(
|
||||
getNextRunDateFilterWidget().should(
|
||||
"contain",
|
||||
"December 10, 2024 - January 5, 2025",
|
||||
);
|
||||
getContentTable().should("not.exist");
|
||||
|
||||
cy.log("next run filter - remove filter");
|
||||
getNextRunFilterWidget().button("Remove filter").click();
|
||||
getNextRunDateFilterWidget().button("Remove filter").click();
|
||||
getContentTable().within(() => {
|
||||
cy.findByText("Hourly job").should("be.visible");
|
||||
cy.findByText("Daily job").should("be.visible");
|
||||
@@ -1819,8 +2270,9 @@ describe("scenarios > admin > transforms > jobs", () => {
|
||||
});
|
||||
}
|
||||
|
||||
testLastRunFilter();
|
||||
testNextRunFilter();
|
||||
testLastRunDateFilter();
|
||||
testLastRunStatusFilter();
|
||||
testNextRunDateFilter();
|
||||
testTagFilter();
|
||||
});
|
||||
});
|
||||
@@ -2245,6 +2697,10 @@ function getRunStatus() {
|
||||
return cy.findByTestId("run-status");
|
||||
}
|
||||
|
||||
function getRunSection() {
|
||||
return cy.findByTestId("run-section");
|
||||
}
|
||||
|
||||
function getRunListLink() {
|
||||
return cy.findByRole("link", { name: "See all runs" });
|
||||
}
|
||||
@@ -2305,12 +2761,16 @@ function getTransformFilterWidget() {
|
||||
return cy.findByRole("group", { name: "Transform" });
|
||||
}
|
||||
|
||||
function getLastRunAtFilterWidget() {
|
||||
function getLastRunDateFilterWidget() {
|
||||
return cy.findByRole("group", { name: "Last run at" });
|
||||
}
|
||||
|
||||
function getNextRunFilterWidget() {
|
||||
return cy.findByRole("group", { name: "Next run" });
|
||||
function getLastRunStatusFilterWidget() {
|
||||
return cy.findByRole("group", { name: "Last run status" });
|
||||
}
|
||||
|
||||
function getNextRunDateFilterWidget() {
|
||||
return cy.findByRole("group", { name: "Next run at" });
|
||||
}
|
||||
|
||||
function getStatusFilterWidget() {
|
||||
@@ -2326,11 +2786,11 @@ function getRunMethodFilterWidget() {
|
||||
}
|
||||
|
||||
function getStartAtFilterWidget() {
|
||||
return cy.findByRole("group", { name: "Start at" });
|
||||
return cy.findByRole("group", { name: "Started at" });
|
||||
}
|
||||
|
||||
function getEndAtFilterWidget() {
|
||||
return cy.findByRole("group", { name: "End at" });
|
||||
return cy.findByRole("group", { name: "Ended at" });
|
||||
}
|
||||
|
||||
function visitTransformListPage() {
|
||||
@@ -2361,6 +2821,11 @@ function runJobAndWaitForSuccess() {
|
||||
getRunButton().should("have.text", "Ran successfully");
|
||||
}
|
||||
|
||||
function runJobAndWaitForFailure() {
|
||||
getRunButton().click();
|
||||
getRunButton().should("have.text", "Run failed");
|
||||
}
|
||||
|
||||
function createMbqlTransform({
|
||||
sourceTable = SOURCE_TABLE,
|
||||
targetTable = TARGET_TABLE,
|
||||
@@ -2395,6 +2860,7 @@ function createMbqlTransform({
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
database: WRITABLE_DB_ID,
|
||||
name: targetTable,
|
||||
schema: targetSchema,
|
||||
},
|
||||
@@ -2433,6 +2899,42 @@ function createSqlTransform({
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
database: WRITABLE_DB_ID,
|
||||
name: targetTable,
|
||||
schema: targetSchema,
|
||||
},
|
||||
tag_ids: tagIds,
|
||||
},
|
||||
{ wrapId: true, visitTransform },
|
||||
);
|
||||
}
|
||||
function createPythonTransform({
|
||||
body,
|
||||
sourceTables,
|
||||
targetTable = TARGET_TABLE,
|
||||
targetSchema = TARGET_SCHEMA,
|
||||
tagIds,
|
||||
visitTransform,
|
||||
}: {
|
||||
body: string;
|
||||
sourceTables: PythonTransformTableAliases;
|
||||
targetTable?: string;
|
||||
targetSchema?: string;
|
||||
tagIds?: TransformTagId[];
|
||||
visitTransform?: boolean;
|
||||
}) {
|
||||
H.createTransform(
|
||||
{
|
||||
name: "Python transform",
|
||||
source: {
|
||||
type: "python",
|
||||
"source-database": WRITABLE_DB_ID,
|
||||
"source-tables": sourceTables,
|
||||
body,
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
database: WRITABLE_DB_ID,
|
||||
name: targetTable,
|
||||
schema: targetSchema,
|
||||
},
|
||||
@@ -2458,24 +2960,6 @@ function visitTableQuestion({
|
||||
);
|
||||
}
|
||||
|
||||
const WAIT_TIMEOUT = 10000;
|
||||
const WAIT_INTERVAL = 100;
|
||||
|
||||
function waitForRuns(timeout = WAIT_TIMEOUT): Cypress.Chainable {
|
||||
return cy
|
||||
.request<ListTransformRunsResponse>("GET", "/api/ee/transform/run")
|
||||
.then((response) => {
|
||||
if (response.body.data.length > 0) {
|
||||
return cy.wrap(response);
|
||||
} else if (timeout > 0) {
|
||||
cy.wait(WAIT_INTERVAL);
|
||||
return waitForRuns(timeout - WAIT_INTERVAL);
|
||||
} else {
|
||||
throw new Error("Run retry timeout");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function assertTableDoesNotExistError({
|
||||
targetTable = TARGET_TABLE,
|
||||
targetSchema = TARGET_SCHEMA,
|
||||
@@ -2496,3 +2980,35 @@ function assertOptionNotSelected(name: string) {
|
||||
function editorSidebar() {
|
||||
return cy.findByTestId("editor-sidebar");
|
||||
}
|
||||
|
||||
function getPythonDataPicker() {
|
||||
return cy.findByTestId("python-data-picker");
|
||||
}
|
||||
|
||||
function createPythonLibrary(path: string, source: string) {
|
||||
cy.request("PUT", `/api/ee/transforms-python/library/${path}`, {
|
||||
source,
|
||||
});
|
||||
}
|
||||
|
||||
function setPythonRunnerSettings() {
|
||||
H.updateEnterpriseSetting("python-runner-url", "http://localhost:5001");
|
||||
H.updateEnterpriseSetting("python-runner-api-token", "dev-token-12345");
|
||||
H.updateEnterpriseSetting(
|
||||
"python-storage-s-3-endpoint",
|
||||
"http://localhost:4566",
|
||||
);
|
||||
H.updateEnterpriseSetting("python-storage-s-3-region", "us-east-1");
|
||||
H.updateEnterpriseSetting(
|
||||
"python-storage-s-3-bucket",
|
||||
"metabase-python-runner",
|
||||
);
|
||||
H.updateEnterpriseSetting("python-storage-s-3-prefix", "test-prefix");
|
||||
H.updateEnterpriseSetting("python-storage-s-3-access-key", "test");
|
||||
H.updateEnterpriseSetting("python-storage-s-3-secret-key", "test");
|
||||
H.updateEnterpriseSetting(
|
||||
"python-storage-s-3-container-endpoint",
|
||||
"http://localstack:4566",
|
||||
);
|
||||
H.updateEnterpriseSetting("python-storage-s-3-path-style-access", true);
|
||||
}
|
||||
|
||||
@@ -99,14 +99,6 @@ describe("collection permissions", () => {
|
||||
it("should be able to duplicate the dashboard without obstructions from the modal (metabase#15256)", () => {
|
||||
duplicate("Orders in a dashboard");
|
||||
});
|
||||
|
||||
it(
|
||||
"should be able to duplicate the question (metabase#15255)",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
duplicate("Orders");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("archive", () => {
|
||||
|
||||
@@ -553,7 +553,10 @@ describe("scenarios > dashboard > dashboard drill", () => {
|
||||
cy.wait("@dataset").then((xhr) => {
|
||||
expect(xhr.response.body.error).not.to.exist;
|
||||
});
|
||||
cy.findByTestId("object-detail").findByText("Fantastic Wool Shirt");
|
||||
cy.findByTestId("object-detail")
|
||||
.findAllByText("Fantastic Wool Shirt")
|
||||
.should("have.length", 2)
|
||||
.and("be.visible");
|
||||
});
|
||||
|
||||
it("should apply correct date range on a graph drill-through (metabase#13785)", () => {
|
||||
|
||||
@@ -33,9 +33,6 @@ function createDashboardDetails({ parameters }) {
|
||||
|
||||
const TOAST_TIMEOUT = 16000;
|
||||
|
||||
const TOAST_MESSAGE =
|
||||
"You can make this dashboard snappier by turning off auto-applying filters.";
|
||||
|
||||
const filterToggleLabel = "Auto-apply filters";
|
||||
|
||||
describe(
|
||||
@@ -288,158 +285,6 @@ describe(
|
||||
H.assertTableRowsCount(200);
|
||||
});
|
||||
});
|
||||
|
||||
it(
|
||||
"should display a toast when a dashboard takes longer than 15s to load even without parameter values (but has parameters with default values)",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
openSlowDashboard();
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().within(() => {
|
||||
cy.findByText(TOAST_MESSAGE).should("be.visible");
|
||||
cy.button("Turn off").click();
|
||||
cy.wait("@updateDashboard");
|
||||
});
|
||||
|
||||
H.openDashboardSettingsSidebar();
|
||||
H.sidesheet()
|
||||
.findByLabelText(filterToggleLabel)
|
||||
.should("not.be.checked");
|
||||
// Gadget
|
||||
const filterDefaultValue = FILTER_WITH_DEFAULT_VALUE.default[0];
|
||||
H.filterWidget().findByText(filterDefaultValue).should("be.visible");
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(53);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should not display the toast when we clear out parameter default value",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
openSlowDashboard({ [FILTER_WITH_DEFAULT_VALUE.slug]: null });
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().should("not.exist");
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(200);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("auto-apply filter toast", () => {
|
||||
it(
|
||||
"should display a toast when a dashboard takes longer than 15s to load",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
createDashboard();
|
||||
openSlowDashboard({ [FILTER.slug]: "Gadget" });
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().within(() => {
|
||||
cy.findByText(TOAST_MESSAGE).should("be.visible");
|
||||
cy.button("Turn off").click();
|
||||
cy.wait("@updateDashboard");
|
||||
});
|
||||
|
||||
H.openDashboardSettingsSidebar();
|
||||
H.sidesheet()
|
||||
.findByLabelText(filterToggleLabel)
|
||||
.should("not.be.checked");
|
||||
H.closeDashboardSettingsSidebar();
|
||||
H.filterWidget().findByText("Gadget").should("be.visible");
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(53);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should display the toast indefinitely unless dismissing manually",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
createDashboard();
|
||||
openSlowDashboard({ [FILTER.slug]: "Gadget" });
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().findByText(TOAST_MESSAGE).should("be.visible");
|
||||
|
||||
cy.tick(100 * TOAST_TIMEOUT);
|
||||
H.undoToast().findByText(TOAST_MESSAGE).should("be.visible");
|
||||
|
||||
H.undoToast().icon("close").click();
|
||||
H.undoToast().should("not.exist");
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should not display the toast when auto applying filters is disabled",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
createDashboard({ dashboardDetails: { auto_apply_filters: false } });
|
||||
openSlowDashboard({ [FILTER.slug]: "Gadget" });
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().should("not.exist");
|
||||
H.filterWidget().findByText("Gadget").should("be.visible");
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(53);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should not display the toast if there are no parameter values",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
createDashboard();
|
||||
openSlowDashboard();
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().should("not.exist");
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should not display the same toast twice for a dashboard",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
createDashboard();
|
||||
openSlowDashboard({ [FILTER.slug]: "Gadget" });
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().within(() => {
|
||||
cy.button("Turn off").should("be.visible");
|
||||
cy.icon("close").click();
|
||||
});
|
||||
H.filterWidget().findByText("Gadget").click();
|
||||
H.popover().within(() => {
|
||||
cy.findByText("Widget").click();
|
||||
cy.findByText("Update filter").click();
|
||||
});
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().should("not.exist");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("no collection curate permission", () => {
|
||||
@@ -456,19 +301,6 @@ describe(
|
||||
H.dashboardHeader().icon("ellipsis").click();
|
||||
H.popover().findByText("Edit settings").should("not.exist");
|
||||
});
|
||||
|
||||
it(
|
||||
"should not display a toast even when a dashboard takes longer than 15s to load",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
cy.clock();
|
||||
openSlowDashboard({ [FILTER.slug]: "Gadget" });
|
||||
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().should("not.exist");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("embeddings", () => {
|
||||
@@ -602,71 +434,6 @@ describe(
|
||||
H.assertTableRowsCount(54);
|
||||
});
|
||||
});
|
||||
|
||||
it(
|
||||
"should display a toast when a dashboard takes longer than 15s to load",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
createDashboard();
|
||||
// Not sure why I need to pass a date in this case, but it doesn't work without it.
|
||||
cy.clock(Date.now());
|
||||
openSlowFullAppEmbeddingDashboard({ [FILTER.slug]: "Gadget" });
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().within(() => {
|
||||
cy.findByText(TOAST_MESSAGE).should("be.visible");
|
||||
cy.button("Turn off").click();
|
||||
cy.wait("@updateDashboard");
|
||||
});
|
||||
|
||||
// In embedding we'll load bookmark after the dashboard is loaded, it's the opposite in normal app because bookmark is cached from somewhere else.
|
||||
// And somehow, dashboard card query will be completed before the dashboard even start to load, and in entity loader it uses `setTimeout`,
|
||||
// so to make sure callback in `setTimeout` is called, we need to advance the clock using cy.tick().
|
||||
cy.tick();
|
||||
|
||||
H.openDashboardSettingsSidebar();
|
||||
H.sidesheet()
|
||||
.findByLabelText(filterToggleLabel)
|
||||
.should("not.be.checked");
|
||||
H.filterWidget().findByText("Gadget").should("be.visible");
|
||||
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(53);
|
||||
});
|
||||
|
||||
// Card result should be updated after manually updating the filter
|
||||
H.filterWidget().icon("close").click();
|
||||
H.applyFilterButton().should("be.visible").click();
|
||||
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(200);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"should not display a toast when a dashboard takes longer than 15s to load if users have no write access to a dashboard",
|
||||
{ tags: "@skip" },
|
||||
() => {
|
||||
createDashboard();
|
||||
cy.signIn("readonly");
|
||||
// Not sure why I need to pass a date in this case, but it doesn't work without it.
|
||||
cy.clock(Date.now());
|
||||
openSlowFullAppEmbeddingDashboard({ [FILTER.slug]: "Gadget" });
|
||||
cy.tick(TOAST_TIMEOUT);
|
||||
cy.wait("@cardQuery");
|
||||
H.undoToast().should("not.exist");
|
||||
|
||||
// In embedding we'll load bookmark after the dashboard is loaded, it's the opposite in normal app because bookmark is cached from somewhere else.
|
||||
// And somehow, dashboard card query will be completed before the dashboard even start to load, and in entity loader it uses `setTimeout`,
|
||||
// so to make sure callback in `setTimeout` is called, we need to advance the clock using cy.tick().
|
||||
cy.tick();
|
||||
|
||||
H.getDashboardCard().within(() => {
|
||||
H.assertTableRowsCount(53);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -753,21 +520,6 @@ const openDashboard = (params = {}) => {
|
||||
H.visitDashboard("@dashboardId", { params });
|
||||
};
|
||||
|
||||
const openSlowDashboard = (params = {}) => {
|
||||
cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
|
||||
"cardQuery",
|
||||
);
|
||||
|
||||
cy.get("@dashboardId").then((dashboardId) => {
|
||||
return cy.visit({
|
||||
url: `/dashboard/${dashboardId}`,
|
||||
qs: params,
|
||||
});
|
||||
});
|
||||
|
||||
H.getDashboardCard().should("be.visible");
|
||||
};
|
||||
|
||||
const openSlowPublicDashboard = (params = {}) => {
|
||||
cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
|
||||
"cardQuery",
|
||||
@@ -798,21 +550,6 @@ const openSlowEmbeddingDashboard = (params = {}) => {
|
||||
H.getDashboardCard().should("be.visible");
|
||||
};
|
||||
|
||||
const openSlowFullAppEmbeddingDashboard = (params = {}) => {
|
||||
cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
|
||||
"cardQuery",
|
||||
);
|
||||
|
||||
cy.get("@dashboardId").then((dashboardId) => {
|
||||
visitFullAppEmbeddingUrl({
|
||||
url: `/dashboard/${dashboardId}`,
|
||||
qs: params,
|
||||
});
|
||||
});
|
||||
|
||||
H.getDashboardCard().should("be.visible");
|
||||
};
|
||||
|
||||
const visitFullAppEmbeddingUrl = ({ url, qs }) => {
|
||||
cy.visit({
|
||||
url,
|
||||
|
||||
@@ -2204,3 +2204,60 @@ describe("issue 63176", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("issue 64138", () => {
|
||||
const MAP_QUESTION = {
|
||||
query: {
|
||||
"source-table": PEOPLE_ID,
|
||||
},
|
||||
|
||||
display: "map",
|
||||
displayIsLocked: true,
|
||||
visualization_settings: {
|
||||
"map.type": "pin",
|
||||
"map.pin_type": "markers",
|
||||
},
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
H.restore();
|
||||
cy.signInAsNormalUser();
|
||||
|
||||
H.createQuestionAndDashboard({
|
||||
questionDetails: MAP_QUESTION,
|
||||
}).then(({ body: { dashboard_id } }) => {
|
||||
H.visitDashboard(dashboard_id);
|
||||
});
|
||||
});
|
||||
|
||||
it("should hide map controls when editing dashboard (metabase#64138)", () => {
|
||||
H.editDashboard();
|
||||
|
||||
cy.log("hovering the map should not show the zoom controls");
|
||||
H.getDashboardCard(0)
|
||||
.realHover({
|
||||
position: "center",
|
||||
})
|
||||
.within(() => {
|
||||
cy.findByLabelText("Zoom in").should("not.exist");
|
||||
cy.findByText("Set as default view").should("be.visible").click();
|
||||
});
|
||||
|
||||
cy.log("hovering marker icons should not open their tooltips");
|
||||
getMarkerIcon(0).realHover();
|
||||
H.popover({ skipVisibilityCheck: true }).should("not.exist");
|
||||
|
||||
cy.log("clicking marker icons should not navigate to the question");
|
||||
getMarkerIcon(0).click({ force: true });
|
||||
cy.location("pathname").should("match", /^\/dashboard\/[0-9]+$/);
|
||||
H.modal().should("not.exist");
|
||||
});
|
||||
|
||||
function getMarkerIcon(index) {
|
||||
// pick the last one so it will be on top
|
||||
return H.getDashboardCard(index)
|
||||
.get(".leaflet-marker-icon")
|
||||
.should("have.length.gt", 0)
|
||||
.last();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -645,6 +645,33 @@ describe("scenarios > dashboard", () => {
|
||||
H.getDashboardCard(1).contains("bottom");
|
||||
},
|
||||
);
|
||||
|
||||
it("should not save the dashboard when the user clicks 'Discard changes'", () => {
|
||||
// Navigate to the dashboard via client-side navigation (to trigger the client-side "Discard changes" prompt)
|
||||
cy.visit("/");
|
||||
cy.findByTestId("main-navbar-root").findByText("Our analytics").click();
|
||||
cy.findByTestId("collection-table")
|
||||
.findByText(originalDashboardName)
|
||||
.click();
|
||||
|
||||
cy.log("Make a change to the dashboard");
|
||||
H.editDashboard();
|
||||
cy.findByTestId("dashboard-empty-state")
|
||||
.findByText("Add a chart")
|
||||
.click();
|
||||
H.sidebar().findByText("Orders, Count").click();
|
||||
H.getDashboardCards().should("have.length", 1);
|
||||
|
||||
cy.log("Navigate back and discard changes");
|
||||
cy.go("back");
|
||||
H.modal().button("Discard changes").click();
|
||||
cy.findByTestId("collection-table")
|
||||
.findByText(originalDashboardName)
|
||||
.click();
|
||||
|
||||
cy.log("Verify changes were not saved");
|
||||
cy.findByTestId("dashboard-empty-state").should("exist");
|
||||
});
|
||||
});
|
||||
|
||||
describe("iframe cards", () => {
|
||||
|
||||
@@ -177,10 +177,16 @@ describe("scenarios > x-rays", { tags: "@slow" }, () => {
|
||||
|
||||
cy.button("Save this").click();
|
||||
|
||||
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
|
||||
cy.findByText("Your dashboard was saved");
|
||||
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
|
||||
cy.findByText("See it").click();
|
||||
cy.log(
|
||||
"'See it' link should be displayed both in the header and in the toast",
|
||||
);
|
||||
H.undoToast()
|
||||
.should("contain", "Your dashboard was saved")
|
||||
.and("contain", "See it");
|
||||
|
||||
cy.findByTestId("automatic-dashboard-header").within(() => {
|
||||
cy.findByRole("link", { name: "See it" }).should("be.visible").click();
|
||||
});
|
||||
|
||||
cy.url().should("contain", "a-look-at-orders");
|
||||
|
||||
|
||||
678
e2e/test/scenarios/dependencies/dependencies.cy.spec.ts
Normal file
@@ -0,0 +1,678 @@
|
||||
const { H } = cy;
|
||||
|
||||
import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
|
||||
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
|
||||
import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";
|
||||
|
||||
const { PRODUCTS_ID } = SAMPLE_DATABASE;
|
||||
|
||||
H.describeWithSnowplowEE("documents", () => {
|
||||
beforeEach(() => {
|
||||
H.restore("postgres-writable");
|
||||
H.resetTestTable({ type: "postgres", table: "many_schemas" });
|
||||
cy.signInAsAdmin();
|
||||
H.activateToken("bleeding-edge");
|
||||
H.resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: "Animals" });
|
||||
H.resetSnowplow();
|
||||
|
||||
cy.intercept("PUT", "/api/card/*").as("updateCard");
|
||||
cy.intercept("PUT", "/api/native-query-snippet/*").as("updateSnippet");
|
||||
cy.intercept("PUT", "/api/ee/transform/*").as("updateTransform");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
H.expectNoBadSnowplowEvents();
|
||||
});
|
||||
|
||||
describe("questions", () => {
|
||||
it("should be able to confirm or cancel breaking changes to a MBQL question", () => {
|
||||
createMbqlQuestionWithDependentMbqlQuestions();
|
||||
|
||||
cy.log("make breaking changes");
|
||||
H.visitQuestion("@questionId");
|
||||
H.openNotebook();
|
||||
H.getNotebookStep("expression").findByText("Expr").icon("close").click();
|
||||
|
||||
cy.log("cancel breaking changes");
|
||||
H.queryBuilderHeader().button("Save").click();
|
||||
H.modal().button("Save").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with fields").should("be.visible");
|
||||
cy.findByText("Question without fields").should("not.exist");
|
||||
cy.findByText("Base question").should("not.exist");
|
||||
cy.button("Cancel").click();
|
||||
});
|
||||
cy.get("@updateCard.all").should("have.length", 0);
|
||||
|
||||
cy.log("confirm breaking changes");
|
||||
H.queryBuilderHeader().button("Save").click();
|
||||
H.modal().button("Save").click();
|
||||
H.modal().button("Save anyway").click();
|
||||
cy.wait("@updateCard");
|
||||
});
|
||||
|
||||
it("should be able to navigate to affected questions or their collection", () => {
|
||||
createMbqlQuestionWithDependentMbqlQuestions();
|
||||
|
||||
cy.log("check that we can navigate to the broken question");
|
||||
H.visitQuestion("@questionId");
|
||||
H.openNotebook();
|
||||
H.getNotebookStep("expression").findByText("Expr").icon("close").click();
|
||||
H.queryBuilderHeader().button("Save").click();
|
||||
H.modal().button("Save").click();
|
||||
H.modal().findByText("Question with fields").click();
|
||||
confirmDiscardChanges();
|
||||
H.queryBuilderHeader()
|
||||
.findByDisplayValue("Question with fields")
|
||||
.should("be.visible");
|
||||
|
||||
cy.log("check that we can navigate to the collection of that question");
|
||||
cy.go("back");
|
||||
H.getNotebookStep("expression").findByText("Expr").icon("close").click();
|
||||
H.queryBuilderHeader().button("Save").click();
|
||||
H.modal().button("Save").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with fields").should("be.visible");
|
||||
cy.findByText("Our analytics").click();
|
||||
});
|
||||
confirmDiscardChanges();
|
||||
H.collectionTable().should("be.visible");
|
||||
|
||||
cy.log("check that we can navigate to the dashboard of that question");
|
||||
cy.go("back");
|
||||
H.getNotebookStep("expression").findByText("Expr").icon("close").click();
|
||||
H.queryBuilderHeader().button("Save").click();
|
||||
H.modal().button("Save").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with fields").should("be.visible");
|
||||
cy.findByText("Orders in a dashboard").click();
|
||||
});
|
||||
confirmDiscardChanges();
|
||||
H.dashboardHeader().should("be.visible");
|
||||
});
|
||||
|
||||
it("should not show a confirmation if there are no breaking changes when updating a MBQL question", () => {
|
||||
createMbqlQuestionWithDependentMbqlQuestions();
|
||||
H.visitQuestion("@questionId");
|
||||
H.openNotebook();
|
||||
H.getNotebookStep("expression").findByText("Expr").click();
|
||||
H.CustomExpressionEditor.clear().type("2 + 2");
|
||||
H.popover().button("Update").click();
|
||||
H.queryBuilderHeader().button("Save").click();
|
||||
H.modal().button("Save").click();
|
||||
cy.wait("@updateCard");
|
||||
});
|
||||
});
|
||||
|
||||
describe("models", () => {
|
||||
it("should be able to confirm or cancel breaking changes to a SQL model", () => {
|
||||
createSqlModelWithDependentSqlQuestions();
|
||||
|
||||
cy.log("make breaking changes");
|
||||
cy.get<number>("@modelId").then(H.visitModel);
|
||||
H.openQuestionActions("Edit query definition");
|
||||
H.NativeEditor.clear().type("SELECT ID, TITLE FROM PRODUCTS");
|
||||
H.runNativeQuery();
|
||||
|
||||
cy.log("cancel breaking changes");
|
||||
H.datasetEditBar().button("Save changes").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with fields").should("be.visible");
|
||||
cy.findByText("Question without fields").should("not.exist");
|
||||
cy.findByText("Base model").should("not.exist");
|
||||
cy.button("Cancel").click();
|
||||
});
|
||||
cy.get("@updateCard.all").should("have.length", 0);
|
||||
|
||||
cy.log("confirm breaking changes");
|
||||
H.datasetEditBar().button("Save changes").click();
|
||||
H.modal().button("Save anyway").click();
|
||||
cy.wait("@updateCard");
|
||||
});
|
||||
|
||||
it("should not show a confirmation if there are no breaking changes when updating a SQL model", () => {
|
||||
createSqlModelWithDependentSqlQuestions();
|
||||
cy.get<number>("@modelId").then(H.visitModel);
|
||||
H.openQuestionActions("Edit query definition");
|
||||
H.NativeEditor.clear().type("SELECT ID, CATEGORY FROM PRODUCTS");
|
||||
H.runNativeQuery();
|
||||
H.datasetEditBar().button("Save changes").click();
|
||||
cy.wait("@updateCard");
|
||||
});
|
||||
});
|
||||
|
||||
describe("metrics", () => {
|
||||
it("should be able to confirm or cancel breaking changes to a metric", () => {
|
||||
createMetricWithDependentMbqlQuestionsAndTransforms();
|
||||
|
||||
cy.log("make breaking changes");
|
||||
cy.get<number>("@metricId").then(H.visitMetric);
|
||||
H.openQuestionActions("Edit metric definition");
|
||||
H.getNotebookStep("summarize").findByText("Min of Score").click();
|
||||
H.popover().within(() => {
|
||||
cy.icon("chevronleft").click();
|
||||
cy.findByText("Maximum of ...").click();
|
||||
cy.findByText("Score").click();
|
||||
});
|
||||
|
||||
cy.log("cancel breaking changes");
|
||||
cy.findByTestId("edit-bar").button("Save changes").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with 2 stages").should("be.visible");
|
||||
cy.findByText("Transform with 2 stages").should("be.visible");
|
||||
cy.findByText("Question with 1 stage").should("not.exist");
|
||||
cy.findByText("Transform with 1 stage").should("not.exist");
|
||||
cy.findByText("Base metric").should("not.exist");
|
||||
cy.button("Cancel").click();
|
||||
});
|
||||
cy.get("@updateCard.all").should("have.length", 0);
|
||||
|
||||
cy.log("confirm breaking changes");
|
||||
cy.findByTestId("edit-bar").button("Save changes").click();
|
||||
H.modal().button("Save anyway").click();
|
||||
cy.wait("@updateCard");
|
||||
});
|
||||
|
||||
it("should not show a warning when a change to a metric is backward-compatible with existing content", () => {
|
||||
createMetricWithDependentMbqlQuestionsAndTransforms();
|
||||
cy.get<number>("@metricId").then(H.visitMetric);
|
||||
H.openQuestionActions("Edit metric definition");
|
||||
H.getNotebookStep("summarize").findByText("Min of Score").click();
|
||||
H.popover().findByText("Name").click();
|
||||
cy.findByTestId("edit-bar").button("Save changes").click();
|
||||
cy.wait("@updateCard");
|
||||
});
|
||||
});
|
||||
|
||||
describe("transforms", () => {
|
||||
it("should be able to confirm or cancel breaking changes to a SQL transform after it was run", () => {
|
||||
createSqlTransformWithDependentMbqlQuestions();
|
||||
|
||||
cy.log("make breaking changes");
|
||||
cy.get<number>("@transformId").then(H.visitTransform);
|
||||
cy.findByTestId("transform-page").findByText("Edit query").click();
|
||||
H.NativeEditor.clear().type('SELECT name FROM "Schema A"."Animals"');
|
||||
|
||||
cy.log("cancel breaking changes");
|
||||
cy.findByTestId("transform-query-editor").button("Save changes").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with fields").should("be.visible");
|
||||
cy.findByText("Question without fields").should("not.exist");
|
||||
cy.findByText("Base transform").should("not.exist");
|
||||
cy.button("Cancel").click();
|
||||
});
|
||||
cy.get("@updateTransform.all").should("have.length", 0);
|
||||
|
||||
cy.log("confirm breaking changes");
|
||||
cy.findByTestId("transform-query-editor").button("Save changes").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Question with fields").should("be.visible");
|
||||
cy.findByText("Question without fields").should("not.exist");
|
||||
cy.findByText("Base transform").should("not.exist");
|
||||
cy.button("Save anyway").click();
|
||||
});
|
||||
cy.wait("@updateTransform");
|
||||
});
|
||||
|
||||
it("should not show a confirmation if there are no breaking changes when updating a SQL transform after it was run", () => {
|
||||
createSqlTransformWithDependentMbqlQuestions();
|
||||
cy.get<number>("@transformId").then(H.visitTransform);
|
||||
cy.findByTestId("transform-page").findByText("Edit query").click();
|
||||
H.NativeEditor.clear().type(
|
||||
'SELECT score, name FROM "Schema A"."Animals"',
|
||||
);
|
||||
cy.findByTestId("transform-query-editor").button("Save changes").click();
|
||||
cy.wait("@updateTransform");
|
||||
});
|
||||
|
||||
it("should be able to confirm or cancel breaking changes to a MBQL transform before it was run", () => {
|
||||
createMbqlTransformWithDependentSqlTransforms();
|
||||
|
||||
cy.log("make breaking changes");
|
||||
cy.get<number>("@transformId").then(H.visitTransform);
|
||||
cy.findByTestId("transform-page").findByText("Edit query").click();
|
||||
H.getNotebookStep("data").findByLabelText("Pick columns").click();
|
||||
H.popover().findByLabelText("Score").click();
|
||||
|
||||
cy.log("cancel breaking changes");
|
||||
cy.findByTestId("transform-query-editor").button("Save changes").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Score transform").should("be.visible");
|
||||
cy.findByText("Name transform").should("not.exist");
|
||||
cy.findByText("Base transform").should("not.exist");
|
||||
cy.button("Cancel").click();
|
||||
});
|
||||
cy.get("@updateTransform.all").should("have.length", 0);
|
||||
|
||||
cy.log("confirm breaking changes");
|
||||
cy.findByTestId("transform-query-editor").button("Save changes").click();
|
||||
H.modal().within(() => {
|
||||
cy.findByText("Score transform").should("be.visible");
|
||||
cy.findByText("Name transform").should("not.exist");
|
||||
cy.button("Save anyway").click();
|
||||
});
|
||||
cy.wait("@updateTransform");
|
||||
});
|
||||
|
||||
it("should not show a confirmation if there are no breaking changes when updating a MBQL transform before it was run", () => {
|
||||
createMbqlTransformWithDependentSqlTransforms();
|
||||
cy.get<number>("@transformId").then(H.visitTransform);
|
||||
cy.findByTestId("transform-page").findByText("Edit query").click();
|
||||
H.getNotebookStep("data").button("Sort").click();
|
||||
H.popover().findByText("Score").click();
|
||||
cy.findByTestId("transform-query-editor").button("Save changes").click();
|
||||
cy.wait("@updateTransform");
|
||||
});
|
||||
});
|
||||
|
||||
describe("snippets", () => {
|
||||
it("should be able to confirm or cancel breaking changes to a snippet", () => {
|
||||
createSnippetWithDependentQuestionsAndTransforms();
|
||||
|
||||
cy.log("make breaking changes");
|
||||
startEditingSnippet();
|
||||
H.modal()
|
||||
.findByLabelText("Enter some SQL here so you can reuse it later")
|
||||
.clear()
|
||||
.type("price = 1");
|
||||
|
||||
cy.log("cancel breaking changes");
|
||||
H.modal().within(() => {
|
||||
cy.button("Save").click();
|
||||
cy.findByText("Question with snippet").should("be.visible");
|
||||
cy.findByText("Transform with snippet").should("be.visible");
|
||||
cy.findByText("ScoreSnippet").should("not.exist");
|
||||
cy.button("Cancel").click();
|
||||
});
|
||||
cy.get("@updateSnippet.all").should("have.length", 0);
|
||||
|
||||
cy.log("confirm breaking changes");
|
||||
H.modal().within(() => {
|
||||
cy.button("Save").click();
|
||||
cy.findByText("Question with snippet").should("be.visible");
|
||||
cy.findByText("Transform with snippet").should("be.visible");
|
||||
cy.findByText("ScoreSnippet").should("not.exist");
|
||||
cy.button("Save anyway").click();
|
||||
});
|
||||
cy.wait("@updateSnippet");
|
||||
});
|
||||
|
||||
it("should not warn if changes to a snippet are backward compatible", () => {
|
||||
createSnippetWithDependentQuestionsAndTransforms();
|
||||
startEditingSnippet();
|
||||
H.modal().within(() => {
|
||||
cy.findByLabelText("Enter some SQL here so you can reuse it later")
|
||||
.clear()
|
||||
.type("score = 2");
|
||||
cy.button("Save").click();
|
||||
});
|
||||
cy.wait("@updateSnippet");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function createMbqlQuestionWithDependentMbqlQuestions() {
|
||||
H.createQuestion({
|
||||
name: "Base question",
|
||||
query: {
|
||||
"source-table": PRODUCTS_ID,
|
||||
expressions: {
|
||||
Expr: ["+", 1, 1],
|
||||
},
|
||||
},
|
||||
}).then(({ body: card }) => {
|
||||
cy.wrap(card.id).as("questionId");
|
||||
|
||||
H.createQuestion({
|
||||
name: "Question with fields",
|
||||
query: {
|
||||
"source-table": `card__${card.id}`,
|
||||
filter: [">", ["field", "Expr", { "base-type": "type/Integer" }], 1],
|
||||
},
|
||||
dashboard_id: ORDERS_DASHBOARD_ID,
|
||||
});
|
||||
|
||||
H.createQuestion({
|
||||
name: "Question without fields",
|
||||
query: {
|
||||
"source-table": `card__${card.id}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createSqlModelWithDependentSqlQuestions() {
|
||||
H.createNativeQuestion({
|
||||
name: "Base model",
|
||||
type: "model",
|
||||
native: {
|
||||
query: "SELECT ID, TITLE, CATEGORY FROM PRODUCTS",
|
||||
"template-tags": {},
|
||||
},
|
||||
}).then(({ body: card }) => {
|
||||
cy.wrap(card.id).as("modelId");
|
||||
cy.request("POST", `/api/card/${card.id}/query`);
|
||||
|
||||
const tagName = `#${card.id}`;
|
||||
H.createNativeQuestion({
|
||||
name: "Question with fields",
|
||||
native: {
|
||||
query: `SELECT ID, CATEGORY FROM {{#${card.id}}}`,
|
||||
"template-tags": {
|
||||
[tagName]: {
|
||||
id: "10422a0f-292d-10a3-fd90-407cc9e3e20e",
|
||||
name: tagName,
|
||||
"display-name": tagName,
|
||||
type: "card",
|
||||
"card-id": card.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
H.createNativeQuestion({
|
||||
name: "Question without fields",
|
||||
native: {
|
||||
query: `SELECT COUNT(*) FROM {{#${card.id}}}`,
|
||||
"template-tags": {
|
||||
[tagName]: {
|
||||
id: "10422a0f-292d-10a3-fd90-407cc9e3e20f",
|
||||
name: tagName,
|
||||
"display-name": tagName,
|
||||
type: "card",
|
||||
"card-id": card.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createMetricWithDependentMbqlQuestionsAndTransforms() {
|
||||
H.getTableId({ databaseId: WRITABLE_DB_ID, name: "Animals" }).then(
|
||||
(tableId) => {
|
||||
H.getFieldId({ tableId, name: "score" }).then((fieldId) => {
|
||||
H.createQuestion({
|
||||
name: "Base metric",
|
||||
type: "metric",
|
||||
database: WRITABLE_DB_ID,
|
||||
query: {
|
||||
"source-table": tableId,
|
||||
aggregation: [["min", ["field", fieldId, null]]],
|
||||
},
|
||||
}).then(({ body: metric }) => {
|
||||
cy.wrap(metric.id).as("metricId");
|
||||
|
||||
H.createQuestion({
|
||||
name: "Question with 1 stage",
|
||||
database: WRITABLE_DB_ID,
|
||||
query: {
|
||||
"source-table": tableId,
|
||||
aggregation: [["metric", metric.id]],
|
||||
},
|
||||
});
|
||||
|
||||
H.createQuestion({
|
||||
name: "Question with 2 stages",
|
||||
database: WRITABLE_DB_ID,
|
||||
query: {
|
||||
"source-query": {
|
||||
"source-table": tableId,
|
||||
aggregation: [["metric", metric.id]],
|
||||
breakout: [["field", fieldId, null]],
|
||||
},
|
||||
aggregation: [
|
||||
["avg", ["field", "min", { "base-type": "type/Integer" }]],
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
H.createTransform({
|
||||
name: "Transform with 1 stage",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "query",
|
||||
query: {
|
||||
"source-table": tableId,
|
||||
aggregation: [["metric", metric.id]],
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: "transform_1_stage",
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
});
|
||||
|
||||
H.createTransform({
|
||||
name: "Transform with 2 stages",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "query",
|
||||
query: {
|
||||
"source-query": {
|
||||
"source-table": tableId,
|
||||
aggregation: [["metric", metric.id]],
|
||||
breakout: [["field", fieldId, null]],
|
||||
},
|
||||
aggregation: [
|
||||
["avg", ["field", "min", { "base-type": "type/Integer" }]],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: "transform_2_stages",
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function createSqlTransformWithDependentMbqlQuestions() {
|
||||
const transformTableName = "base_transform";
|
||||
|
||||
H.createTransform({
|
||||
name: "Base transform",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "native",
|
||||
native: {
|
||||
query: 'SELECT name, score FROM "Schema A"."Animals"',
|
||||
"template-tags": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: transformTableName,
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
}).then(({ body: transform }) => {
|
||||
cy.wrap(transform.id).as("transformId");
|
||||
cy.request("POST", `/api/ee/transform/${transform.id}/run`);
|
||||
H.waitForSucceededTransformRuns();
|
||||
H.resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: transformTableName });
|
||||
|
||||
H.getTableId({ databaseId: WRITABLE_DB_ID, name: transformTableName }).then(
|
||||
(tableId) => {
|
||||
H.createQuestion({
|
||||
name: "Question with fields",
|
||||
database: WRITABLE_DB_ID,
|
||||
query: {
|
||||
"source-table": tableId,
|
||||
filter: [
|
||||
">",
|
||||
["field", "score", { "base-type": "type/Integer" }],
|
||||
1,
|
||||
],
|
||||
},
|
||||
});
|
||||
H.createQuestion({
|
||||
name: "Question without fields",
|
||||
database: WRITABLE_DB_ID,
|
||||
query: {
|
||||
"source-table": tableId,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function createMbqlTransformWithDependentSqlTransforms() {
|
||||
H.getTableId({ name: "Animals", databaseId: WRITABLE_DB_ID }).then(
|
||||
(tableId) => {
|
||||
H.createTransform(
|
||||
{
|
||||
name: "Base transform",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "query",
|
||||
query: {
|
||||
"source-table": tableId,
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: "base_transform",
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
},
|
||||
{ wrapId: true },
|
||||
);
|
||||
|
||||
H.createTransform({
|
||||
name: "Name transform",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "native",
|
||||
native: {
|
||||
query: "SELECT name FROM base_transform",
|
||||
"template-tags": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: "name_transform",
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
});
|
||||
|
||||
H.createTransform({
|
||||
name: "Score transform",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "native",
|
||||
native: {
|
||||
query: "SELECT score FROM base_transform",
|
||||
"template-tags": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: "score_transform",
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function createSnippetWithDependentQuestionsAndTransforms() {
|
||||
H.createSnippet({
|
||||
name: "ScoreSnippet",
|
||||
content: "score = 1",
|
||||
}).then(({ body: snippet }) => {
|
||||
cy.wrap(snippet.id).as("snippetId");
|
||||
|
||||
H.createNativeQuestion({
|
||||
name: "Question with snippet",
|
||||
database: WRITABLE_DB_ID,
|
||||
native: {
|
||||
query:
|
||||
'SELECT * FROM "Schema A"."Animals" WHERE {{snippet:ScoreSnippet}}',
|
||||
"template-tags": {
|
||||
"snippet:ScoreSnippet": {
|
||||
id: "4b77cc1f-ea70-4ef6-84db-58432fce6928",
|
||||
name: "snippet:ScoreSnippet",
|
||||
"display-name": "snippet:ScoreSnippet",
|
||||
type: "snippet",
|
||||
"snippet-id": snippet.id,
|
||||
"snippet-name": snippet.name,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
H.createTransform({
|
||||
name: "Transform with snippet",
|
||||
source: {
|
||||
type: "query",
|
||||
query: {
|
||||
database: WRITABLE_DB_ID,
|
||||
type: "native",
|
||||
native: {
|
||||
query:
|
||||
'SELECT * FROM "Schema A"."Animals" WHERE {{snippet:ScoreSnippet}}',
|
||||
"template-tags": {
|
||||
"snippet:ScoreSnippet": {
|
||||
id: "4b77cc1f-ea70-4ef6-84db-58432fce6929",
|
||||
name: "snippet:ScoreSnippet",
|
||||
"display-name": "snippet:ScoreSnippet",
|
||||
type: "snippet",
|
||||
"snippet-id": snippet.id,
|
||||
"snippet-name": snippet.name,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
type: "table",
|
||||
name: "transform_with_snippet",
|
||||
schema: "public",
|
||||
database: WRITABLE_DB_ID,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function startEditingSnippet() {
|
||||
H.startNewNativeQuestion();
|
||||
cy.findByTestId("native-query-editor-action-buttons").icon("snippet").click();
|
||||
cy.findByTestId("sidebar-content").within(() => {
|
||||
cy.icon("chevrondown").click({ force: true });
|
||||
cy.button(/Edit/).click();
|
||||
});
|
||||
}
|
||||
|
||||
function confirmDiscardChanges() {
|
||||
H.modal().should("have.length", 2).last().button("Discard changes").click();
|
||||
}
|
||||
@@ -44,7 +44,9 @@ describe("detail view", () => {
|
||||
});
|
||||
|
||||
DetailView.verifyDetails([
|
||||
["ID", "1"],
|
||||
["Ean", "1018947080336"],
|
||||
["Title", "Rustic Paper Wallet"],
|
||||
["Category", "Gizmo"],
|
||||
["Vendor", "Swaniawski, Casper and Hilll"],
|
||||
["Price", "29.46"],
|
||||
@@ -122,6 +124,7 @@ describe("detail view", () => {
|
||||
});
|
||||
|
||||
DetailView.verifyDetails([
|
||||
["ID", "1"],
|
||||
["User ID", "1"],
|
||||
["Product ID", "14"],
|
||||
["Subtotal", "37.65"],
|
||||
@@ -137,6 +140,7 @@ describe("detail view", () => {
|
||||
["Products → Ean", "8833419218504"],
|
||||
["Products → Price", "25.1"],
|
||||
["Products → Rating", "4"],
|
||||
["Products → Title", "Awesome Concrete Shoes"],
|
||||
["Products → Vendor", "McClure-Lockman"],
|
||||
]);
|
||||
|
||||
@@ -273,6 +277,7 @@ describe("detail view", () => {
|
||||
});
|
||||
|
||||
DetailView.verifyDetails([
|
||||
["ID", "1"],
|
||||
["User", "Hudson Borer"],
|
||||
["Product", "Product: Awesome Concrete Shoes"],
|
||||
["Subtotal ($)", "37.65"],
|
||||
@@ -281,17 +286,19 @@ describe("detail view", () => {
|
||||
["Discount ($)", "empty"],
|
||||
["Created At", "February 11, 2025, 9:40 PM"],
|
||||
["Quantity", "two"],
|
||||
["Order image", "https://example.com/order/1.jpg"],
|
||||
["Product image", "https://example.com/product/14.jpg"],
|
||||
["Products → Category", "Widget"],
|
||||
["Products → Created At", "December 31, 2023, 2:41 PM"],
|
||||
["Products → Ean", "8833419218504"],
|
||||
["Products → Price", "25.1"],
|
||||
["Products → Rating", "4"],
|
||||
["Products → Title", "Awesome Concrete Shoes"],
|
||||
["Products → Vendor", "McClure-Lockman"],
|
||||
]);
|
||||
|
||||
cy.log("user id remapped to user name");
|
||||
DetailView.getDetailsRowValue({ index: 0, rowsCount: 15 }).within(() => {
|
||||
DetailView.getDetailsRowValue({ index: 1, rowsCount: 18 }).within(() => {
|
||||
cy.findByRole("link", { name: "Hudson Borer" })
|
||||
.should("be.visible")
|
||||
.and("have.attr", "href", `/table/${PEOPLE_ID}/detail/1`);
|
||||
@@ -300,7 +307,7 @@ describe("detail view", () => {
|
||||
cy.log(
|
||||
"product id remapped to product title, and custom view_as setting",
|
||||
);
|
||||
DetailView.getDetailsRowValue({ index: 1, rowsCount: 15 }).within(() => {
|
||||
DetailView.getDetailsRowValue({ index: 2, rowsCount: 18 }).within(() => {
|
||||
cy.findByRole("link", { name: "Product: Awesome Concrete Shoes" })
|
||||
.should("be.visible")
|
||||
.and("have.attr", "href", "https://example.com/14")
|
||||
@@ -314,13 +321,13 @@ describe("detail view", () => {
|
||||
});
|
||||
|
||||
cy.log("image should be rendered in a frame with a link");
|
||||
DetailView.getDetailsRowValue({ index: 8, rowsCount: 15 }).within(() => {
|
||||
DetailView.getDetailsRowValue({ index: 10, rowsCount: 18 }).within(() => {
|
||||
cy.findByRole("img")
|
||||
.should("exist") // do not wait for image to load
|
||||
.and("have.attr", "src", "https://example.com/product/14.jpg");
|
||||
|
||||
cy.findByRole("link")
|
||||
.should("be.visible")
|
||||
.should("exist")
|
||||
.and("have.text", "https://example.com/product/14.jpg")
|
||||
.and("have.attr", "href", "https://example.com/product/14.jpg")
|
||||
.and("have.attr", "target", "_blank")
|
||||
@@ -332,7 +339,7 @@ describe("detail view", () => {
|
||||
it("displays emails as links", () => {
|
||||
DetailView.visitTable(PEOPLE_ID, 1);
|
||||
|
||||
DetailView.getDetailsRowValue({ index: 1, rowsCount: 11 }).within(() => {
|
||||
DetailView.getDetailsRowValue({ index: 2, rowsCount: 13 }).within(() => {
|
||||
cy.findByRole("link", { name: "borer-hudson@yahoo.com" }).should(
|
||||
"have.attr",
|
||||
"href",
|
||||
|
||||
593
e2e/test/scenarios/documents/card-embed-node.cy.spec.ts
Normal file
@@ -0,0 +1,593 @@
|
||||
import {
|
||||
DOCUMENT_WITH_THREE_CARDS_AND_COLUMNS,
|
||||
DOCUMENT_WITH_TWO_CARDS,
|
||||
} from "e2e/support/document-initial-data";
|
||||
|
||||
const { H } = cy;
|
||||
|
||||
describe("documents card embed node custom logic", () => {
|
||||
beforeEach(() => {
|
||||
H.restore();
|
||||
cy.signInAsAdmin();
|
||||
H.activateToken("bleeding-edge");
|
||||
});
|
||||
|
||||
describe("cardEmbed drag and drop", () => {
|
||||
beforeEach(() => {
|
||||
H.createDocument({
|
||||
name: "DnD Test Document",
|
||||
document: DOCUMENT_WITH_TWO_CARDS,
|
||||
collection_id: null,
|
||||
alias: "document",
|
||||
idAlias: "documentId",
|
||||
});
|
||||
|
||||
cy.get("@documentId").then((id) => cy.visit(`/document/${id}`));
|
||||
});
|
||||
|
||||
it("should create a flexContainer when dropping one cardEmbed onto another standalone cardEmbed", () => {
|
||||
// Wait for cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
// Verify no flexContainer exists initially
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("not.exist");
|
||||
|
||||
H.dragAndDropCardOnAnotherCard("Orders", "Orders, Count");
|
||||
|
||||
// Verify flexContainer was created
|
||||
H.documentContent().find('[data-type="flexContainer"]').should("exist");
|
||||
|
||||
// Verify both cards are now inside the flexContainer
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder(["Orders", "Orders, Count"]);
|
||||
});
|
||||
|
||||
// Verify the flexContainer is wrapped in a resizeNode
|
||||
H.documentContent()
|
||||
.find('[data-type="resizeNode"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
cy.get('[data-type="flexContainer"]').should("exist");
|
||||
});
|
||||
|
||||
// Verify that originally separate cards are now side by side
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.within(() => {
|
||||
cy.findAllByTestId("document-card-embed").should("have.length", 2);
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle drag and drop with proper drop side positioning", () => {
|
||||
// Wait for cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
H.dragAndDropCardOnAnotherCard("Orders", "Orders, Count", {
|
||||
side: "right",
|
||||
});
|
||||
|
||||
// Verify flexContainer was created with correct order
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
// Orders, Count should be first (left), Orders should be second (right)
|
||||
assertFlexContainerCardsOrder(["Orders, Count", "Orders"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should prevent dropping a card onto itself", () => {
|
||||
// Wait for cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
// Verify initial state - no flexContainer
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("not.exist");
|
||||
|
||||
// Attempt to drag and drop the card onto itself
|
||||
H.dragAndDropCardOnAnotherCard("Orders", "Orders");
|
||||
|
||||
// Verify no flexContainer was created
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("not.exist");
|
||||
|
||||
// Verify the card is still standalone
|
||||
H.getDocumentCard("Orders").should("exist");
|
||||
});
|
||||
});
|
||||
|
||||
describe("advanced flexContainer scenarios", () => {
|
||||
beforeEach(() => {
|
||||
H.createDocument({
|
||||
name: "Advanced DnD Test Document",
|
||||
document: DOCUMENT_WITH_THREE_CARDS_AND_COLUMNS,
|
||||
collection_id: null,
|
||||
alias: "document",
|
||||
idAlias: "documentId",
|
||||
});
|
||||
|
||||
cy.get("@documentId").then((id) => cy.visit(`/document/${id}`));
|
||||
});
|
||||
|
||||
it("should allow you to resize the cards inside a flex container", () => {
|
||||
getCardWidths(["Orders", "Orders, Count"], (first, second) => {
|
||||
cy.wrap(first).as("ogWidth1");
|
||||
cy.wrap(second).as("ogWidth2");
|
||||
expect(first).to.be.closeTo(second, 3);
|
||||
});
|
||||
|
||||
H.getDocumentCard("Orders").as("ORDERS_CARD");
|
||||
H.getDocumentCard("Orders, Count").as("ORDERS_COUNT_CARD");
|
||||
|
||||
const flexContainer = H.getFlexContainerForCard("Orders");
|
||||
|
||||
const handles = H.getResizeHandlesForFlexContianer(flexContainer);
|
||||
|
||||
H.documentDoDrag(handles.eq(0), { x: 100 });
|
||||
|
||||
getCardWidths(["Orders", "Orders, Count"], (first, second) => {
|
||||
cy.get("@ogWidth1").then((_first) => {
|
||||
cy.get("@ogWidth2").then((_second) => {
|
||||
cy.log("compare that changes are close to the drag distance");
|
||||
expect((_first as unknown as number) + 100).to.be.closeTo(first, 3);
|
||||
expect((_second as unknown as number) - 100).to.be.closeTo(
|
||||
second,
|
||||
3,
|
||||
);
|
||||
|
||||
expect(first).to.be.closeTo(second + 200, 3);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should add a third card to an existing flexContainer with 2 cards", () => {
|
||||
// Wait for all cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count, Grouped by Created At (year)")
|
||||
.should("be.visible")
|
||||
.findByTestId("chart-container")
|
||||
.should("exist");
|
||||
|
||||
// Verify initial state - flexContainer exists with 2 cards
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
cy.findAllByTestId("document-card-embed").should("have.length", 2);
|
||||
});
|
||||
|
||||
// Drag the standalone card (Orders by Year) onto one of the cards in the flexContainer
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders",
|
||||
{ side: "left" },
|
||||
);
|
||||
|
||||
// Verify the flexContainer now has 3 cards
|
||||
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder([
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders",
|
||||
"Orders, Count",
|
||||
]);
|
||||
});
|
||||
|
||||
H.documentUndo();
|
||||
|
||||
// Drag the standalone card (Orders by Year) onto one of the cards in the flexContainer
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders",
|
||||
{ side: "right" },
|
||||
);
|
||||
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder([
|
||||
"Orders",
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders, Count",
|
||||
]);
|
||||
});
|
||||
|
||||
H.documentUndo();
|
||||
|
||||
// Drag the standalone card (Orders by Year) onto one of the cards in the flexContainer
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders, Count",
|
||||
{ side: "right" },
|
||||
);
|
||||
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder([
|
||||
"Orders",
|
||||
"Orders, Count",
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
]);
|
||||
});
|
||||
|
||||
cy.log("changing the widths of 2 cards should leave the 3rd alone");
|
||||
|
||||
const cardNames = [
|
||||
"Orders",
|
||||
"Orders, Count",
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
];
|
||||
|
||||
getCardWidths(cardNames, (first, second, third) => {
|
||||
cy.wrap(first).as("_first");
|
||||
cy.wrap(second).as("_second");
|
||||
cy.wrap(third).as("_third");
|
||||
expect(first).to.be.closeTo(second, 10);
|
||||
expect(first).to.be.closeTo(third as unknown as number, 10);
|
||||
});
|
||||
|
||||
const flexContainer = H.getFlexContainerForCard("Orders");
|
||||
|
||||
const handles = H.getResizeHandlesForFlexContianer(flexContainer);
|
||||
|
||||
H.documentDoDrag(handles.eq(1), { x: 50 });
|
||||
|
||||
getCardWidths(cardNames, (first, second, third) => {
|
||||
cy.get("@_first").then((_first) => {
|
||||
cy.get("@_second").then((_second) => {
|
||||
cy.get("@_third").then((_third) => {
|
||||
expect(first).to.be.closeTo(_first as unknown as number, 3);
|
||||
expect(second).to.be.greaterThan(_second as unknown as number);
|
||||
expect(third).to.be.lessThan(_third as unknown as number);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should prevent adding a fourth card to a flexContainer with 3 cards", () => {
|
||||
// Wait for all cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
// First, add the third card to reach the limit
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders",
|
||||
{ side: "right" },
|
||||
);
|
||||
|
||||
// Verify we have 3 cards in the flexContainer
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.within(() => {
|
||||
cy.findAllByTestId("document-card-embed").should("have.length", 3);
|
||||
});
|
||||
|
||||
// Add another card to try to exceed the limit
|
||||
addNewStandaloneCard("Orders Model", "model");
|
||||
|
||||
// Wait for the new card to be added
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 4); // 3 in flexContainer + 1 new standalone
|
||||
|
||||
// Try to drag the new standalone card onto the flexContainer
|
||||
H.dragAndDropCardOnAnotherCard("Orders", "Orders, Count", {
|
||||
side: "left",
|
||||
});
|
||||
|
||||
// Verify the flexContainer still has only 3 cards (drop should be rejected)
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.within(() => {
|
||||
cy.findAllByTestId("document-card-embed").should("have.length", 3);
|
||||
});
|
||||
|
||||
// Verify the standalone card is still separate
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 4); // Still 4 total, with 1 standalone
|
||||
});
|
||||
|
||||
it("should reorder cards within the same flexContainer", () => {
|
||||
// Wait for all cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
// Verify initial order: Orders | Orders, Count
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder(["Orders", "Orders, Count"]);
|
||||
});
|
||||
|
||||
// Drag Orders to the right side of Orders, Count to reorder them
|
||||
H.dragAndDropCardOnAnotherCard("Orders", "Orders, Count", {
|
||||
side: "right",
|
||||
});
|
||||
|
||||
// Verify new order: Orders, Count | Orders
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder(["Orders, Count", "Orders"]);
|
||||
});
|
||||
|
||||
H.dragAndDropCardOnAnotherCard("Orders", "Orders, Count", {
|
||||
side: "left",
|
||||
});
|
||||
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
assertFlexContainerCardsOrder(["Orders", "Orders, Count"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle moving cards between different flexContainers", () => {
|
||||
// First create another flexContainer by dragging the standalone card onto a new location
|
||||
// Add another standalone card first
|
||||
addNewStandaloneCard("Orders Model", "model");
|
||||
|
||||
// Wait for the new card
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 4);
|
||||
|
||||
// Create a second flexContainer by dropping Orders by Year onto the new Orders card
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders Model",
|
||||
);
|
||||
|
||||
// Verify we now have 2 flexContainers
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("have.length", 2);
|
||||
|
||||
// Move a card from the first flexContainer to the second one
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count",
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
{ side: "right" },
|
||||
);
|
||||
|
||||
// Verify the first flexContainer now has only 1 card (should be unwrapped)
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("have.length", 1);
|
||||
|
||||
// Verify the remaining flexContainer has 3 cards
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.within(() => {
|
||||
cy.findAllByTestId("document-card-embed").should("have.length", 3);
|
||||
});
|
||||
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders",
|
||||
{ side: "right" },
|
||||
);
|
||||
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("have.length", 2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deleting a cardEmbed", () => {
|
||||
it("should delete a cardEmbed when selected and Backspace is pressed", () => {
|
||||
H.createDocument({
|
||||
name: "DnD Test Document",
|
||||
document: DOCUMENT_WITH_TWO_CARDS,
|
||||
collection_id: null,
|
||||
alias: "document",
|
||||
idAlias: "documentId",
|
||||
});
|
||||
|
||||
cy.get("@documentId").then((id) => cy.visit(`/document/${id}`));
|
||||
|
||||
// Wait for cards to load
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
// Verify initial state - we have 2 standalone cards
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 2);
|
||||
|
||||
// Click on the Orders card to select it
|
||||
H.getDocumentCard("Orders").realClick({ position: "top" });
|
||||
|
||||
// Press Backspace to delete the selected card
|
||||
cy.realPress("Backspace");
|
||||
|
||||
// Verify the Orders card has been deleted
|
||||
H.getDocumentCard("Orders", false).should("not.exist");
|
||||
|
||||
// Verify only one card remains
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 1);
|
||||
|
||||
// Verify the remaining card is Orders, Count
|
||||
H.getDocumentCard("Orders, Count").should("exist").and("be.visible");
|
||||
});
|
||||
|
||||
it("should delete a cardEmbed from a flexContainer when selected and Backspace is pressed", () => {
|
||||
H.createDocument({
|
||||
name: "DnD Test Document",
|
||||
document: DOCUMENT_WITH_THREE_CARDS_AND_COLUMNS,
|
||||
collection_id: null,
|
||||
alias: "document",
|
||||
idAlias: "documentId",
|
||||
});
|
||||
|
||||
cy.get("@documentId").then((id) => cy.visit(`/document/${id}`));
|
||||
|
||||
// First create a flexContainer by dropping one card onto another
|
||||
H.getDocumentCard("Orders")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
H.getDocumentCard("Orders, Count")
|
||||
.should("be.visible")
|
||||
.findByTestId("table-root")
|
||||
.should("exist");
|
||||
|
||||
// Create flexContainer
|
||||
H.dragAndDropCardOnAnotherCard(
|
||||
"Orders, Count, Grouped by Created At (year)",
|
||||
"Orders",
|
||||
{ side: "right" },
|
||||
);
|
||||
|
||||
// Verify flexContainer was created with 2 cards
|
||||
H.documentContent()
|
||||
.find('[data-type="flexContainer"]')
|
||||
.should("exist")
|
||||
.within(() => {
|
||||
cy.findAllByTestId("document-card-embed").should("have.length", 3);
|
||||
});
|
||||
|
||||
// Click on one of the cards in the flexContainer to select it
|
||||
H.getDocumentCard("Orders").realClick({ position: "top" });
|
||||
|
||||
// Press Backspace to delete the selected card
|
||||
cy.realPress("Backspace");
|
||||
|
||||
// Verify the Orders card has been deleted from the flexContainer
|
||||
H.getDocumentCard("Orders", false).should("not.exist");
|
||||
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 2);
|
||||
|
||||
H.documentContent().get('[data-type="flexContainer"]').should("exist");
|
||||
|
||||
// Click on one of the cards in the flexContainer to select it
|
||||
H.getDocumentCard("Orders, Count").realClick({ position: "top" });
|
||||
|
||||
// Press Backspace to delete the selected card
|
||||
cy.realPress("Backspace");
|
||||
|
||||
// Verify the flexContainer now has only 1 card and should be unwrapped back to standalone
|
||||
H.documentContent()
|
||||
.get('[data-type="flexContainer"]')
|
||||
.should("not.exist"); // FlexContainer should be unwrapped when only 1 card remains
|
||||
|
||||
// Verify only the Orders, Count card remains as a standalone card
|
||||
H.documentContent()
|
||||
.findAllByTestId("document-card-embed")
|
||||
.should("have.length", 1);
|
||||
H.getDocumentCard("Orders, Count, Grouped by Created At (year)").should(
|
||||
"exist",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function assertFlexContainerCardsOrder(expectedCardTitles: string[]) {
|
||||
for (let i = 0; i < expectedCardTitles.length; i++) {
|
||||
cy.findAllByTestId("document-card-embed")
|
||||
.should("have.length", expectedCardTitles.length)
|
||||
.eq(i)
|
||||
.findByTestId("card-embed-title")
|
||||
.should("contain.text", expectedCardTitles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function addNewStandaloneCard(
|
||||
cardName: string,
|
||||
cardType: "question" | "model",
|
||||
) {
|
||||
cy.get(".node-paragraph.is-empty").click();
|
||||
H.addToDocument("/", false);
|
||||
H.commandSuggestionItem("Chart").click();
|
||||
H.entityPickerModalTab(
|
||||
cardType === "question" ? "Questions" : "Models",
|
||||
).click();
|
||||
H.entityPickerModalItem(1, cardName).click();
|
||||
}
|
||||
|
||||
function getCardWidths(
|
||||
cardNames: string[],
|
||||
cb: (val1: number, val2: number, val3?: number) => void,
|
||||
) {
|
||||
const [firstCardName, secondCardName, thirdCardName] = cardNames;
|
||||
H.getDocumentCard(firstCardName).then((firstCard) => {
|
||||
H.getDocumentCard(secondCardName).then((secondCard) => {
|
||||
if (thirdCardName) {
|
||||
H.getDocumentCard(thirdCardName).then((thirdCard) => {
|
||||
cb(
|
||||
firstCard.width() as number,
|
||||
secondCard.width() as number,
|
||||
thirdCard.width() as number,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
cb(firstCard.width() as number, secondCard.width() as number);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||