diff --git a/package.json b/package.json index 0c3c36b6..e5b79396 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "prepare": "husky install", "snapshot": "fedx-scripts jest --updateSnapshot", "start": "fedx-scripts webpack-dev-server --progress", - "test": "fedx-scripts jest --coverage --passWithNoTests" + "test": "fedx-scripts jest --coverage --passWithNoTests", + "testx": "fedx-scripts jest -t 'Outline Tab' --coverage --passWithNoTests" }, "author": "edX", "license": "AGPL-3.0", diff --git a/src/course-home/outline-tab/OutlineTab.test.jsx b/src/course-home/outline-tab/OutlineTab.test.jsx index 9e23f478..da4ac1e8 100644 --- a/src/course-home/outline-tab/OutlineTab.test.jsx +++ b/src/course-home/outline-tab/OutlineTab.test.jsx @@ -23,6 +23,8 @@ import { CERT_STATUS_TYPE } from './alerts/certificate-status-alert/CertificateS import OutlineTab from './OutlineTab'; import LoadedTabPage from '../../tab-page/LoadedTabPage'; +import SequenceLink from './SequenceLink'; + initializeMockApp(); jest.mock('@edx/frontend-platform/analytics'); @@ -155,29 +157,48 @@ describe('Outline Tab', () => { expect(sequenceLink.getAttribute('href')).toContain(`/course/${courseId}`); }); - // TODO: insert unit test for if due date is null or not, what the subtitle - // If due date set, make sure subtitle says description AND due date - it('exam subsection description and due date display correctly', async () => { - const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { resumeBlock: true }); + it('if exam due date set, exam description AND due date appear', async () => { + // Create a due date set a year into the future + const now = new Date(); + const dueDate = new Date(now.getFullYear() + 1, now.getMonth(), now.getDate()); + + // Build course blocks with a future due date set + const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { + sequenceBlocks: [ + , + ], + }); setTabData({ course_blocks: { blocks: courseBlocks.blocks }, }); await fetchAndRender(); + // Button renders as "Expand All" + const expandButton = screen.getByRole('button', { name: 'Expand all' }); + expect(expandButton).toBeInTheDocument(); + + // Click to expand section + userEvent.click(expandButton); + // Look for a substring that says "(exam type) Exam due (datetime)"" expect(screen.getByText(/Exam due/)).toBeInDocument(); }); // If due date is NOT set, ONLY display description - it('exam subsection description and due date display correctly', async () => { - const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { resumeBlock: true }); - setTabData({ - course_blocks: { blocks: courseBlocks.blocks }, - }); - await fetchAndRender(); - // Look for a substring that only says "(exam type) Exam" - expect(screen.getByText(/Exam$/)).toBeInDocument(); - }); }); describe('Suggested schedule alerts', () => {