From 26ff6fcac7990d8fcc9cc72f16158be393c12bca Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 5 Jul 2024 12:03:53 +0530 Subject: [PATCH 01/23] added tests for build-newsroom-videos.js --- scripts/build-newsroom-videos.js | 56 +++++++++++++------------ tests/build-newsroom-videos.test.js | 65 +++++++++++++++++++++++++++++ tests/fixtures/newsroomData.js | 49 ++++++++++++++++++++++ 3 files changed, 144 insertions(+), 26 deletions(-) create mode 100644 tests/build-newsroom-videos.test.js create mode 100644 tests/fixtures/newsroomData.js diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 073a63db9b1d..fc5ab6e0e94c 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -1,10 +1,9 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); -const fetch = require('node-fetch') -async function buildNewsroomVideos() { +const fetch = require('node-fetch'); +async function buildNewsroomVideos() { try { - let data; const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ key: process.env.YOUTUBE_TOKEN, part: 'snippet', @@ -13,32 +12,37 @@ async function buildNewsroomVideos() { type: 'video', order: 'Date', maxResults: 5, - })) - data = await response.json() - const videoDataItems = data.items.map((video) => { - return { - image_url: video.snippet.thumbnails.high.url, - title: video.snippet.title, - description: video.snippet.description, - videoId: video.id.videoId, - } - }) - const videoData = JSON.stringify(videoDataItems, null, ' '); - console.log('The following are the Newsroom Youtube videos: ', videoData) - - try { - writeFileSync( - resolve(__dirname, '../config', 'newsroom_videos.json'), - videoData - ); - } catch (err) { - console.error(err); + })); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const data = await response.json(); + + if (!data || !data.items) { + throw new Error('Invalid data structure received from YouTube API'); } + + const videoDataItems = data.items.map((video) => ({ + image_url: video.snippet.thumbnails.high.url, + title: video.snippet.title, + description: video.snippet.description, + videoId: video.id.videoId, + })); + + const videoData = JSON.stringify(videoDataItems, null, ' '); + console.log('The following are the Newsroom Youtube videos: ', videoData); + + writeFileSync( + resolve(__dirname, '../config', 'newsroom_videos.json'), + videoData + ); + return videoData; } catch (err) { - console.log(err) + throw new Error(`Failed to build newsroom videos: ${err.message}`); } } -buildNewsroomVideos() -module.exports={buildNewsroomVideos} \ No newline at end of file +module.exports = { buildNewsroomVideos }; \ No newline at end of file diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js new file mode 100644 index 000000000000..e9830a4e038d --- /dev/null +++ b/tests/build-newsroom-videos.test.js @@ -0,0 +1,65 @@ +const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); +const { writeFileSync } = require('fs'); +const fetch = require('node-fetch'); +const { resolve } = require('path'); + +const { mockApiResponse,expectedResult } = require('./fixtures/newsroomData') + +const resolvedPath = resolve(__dirname, '../config', 'newsroom_videos.json'); + +jest.mock('node-fetch', () => jest.fn()); +jest.mock('fs', () => ({ + writeFileSync: jest.fn(), +})); + +describe('buildNewsroomVideos', () => { + beforeEach(() => { + fetch.mockClear(); + writeFileSync.mockClear(); + process.env.YOUTUBE_TOKEN = 'testkey'; + }); + + it('should fetch video data and write to file', async () => { + + fetch.mockResolvedValue({ + ok: true, + json: jest.fn().mockResolvedValue(mockApiResponse), + }); + + const result = await buildNewsroomVideos(); + + expect(fetch).toHaveBeenCalledWith(expect.stringContaining('https://youtube.googleapis.com/youtube/v3/search?')); + expect(writeFileSync).toHaveBeenCalledWith(resolvedPath,expectedResult); + + expect(result).toEqual(expectedResult); + }); + + it('should handle fetch errors', async () => { + fetch.mockRejectedValue(new Error('Fetch error')); + + await expect(buildNewsroomVideos()).rejects.toThrow('Failed to build newsroom videos: Fetch error'); + }); + + it('should handle file write errors', async () => { + + fetch.mockResolvedValue({ + ok: true, + json: jest.fn().mockResolvedValue(mockApiResponse), + }); + + writeFileSync.mockImplementation(() => { + throw new Error('Write error'); + }); + + await expect(buildNewsroomVideos()).rejects.toThrow('Failed to build newsroom videos: Write error'); + }); + + it('should handle invalid API response', async () => { + fetch.mockResolvedValue({ + ok: true, + json: jest.fn().mockResolvedValue({}), + }); + + await expect(buildNewsroomVideos()).rejects.toThrow('Failed to build newsroom videos: Invalid data structure received from YouTube API'); + }); +}); \ No newline at end of file diff --git a/tests/fixtures/newsroomData.js b/tests/fixtures/newsroomData.js new file mode 100644 index 000000000000..47f5343c1056 --- /dev/null +++ b/tests/fixtures/newsroomData.js @@ -0,0 +1,49 @@ +const mockApiResponse = { + items: [ + { + snippet: { + thumbnails: { + high: { + url: 'https://i.ytimg.com/vi/K7fvKbOfqOg/hqdefault.jpg', + }, + }, + title: 'Developer Experience Working Group, 14:00 UTC Thursday May 23rd 2024', + description: 'Define our vision and plans https://github.com/asyncapi/community/issues/1220.', + }, + id: { + videoId: 'K7fvKbOfqOg', + }, + }, + { + snippet: { + thumbnails: { + high: { + url: 'https://i.ytimg.com/vi/94SSXX78VCU/hqdefault.jpg', + }, + }, + title: 'Essential Building Blocks Working Group, 18:00 UTC Tuesday May 14th 2024', + description: 'https://github.com/asyncapi/community/issues/1200.', + }, + id: { + videoId: '94SSXX78VCU', + }, + }, + ], +}; + +const expectedResult = JSON.stringify([ + { + "image_url": "https://i.ytimg.com/vi/K7fvKbOfqOg/hqdefault.jpg", + "title": "Developer Experience Working Group, 14:00 UTC Thursday May 23rd 2024", + "description": "Define our vision and plans https://github.com/asyncapi/community/issues/1220.", + "videoId": "K7fvKbOfqOg" + }, + { + "image_url": "https://i.ytimg.com/vi/94SSXX78VCU/hqdefault.jpg", + "title": "Essential Building Blocks Working Group, 18:00 UTC Tuesday May 14th 2024", + "description": "https://github.com/asyncapi/community/issues/1200.", + "videoId": "94SSXX78VCU" + }, +], null, ' '); + +module.exports = {mockApiResponse,expectedResult} \ No newline at end of file From 129f6bc04ecfde9de4739a8f8d16876bb7b90b98 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sun, 14 Jul 2024 10:48:28 +0530 Subject: [PATCH 02/23] update test for newsroom videos --- scripts/build-newsroom-videos.js | 7 ++-- tests/build-newsroom-videos.test.js | 53 ++++++++++++++--------------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index fc5ab6e0e94c..8ce4dc9d320d 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -2,7 +2,7 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); const fetch = require('node-fetch'); -async function buildNewsroomVideos() { +async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', 'newsroom_videos.json')) { try { const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ key: process.env.YOUTUBE_TOKEN, @@ -34,10 +34,7 @@ async function buildNewsroomVideos() { const videoData = JSON.stringify(videoDataItems, null, ' '); console.log('The following are the Newsroom Youtube videos: ', videoData); - writeFileSync( - resolve(__dirname, '../config', 'newsroom_videos.json'), - videoData - ); + writeFileSync(writePath,videoData); return videoData; } catch (err) { diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index e9830a4e038d..7a086b453471 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -1,35 +1,38 @@ const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); -const { writeFileSync } = require('fs'); const fetch = require('node-fetch'); const { resolve } = require('path'); +const { mkdirSync, readFileSync, rmSync } = require('fs'); +const { mockApiResponse, expectedResult } = require('./fixtures/newsroomData'); -const { mockApiResponse,expectedResult } = require('./fixtures/newsroomData') - -const resolvedPath = resolve(__dirname, '../config', 'newsroom_videos.json'); +const testDir = resolve(__dirname, 'test_config'); +const testFilePath = resolve(testDir, 'newsroom_videos.json'); jest.mock('node-fetch', () => jest.fn()); -jest.mock('fs', () => ({ - writeFileSync: jest.fn(), -})); describe('buildNewsroomVideos', () => { beforeEach(() => { fetch.mockClear(); - writeFileSync.mockClear(); process.env.YOUTUBE_TOKEN = 'testkey'; + + mkdirSync(testDir, { recursive: true }); }); - it('should fetch video data and write to file', async () => { + afterEach(() => { + rmSync(testDir, { recursive: true, force: true }); + }); + it('should fetch video data and write to file', async () => { fetch.mockResolvedValue({ ok: true, json: jest.fn().mockResolvedValue(mockApiResponse), }); - const result = await buildNewsroomVideos(); + const result = await buildNewsroomVideos(testFilePath); expect(fetch).toHaveBeenCalledWith(expect.stringContaining('https://youtube.googleapis.com/youtube/v3/search?')); - expect(writeFileSync).toHaveBeenCalledWith(resolvedPath,expectedResult); + + const response = readFileSync(testFilePath, 'utf8'); + expect(response).toEqual(expectedResult); expect(result).toEqual(expectedResult); }); @@ -37,21 +40,7 @@ describe('buildNewsroomVideos', () => { it('should handle fetch errors', async () => { fetch.mockRejectedValue(new Error('Fetch error')); - await expect(buildNewsroomVideos()).rejects.toThrow('Failed to build newsroom videos: Fetch error'); - }); - - it('should handle file write errors', async () => { - - fetch.mockResolvedValue({ - ok: true, - json: jest.fn().mockResolvedValue(mockApiResponse), - }); - - writeFileSync.mockImplementation(() => { - throw new Error('Write error'); - }); - - await expect(buildNewsroomVideos()).rejects.toThrow('Failed to build newsroom videos: Write error'); + await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: Fetch error'); }); it('should handle invalid API response', async () => { @@ -60,6 +49,14 @@ describe('buildNewsroomVideos', () => { json: jest.fn().mockResolvedValue({}), }); - await expect(buildNewsroomVideos()).rejects.toThrow('Failed to build newsroom videos: Invalid data structure received from YouTube API'); + await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: Invalid data structure received from YouTube API'); }); -}); \ No newline at end of file + + it('should throw an error with incorrect parameters', async () => { + try { + await buildNewsroomVideos('randomePath'); + } catch (error) { + expect(error.message).toContain("Failed to build newsroom videos"); + } + }); +}); From eda22a0bc21e3fa0680c9d7e5adea8f700dc2911 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 24 Jul 2024 20:11:21 +0530 Subject: [PATCH 03/23] updated tests --- scripts/build-newsroom-videos.js | 6 +++--- tests/build-newsroom-videos.test.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 8ce4dc9d320d..7375fd1ec37c 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -1,6 +1,6 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); -const fetch = require('node-fetch'); +const fetch = require('node-fetch-2'); async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', 'newsroom_videos.json')) { try { @@ -15,7 +15,7 @@ async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', ' })); if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); + throw new Error(`HTTP error! with status code: ${response.status}`); } const data = await response.json(); @@ -42,4 +42,4 @@ async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', ' } } -module.exports = { buildNewsroomVideos }; \ No newline at end of file +module.exports = { buildNewsroomVideos }; diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 7a086b453471..e7545391dd4c 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -1,5 +1,5 @@ const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); -const fetch = require('node-fetch'); +const fetch = require('node-fetch-2'); const { resolve } = require('path'); const { mkdirSync, readFileSync, rmSync } = require('fs'); const { mockApiResponse, expectedResult } = require('./fixtures/newsroomData'); @@ -7,7 +7,7 @@ const { mockApiResponse, expectedResult } = require('./fixtures/newsroomData'); const testDir = resolve(__dirname, 'test_config'); const testFilePath = resolve(testDir, 'newsroom_videos.json'); -jest.mock('node-fetch', () => jest.fn()); +jest.mock('node-fetch-2', () => jest.fn()); describe('buildNewsroomVideos', () => { beforeEach(() => { From 105b4dd0888bab76b82aec92aee01bb0cfe42f08 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 24 Jul 2024 20:11:54 +0530 Subject: [PATCH 04/23] updated tests --- tests/fixtures/newsroomData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/newsroomData.js b/tests/fixtures/newsroomData.js index 47f5343c1056..d0d73f42bdc8 100644 --- a/tests/fixtures/newsroomData.js +++ b/tests/fixtures/newsroomData.js @@ -46,4 +46,4 @@ const expectedResult = JSON.stringify([ }, ], null, ' '); -module.exports = {mockApiResponse,expectedResult} \ No newline at end of file +module.exports = {mockApiResponse,expectedResult} From 38d4229a3994753fce15bff130481f83cd39ffe4 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 26 Jul 2024 09:37:29 +0530 Subject: [PATCH 05/23] udpated test --- scripts/build-newsroom-videos.js | 7 +++++-- tests/build-newsroom-videos.test.js | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 7375fd1ec37c..b25ca8805036 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -2,7 +2,7 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); const fetch = require('node-fetch-2'); -async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', 'newsroom_videos.json')) { +async function buildNewsroomVideos(writePath) { try { const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ key: process.env.YOUTUBE_TOKEN, @@ -34,7 +34,7 @@ async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', ' const videoData = JSON.stringify(videoDataItems, null, ' '); console.log('The following are the Newsroom Youtube videos: ', videoData); - writeFileSync(writePath,videoData); + writeFileSync(writePath, videoData); return videoData; } catch (err) { @@ -42,4 +42,7 @@ async function buildNewsroomVideos(writePath = resolve(__dirname, '../config', ' } } +buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')) + .catch(err => console.error(err)); + module.exports = { buildNewsroomVideos }; diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index e7545391dd4c..91dcbfc815ad 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -52,11 +52,17 @@ describe('buildNewsroomVideos', () => { await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: Invalid data structure received from YouTube API'); }); + it('should handle HTTP status code', async () => { + fetch.mockResolvedValue({ + ok: false, + status: 404, + json: jest.fn().mockResolvedValue({}), + }); + + await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: HTTP error! with status code: 404'); + }); + it('should throw an error with incorrect parameters', async () => { - try { - await buildNewsroomVideos('randomePath'); - } catch (error) { - expect(error.message).toContain("Failed to build newsroom videos"); - } - }); + await expect(buildNewsroomVideos('randomePath')).rejects.toThrow("Failed to build newsroom videos"); + }); }); From 65fc7a95dfe9ed8e77c4318ea8ce5880a22fcac2 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 26 Jul 2024 09:47:20 +0530 Subject: [PATCH 06/23] lint fix --- components/campaigns/AnnouncementHero.tsx | 2 +- components/helpers/read-yaml-file.js | 4 ++-- pages/casestudies/[id].tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/campaigns/AnnouncementHero.tsx b/components/campaigns/AnnouncementHero.tsx index ac85509f5d51..04ffae7f2de7 100644 --- a/components/campaigns/AnnouncementHero.tsx +++ b/components/campaigns/AnnouncementHero.tsx @@ -57,7 +57,7 @@ export default function AnnouncementHero({ className = '', small = false }: IAnn )}
-
+
{banners.map( (banner, index) => banner.show && ( diff --git a/components/helpers/read-yaml-file.js b/components/helpers/read-yaml-file.js index 8cfbe5217463..d883d14109df 100644 --- a/components/helpers/read-yaml-file.js +++ b/components/helpers/read-yaml-file.js @@ -1,6 +1,6 @@ import fs from 'fs/promises'; -export const readYamlFile = async (fileName) => { +export default async function readYamlFile(fileName) { try { const data = await fs.readFile(`./public/${fileName}`, 'utf-8'); const yamlString = `\`\`\`yaml\n${data}\`\`\``; @@ -9,4 +9,4 @@ export const readYamlFile = async (fileName) => { } catch (error) { throw new Error(`Error: something went wrong while reading ${fileName} file: ${error.message}`); } -}; +} diff --git a/pages/casestudies/[id].tsx b/pages/casestudies/[id].tsx index d0668740edb9..d418e038629d 100644 --- a/pages/casestudies/[id].tsx +++ b/pages/casestudies/[id].tsx @@ -3,6 +3,7 @@ import type { MDXRemoteSerializeResult } from 'next-mdx-remote'; import { MDXRemote } from 'next-mdx-remote'; import { serialize } from 'next-mdx-remote/serialize'; +import { readYamlFile } from '@/components/helpers/read-yaml-file'; import type { ICaseStudy } from '@/types/post'; import { HeadingTypeStyle } from '@/types/typography/Heading'; import { ParagraphTypeStyle } from '@/types/typography/Paragraph'; @@ -14,7 +15,6 @@ import Heading from '../../components/typography/Heading'; import Paragraph from '../../components/typography/Paragraph'; import CaseStudiesList from '../../config/case-studies.json'; import { generateCaseStudyContent } from '../../utils/staticHelpers'; -import { readYamlFile } from '@/components/helpers/read-yaml-file'; interface IndexProps { casestudy: ICaseStudy; From a819c46fa5e52d85464dbe9fcd20fac30d997de9 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 26 Jul 2024 09:51:32 +0530 Subject: [PATCH 07/23] build fix --- components/helpers/read-yaml-file.ts | 2 +- pages/casestudies/[id].tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/helpers/read-yaml-file.ts b/components/helpers/read-yaml-file.ts index f8c1e361b1e5..d1632e2cb6a4 100644 --- a/components/helpers/read-yaml-file.ts +++ b/components/helpers/read-yaml-file.ts @@ -1,6 +1,6 @@ import fs from 'fs/promises'; -export const readYamlFile = async (fileName: string) => { +export default async function readYamlFile(fileName: string) { try { const data = await fs.readFile(`./public/${fileName}`, 'utf-8'); const yamlString = `\`\`\`yaml\n${data}\`\`\``; diff --git a/pages/casestudies/[id].tsx b/pages/casestudies/[id].tsx index d418e038629d..ddd7757a160c 100644 --- a/pages/casestudies/[id].tsx +++ b/pages/casestudies/[id].tsx @@ -3,7 +3,7 @@ import type { MDXRemoteSerializeResult } from 'next-mdx-remote'; import { MDXRemote } from 'next-mdx-remote'; import { serialize } from 'next-mdx-remote/serialize'; -import { readYamlFile } from '@/components/helpers/read-yaml-file'; +import readYamlFile from '@/components/helpers/read-yaml-file'; import type { ICaseStudy } from '@/types/post'; import { HeadingTypeStyle } from '@/types/typography/Heading'; import { ParagraphTypeStyle } from '@/types/typography/Paragraph'; From 0e2a7098a45f7bfd3446951937182dbbfca23c4c Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 26 Jul 2024 09:55:02 +0530 Subject: [PATCH 08/23] lint fix --- components/helpers/read-yaml-file.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/helpers/read-yaml-file.ts b/components/helpers/read-yaml-file.ts index d1632e2cb6a4..53a2da0eb459 100644 --- a/components/helpers/read-yaml-file.ts +++ b/components/helpers/read-yaml-file.ts @@ -1,5 +1,12 @@ import fs from 'fs/promises'; +/** + * Reads a YAML file from the public directory and returns its content as a formatted string. + * + * @param {string} fileName - The name of the YAML file to read. + * @returns {Promise} The content of the YAML file formatted as a string with YAML syntax highlighting. + * @throws {Error} If there is an error reading the file. + */ export default async function readYamlFile(fileName: string) { try { const data = await fs.readFile(`./public/${fileName}`, 'utf-8'); @@ -9,4 +16,4 @@ export default async function readYamlFile(fileName: string) { } catch (error: any) { throw new Error(`Error: something went wrong while reading ${fileName} file: ${error.message}`); } -}; +} From a81fd28875ea7cb21c2045f78e0f3f69e39de5bf Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 9 Aug 2024 10:09:41 +0530 Subject: [PATCH 09/23] remove unwanted changes --- components/campaigns/AnnouncementHero.tsx | 8 ++++++-- components/helpers/read-yaml-file.js | 12 ------------ components/helpers/read-yaml-file.ts | 11 ++--------- pages/casestudies/[id].tsx | 4 ++-- 4 files changed, 10 insertions(+), 25 deletions(-) delete mode 100644 components/helpers/read-yaml-file.js diff --git a/components/campaigns/AnnouncementHero.tsx b/components/campaigns/AnnouncementHero.tsx index 04ffae7f2de7..75438c7cc738 100644 --- a/components/campaigns/AnnouncementHero.tsx +++ b/components/campaigns/AnnouncementHero.tsx @@ -44,8 +44,12 @@ export default function AnnouncementHero({ className = '', small = false }: IAnn }; }, [activeIndex]); + if (numberOfVisibleBanners === 0) { + return null; + } + return ( - +
{numberOfVisibleBanners > 1 && (
); -} +} \ No newline at end of file diff --git a/components/helpers/read-yaml-file.js b/components/helpers/read-yaml-file.js deleted file mode 100644 index d883d14109df..000000000000 --- a/components/helpers/read-yaml-file.js +++ /dev/null @@ -1,12 +0,0 @@ -import fs from 'fs/promises'; - -export default async function readYamlFile(fileName) { - try { - const data = await fs.readFile(`./public/${fileName}`, 'utf-8'); - const yamlString = `\`\`\`yaml\n${data}\`\`\``; - - return yamlString; - } catch (error) { - throw new Error(`Error: something went wrong while reading ${fileName} file: ${error.message}`); - } -} diff --git a/components/helpers/read-yaml-file.ts b/components/helpers/read-yaml-file.ts index 53a2da0eb459..f9557e151933 100644 --- a/components/helpers/read-yaml-file.ts +++ b/components/helpers/read-yaml-file.ts @@ -1,13 +1,6 @@ import fs from 'fs/promises'; -/** - * Reads a YAML file from the public directory and returns its content as a formatted string. - * - * @param {string} fileName - The name of the YAML file to read. - * @returns {Promise} The content of the YAML file formatted as a string with YAML syntax highlighting. - * @throws {Error} If there is an error reading the file. - */ -export default async function readYamlFile(fileName: string) { +export const readYamlFile = async (fileName: string) => { try { const data = await fs.readFile(`./public/${fileName}`, 'utf-8'); const yamlString = `\`\`\`yaml\n${data}\`\`\``; @@ -16,4 +9,4 @@ export default async function readYamlFile(fileName: string) { } catch (error: any) { throw new Error(`Error: something went wrong while reading ${fileName} file: ${error.message}`); } -} +}; \ No newline at end of file diff --git a/pages/casestudies/[id].tsx b/pages/casestudies/[id].tsx index ddd7757a160c..bf2e349ea205 100644 --- a/pages/casestudies/[id].tsx +++ b/pages/casestudies/[id].tsx @@ -3,7 +3,7 @@ import type { MDXRemoteSerializeResult } from 'next-mdx-remote'; import { MDXRemote } from 'next-mdx-remote'; import { serialize } from 'next-mdx-remote/serialize'; -import readYamlFile from '@/components/helpers/read-yaml-file'; +import { readYamlFile } from '@/components/helpers/read-yaml-file'; import type { ICaseStudy } from '@/types/post'; import { HeadingTypeStyle } from '@/types/typography/Heading'; import { ParagraphTypeStyle } from '@/types/typography/Paragraph'; @@ -262,4 +262,4 @@ const Index: React.FC = ({ ); }; -export default Index; +export default Index; \ No newline at end of file From f97d1202e340653becd5d8bc634ccb97273552d9 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 9 Aug 2024 10:12:30 +0530 Subject: [PATCH 10/23] wqfef --- components/campaigns/AnnouncementHero.tsx | 2 +- components/helpers/read-yaml-file.ts | 2 +- pages/casestudies/[id].tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/campaigns/AnnouncementHero.tsx b/components/campaigns/AnnouncementHero.tsx index 75438c7cc738..1f84cb48c5ec 100644 --- a/components/campaigns/AnnouncementHero.tsx +++ b/components/campaigns/AnnouncementHero.tsx @@ -105,4 +105,4 @@ export default function AnnouncementHero({ className = '', small = false }: IAnn
); -} \ No newline at end of file +} diff --git a/components/helpers/read-yaml-file.ts b/components/helpers/read-yaml-file.ts index f9557e151933..f8c1e361b1e5 100644 --- a/components/helpers/read-yaml-file.ts +++ b/components/helpers/read-yaml-file.ts @@ -9,4 +9,4 @@ export const readYamlFile = async (fileName: string) => { } catch (error: any) { throw new Error(`Error: something went wrong while reading ${fileName} file: ${error.message}`); } -}; \ No newline at end of file +}; diff --git a/pages/casestudies/[id].tsx b/pages/casestudies/[id].tsx index bf2e349ea205..d418e038629d 100644 --- a/pages/casestudies/[id].tsx +++ b/pages/casestudies/[id].tsx @@ -262,4 +262,4 @@ const Index: React.FC = ({ ); }; -export default Index; \ No newline at end of file +export default Index; From 3aa3d897a95826c0571c268ca1e86d2cb2bd4da1 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sun, 18 Aug 2024 12:28:30 +0530 Subject: [PATCH 11/23] script update --- scripts/build-newsroom-videos.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index b25ca8805036..bd3d0c2e2a39 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -14,16 +14,8 @@ async function buildNewsroomVideos(writePath) { maxResults: 5, })); - if (!response.ok) { - throw new Error(`HTTP error! with status code: ${response.status}`); - } - const data = await response.json(); - if (!data || !data.items) { - throw new Error('Invalid data structure received from YouTube API'); - } - const videoDataItems = data.items.map((video) => ({ image_url: video.snippet.thumbnails.high.url, title: video.snippet.title, @@ -43,6 +35,5 @@ async function buildNewsroomVideos(writePath) { } buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')) - .catch(err => console.error(err)); module.exports = { buildNewsroomVideos }; From d47fc30f13f4e315de7c97745098cbf7833857f1 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sun, 18 Aug 2024 16:51:34 +0530 Subject: [PATCH 12/23] test and script updated --- scripts/build-newsroom-videos.js | 67 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index bd3d0c2e2a39..8067ee7ae3d0 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -3,37 +3,46 @@ const { resolve } = require('path'); const fetch = require('node-fetch-2'); async function buildNewsroomVideos(writePath) { - try { - const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ - key: process.env.YOUTUBE_TOKEN, - part: 'snippet', - channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', - eventType: 'completed', - type: 'video', - order: 'Date', - maxResults: 5, - })); - - const data = await response.json(); - - const videoDataItems = data.items.map((video) => ({ - image_url: video.snippet.thumbnails.high.url, - title: video.snippet.title, - description: video.snippet.description, - videoId: video.id.videoId, - })); - - const videoData = JSON.stringify(videoDataItems, null, ' '); - console.log('The following are the Newsroom Youtube videos: ', videoData); - - writeFileSync(writePath, videoData); - - return videoData; - } catch (err) { - throw new Error(`Failed to build newsroom videos: ${err.message}`); + const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ + key: process.env.YOUTUBE_TOKEN, + part: 'snippet', + channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', + eventType: 'completed', + type: 'video', + order: 'Date', + maxResults: 5, + })); + + if (!response.ok) { + throw new Error(`HTTP error! with status code: ${response.status}`); } + + const data = await response.json(); + + if (!data.items || !Array.isArray(data.items)) { + throw new Error('Invalid data structure received from YouTube API'); + } + + const videoDataItems = data.items.map((video) => ({ + image_url: video.snippet.thumbnails.high.url, + title: video.snippet.title, + description: video.snippet.description, + videoId: video.id.videoId, + })); + + const videoData = JSON.stringify(videoDataItems, null, ' '); + console.log('The following are the Newsroom Youtube videos: ', videoData); + + writeFileSync(writePath, videoData); + + return videoData; } -buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')) +// Only call buildNewsroomVideos if this script is run directly (not required/imported as a module) +if (require.main === module) { + const writePath = resolve(__dirname, '../config', 'newsroom_videos.json'); + buildNewsroomVideos(writePath).then(result => { + console.log('Newsroom videos successfully built.'); + })} module.exports = { buildNewsroomVideos }; From 5757393e4018ffc6c6e86e063ffb31caafdad2f1 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sun, 18 Aug 2024 16:55:06 +0530 Subject: [PATCH 13/23] test and script updated --- tests/build-newsroom-videos.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 91dcbfc815ad..38560634884b 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -40,7 +40,7 @@ describe('buildNewsroomVideos', () => { it('should handle fetch errors', async () => { fetch.mockRejectedValue(new Error('Fetch error')); - await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: Fetch error'); + await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Fetch error'); }); it('should handle invalid API response', async () => { @@ -49,7 +49,7 @@ describe('buildNewsroomVideos', () => { json: jest.fn().mockResolvedValue({}), }); - await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: Invalid data structure received from YouTube API'); + await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Invalid data structure received from YouTube API'); }); it('should handle HTTP status code', async () => { @@ -59,10 +59,10 @@ describe('buildNewsroomVideos', () => { json: jest.fn().mockResolvedValue({}), }); - await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Failed to build newsroom videos: HTTP error! with status code: 404'); + await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('HTTP error! with status code: 404'); }); it('should throw an error with incorrect parameters', async () => { - await expect(buildNewsroomVideos('randomePath')).rejects.toThrow("Failed to build newsroom videos"); + await expect(buildNewsroomVideos('randomPath')).rejects.toThrow('HTTP error! with status code: 404'); }); }); From 5d3c6dee94f8f9790f0b300d68895c4c07708ecb Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sun, 18 Aug 2024 16:58:20 +0530 Subject: [PATCH 14/23] code format --- scripts/build-newsroom-videos.js | 3 ++- tests/build-newsroom-videos.test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 8067ee7ae3d0..8b980d0c334e 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -43,6 +43,7 @@ if (require.main === module) { const writePath = resolve(__dirname, '../config', 'newsroom_videos.json'); buildNewsroomVideos(writePath).then(result => { console.log('Newsroom videos successfully built.'); - })} + }) +} module.exports = { buildNewsroomVideos }; diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 38560634884b..5235add3d17a 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -30,7 +30,7 @@ describe('buildNewsroomVideos', () => { const result = await buildNewsroomVideos(testFilePath); expect(fetch).toHaveBeenCalledWith(expect.stringContaining('https://youtube.googleapis.com/youtube/v3/search?')); - + const response = readFileSync(testFilePath, 'utf8'); expect(response).toEqual(expectedResult); From 01aaa1f6231b9257c5489010d43209e93d3b345e Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sun, 18 Aug 2024 17:11:04 +0530 Subject: [PATCH 15/23] function updated --- scripts/build-newsroom-videos.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 8b980d0c334e..60856e9d9361 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -18,6 +18,7 @@ async function buildNewsroomVideos(writePath) { } const data = await response.json(); + console.log(data) if (!data.items || !Array.isArray(data.items)) { throw new Error('Invalid data structure received from YouTube API'); @@ -38,12 +39,8 @@ async function buildNewsroomVideos(writePath) { return videoData; } -// Only call buildNewsroomVideos if this script is run directly (not required/imported as a module) if (require.main === module) { - const writePath = resolve(__dirname, '../config', 'newsroom_videos.json'); - buildNewsroomVideos(writePath).then(result => { - console.log('Newsroom videos successfully built.'); - }) + buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')) } module.exports = { buildNewsroomVideos }; From c74997cbc374976661d44af34001581cdb072887 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Mon, 19 Aug 2024 20:08:19 +0530 Subject: [PATCH 16/23] test updated --- scripts/build-newsroom-videos.js | 70 +++++++++++++++-------------- tests/build-newsroom-videos.test.js | 60 +++++++++++++++++-------- 2 files changed, 79 insertions(+), 51 deletions(-) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 60856e9d9361..8c76aeab28de 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -3,40 +3,44 @@ const { resolve } = require('path'); const fetch = require('node-fetch-2'); async function buildNewsroomVideos(writePath) { - const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ - key: process.env.YOUTUBE_TOKEN, - part: 'snippet', - channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', - eventType: 'completed', - type: 'video', - order: 'Date', - maxResults: 5, - })); - - if (!response.ok) { - throw new Error(`HTTP error! with status code: ${response.status}`); + try { + const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ + key: process.env.YOUTUBE_TOKEN, + part: 'snippet', + channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', + eventType: 'completed', + type: 'video', + order: 'Date', + maxResults: 5, + })); + + if (!response.ok) { + throw new Error(`HTTP error! with status code: ${response.status}`); + } + + const data = await response.json(); + console.log(data) + + if (!data.items || !Array.isArray(data.items)) { + throw new Error('Invalid data structure received from YouTube API'); + } + + const videoDataItems = data.items.map((video) => ({ + image_url: video.snippet.thumbnails.high.url, + title: video.snippet.title, + description: video.snippet.description, + videoId: video.id.videoId, + })); + + const videoData = JSON.stringify(videoDataItems, null, ' '); + console.log('The following are the Newsroom Youtube videos: ', videoData); + + writeFileSync(writePath, videoData); + + return videoData; + } catch (err) { + throw new Error(`Failed to build newsroom videos: ${err.message}`); } - - const data = await response.json(); - console.log(data) - - if (!data.items || !Array.isArray(data.items)) { - throw new Error('Invalid data structure received from YouTube API'); - } - - const videoDataItems = data.items.map((video) => ({ - image_url: video.snippet.thumbnails.high.url, - title: video.snippet.title, - description: video.snippet.description, - videoId: video.id.videoId, - })); - - const videoData = JSON.stringify(videoDataItems, null, ' '); - console.log('The following are the Newsroom Youtube videos: ', videoData); - - writeFileSync(writePath, videoData); - - return videoData; } if (require.main === module) { diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 5235add3d17a..14634a918124 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -1,26 +1,28 @@ -const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); -const fetch = require('node-fetch-2'); +const { writeFileSync, readFileSync, rmSync, mkdirSync } = require('fs'); const { resolve } = require('path'); -const { mkdirSync, readFileSync, rmSync } = require('fs'); +const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); const { mockApiResponse, expectedResult } = require('./fixtures/newsroomData'); - -const testDir = resolve(__dirname, 'test_config'); -const testFilePath = resolve(testDir, 'newsroom_videos.json'); +const fetch = require('node-fetch-2'); jest.mock('node-fetch-2', () => jest.fn()); describe('buildNewsroomVideos', () => { - beforeEach(() => { - fetch.mockClear(); - process.env.YOUTUBE_TOKEN = 'testkey'; + const testDir = resolve(__dirname, 'test_config'); + const testFilePath = resolve(testDir, 'newsroom_videos.json'); + beforeAll(() => { mkdirSync(testDir, { recursive: true }); + process.env.YOUTUBE_TOKEN = 'testkey'; }); - afterEach(() => { + afterAll(() => { rmSync(testDir, { recursive: true, force: true }); }); + beforeEach(() => { + fetch.mockClear(); + }); + it('should fetch video data and write to file', async () => { fetch.mockResolvedValue({ ok: true, @@ -30,17 +32,19 @@ describe('buildNewsroomVideos', () => { const result = await buildNewsroomVideos(testFilePath); expect(fetch).toHaveBeenCalledWith(expect.stringContaining('https://youtube.googleapis.com/youtube/v3/search?')); - const response = readFileSync(testFilePath, 'utf8'); expect(response).toEqual(expectedResult); - expect(result).toEqual(expectedResult); }); it('should handle fetch errors', async () => { fetch.mockRejectedValue(new Error('Fetch error')); - - await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Fetch error'); + + try { + await buildNewsroomVideos(testFilePath); + } catch (err) { + expect(err.message).toContain('Fetch error'); + } }); it('should handle invalid API response', async () => { @@ -49,7 +53,11 @@ describe('buildNewsroomVideos', () => { json: jest.fn().mockResolvedValue({}), }); - await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('Invalid data structure received from YouTube API'); + try { + await buildNewsroomVideos(testFilePath); + } catch (err) { + expect(err.message).toContain('Invalid data structure received from YouTube API'); + } }); it('should handle HTTP status code', async () => { @@ -59,10 +67,26 @@ describe('buildNewsroomVideos', () => { json: jest.fn().mockResolvedValue({}), }); - await expect(buildNewsroomVideos(testFilePath)).rejects.toThrow('HTTP error! with status code: 404'); + try { + await buildNewsroomVideos(testFilePath); + } catch (err) { + expect(err.message).toContain('HTTP error! with status code: 404'); + } }); - it('should throw an error with incorrect parameters', async () => { - await expect(buildNewsroomVideos('randomPath')).rejects.toThrow('HTTP error! with status code: 404'); + it('should handle file write errors', async () => { + fetch.mockResolvedValue({ + ok: true, + json: jest.fn().mockResolvedValue(mockApiResponse), + }); + + const invalidPath = '/invalid_dir/newsroom_videos.json'; + + try { + await buildNewsroomVideos(invalidPath); + } catch (err) { + expect(err.message).toMatch(/ENOENT|EACCES/); + } }); + }); From 56d07d825d139e92306529386f40458157c6de7f Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Mon, 19 Aug 2024 20:10:59 +0530 Subject: [PATCH 17/23] test updated again --- tests/build-newsroom-videos.test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 14634a918124..112626441d1c 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -31,7 +31,16 @@ describe('buildNewsroomVideos', () => { const result = await buildNewsroomVideos(testFilePath); - expect(fetch).toHaveBeenCalledWith(expect.stringContaining('https://youtube.googleapis.com/youtube/v3/search?')); + const expectedUrl = new URL('https://youtube.googleapis.com/youtube/v3/search'); + expectedUrl.searchParams.set('key', 'testkey'); + expectedUrl.searchParams.set('part', 'snippet'); + expectedUrl.searchParams.set('channelId', 'UCIz9zGwDLbrYQcDKVXdOstQ'); + expectedUrl.searchParams.set('eventType', 'completed'); + expectedUrl.searchParams.set('type', 'video'); + expectedUrl.searchParams.set('order', 'Date'); + expectedUrl.searchParams.set('maxResults', '5'); + + expect(fetch).toHaveBeenCalledWith(expectedUrl.toString()); const response = readFileSync(testFilePath, 'utf8'); expect(response).toEqual(expectedResult); expect(result).toEqual(expectedResult); From 7a78f9eb08685b3fa186ac0f3dc72cb095c7fe87 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Mon, 19 Aug 2024 20:17:57 +0530 Subject: [PATCH 18/23] fefe --- tests/build-newsroom-videos.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 112626441d1c..3f043cc449df 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -1,4 +1,4 @@ -const { writeFileSync, readFileSync, rmSync, mkdirSync } = require('fs'); +const { readFileSync, rmSync, mkdirSync } = require('fs'); const { resolve } = require('path'); const { buildNewsroomVideos } = require('../scripts/build-newsroom-videos'); const { mockApiResponse, expectedResult } = require('./fixtures/newsroomData'); From 4f4efde3b99c71f48b4bf95bd86bbcb6c7b98529 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Tue, 20 Aug 2024 12:57:40 +0530 Subject: [PATCH 19/23] format --- tests/build-newsroom-videos.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/build-newsroom-videos.test.js b/tests/build-newsroom-videos.test.js index 3f043cc449df..63f571466944 100644 --- a/tests/build-newsroom-videos.test.js +++ b/tests/build-newsroom-videos.test.js @@ -48,7 +48,7 @@ describe('buildNewsroomVideos', () => { it('should handle fetch errors', async () => { fetch.mockRejectedValue(new Error('Fetch error')); - + try { await buildNewsroomVideos(testFilePath); } catch (err) { @@ -90,7 +90,7 @@ describe('buildNewsroomVideos', () => { }); const invalidPath = '/invalid_dir/newsroom_videos.json'; - + try { await buildNewsroomVideos(invalidPath); } catch (err) { From 51b02c4bc33fcbd5fe12b995604fa2535b96657f Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Sun, 25 Aug 2024 05:44:10 +0000 Subject: [PATCH 20/23] nit: lint fix --- tests/fixtures/newsroomData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/newsroomData.js b/tests/fixtures/newsroomData.js index d0d73f42bdc8..a42f93636492 100644 --- a/tests/fixtures/newsroomData.js +++ b/tests/fixtures/newsroomData.js @@ -46,4 +46,4 @@ const expectedResult = JSON.stringify([ }, ], null, ' '); -module.exports = {mockApiResponse,expectedResult} +module.exports = { mockApiResponse, expectedResult } From ea4524902a7ac4c5f32161918136b6c7381eb43f Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Sun, 25 Aug 2024 05:47:57 +0000 Subject: [PATCH 21/23] ignore untestable branch --- scripts/build-newsroom-videos.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 8c76aeab28de..b67ee0378cf2 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -43,6 +43,7 @@ async function buildNewsroomVideos(writePath) { } } +/* istanbul ignore next */ if (require.main === module) { buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')) } From 1f68ed1bb279fd3f6a00737037b63386655aa739 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Sun, 25 Aug 2024 05:52:39 +0000 Subject: [PATCH 22/23] Empty Commit From 8b343cbb7a9881a7b8330088cacec0985ff8df76 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Sun, 25 Aug 2024 05:58:59 +0000 Subject: [PATCH 23/23] modify prettier lock --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index c271fd28258d..879c389d24d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,7 +52,7 @@ "node-fetch": "^3.3.2", "node-fetch-2": "npm:node-fetch@^2.7.0", "postcss": "^8.4.35", - "prettier": "^3.3.0", + "prettier": "^3.3.3", "react": "^18", "react-dom": "^18", "react-ga": "^3.3.1", @@ -24202,9 +24202,9 @@ } }, "node_modules/prettier": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", - "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "bin": { "prettier": "bin/prettier.cjs" }, diff --git a/package.json b/package.json index 01fa27ea3f4b..fde5349b991c 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "node-fetch": "^3.3.2", "node-fetch-2": "npm:node-fetch@^2.7.0", "postcss": "^8.4.35", - "prettier": "^3.3.0", + "prettier": "^3.3.3", "react": "^18", "react-dom": "^18", "react-ga": "^3.3.1",