From cfa5fcba79b2b90fdf26f34a5e361cc7f1de1ff6 Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Thu, 25 Jul 2024 16:28:59 -0500 Subject: [PATCH] Press page All this just to get coverage for one branch in clipped-image.tsx! (But also additional code in TSX with coverage, plus a couple fixes) --- package.json | 4 +- src/app/helpers/use-page-data.tsx | 10 +- .../{page-context.js => page-context.tsx} | 25 +- .../press/press-releases/press-releases.js | 2 +- src/app/pages/press/{press.js => press.tsx} | 5 +- .../new/specific/find-translation.tsx | 7 +- test/helpers/fetch-mocker.js | 4 +- test/src/data/press.js | 577 +++++++----------- test/src/pages/press/press.test.tsx | 50 ++ webpack.config.js | 1 + yarn.lock | 18 +- 11 files changed, 313 insertions(+), 390 deletions(-) rename src/app/pages/press/{page-context.js => page-context.tsx} (53%) rename src/app/pages/press/{press.js => press.tsx} (96%) create mode 100644 test/src/pages/press/press.test.tsx diff --git a/package.json b/package.json index 7033b5ad6..cc0c07e15 100644 --- a/package.json +++ b/package.json @@ -35,9 +35,11 @@ "esbuild-loader": "^3.0.1", "js-cookie": "^3.0.5", "lodash": "^4.17.21", + "react": "npm:@preact/compat", + "react-dom": "npm:@preact/compat", "react-accessible-accordion": "^4.0.0", "react-aria": "^3.31.1", - "react-aria-carousel": "^0.1.0", + "react-aria-carousel": "^0.2.0", "react-intl": "^6.3.2", "react-lazyload": "^3.2.0", "react-loadable": "^5.5.0", diff --git a/src/app/helpers/use-page-data.tsx b/src/app/helpers/use-page-data.tsx index f8f209d91..64fad7b5b 100644 --- a/src/app/helpers/use-page-data.tsx +++ b/src/app/helpers/use-page-data.tsx @@ -35,11 +35,11 @@ async function fetchDataAndExpandImages( return data; } -export function fetchPageData( +export function fetchPageData( slug: string, preserveWrapping: boolean, noCamelCase: boolean -): Promise { +): Promise { const camelCaseOrNot = noCamelCase ? (obj: object) => obj : camelCaseKeys; return fetchDataAndExpandImages(slug, preserveWrapping).then( @@ -47,15 +47,15 @@ export function fetchPageData( ); } -export default function usePageData( +export default function usePageData( slug: string, preserveWrapping = false, noCamelCase = false ) { - const [data, setData] = React.useState(); + const [data, setData] = React.useState(); React.useEffect(() => { - fetchPageData(slug, preserveWrapping, noCamelCase).then(setData); + fetchPageData(slug, preserveWrapping, noCamelCase).then(setData); }, [slug, preserveWrapping, noCamelCase]); return data; diff --git a/src/app/pages/press/page-context.js b/src/app/pages/press/page-context.tsx similarity index 53% rename from src/app/pages/press/page-context.js rename to src/app/pages/press/page-context.tsx index 3130ec0d6..8ea59bc5a 100644 --- a/src/app/pages/press/page-context.js +++ b/src/app/pages/press/page-context.tsx @@ -1,8 +1,31 @@ import buildContext from '~/components/jsx-helpers/build-context'; import usePageData from '~/helpers/use-page-data'; +type FeaturedInRollup = { + name: string; + url: string; + image: string; +}; + +// This will need more filling in as other components move to TSX +type PressPageData = { + meta: object; + mentions: { + date: string; + featuredIn: boolean; + headline: string; + source: { + id: number; + logo: string; + name: string; + }; + url: string; + }[]; + featuredIn: FeaturedInRollup[]; +} + function useContextValue() { - const value = usePageData('press'); + const value = usePageData('press'); if (value) { value.featuredIn = value.mentions.filter( diff --git a/src/app/pages/press/press-releases/press-releases.js b/src/app/pages/press/press-releases/press-releases.js index a934d7c5f..5e1fe8829 100644 --- a/src/app/pages/press/press-releases/press-releases.js +++ b/src/app/pages/press/press-releases/press-releases.js @@ -4,7 +4,7 @@ import MoreFewer from '~/components/more-fewer/more-fewer'; import {convertedDate, asDate, PressExcerpt} from '../helpers'; import './press-releases.scss'; -export default function PressReleases({excludeSlug, Container = MoreFewer}) { +export default function PressReleases({excludeSlug='', Container = MoreFewer}) { const pageData = usePageContext(); if (!pageData?.releases) { diff --git a/src/app/pages/press/press.js b/src/app/pages/press/press.tsx similarity index 96% rename from src/app/pages/press/press.js rename to src/app/pages/press/press.tsx index a08c74712..42b7bbdc0 100644 --- a/src/app/pages/press/press.js +++ b/src/app/pages/press/press.tsx @@ -22,13 +22,12 @@ function MainPage() { useCanonicalLink(true); React.useEffect(() => { - if (pageData) { - setPageTitleAndDescriptionFromBookData(pageData); - } + setPageTitleAndDescriptionFromBookData(pageData); }, [pageData]); return ( +
In the press
diff --git a/src/app/pages/subjects/new/specific/find-translation.tsx b/src/app/pages/subjects/new/specific/find-translation.tsx index b5ebd5f99..94a853aa0 100644 --- a/src/app/pages/subjects/new/specific/find-translation.tsx +++ b/src/app/pages/subjects/new/specific/find-translation.tsx @@ -5,9 +5,14 @@ import type {LocaleEntry} from '~/components/language-selector/language-selector import useLanguageContext from '~/contexts/language'; import {useIntl} from 'react-intl'; +type PageData = { + error?: string; + translations: LocaleEntry[][]; +} + export default function FindTranslation() { const subject = useParams().subject; - const pageData = usePageData(`pages/${subject}-books`); + const pageData = usePageData(`pages/${subject}-books`); if (!pageData) { return null; diff --git a/test/helpers/fetch-mocker.js b/test/helpers/fetch-mocker.js index 952d49c69..7475184e8 100644 --- a/test/helpers/fetch-mocker.js +++ b/test/helpers/fetch-mocker.js @@ -75,8 +75,8 @@ global.fetch = jest.fn().mockImplementation((...args) => { const isOsNews = (/openstax-news/).test(args[0]); const isPartner = (/pages\/partners/).test(args[0]); const isPolishPhysics = (/fizyka/).test(args[0]); - const isPress = (/api\/press\/?$/).test(args[0]); - const isPressArticle = (/api\/press\/./).test(args[0]); + const isPress = (/api\/press\/\?/).test(args[0]); + const isPressArticle = (/api\/press\/[a-z]/).test(args[0]); const isPrintOrder = (/pages\/print-order/).test(args[0]); const isRenewal = args[0].includes('renewal?account_uuid'); const isRoles = (/snippets\/roles/).test(args[0]); diff --git a/test/src/data/press.js b/test/src/data/press.js index 07beab658..66296b1da 100644 --- a/test/src/data/press.js +++ b/test/src/data/press.js @@ -1,402 +1,235 @@ +/* eslint-disable camelcase, max-len */ export default { - "id": 224, - "meta": { - "slug": "news", - "seo_title": "", - "search_description": "", - "type": "news.PressIndex", - "detail_url": "https://cms-dev.openstax.org/api/v2/pages/224/", - "html_url": "http://openstax.org/news/", - "show_in_menus": false, - "first_published_at": "2018-06-18T21:26:14.341637-05:00", - "parent": { - "id": 29, - "meta": { - "type": "pages.HomePage", - "detail_url": "https://cms-dev.openstax.org/api/v2/pages/29/", - "html_url": "http://openstax.org/" + id: 224, + meta: { + slug: 'news', + seo_title: 'Learn about the way our textbooks have impacted the world', + search_description: + 'Read press releases and news mentions from all around the world...', + type: 'news.PressIndex', + detail_url: 'https://openstax.org/apps/cms/api/v2/pages/224/', + html_url: 'https://openstax.org/news/', + show_in_menus: false, + first_published_at: '2018-06-18T21:26:14.341637-05:00', + alias_of: null, + parent: { + id: 29, + meta: { + type: 'pages.HomePage', + detail_url: 'https://openstax.org/apps/cms/api/v2/pages/29/', + html_url: 'https://openstax.org/' }, - "title": "Openstax Homepage" - } - }, - "title": "In the news", - "press_kit": { - "id": 326, - "meta": { - "type": "wagtaildocs.Document", - "detail_url": "https://cms-dev.openstax.org/api/v2/documents/326/", - "download_url": "https://cms-dev.openstax.org/documents/326/press_kit_2.zip" + title: 'OpenStax Homepage' }, - "title": "OpenStax Press Kit.zip" + locale: 'en' }, - "press_kit_url": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/documents/press_kit_2.zip", - "releases": { - "press/rice-engineer-richard-baraniuk-elected-american-academy-arts-and-sciences": { - "date": "2017-04-12", - "author": "B.J. Almond", - "detail_url": "/apps/cms/api/v2/pages/235/", - "excerpt": "Rice University professor and engineer Richard Baraniuk has been elected to the American Academy of Arts and Sciences.", - "heading": "Rice engineer Richard Baraniuk elected to American Academy of Arts and Sciences" - }, - "press/nearly-15-million-college-students-use-free-textbooks-school-year": { - "date": "2017-08-10", - "author": "David Ruth", - "detail_url": "/apps/cms/api/v2/pages/231/", - "excerpt": "Nearly 1.5 million U.S. college students are expected to save an estimated $145 million in the 2017-18 academic year by using free textbooks from OpenStax, the Rice University-based publisher of open education resource materials.", - "heading": "Nearly 1.5 million college students to use free textbooks this school year" - }, - "press/openstax-publishes-new-business-textbook-series": { - "date": "2018-09-18", - "author": "David Ruth, Rice News", - "detail_url": "/apps/cms/api/v2/pages/260/", - "excerpt": "Rice University-based publisher OpenStax announced today that it is publishing six new textbooks designed for introductory business courses. The courses covered are taught at most colleges and universities in the U.S. and enroll an estimated two mill", - "heading": "OpenStax publishes new business textbook series" - }, - "press/oer-expert-available-comment-amazon-inspire-relaunch": { - "date": "2017-07-18", - "author": "David Ruth", - "detail_url": "/apps/cms/api/v2/pages/232/", - "excerpt": "Daniel Williamson, managing director of OpenStax, a Rice University-based publisher of open education resources (OER) and textbooks, is available to comment on the relaunch of Amazon Inspire.", - "heading": "OER expert available to comment on Amazon Inspire relaunch" - }, - "press/48-percent-colleges-22-million-students-using-free-openstax-textbooks-year": { - "date": "2018-08-01", - "author": "David Ruth", - "detail_url": "/apps/cms/api/v2/pages/240/", - "excerpt": "This year, over 2.2 million students are saving an estimated $177 million by using free textbooks from OpenStax, the Rice University-based publisher of open educational resource materials.", - "heading": "48 percent of colleges, 2.2 million students using free OpenStax textbooks this year" - }, - "press/openstaxs-2016-partner-schools-expected-to-save-students-82m": { - "date": "2017-06-27", - "author": "Jade Boyd", - "detail_url": "/apps/cms/api/v2/pages/234/", - "excerpt": "Eleven U.S. colleges and universities that partnered last summer with OpenStax to boost the use of freely available textbooks and learning materials on their campuses expect the program to save their students nearly $8.2 million.", - "heading": "OpenStax’s 2016 partner schools expected to save students $8.2M" - }, - "press/openstax-launches-personalized-learning-tool-college-courses": { - "date": "2017-07-10", - "author": "Jade Boyd", - "detail_url": "/apps/cms/api/v2/pages/233/", - "excerpt": "Rice University-based nonprofit OpenStax launched a low-cost, personalized learning system called OpenStax Tutor Beta that studies how students learn to offer them individualized homework and tutoring.", - "heading": "OpenStax launches personalized learning tool for college courses" - }, - "press/openstax-director-comments-new-babson-oer-survey-results": { - "date": "2017-12-19", - "author": "David Ruth", - "detail_url": "/apps/cms/api/v2/pages/228/", - "excerpt": "The director of Rice University-based OpenStax is available to comment on new findings released today by Babson Survey Research Group about faculty awareness and satisfaction with open educational resources (OER), such as textbooks.", - "heading": "OpenStax director comments on new Babson OER survey results" - }, - "press/rice-expert-available-comment-proposed-free-textbook-legislation": { - "date": "2017-09-27", - "author": "David Ruth", - "detail_url": "/apps/cms/api/v2/pages/229/", - "excerpt": "Daniel Williamson, managing director of Rice University-based nonprofit OpenStax, is available to comment on a bill reintroduced yesterday which is “designed to help students manage costs by making high-quality textbooks easily accessible to students.\"", - "heading": "Rice expert available to comment on proposed free textbook legislation" - }, - "press/openstax-textbooks-now-available-through-bookstore-digital-access-programs": { - "date": "2017-11-10", - "author": "David Ruth, Rice News", - "detail_url": "/apps/cms/api/v2/pages/226/", - "excerpt": "Rice University-based publisher OpenStax announced today that its textbooks are now available through VitalSource and RedShelf, which will include OpenStax content for free or for no additional cost beyond a marginal platform fee.", - "heading": "OpenStax textbooks now available through bookstore digital access programs" - }, - "press/openstax-partners-katalyst-deliver-free-textbooks-poland": { - "date": "2017-09-20", - "author": "David Ruth, Rice News", - "detail_url": "/apps/cms/api/v2/pages/227/", - "excerpt": "Rice University-based nonprofit OpenStax is partnering with Katalyst Education to bring free, peer-reviewed, openly licensed textbooks to Poland as part of a new effort to internationalize OpenStax’s free open textbook model.", - "heading": "OpenStax partners with Katalyst to deliver free textbooks to Poland" - }, - "press/openstax-partner-schools-expected-save-students-174m-textbooks": { - "date": "2018-08-22", - "author": "David Ruth, Rice News", - "detail_url": "/apps/cms/api/v2/pages/253/", - "excerpt": "Eleven U.S. colleges and universities that partnered with OpenStax last summer expect to save their students nearly $17.4 million on textbook and materials in the coming academic year.", - "heading": "OpenStax partner schools expected to save students $17.4M on textbooks" - }, - "press/rice-university-based-openstax-partners-uk-open-textbooks": { - "date": "2017-09-12", - "author": "Jade Boyd", - "detail_url": "/apps/cms/api/v2/pages/230/", - "excerpt": "Rice University-based nonprofit OpenStax, which already provides free, high quality, openly licensed textbooks to nearly 1.5 million college students per year, is partnering with Open University’s UK Open Textbooks initiative to bring OpenStax’s textbooks", - "heading": "Rice University-based OpenStax partners with UK Open Textbooks" + title: 'In the Press', + press_kit: { + id: 2233, + meta: { + type: 'wagtaildocs.Document', + detail_url: 'https://openstax.org/apps/cms/api/v2/documents/2233/', + download_url: + 'https://openstax.org/documents/2233/OpenStax_Press_Kit.pdf' + }, + title: 'OpenStax Press Kit' + }, + press_kit_url: + 'https://assets.openstax.org/oscms-prodcms/media/documents/OpenStax_Press_Kit.pdf', + about: '

OpenStax is part of Rice University, which is a 501(c)(3) nonprofit charitable organization.

', + releases: { + 'press/openstax-director-comments-new-babson-oer-survey-results': { + detail_url: '/apps/cms/api/v2/pages/228/', + date: '2017-12-19', + heading: + 'OpenStax director comments on new Babson OER survey results', + excerpt: + 'The director of Rice University-based OpenStax is available to comment on new findings released today by Babson Survey Research Group about faculty awareness and satisfaction with open educational resources (OER), such as textbooks.', + author: 'David Ruth' } }, - "promote_image": null, - "experts_heading": "Book our experts", - "experts_blurb": "To reach out to one of our experts for comments, interviews, or speaking engagements, contact media@OpenStax.org.", - "experts_bios": [ - { - "id": 1, - "meta": { - "type": "news.ExpertsBios" - }, - "name": "Richard Baraniuk", - "email": null, - "title": "Founder/Director", - "bio": "In addition to his work with OpenStax, Rich is an electrical and computer engineering professor at Rice University. His current focus at OpenStax is developing new machine learning algorithms to drive personalized learning functions for OpenStax Tutor.", - "expert_image": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Richard.png" - }, - { - "id": 2, - "meta": { - "type": "news.ExpertsBios" + promote_image: { + id: 2152, + meta: { + width: 2048, + height: 1365, + type: 'wagtailimages.Image', + detail_url: 'https://openstax.org/apps/cms/api/v2/images/2152/', + download_url: + 'https://assets.openstax.org/oscms-prodcms/media/original_images/OpenStax_August_2023-225.jpg' + }, + title: 'OpenStaxPhysicsStudent_PressIndexSupporters_2024' + }, + experts_heading: 'Senior Leadership', + experts_blurb: + 'To reach out to one of our leaders for comments, interviews, or speaking engagements, contact media@OpenStax.org.', + experts_bios: [ + { + id: 33, + meta: { + type: 'news.ExpertsBios' }, - "name": "Daniel Williamson", - "email": null, - "title": "Managing Director", - "bio": "Daniel specializes in education policy, open education, content development, ed-tech, consumer intelligence, and management. You can follow him on Twitter @new_edu.", - "expert_image": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Daniel.png" + name: 'Richard Baraniuk', + email: null, + title: 'Founder/Director', + bio: 'In addition to his work with OpenStax, Professor Baraniuk is a C. Sidney Burrus Professor of Electrical and Computer Engineering at Rice University and the Director of SafeInsights, a large-scale education research hub led by OpenStax. His research interests include new theory, algorithms, and hardware for sensing, signal processing, and machine learning.', + expert_image: + 'https://assets.openstax.org/oscms-prodcms/media/original_images/Rich_Pic_Web.jpg' }, { - "id": 3, - "meta": { - "type": "news.ExpertsBios" + id: 34, + meta: { + type: 'news.ExpertsBios' }, - "name": "Nicole Finkbeiner", - "email": null, - "title": "Director of Institutional Relations", - "bio": "Nicole’s expertise includes open education, encouraging faculty to adopt open educational resources, community college administration, educational technology business models, consumer behavior, leadership, marketing, and advertising. You can follow her on Twitter @nfinkbeiner.", - "expert_image": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Nicole.png" + name: 'Daniel Williamson', + email: null, + title: 'Managing Director', + bio: 'Daniel specializes in education policy, open education, content development, ed-tech, consumer intelligence, and management. You can follow him on Twitter @new_edu.', + expert_image: + 'https://assets.openstax.org/oscms-prodcms/media/original_images/Daniel_Web.jpg' } ], - "mentions": [ - { - "id": "7109e9c6-c76b-43ed-a130-7ecbc4b0da86", - "type": "mention", - "value": { - "date": "2018-08-02", - "url": "https://edscoop.com/nearly-half-of-u-s-colleges-are-using-openstax-textbooks-this-year", - "source": { - "name": "EdScoop", - "id": 14, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/edscoop_icon.png" - }, - "headline": "Nearly half of U.S. colleges are using OpenStax textbooks this year" - } - }, - { - "id": "f5740a1b-cbc0-4e47-b88b-767b482284e7", - "type": "mention", - "value": { - "date": "2018-07-26", - "url": "https://www.insidehighered.com/news/2018/07/26/students-sacrifice-meals-and-trips-home-pay-textbooks", - "source": { - "name": "Inside Higher Ed", - "id": 13, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/inside_higher_ed_logo.jpg" - }, - "headline": "Textbook Trade-Offs" - } - }, - { - "id": "8a73f671-5f23-4b9d-a460-ad963cc2ef4d", - "type": "mention", - "value": { - "date": "2018-06-20", - "url": "http://www.surfsantamonica.com/ssm_site/the_lookout/news/News-2018/June-2018/06_20_2018_Santa_Monica_College_to_Increase_Use_of_Free_Textbooks_Through_OpenStax.html", - "source": { - "name": "Santa Monica Lookout", - "id": 10, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Screen_Shot_2018-06-21_at_11.13.52_AM.png" - }, - "headline": "Santa Monica College to Increase Use of Free Textbooks Through OpenStax" - } - }, - { - "id": "e8525ce6-2643-4c0b-9112-e9a5ab7f6988", - "type": "mention", - "value": { - "date": "2018-06-19", - "url": "https://www.fox16.com/news/education/a-state-to-increase-use-of-free-textbooks-by-partnering-with-openstax/1249400802", - "source": { - "name": "FOX16 News", - "id": 11, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/fox_news_logo.png" - }, - "headline": "A-State to Increase Use of Free Textbooks by Partnering with OpenStax" - } - }, - { - "id": "c0391e9b-d576-4ed4-ac9a-200b360fd919", - "type": "mention", - "value": { - "date": "2018-06-19", - "url": "http://www.kark.com/news/education/asu-to-increase-use-of-free-textbooks-by-partnering-with-openstax/1249381059", - "source": { - "name": "KARK", - "id": 12, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/kark_news_logo.png" - }, - "headline": "ASU to Increase Use of Free Textbooks by Partnering with OpenStax" - } - }, - { - "id": "6602322f-25dc-4750-86ff-c8a32689e20b", - "type": "mention", - "value": { - "date": "2018-06-02", - "url": "http://bit.ly/2HkqfuT", - "source": { - "name": "State of Digital Publishing", - "id": 9, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/sdp_pic.jpeg" - }, - "headline": "EP 14 — ‘State of Higher Education Publishing’ with David Harris (OpenStax)" - } - }, - { - "id": "3dcf0fa9-c420-42ba-b7df-bc816688dcd6", - "type": "mention", - "value": { - "date": "2018-06-01", - "url": "http://bit.ly/2JbboIX", - "source": { - "name": "Journal of Petroleum Technology", - "id": 2, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/jpt.original.png" - }, - "headline": "Time to enlist in the analytics army" - } - }, - { - "id": "054022b3-3fff-44d1-b62a-82c46c921e28", - "type": "mention", - "value": { - "date": "2018-05-25", - "url": "http://bit.ly/2LFDycH", - "source": { - "name": "Grand Rapids Business Journal", - "id": 3, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Screen_Shot_2018-06-12_at_11.00.09_AM.png" - }, - "headline": "Change-Ups: Gill elected to airport trade association’s board" - } - }, - { - "id": "1f9a44ff-0ef1-4b6b-b6d2-ba38f3c5b7c3", - "type": "mention", - "value": { - "date": "2018-05-22", - "url": "http://bit.ly/2LmDBtE", - "source": { - "name": "Community College Daily", - "id": 4, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Screen_Shot_2018-06-12_at_11.00.49_AM.png" - }, - "headline": "Reporter's notebook" - } - }, - { - "id": "bf3dba93-21b4-4c41-9a3b-0c46ecc07568", - "type": "mention", - "value": { - "date": "2018-05-08", - "url": "http://bit.ly/2I0VkIZ", - "source": { - "name": "San Francisco Chronicle", - "id": 5, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/sf_gate_logo.png" - }, - "headline": "Federal government on track with pilot program to offer free textbooks" - } - }, - { - "id": "33fdf244-0cd5-4998-b8be-d98e69d8df14", - "type": "mention", - "value": { - "date": "2018-05-08", - "url": "https://wapo.st/2rrJ6yb", - "source": { - "name": "Washington Post", - "id": 1, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Washington-post-logo-thumb.jpg" + infographic_image: { + id: 2173, + meta: { + width: 1600, + height: 982, + type: 'wagtailimages.Image', + detail_url: 'https://openstax.org/apps/cms/api/v2/images/2173/', + download_url: + 'https://assets.openstax.org/oscms-prodcms/media/original_images/press_infographic_S2XYYNy.jpg' + }, + title: 'press infographic' + }, + infographic_text: 'Increasing access for all', + testimonials: [ + { + type: 'testimonial', + value: [ + { + image: { + id: 1947, + file: 'https://assets.openstax.org/oscms-prodcms/media/original_images/press_testimonial_thumbnails-01.jpg', + title: 'PressTestimonialThumbnails01_PressIndex_2024', + height: 2550, + width: 2550, + created_at: '2023-06-15T09:10:28.635737-05:00' + }, + testimonial: + '“I have had many students tell me if it wasn’t for OpenStax they would have considered leaving school because they could not afford the additional expense of traditional textbooks.” - Vincent Scarpinato, Business Department Chair, Arizona Christian University' }, - "headline": "Free textbooks? Federal government is on track with a pilot program" - } - }, - { - "id": "d8c34cbb-8b5d-4a85-a761-a8656da48cbc", - "type": "mention", - "value": { - "date": "2018-05-01", - "url": "http://bit.ly/2jpWXkS", - "source": { - "name": "Cloud Tweaks", - "id": 6, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/CloudTweaksPress.png" + { + image: { + id: 1949, + file: 'https://assets.openstax.org/oscms-prodcms/media/original_images/press_testimonial_thumbnails-03.jpg', + title: 'PressTestimonialThumbnails03_PressIndex_2024', + height: 2550, + width: 2550, + created_at: '2023-06-15T09:11:18.222708-05:00' + }, + testimonial: + '“The interactiveness of the textbooks makes learning fun. Additional textbooks also cost money which is not an issue when it comes to OpenStax. Overall, I would say that OpenStax has been a great teacher.” - Shakari Jones, Midlands Technical College' }, - "headline": "What every executive needs to know" - } + { + image: { + id: 1948, + file: 'https://assets.openstax.org/oscms-prodcms/media/original_images/press_testimonial_thumbnails-02.jpg', + title: 'PressTestimonialThumbnails02_PressIndex_2024', + height: 2550, + width: 2550, + created_at: '2023-06-15T09:10:53.657664-05:00' + }, + testimonial: + 'I definitely recommend it to everyone, especially those who are interested in a topic but don’t know where to start. OpenStax is a great resource because it is well-written by those who know what they are talking about. To students who have never used OpenStax before: “Try it. Why not, it’s free!” - Marcia Humphreys, Truman State Univ.' + } + ], + id: '4e813412-a11d-482d-bd86-c1860cb3a4ca' + } + ], + faqs: [ + { + type: 'faq', + value: { + question: + '

How does OpenStax make any money or remain sustainable, considering you offer free resources?

', + slug: '/unknown', + answer: '

OpenStax has longstanding partnerships with philanthropic foundations like Arnold Ventures, Bill & Melinda Gates Foundation, William & Flora Hewlett Foundation, as well as public funders like the National Science Foundation and Texas Higher Ed Coordinating Board, who provide the funding to create peer-reviewed, openly licensed resources and technology. OpenStax also generates earned revenue through print sales of their textbooks and mission support fees from for-profit edtech partners who provide optional resources, such as homework solutions that wrap around OpenStax content. This sustainable business model helps ensure that OpenStax textbooks are always up-to-date and available to instructors and students for free. To learn more about our supporters and partners, visit openstax.org.

', + document: null + }, + id: '698151ab-341b-4710-8e0b-a60e8e331c73' }, { - "id": "70b1a74d-3944-4b24-a3c0-45b659143366", - "type": "mention", - "value": { - "date": "2018-04-17", - "url": "http://bit.ly/2J4toA2", - "source": { - "name": "Albany Herald", - "id": 7, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Screen_Shot_2018-06-12_at_11.04.37_AM.png" + type: 'faq', + value: { + question: + '

What is the difference between other openly licensed or traditionally published books and OpenStax texts?

', + slug: '/unknown', + answer: '

OpenStax textbooks are different from many open educational resources (OER) in that they are written by subject matter experts, peer-reviewed by experienced faculty and industry leaders, undergo an extensive collaborative editorial process, and employ professional art programs. Our textbooks have the same look and feel and undergo the same rigorous editorial process as the traditional textbooks that cost hundreds of dollars.

', + document: null + }, + id: '7c476a80-a674-487a-a64d-f70f32c0f001' + } + ], + mentions: [ + { + type: 'mention', + value: { + source: { + id: 25, + name: 'EdSurge', + logo: 'https://assets.openstax.org/oscms-prodcms/media/original_images/ed_surge_logo.png' }, - "headline": "USG says no tuition hike during 2018-2019" - } + url: 'https://www.edsurge.com/news/2024-05-17-this-90m-education-research-project-is-banking-on-data-privacy-to-drive-insights?utm_campaign=GSVN2K&utm_medium=email&_hsenc=p2ANqtz--NpqStX4gxvZEnTuU4-ZvWfWuqHIw48yBQssuVCbUC9OV9_Qyb5luutiOTTnNWwkETWsqEsnKGvNk16AB-2OyV6Nzi0Q&_hsmi=307516376&utm_content=307516376&utm_source=hs_email', + headline: + 'This $90M Education Research Project is Banking on Data Privacy to Drive Insights', + date: '2024-05-17', + featured_in: true + }, + id: '7e0b71e1-06bb-48f1-a69b-d4fc098e8290' }, { - "id": "5d191862-eb2a-4a4e-83c5-34e83787ab89", - "type": "mention", - "value": { - "date": "2018-04-16", - "url": "http://bit.ly/2JPZ79o", - "source": { - "name": "Campus Technology", - "id": 8, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/CTlogo.jpg" + type: 'mention', + value: { + source: { + id: 157, + name: 'Google for Education', + logo: 'https://assets.openstax.org/oscms-prodcms/media/original_images/GAFE_Logo.png' }, - "headline": "OER vendor Top Hat commits to CARE; opens content" - } + url: 'https://blog.google/products/classroom/google-ai-gemini-workspace-for-education/', + headline: 'Bringing Gemini to Google Workspace for Education', + date: '2024-05-16', + featured_in: true + }, + id: '5896ac1b-38e4-497e-845c-987b56de4a31' }, { - "id": "d6a957aa-f6ab-4229-bd09-3d37af41441b", - "type": "mention", - "value": { - "date": "2018-04-14", - "url": "https://wapo.st/2JRwDMi", - "source": { - "name": "Washington Post", - "id": 1, - "logo": "https://d3bxy9euw4e147.cloudfront.net/oscms-dev/media/original_images/Washington-post-logo-thumb.jpg" + type: 'mention', + value: { + source: { + id: 1, + name: 'Washington Post', + logo: 'https://assets.openstax.org/oscms-prodcms/media/original_images/Washington-post-logo-thumb.jpg' }, - "headline": "Battle over college course material is a textbook example of technological change" - } + url: 'https://wapo.st/2JRwDMi', + headline: + 'Battle over college course material is a textbook example of technological change', + date: '2018-04-14', + featured_in: false + }, + id: 'd6a957aa-f6ab-4229-bd09-3d37af41441b' } ], - "mission_statements": [ - { - "id": 1, - "meta": { - "type": "news.MissionStatements" - }, - "statement": "To increase access to education by providing effective educational materials for free, or at minimal cost." - }, - { - "id": 2, - "meta": { - "type": "news.MissionStatements" - }, - "statement": "To partner with educators to help meet the needs of their students." - }, + mission_statements: [ { - "id": 3, - "meta": { - "type": "news.MissionStatements" + id: 43, + meta: { + type: 'news.MissionStatements' }, - "statement": "To leverage our freedom as a nonprofit to make learning outcomes–not financial outcomes–our metric for success." + statement: + 'To transform learning so that education works for every student.' } ], - "press_inquiry_name": "Dani Nicholson", - "press_inquiry_phone": "713-348-2975", - "press_inquiry_email": "media@OpenStax.org" + press_inquiry_name: 'Kate Rybka Brennan', + press_inquiry_phone: '713-348-4484', + press_inquiry_email: 'media@openstax.org' }; diff --git a/test/src/pages/press/press.test.tsx b/test/src/pages/press/press.test.tsx new file mode 100644 index 000000000..058f5c07a --- /dev/null +++ b/test/src/pages/press/press.test.tsx @@ -0,0 +1,50 @@ +import React from 'react'; +import {render, screen, waitFor} from '@testing-library/preact'; +import {describe, it} from '@jest/globals'; +import {MemoryRouter} from 'react-router-dom'; +import Press from '~/pages/press/press'; + +const mockPathname = jest.fn(); +const mockNavigate = jest.fn(); +const mockCarousel = ({children}: React.PropsWithChildren) =>
{children}
; + +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useLocation: () => ({ + get pathname() {return mockPathname();} + }), + Navigate: () => mockNavigate() +})); +jest.mock('~/components/carousel/carousel', () => mockCarousel); + +describe('press page', () => { + it('renders main press page', async () => { + mockPathname.mockReturnValueOnce('').mockReturnValueOnce(''); + render( + + + + ); + await screen.findByText('In the press'); + await waitFor(() => expect(document.title).toMatch('- OpenStax')); + document.title = ''; + }); + it('renders press article page', async () => { + render( + + + + ); + expect(await screen.findAllByRole('heading')).toHaveLength(2); + }); + it('tries to Navigate on slash', async () => { + mockPathname.mockReturnValueOnce('/').mockReturnValueOnce(''); + mockNavigate.mockReturnValue(
This is navigate
); + render( + + + + ); + await screen.findByText('This is navigate'); + }); +}); diff --git a/webpack.config.js b/webpack.config.js index fb7b25eb8..1adc075ff 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -96,6 +96,7 @@ const config = { react: 'preact/compat', 'react-dom/test-utils': 'preact/test-utils', 'react-dom': 'preact/compat', + 'react/jsx-runtime': 'preact/jsx-runtime', '~': path.resolve(__dirname, 'src/app') }, modules: [path.resolve(__dirname, 'src/app'), 'node_modules'], diff --git a/yarn.lock b/yarn.lock index cda49c87b..8ffaebd46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10787,10 +10787,10 @@ react-accessible-accordion@^4.0.0: resolved "https://registry.yarnpkg.com/react-accessible-accordion/-/react-accessible-accordion-4.0.0.tgz#83bf0c3e403e7627dbf3109c628b597142923937" integrity sha512-MovuWj2Uweo57LSgTIPpB83IYq8BNdZJ44j4NmDKYxaHC/H0JjYiqt8OfNMt+YK+XN8qRON13ERQnLfM73vmqw== -react-aria-carousel@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/react-aria-carousel/-/react-aria-carousel-0.1.0.tgz#9aca5777c6552e2c63dec6f7eeff754d256f37b4" - integrity sha512-Jk9fVKa0Hd41iL/iGSxL4vH+KuhdTgQuAsxEIXQqJpG3yN1uQ96+/i83spetHOBGYWQ04Ub4f7On1wfKkuNCTA== +react-aria-carousel@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/react-aria-carousel/-/react-aria-carousel-0.2.0.tgz#7cde3bbbeda7d2d5e7acb01d43ac8901d97f76f3" + integrity sha512-XSQ2qnn7lVo0pE+3oR6nutoZEVpRsasEJ1uu3NAzV8i5Tf59HiM0xbqTrFjjcBuwGsQ8Ny9Lo+5/XrQf2cThRw== react-aria@^3.31.1: version "3.33.1" @@ -10835,6 +10835,11 @@ react-aria@^3.31.1: "@react-aria/visually-hidden" "^3.8.12" "@react-types/shared" "^3.23.1" +"react-dom@npm:@preact/compat": + version "17.1.2" + resolved "https://registry.yarnpkg.com/@preact/compat/-/compat-17.1.2.tgz#928756713b07af6faf7812f6a56840d8ce6fed37" + integrity sha512-7pOZN9lMDDRQ+6aWvjwTp483KR8/zOpfS83wmOo3zfuLKdngS8/5RLbsFWzFZMGdYlotAhX980hJ75bjOHTwWg== + react-intl@^6.3.2: version "6.6.8" resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-6.6.8.tgz#cb60c90502d0025caf9f86ec298cdc4348da17c2" @@ -10952,6 +10957,11 @@ react-stately@^3.29.1: "@react-stately/tree" "^3.8.1" "@react-types/shared" "^3.23.1" +"react@npm:@preact/compat": + version "17.1.2" + resolved "https://registry.yarnpkg.com/@preact/compat/-/compat-17.1.2.tgz#928756713b07af6faf7812f6a56840d8ce6fed37" + integrity sha512-7pOZN9lMDDRQ+6aWvjwTp483KR8/zOpfS83wmOo3zfuLKdngS8/5RLbsFWzFZMGdYlotAhX980hJ75bjOHTwWg== + read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"