Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PADV-1475 test: Creating test for shared componets and helper functions. #19

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

nandodev-net
Copy link
Contributor

@nandodev-net nandodev-net commented Sep 5, 2024

Tickets

Description

This PR aims to improve and finalize the test coverage for the core application components and helper functions. It includes comprehensive test suites for the following components:

  1. Core Components:
  • Main.jsx: Ensures that the main application routing and component loading logic are correctly implemented, covering all possible routes and their respective components (ClassRoster, LabSummary, LabDetails).
  1. Main Views:

ClassRoster:

  • Index.jsx: Tests for correct rendering, data fetching, error handling, and interactions.
  • Columns.jsx: Tests column definitions and specific cell rendering logic.

LabSummary:

  • Index.jsx: Includes tests for component rendering, pagination, error handling, and data fetching.
  • Columns.jsx: Verifies the column configurations, including custom cell logic for different data types.

LabDetails:

  • Index.jsx: Ensures that lab details are fetched correctly, errors are managed properly, and navigation actions work as expected.
  1. Helper Functions:

Helpers/Index.js: Covers all utility functions and ensures their expected behavior across different scenarios.

Changes Made

This PR targets increasing the test coverage for the critical parts of the application, particularly focusing on routing, main view functionality, and helper functions. Expected coverage:

  • Main.jsx: 89.47%
  • ClassRoster: Index and Columns at 94.44%
  • LabSummary: Index and Columns at 93.18%
  • LabDetails: Index at 95.83%
  • Helper functions: 100%

How To Test

  1. Ensure your development environment is set up with the latest dependencies by running npm i in your MFE folder.
  2. Run all test with npm test -- --verbose
    Verify that all tests pass and that coverage reports indicate the coverage for the targeted files.

Component Tests

  • Helpers

    • Index ----> Done cov. 100/100
  • Views

    • ClassRoster

      • Index ----> Done cov. 92.85/100
      • Columns ----> Done cov. 100/100
    • LabSummary

      • Index ----> Done cov. 90.32/100
      • Columns ----> Done cov. 100/100
    • LabDetails

      • Index ----> Done cov. 95.83/100
  • Core

    • Main ----> Done cov. 89.47/100

image

@nandodev-net nandodev-net self-assigned this Sep 5, 2024
@nandodev-net nandodev-net force-pushed the vue/PADV-1475 branch 6 times, most recently from 398cbf5 to 161a544 Compare September 10, 2024 14:06
@nandodev-net nandodev-net changed the title test: Creating test for shared componets and helper functions. PADV-1475 test: Creating test for shared componets and helper functions. Sep 10, 2024
@nandodev-net nandodev-net marked this pull request as ready for review September 10, 2024 18:07
package.json Outdated Show resolved Hide resolved
src/core/tests/Main.test.jsx Outdated Show resolved Hide resolved
src/core/tests/Main.test.jsx Show resolved Hide resolved
src/core/tests/Main.test.jsx Show resolved Hide resolved
src/helpers/tests/index.test.js Show resolved Hide resolved
Comment on lines 12 to 17
import { logError } from '@edx/frontend-platform/logging';
import LabSummary from '../index';
import '@testing-library/jest-dom';
import { columns } from '../columns';
import { formatUnixTimestamp } from '../../../helpers';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { logError } from '@edx/frontend-platform/logging';
import LabSummary from '../index';
import '@testing-library/jest-dom';
import { columns } from '../columns';
import { formatUnixTimestamp } from '../../../helpers';
import { logError } from '@edx/frontend-platform/logging';
import '@testing-library/jest-dom';
import LabSummary from '../index';
import { columns } from '../columns';
import { formatUnixTimestamp } from '../../../helpers';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/views/LabSummary/tests/index.test.jsx Outdated Show resolved Hide resolved
src/views/LabSummary/tests/index.test.jsx Outdated Show resolved Hide resolved
src/views/LabSummary/tests/index.test.jsx Outdated Show resolved Hide resolved
src/views/LabSummary/tests/index.test.jsx Outdated Show resolved Hide resolved
@JuanDavidBuitrago
Copy link
Contributor

@nandodev-net You have a lot of unnecessary inline comments, even in Spanish.

@nandodev-net
Copy link
Contributor Author

@nandodev-net You have a lot of unnecessary inline comments, even in Spanish.

@JuanDavidBuitrago Sure, but given so many tests of that tool that I don't know well, for me they were very useful. Now that I know the approach makes sense, I clean them

jest.config.js Outdated
Comment on lines 2 to 9
// Your existing Jest configuration options
moduleNameMapper: {
'^views/(.*)$': '<rootDir>/src/views/$1',
'^shared/(.*)$': '<rootDir>/src/shared/$1',
'^constants/(.*)$': '<rootDir>/src/constants/$1',
// Add more mappings as needed
'\\.(css|less|scss|sass)$': 'identity-obj-proxy', // Mock CSS modules
'\\.(svg|png|jpg|jpeg|gif)$': '<rootDir>/__mocks__/fileMock.js', // Mock files like images
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These inline comments are necessaries? @nandodev-net

@nandodev-net nandodev-net merged commit b5fecd6 into main Sep 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants