Sameerali0 commented on code in PR #33965:
URL: https://github.com/apache/superset/pull/33965#discussion_r2222276465
##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -316,7 +316,11 @@ export function dbReducer(
...extraJson,
schemas_allowed_for_file_upload: (action.payload.value || '')
.split(',')
- .filter(schema => schema !== ''),
+ .filter((schema, index, arr) => {
+ const trimmed = schema.trim();
+ if (index === arr.length - 1) return true;
+ return trimmed !== '';
+ }),
Review Comment:
The test is failing because if the user writes "bar," in the schema then
there should only be a bar schema but we also have an "" empty schema with it
thus the test fails. The provided solution doesnt works.
Here is the output of the failing test:
Error: The document global was defined when React was initialized, but is
not defined anymore. This can happen in a test environment if a component
schedules an update from an asynchronous callback, but the test has already
finished running. To solve this, you can either unmount the component at the
end of your test (and ensure that any asynchronous operations get canceled in
componentWillUnmount), or you can change the test itself to be asynchronous.
at Object.invokeGuardedCallbackDev
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:3901:17)
at invokeGuardedCallback
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:4056:31)
at flushPassiveEffectsImpl
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:23543:11)
at unstable_runWithPriority
(/app/superset-frontend/node_modules/scheduler/cjs/scheduler.development.js:468:12)
at runWithPriority$1
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:11276:10)
at flushPassiveEffects
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:23447:14)
at Object.<anonymous>.flushWork
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom-test-utils.development.js:992:10)
at Immediate.<anonymous>
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1003:11)
at processImmediate (node:internal/timers:483:21)
Node.js v20.19.4
Browserslist: browsers data (caniuse-lite) is 6 months old. Please run:
npx update-browserslist-db@latest
Why you should do it regularly:
https://github.com/browserslist/update-db#readme
/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:3901
throw Error( "The document global was defined when React was
initialized, but is not defined anymore. This can happen in a test environment
if a component schedules an update from an asynchronous callback, but the test
has already finished running. To solve this, you can either unmount the
component at the end of your test (and ensure that any asynchronous operations
get canceled in componentWillUnmount), or you can change the test itself to be
asynchronous." );
^
Error: The document global was defined when React was initialized, but is
not defined anymore. This can happen in a test environment if a component
schedules an update from an asynchronous callback, but the test has already
finished running. To solve this, you can either unmount the component at the
end of your test (and ensure that any asynchronous operations get canceled in
componentWillUnmount), or you can change the test itself to be asynchronous.
at Object.invokeGuardedCallbackDev
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:3901:17)
at invokeGuardedCallback
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:4056:31)
at flushPassiveEffectsImpl
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:23543:11)
at unstable_runWithPriority
(/app/superset-frontend/node_modules/scheduler/cjs/scheduler.development.js:468:12)
at runWithPriority$1
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:11276:10)
at flushPassiveEffects
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom.development.js:23447:14)
at Object.<anonymous>.flushWork
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom-test-utils.development.js:992:10)
at Immediate.<anonymous>
(/app/superset-frontend/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1003:11)
at processImmediate (node:internal/timers:483:21)
Node.js v20.19.4
Browserslist: browsers data (caniuse-lite) is 6 months old. Please run:
npx update-browserslist-db@latest
Why you should do it regularly:
https://github.com/browserslist/update-db#readme
FAIL src/features/databases/DatabaseModal/index.test.tsx (260.128 s)
● dbReducer › it will set state to payload from extra
input change when schemas_allowed_for_file_upload
with blank list
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Object {
"backend": "postgres",
"configuration_method": "dynamic_form",
"database_name": "Postgres",
"driver": "psycopg2",
- "extra": "{\"schemas_allowed_for_file_upload\":[\"bar\"]}",
+ "extra": "{\"schemas_allowed_for_file_upload\":[\"bar\",\"\"]}",
"id": 123,
"is_managed_externally": false,
"name": "PostgresDB",
}
1755 |
1756 | // extra should be serialized
> 1757 | expect(currentState).toEqual({
| ^
1758 | ...databaseFixture,
1759 | extra: '{"schemas_allowed_for_file_upload":["bar"]}',
1760 | });
at Object.toEqual
(src/features/databases/DatabaseModal/index.test.tsx:1757:26)
jest-html-reporter >> Report generated
(/app/superset-frontend/test-report.html)
Summary of all failing tests
FAIL src/features/databases/DatabaseModal/index.test.tsx (260.128 s)
● dbReducer › it will set state to payload from extra
input change when schemas_allowed_for_file_upload
with blank list
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
Object {
"backend": "postgres",
"configuration_method": "dynamic_form",
"database_name": "Postgres",
"driver": "psycopg2",
- "extra": "{\"schemas_allowed_for_file_upload\":[\"bar\"]}",
+ "extra": "{\"schemas_allowed_for_file_upload\":[\"bar\",\"\"]}",
"id": 123,
"is_managed_externally": false,
"name": "PostgresDB",
}
1755 |
1756 | // extra should be serialized
> 1757 | expect(currentState).toEqual({
| ^
1758 | ...databaseFixture,
1759 | extra: '{"schemas_allowed_for_file_upload":["bar"]}',
1760 | });
at Object.toEqual
(src/features/databases/DatabaseModal/index.test.tsx:1757:26)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]