From f24f04b97f7ffab0a0395cf8f997e21aba44555f Mon Sep 17 00:00:00 2001 From: jciasenza Date: Mon, 9 Dec 2024 11:55:06 -0300 Subject: [PATCH 1/3] fix: styles conventions --- lms/templates/header/navbar-not-authenticated.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/header/navbar-not-authenticated.html b/lms/templates/header/navbar-not-authenticated.html index 61448b73bd84..b50e535acda6 100644 --- a/lms/templates/header/navbar-not-authenticated.html +++ b/lms/templates/header/navbar-not-authenticated.html @@ -39,7 +39,7 @@ % if allows_login: % if can_discover_courses: %endif % endif From 57bbb1ca75e5e614c881f33286c05f986c9c3d7d Mon Sep 17 00:00:00 2001 From: jciasenza Date: Thu, 12 Dec 2024 17:07:12 -0300 Subject: [PATCH 2/3] comillas mal cambiadas --- lms/templates/header/navbar-not-authenticated.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/header/navbar-not-authenticated.html b/lms/templates/header/navbar-not-authenticated.html index b50e535acda6..61448b73bd84 100644 --- a/lms/templates/header/navbar-not-authenticated.html +++ b/lms/templates/header/navbar-not-authenticated.html @@ -39,7 +39,7 @@ % if allows_login: % if can_discover_courses: %endif % endif From 7187f63196559a5ad6829e2516654fefe066658c Mon Sep 17 00:00:00 2001 From: jciasenza Date: Thu, 12 Dec 2024 17:40:57 -0300 Subject: [PATCH 3/3] fix: enzyme testing replaced by react tester --- .../components/Main/Main.test.jsx | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/lms/djangoapps/instructor/static/instructor/ProblemBrowser/components/Main/Main.test.jsx b/lms/djangoapps/instructor/static/instructor/ProblemBrowser/components/Main/Main.test.jsx index fc44829b906e..ea9495fcd34f 100644 --- a/lms/djangoapps/instructor/static/instructor/ProblemBrowser/components/Main/Main.test.jsx +++ b/lms/djangoapps/instructor/static/instructor/ProblemBrowser/components/Main/Main.test.jsx @@ -1,11 +1,7 @@ -// eslint-disable-next-line no-redeclare -/* global jest,test,describe,expect */ -import { Button } from '@edx/paragon'; -import BlockBrowserContainer from 'BlockBrowser/components/BlockBrowser/BlockBrowserContainer'; +/* global jest, test, describe, expect */ import { Provider } from 'react-redux'; -import { shallow } from 'enzyme'; import React from 'react'; -import renderer from 'react-test-renderer'; +import { render, screen, fireEvent } from '@testing-library/react'; // Importa render y fireEvent import store from '../../data/store'; import Main from './Main'; @@ -17,7 +13,7 @@ describe('ProblemBrowser Main component', () => { const excludedBlockTypes = []; test('render with basic parameters', () => { - const component = renderer.create( + const { asFragment } = render(
{ selectedBlock={null} taskStatusEndpoint={taskStatusEndpoint} /> - , + ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); test('render with selected block', () => { - const component = renderer.create( + const { asFragment } = render(
{ selectedBlock="some-selected-block" taskStatusEndpoint={taskStatusEndpoint} /> - , + ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); test('fetch course block on toggling dropdown', () => { const fetchCourseBlocksMock = jest.fn(); - const component = renderer.create( + render(
{ selectedBlock="some-selected-block" taskStatusEndpoint={taskStatusEndpoint} /> - , + ); - // eslint-disable-next-line prefer-destructuring - const instance = component.root.children[0].instance; - instance.handleToggleDropdown(); - expect(fetchCourseBlocksMock.mock.calls.length).toBe(1); + + const toggleButton = screen.getByRole('button', { name: 'Select a section or problem' }); + fireEvent.click(toggleButton); + expect(fetchCourseBlocksMock).toHaveBeenCalledTimes(1); }); test('display dropdown on toggling dropdown', () => { - const component = shallow( -
, + render( + +
+ ); - expect(component.find(BlockBrowserContainer).length).toBeFalsy(); - component.find(Button).find({ label: 'Select a section or problem' }).simulate('click'); - expect(component.find(BlockBrowserContainer).length).toBeTruthy(); + + expect(screen.queryByTestId('block-browser-container')).toBeNull(); + const toggleButton = screen.getByRole('button', { name: 'Select a section or problem' }); + fireEvent.click(toggleButton); + expect(screen.getByTestId('block-browser-container')).toBeInTheDocument(); }); });