From 8ce397921524c6c36b11276ae412f1bad3204d03 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Thu, 12 Mar 2026 00:42:20 +0500 Subject: [PATCH] fix: resolve PropType validation errors and add test data defaults --- .github/workflows/release.yml | 64 ++++++++++++------- src/Notification/NotificationRowItem.jsx | 6 +- .../__factories__/notifications.factory.js | 3 +- src/Notification/index.jsx | 3 +- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a167772..19f44b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,51 @@ -name: Release +name: Release CI on: push: branches: - main permissions: - id-token: write # Required for OIDC - contents: write # For Semantic Release tagging - + contents: read # for checkout jobs: release: name: Release runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for trusted publishing and npm provenance steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - - name: Install dependencies - run: npm ci - - name: Test - run: npm run test - - name: Build - run: npm run build - - name: Release - run: npx semantic-release@25 - env: - GITHUB_TOKEN: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Setup Nodejs Env + run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV + - name: Setup Node.js + uses: actions/setup-node@v5 + with: + node-version: ${{ env.NODE_VER }} + - name: Install dependencies + run: npm ci + - name: Validate package-lock.json changes + run: make validate-no-uncommitted-package-lock-changes + - name: Lint + run: npm run lint + - name: Type check + run: npm run types + - name: Test + run: npm run test + - name: i18n_extract + run: npm run i18n_extract + - name: Coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false + - name: Build + run: npm run build + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} + run: npx semantic-release@25 diff --git a/src/Notification/NotificationRowItem.jsx b/src/Notification/NotificationRowItem.jsx index 6547c01..6be336e 100644 --- a/src/Notification/NotificationRowItem.jsx +++ b/src/Notification/NotificationRowItem.jsx @@ -14,7 +14,7 @@ import { useNotification } from './data/hook'; import { notificationsContext } from './context/notificationsContext'; const NotificationRowItem = ({ - id, type, contentUrl, content, courseName, createdAt, lastRead, + id, type = '', contentUrl, content, courseName, createdAt, lastRead = '', }) => { timeago.register('time-locale', timeLocale); const intl = useIntl(); @@ -85,12 +85,12 @@ const NotificationRowItem = ({ NotificationRowItem.propTypes = { id: PropTypes.number.isRequired, - type: PropTypes.string.isRequired, + type: PropTypes.string, contentUrl: PropTypes.string.isRequired, content: PropTypes.node.isRequired, courseName: PropTypes.string.isRequired, createdAt: PropTypes.string.isRequired, - lastRead: PropTypes.string.isRequired, + lastRead: PropTypes.string, }; export default React.memo(NotificationRowItem); diff --git a/src/Notification/data/__factories__/notifications.factory.js b/src/Notification/data/__factories__/notifications.factory.js index a5f0b0f..b628363 100644 --- a/src/Notification/data/__factories__/notifications.factory.js +++ b/src/Notification/data/__factories__/notifications.factory.js @@ -10,7 +10,8 @@ Factory.define('notificationsCount') authoring: 5, }) .attr('showNotificationsTray', true) - .attr('isNewNotificationViewEnabled', true); + .attr('isNewNotificationViewEnabled', true) + .attr('notification_expiry_days', 60); Factory.define('notification') .sequence('id') diff --git a/src/Notification/index.jsx b/src/Notification/index.jsx index 0fd9e76..c9b5a2f 100644 --- a/src/Notification/index.jsx +++ b/src/Notification/index.jsx @@ -62,6 +62,7 @@ const Notifications = ({ notificationAppData, margins }) => { setNotificationData(prevData => ({ ...prevData, ...notificationAppData, + notificationExpiryDays: notificationAppData.notificationExpiryDays ?? 0, })); }, [notificationAppData]); @@ -220,7 +221,7 @@ Notifications.propTypes = { ).isRequired, appsId: PropTypes.arrayOf(PropTypes.string).isRequired, isNewNotificationViewEnabled: PropTypes.bool.isRequired, - notificationExpiryDays: PropTypes.number.isRequired, + notificationExpiryDays: PropTypes.number, notificationStatus: PropTypes.string.isRequired, showNotificationsTray: PropTypes.bool.isRequired, tabsCount: PropTypes.shape({