11import { getConfig , history } from '@edx/frontend-platform' ;
22import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth' ;
33import { AppProvider } from '@edx/frontend-platform/react' ;
4- import { waitForElementToBeRemoved , fireEvent } from '@testing-library/dom' ;
4+ import { waitForElementToBeRemoved } from '@testing-library/dom' ;
55import '@testing-library/jest-dom' ;
66import { render , screen } from '@testing-library/react' ;
77import React from 'react' ;
@@ -193,15 +193,13 @@ describe('CoursewareContainer', () => {
193193 expect ( courseHeader . querySelector ( '.course-title' ) ) . toHaveTextContent ( courseHomeMetadata . title ) ;
194194 }
195195
196- function assertSequenceNavigation ( container , expectedUnitCount = 3 ) {
197- // Ensure we had appropriate sequence navigation buttons. We should only have one unit.
196+ function assertNoSequenceNavigation ( container ) {
198197 const sequenceNavButtons = container . querySelectorAll ( 'nav.sequence-navigation a, nav.sequence-navigation button' ) ;
199- expect ( sequenceNavButtons ) . toHaveLength ( expectedUnitCount + 2 ) ;
198+ expect ( sequenceNavButtons ) . toHaveLength ( 0 ) ;
200199
201- expect ( sequenceNavButtons [ 0 ] ) . toHaveTextContent ( 'Previous' ) ;
202- // Prove this button is rendering an SVG tasks icon, meaning it's a unit/vertical.
203- expect ( sequenceNavButtons [ 1 ] . querySelector ( 'svg' ) ) . toHaveClass ( 'fa-tasks' ) ;
204- expect ( sequenceNavButtons [ sequenceNavButtons . length - 1 ] ) . toHaveTextContent ( 'Next' ) ;
200+ expect ( container . querySelector ( 'button, a' ) ) . not . toHaveTextContent ( 'Previous' ) ;
201+ expect ( container . querySelector ( 'svg.fa-tasks' ) ) . toBeNull ( ) ;
202+ expect ( container . querySelector ( 'button, a' ) ) . not . toHaveTextContent ( 'Next' ) ;
205203 }
206204
207205 beforeEach ( async ( ) => {
@@ -224,7 +222,7 @@ describe('CoursewareContainer', () => {
224222 const container = await loadContainer ( ) ;
225223
226224 assertLoadedHeader ( container ) ;
227- assertSequenceNavigation ( container ) ;
225+ assertNoSequenceNavigation ( container ) ;
228226
229227 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( 'Unit Contents' ) ;
230228 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( courseId ) ;
@@ -247,7 +245,7 @@ describe('CoursewareContainer', () => {
247245 const container = await loadContainer ( ) ;
248246
249247 assertLoadedHeader ( container ) ;
250- assertSequenceNavigation ( container ) ;
248+ assertNoSequenceNavigation ( container ) ;
251249
252250 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( 'Unit Contents' ) ;
253251 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( courseId ) ;
@@ -274,29 +272,12 @@ describe('CoursewareContainer', () => {
274272 setUpMockRequests ( { courseBlocks } ) ;
275273 } ) ;
276274
277- // describe('when the URL contains a unit ID', () => {
278- // it('should ignore the section ID and redirect based on the unit ID', async () => {
279- // const urlUnit = unitTree[1][1][1];
280- // setUrl(sectionTree[1].id, urlUnit.id);
281- // const container = await loadContainer();
282- // assertLoadedHeader(container);
283- // assertSequenceNavigation(container, 2);
284- // assertLocation(container, sequenceTree[1][1].id, urlUnit.id);
285- // });
286-
287- // it('should ignore invalid unit IDs and redirect to the course root', async () => {
288- // setUrl(sectionTree[1].id, 'foobar');
289- // await loadContainer();
290- // expect(global.location.href).toEqual(`http://localhost/course/${courseId}`);
291- // });
292- // });
293-
294275 describe ( 'when the URL does not contain a unit ID' , ( ) => {
295276 it ( 'should choose a unit within the section\'s first sequence' , async ( ) => {
296277 setUrl ( sectionTree [ 1 ] . id ) ;
297278 const container = await loadContainer ( ) ;
298279 assertLoadedHeader ( container ) ;
299- assertSequenceNavigation ( container , 2 ) ;
280+ assertNoSequenceNavigation ( container ) ;
300281 assertLocation ( container , sequenceTree [ 1 ] [ 0 ] . id , unitTree [ 1 ] [ 0 ] [ 0 ] . id ) ;
301282 } ) ;
302283 } ) ;
@@ -342,27 +323,6 @@ describe('CoursewareContainer', () => {
342323 } ) ;
343324 } ) ;
344325
345- // describe('when the URL only contains a unit ID', () => {
346- // const { courseBlocks, unitTree, sequenceTree } = buildBinaryCourseBlocks(courseId, courseMetadata.name);
347-
348- // beforeEach(async () => {
349- // setUpMockRequests({ courseBlocks });
350- // });
351-
352- // it('should insert the sequence ID into the URL', async () => {
353- // const unit = unitTree[1][0][1];
354- // history.push(`/course/${courseId}/${unit.id}`);
355- // const container = await loadContainer();
356-
357- // assertLoadedHeader(container);
358- // assertSequenceNavigation(container, 2);
359- // const expectedSequenceId = sequenceTree[1][0].id;
360- // const expectedUrl = `http://localhost/course/${courseId}/${expectedSequenceId}/${unit.id}`;
361- // expect(global.location.href).toEqual(expectedUrl);
362- // expect(container.querySelector('.fake-unit')).toHaveTextContent(unit.id);
363- // });
364- // });
365-
366326 describe ( 'when the URL contains a course ID and sequence ID' , ( ) => {
367327 const sequenceBlock = defaultSequenceBlock ;
368328 const unitBlocks = defaultUnitBlocks ;
@@ -372,7 +332,7 @@ describe('CoursewareContainer', () => {
372332 const container = await loadContainer ( ) ;
373333
374334 assertLoadedHeader ( container ) ;
375- assertSequenceNavigation ( container ) ;
335+ assertNoSequenceNavigation ( container ) ;
376336
377337 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( 'Unit Contents' ) ;
378338 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( courseId ) ;
@@ -391,7 +351,7 @@ describe('CoursewareContainer', () => {
391351 const container = await loadContainer ( ) ;
392352
393353 assertLoadedHeader ( container ) ;
394- assertSequenceNavigation ( container ) ;
354+ assertNoSequenceNavigation ( container ) ;
395355
396356 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( 'Unit Contents' ) ;
397357 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( courseId ) ;
@@ -408,44 +368,24 @@ describe('CoursewareContainer', () => {
408368 const container = await loadContainer ( ) ;
409369
410370 assertLoadedHeader ( container ) ;
411- assertSequenceNavigation ( container ) ;
371+ assertNoSequenceNavigation ( container ) ;
412372
413373 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( 'Unit Contents' ) ;
414374 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( courseId ) ;
415375 expect ( container . querySelector ( '.fake-unit' ) ) . toHaveTextContent ( unitBlocks [ 2 ] . id ) ;
416376 } ) ;
417377
418- it ( 'should navigate between units and check block completion ' , async ( ) => {
419- axiosMock . onPost ( ` ${ courseId } /xblock/ ${ sequenceBlock . id } /handler/get_completion` ) . reply ( 200 , {
420- complete : true ,
421- } ) ;
378+ it ( 'should render the sequence_navigation plugin slot correctly ' , async ( ) => {
379+ axiosMock
380+ . onPost ( ` ${ courseId } /xblock/ ${ sequenceBlock . id } /handler/get_completion` )
381+ . reply ( 200 , { complete : true } ) ;
422382
423383 history . push ( `/course/${ courseId } /${ sequenceBlock . id } /${ unitBlocks [ 0 ] . id } ` ) ;
424- const container = await loadContainer ( ) ;
425-
426- const sequenceNavButtons = container . querySelectorAll ( 'nav.sequence-navigation a, nav.sequence-navigation button' ) ;
427- const sequenceNextButton = sequenceNavButtons [ 4 ] ;
428- expect ( sequenceNextButton ) . toHaveTextContent ( 'Next' ) ;
429- fireEvent . click ( sequenceNextButton ) ;
384+ await loadContainer ( ) ;
430385
431- expect ( global . location . href ) . toEqual ( `http://localhost/course/ ${ courseId } / ${ sequenceBlock . id } / ${ unitBlocks [ 1 ] . id } ` ) ;
386+ expect ( screen . getByTestId ( 'org.openedx.frontend.learning.sequence_navigation.v1' ) ) . toBeInTheDocument ( ) ;
432387 } ) ;
433388 } ) ;
434-
435- // describe('when the current sequence is an exam', () => {
436- // const { location } = window;
437-
438- // beforeEach(() => {
439- // delete window.location;
440- // window.location = {
441- // assign: jest.fn(),
442- // };
443- // });
444-
445- // afterEach(() => {
446- // window.location = location;
447- // });
448- // });
449389 } ) ;
450390
451391 describe ( 'when receiving a course_access error_code' , ( ) => {
0 commit comments