gabotorresruiz commented on code in PR #35254:
URL: https://github.com/apache/superset/pull/35254#discussion_r2395599597
##########
superset-frontend/src/features/themes/ThemeModal.test.tsx:
##########
@@ -87,200 +57,385 @@ const mockTheme: ThemeObject = {
},
};
-// Mock theme API endpoints
-fetchMock.get('glob:*/api/v1/theme/1', {
- result: mockTheme,
-});
-
-fetchMock.post('glob:*/api/v1/theme/', {
- result: { ...mockTheme, id: 2 },
-});
+const mockSystemTheme: ThemeObject = {
+ ...mockTheme,
+ id: 2,
+ theme_name: 'System Theme',
+ is_system: true,
+};
-fetchMock.put('glob:*/api/v1/theme/1', {
- result: mockTheme,
-});
+const defaultProps = {
+ addDangerToast: jest.fn(),
+ addSuccessToast: jest.fn(),
+ onThemeAdd: jest.fn(),
+ onHide: jest.fn(),
+ show: true,
+ canDevelop: false,
+};
-// These are defined but not used in the simplified tests
-// const mockUser = {
-// userId: 1,
-// firstName: 'Admin',
-// lastName: 'User',
-// roles: { Admin: [['can_write', 'Dashboard']] },
-// permissions: {},
-// isActive: true,
-// isAnonymous: false,
-// username: 'admin',
-// email: '[email protected]',
-// user_id: 1,
-// first_name: 'Admin',
-// last_name: 'User',
-// };
-
-// const defaultProps = {
-// addDangerToast: jest.fn(),
-// addSuccessToast: jest.fn(),
-// onThemeAdd: jest.fn(),
-// onHide: jest.fn(),
-// show: true,
-// };
+const setup = (props = {}) => {
+ const utils = render(<ThemeModal {...defaultProps} {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ });
+ return {
+ ...utils,
+ mockProps: { ...defaultProps, ...props },
+ };
+};
describe('ThemeModal', () => {
beforeEach(() => {
- fetchMock.resetHistory();
+ fetchMock.reset();
+ fetchMock.get('glob:*/api/v1/theme/1', { result: mockTheme });
+ fetchMock.get('glob:*/api/v1/theme/2', { result: mockSystemTheme });
+ fetchMock.get('glob:*/api/v1/theme/*', { result: mockTheme });
+ fetchMock.post('glob:*/api/v1/theme/', { result: { ...mockTheme, id: 3 }
});
+ fetchMock.put('glob:*/api/v1/theme/*', { result: mockTheme });
jest.clearAllMocks();
});
afterEach(() => {
fetchMock.restore();
});
- test('should export ThemeModal component', () => {
- const ThemeModalModule = jest.requireActual('./ThemeModal');
- expect(ThemeModalModule.default).toBeDefined();
- expect(typeof ThemeModalModule.default).toBe('object'); // HOC wrapped
component
- });
+ describe('Component Rendering', () => {
Review Comment:
Done!
--
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]