rusackas commented on code in PR #41491:
URL: https://github.com/apache/superset/pull/41491#discussion_r3532968886
##########
superset-frontend/src/embedded/index.test.tsx:
##########
@@ -16,26 +16,104 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { setupAGGridModules } from
'@superset-ui/core/components/ThemedAgGridReact';
+// Mark this file as a module so its top-level declarations stay file-scoped
+// (the file has no imports; modules are loaded via require() inside tests).
+export {};
+
+// Stable mock references so they survive jest.resetModules() between tests
+// (a factory-created jest.fn() would otherwise be replaced on each reset,
+// leaving these imported handles pointing at a stale instance).
+const mockSetupAGGridModules = jest.fn();
+const mockLogging = { debug: jest.fn(), warn: jest.fn(), error: jest.fn() };
jest.mock('src/public-path', () => ({}));
jest.mock('query-string', () => ({}));
jest.mock('@superset-ui/core/components/ThemedAgGridReact', () => ({
- setupAGGridModules: jest.fn(),
+ setupAGGridModules: mockSetupAGGridModules,
}));
-jest.mock('src/preamble', () => jest.fn().mockResolvedValue(true));
+jest.mock('@apache-superset/core/utils', () => ({
+ logging: mockLogging,
+}));
-jest.mock('src/setup/setupPlugins', () => jest.fn(), { virtual: true });
+// setupPlugins is driven per-test so the retry path can force a rejection.
+const mockSetupPlugins = jest.fn();
+jest.mock('src/setup/setupPlugins', () => mockSetupPlugins, { virtual: true });
jest.mock('src/setup/setupCodeOverrides', () => jest.fn(), { virtual: true });
+jest.mock('src/preamble', () => jest.fn().mockResolvedValue(true));
+
+// makeApi returns a callable that resolves with the current user roles.
+const mockGetMeWithRole = jest.fn();
+jest.mock('@superset-ui/core', () => ({
+ ...jest.requireActual('@superset-ui/core'),
+ makeApi: () => mockGetMeWithRole,
+}));
+
+jest.mock('src/components/UiConfigContext', () => ({
+ useUiConfig: () => ({}),
+}));
+
+// Capture the guestToken handler that start() is wired to, so tests can
+// re-trigger the handshake and assert the retry behavior.
+const mockSwitchboard = {
+ handler: undefined as ((arg: { guestToken: string }) => void) | undefined,
+};
+jest.mock('@superset-ui/switchboard', () => ({
+ __esModule: true,
+ default: {
+ init: jest.fn(),
+ start: jest.fn(),
+ defineMethod: (name: string, fn: (...args: any[]) => any) => {
+ if (name === 'guestToken') {
Review Comment:
Good catch, replaced the `any[]`/`any` with the concrete `{ guestToken:
string }` shape the mock actually uses. Pushed 89dd83a.
--
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]