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

614-fix: Pre school subtitle #675

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions dev-data/about-course.data.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ROUTES } from '@/core/const';

Check warning on line 1 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/core/const" is not allowed
import awardIcon from '@/shared/assets/icons/award-icon.webp';

Check warning on line 2 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/shared/assets/icons/award-icon.webp" is not allowed
import giftIcon from '@/shared/assets/icons/gift.webp';

Check warning on line 3 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/shared/assets/icons/gift.webp" is not allowed
import noteIcon from '@/shared/assets/icons/note-icon.webp';

Check warning on line 4 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/shared/assets/icons/note-icon.webp" is not allowed
import paperIcon from '@/shared/assets/icons/paper-icon.webp';

Check warning on line 5 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/shared/assets/icons/paper-icon.webp" is not allowed
import personIcon from '@/shared/assets/icons/person-icon.webp';

Check warning on line 6 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/shared/assets/icons/person-icon.webp" is not allowed
import planetIcon from '@/shared/assets/icons/planet.webp';

Check warning on line 7 in dev-data/about-course.data.tsx

View workflow job for this annotation

GitHub Actions / CI

Reaching to "@/shared/assets/icons/planet.webp" is not allowed
import { LinkCustom } from '@/shared/ui/link-custom';
import { List } from '@/shared/ui/list';
import type { AboutCourseInfo } from 'data';
Expand All @@ -14,23 +14,33 @@
[key in CourseNamesChannels]: AboutCourseInfo[];
};

const enIntro = {
title: 'About the course',
linkLabel: 'Become a student',
paragraph: null,
};
const ruIntro = {
title: 'О курсС',
linkLabel: 'CΡ‚Π°Ρ‚ΡŒ студСнтом',
paragraph: null,
};
const preSchoolIntro = {
title: 'JS/Frontend-Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ°. ΠŸΠΎΠ΄Π³ΠΎΡ‚ΠΎΠ²ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ этап',
linkLabel: 'Π‘Ρ‚Π°Ρ‚ΡŒ студСнтом',
paragraph:
'ΠŸΠΎΠ΄Π³ΠΎΡ‚ΠΎΠ²ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ этап ΠΏΠΎΠΌΠΎΠΆΠ΅Ρ‚ Ρ‚Π΅ΠΌ, ΠΊΡ‚ΠΎ ΠΌΠ°Π»ΠΎ Π·Π½Π°ΠΊΠΎΠΌ ΠΈΠ»ΠΈ совсСм Π½Π΅ Π·Π½Π°ΠΊΠΎΠΌ с ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΈ Ρ…ΠΎΡ‚Π΅Π» Π±Ρ‹ впослСдствии ΡƒΡ‡ΠΈΡ‚ΡŒΡΡ Π½Π° основном курсС Β«JavaScript/Front-endΒ».',
};

export const introLocalizedContent = {
en: {
title: 'About the course',
linkLabel: 'Become a student',
paragraph: '',
},
ru: {
title: 'О курсС',
linkLabel: 'CΡ‚Π°Ρ‚ΡŒ студСнтом',
paragraph: '',
},
'pre-school-ru': {
title: 'JS/Frontend-Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ°. ΠŸΠΎΠ΄Π³ΠΎΡ‚ΠΎΠ²ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ этап',
linkLabel: 'Π‘Ρ‚Π°Ρ‚ΡŒ студСнтом',
paragraph:
'ΠŸΠΎΠ΄Π³ΠΎΡ‚ΠΎΠ²ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ этап ΠΏΠΎΠΌΠΎΠΆΠ΅Ρ‚ Ρ‚Π΅ΠΌ, ΠΊΡ‚ΠΎ ΠΌΠ°Π»ΠΎ Π·Π½Π°ΠΊΠΎΠΌ ΠΈΠ»ΠΈ совсСм Π½Π΅ Π·Π½Π°ΠΊΠΎΠΌ с ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΈ Ρ…ΠΎΡ‚Π΅Π» Π±Ρ‹ впослСдствии ΡƒΡ‡ΠΈΡ‚ΡŒΡΡ Π½Π° основном курсС Β«JavaScript/Front-endΒ».',
},
[COURSE_TITLES.JS_PRESCHOOL_RU]: preSchoolIntro,
[COURSE_TITLES.JS_EN]: enIntro,
[COURSE_TITLES.JS_RU]: ruIntro,
[COURSE_TITLES.REACT]: enIntro,
[COURSE_TITLES.ANGULAR]: enIntro,
[COURSE_TITLES.NODE]: enIntro,
[COURSE_TITLES.AWS_FUNDAMENTALS]: enIntro,
[COURSE_TITLES.AWS_CLOUD_DEVELOPER]: enIntro,
[COURSE_TITLES.AWS_DEVOPS]: enIntro,
};

const listData = {
Expand Down
9 changes: 9 additions & 0 deletions dev-data/courses.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const courses: Course[] = [
{
id: '1',
title: COURSE_TITLES.JS_PRESCHOOL_RU,
subTitle: 'Pre-school RU',
alias: COURSE_ALIASES.JS_PRESCHOOL_RU,
altTitle: 'JavaScript / Front-end',
iconSrc: javascript,
Expand All @@ -43,6 +44,7 @@ export const courses: Course[] = [
{
id: '2',
title: COURSE_TITLES.JS_EN,
subTitle: null,
alias: COURSE_ALIASES.JS_EN,
altTitle: 'JavaScript / Front-end',
iconSrc: javascript,
Expand All @@ -62,6 +64,7 @@ export const courses: Course[] = [
{
id: '3',
title: COURSE_TITLES.JS_RU,
subTitle: null,
alias: COURSE_ALIASES.JS_RU,
altTitle: 'JavaScript / Front-end',
iconSrc: javascript,
Expand All @@ -81,6 +84,7 @@ export const courses: Course[] = [
{
id: '4',
title: COURSE_TITLES.REACT,
subTitle: null,
alias: COURSE_ALIASES.REACT,
iconSrc: react,
iconSmall: reactSmall,
Expand All @@ -99,6 +103,7 @@ export const courses: Course[] = [
{
id: '5',
title: COURSE_TITLES.ANGULAR,
subTitle: null,
alias: COURSE_ALIASES.ANGULAR,
iconSrc: angular,
iconSmall: angularSmall,
Expand All @@ -117,6 +122,7 @@ export const courses: Course[] = [
{
id: '6',
title: COURSE_TITLES.NODE,
subTitle: null,
alias: COURSE_ALIASES.NODE,
iconSrc: nodejs,
iconSmall: nodejsSmall,
Expand All @@ -135,6 +141,7 @@ export const courses: Course[] = [
{
id: '7',
title: COURSE_TITLES.AWS_FUNDAMENTALS,
subTitle: null,
alias: COURSE_ALIASES.AWS_FUNDAMENTALS,
iconSrc: aws,
iconSmall: awsFundSmall,
Expand All @@ -154,6 +161,7 @@ export const courses: Course[] = [
{
id: '8',
title: COURSE_TITLES.AWS_CLOUD_DEVELOPER,
subTitle: null,
alias: COURSE_ALIASES.AWS_CLOUD_DEVELOPER,
iconSrc: aws,
iconSmall: awsDevSmall,
Expand All @@ -172,6 +180,7 @@ export const courses: Course[] = [
{
id: '9',
title: COURSE_TITLES.AWS_DEVOPS,
subTitle: null,
alias: COURSE_ALIASES.AWS_DEVOPS,
iconSrc: aws,
iconSmall: awsDevSmall,
Expand Down
4 changes: 1 addition & 3 deletions src/app/courses/javascript-preschool-ru/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ export async function generateMetadata(): Promise<Metadata> {
export default async function JsPreRoute() {
const course = await selectCourse(courseName);

return (
<JavaScriptPreSchoolRu lang="ru" type="pre-school-ru" course={course} courseName={courseName} />
);
return <JavaScriptPreSchoolRu lang="ru" course={course} courseName={courseName} />;
}
1 change: 1 addition & 0 deletions src/entities/course/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type ApiCoursesResponse = Readonly<{
export type Course = {
id: string;
title: CourseNamesKeys;
subTitle: string | null;
alias: CourseAliasValues;
altTitle?: string;
iconSrc: StaticImageData;
Expand Down
6 changes: 6 additions & 0 deletions src/shared/__tests__/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const mockedCourses: Course[] = [
{
id: '1',
title: COURSE_TITLES.JS_PRESCHOOL_RU,
subTitle: 'Pre-school RU',
alias: COURSE_ALIASES.JS_PRESCHOOL_RU,
startDate: 'Jun 24, 2024',
registrationEndDate: 'Jun 24, 2024',
Expand All @@ -44,6 +45,7 @@ export const mockedCourses: Course[] = [
{
id: '2',
title: COURSE_TITLES.JS_EN,
subTitle: null,
alias: COURSE_ALIASES.JS_EN,
startDate: 'Oct, 2024',
registrationEndDate: 'Jun 24, 2025',
Expand All @@ -63,6 +65,7 @@ export const mockedCourses: Course[] = [
{
id: '3',
title: COURSE_TITLES.JS_RU,
subTitle: null,
alias: COURSE_ALIASES.JS_RU,
startDate: 'Oct, 2024',
registrationEndDate: 'Jun 24, 2025',
Expand All @@ -82,6 +85,7 @@ export const mockedCourses: Course[] = [
{
id: '4',
title: COURSE_TITLES.REACT,
subTitle: null,
alias: COURSE_ALIASES.REACT,
startDate: 'Jul 1, 2024',
registrationEndDate: 'Jun 24, 2024',
Expand All @@ -101,6 +105,7 @@ export const mockedCourses: Course[] = [
{
id: '5',
title: COURSE_TITLES.ANGULAR,
subTitle: null,
alias: COURSE_ALIASES.ANGULAR,
startDate: 'Jul 1, 2024',
registrationEndDate: 'Jun 24, 2025',
Expand All @@ -120,6 +125,7 @@ export const mockedCourses: Course[] = [
{
id: '6',
title: COURSE_TITLES.AWS_FUNDAMENTALS,
subTitle: null,
alias: COURSE_ALIASES.AWS_FUNDAMENTALS,
startDate: 'Jul 1, 2024',
registrationEndDate: 'Jun 24, 2025',
Expand Down
3 changes: 3 additions & 0 deletions src/shared/helpers/getActualData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const coursesMock: Course[] = [
id: '1',
title: COURSE_TITLES.REACT,
alias: COURSE_ALIASES.REACT,
subTitle: null,
altTitle: 'altTitle',
iconSrc: {
src: 'icon',
Expand Down Expand Up @@ -50,6 +51,7 @@ const coursesMock: Course[] = [
{
id: '2',
title: COURSE_TITLES.REACT,
subTitle: null,
alias: COURSE_ALIASES.REACT,
altTitle: 'altTitle',
iconSrc: {
Expand Down Expand Up @@ -81,6 +83,7 @@ const coursesMock: Course[] = [
{
id: '3',
title: COURSE_TITLES.REACT,
subTitle: null,
alias: COURSE_ALIASES.REACT,
altTitle: 'altTitle',
iconSrc: {
Expand Down
12 changes: 3 additions & 9 deletions src/views/javascript-preschool-ru.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@ import { CourseNames, preSchoolRu } from 'data';
type JavaScriptPreSchoolRuProps = {
course: Course;
lang: 'ru' | 'en';
type?: 'pre-school-ru';
courseName: CourseNames['JS_PRESCHOOL_RU'];
};

export const JavaScriptPreSchoolRu = ({
lang,
type,
course,
courseName,
}: JavaScriptPreSchoolRuProps) => {
export const JavaScriptPreSchoolRu = ({ lang, course, courseName }: JavaScriptPreSchoolRuProps) => {
return (
<>
<HeroCourse type={type} lang={lang} course={course} />
<HeroCourse lang={lang} course={course} />
<Breadcrumbs />
<AboutCourse courseName={courseName} type={type} course={course} />
<AboutCourse courseName={courseName} course={course} />
<TrainingProgram courseName={courseName} lang={lang} course={course} />
<Required courseName={courseName} />
<Certification courseName={courseName} />
Expand Down
2 changes: 1 addition & 1 deletion src/views/javascript-ru.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const JavaScriptRu = ({ lang, course, courseName }: JavaScriptRuProps) =>
<HeroCourse course={course} lang={lang} />
<Breadcrumbs />
<TrainingProgram course={course} courseName={courseName} lang={lang} />
<AboutCourse course={course} courseName={courseName} type={lang} />
<AboutCourse course={course} courseName={courseName} />
<Certification courseName={courseName} />
<Communication courseName={courseName} lang={lang} />
<AboutVideo lang={lang} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const mockedReactCourse: Course = {
iconSmall: MOCKED_IMAGE_PATH,
iconSrc: MOCKED_IMAGE_PATH,
title: COURSE_TITLES.REACT,
subTitle: null,
alias: COURSE_ALIASES.REACT,
language: ['en'],
mode: 'online',
Expand Down Expand Up @@ -76,11 +77,7 @@ describe('AboutCourse component', () => {
describe('render "Paragraph" with "js / front-end pre-school ru" props', () => {
it("renders 'Paragraph' and its' content", async () => {
renderWithRouter(
<AboutCourse
course={mockedPreSchoolCourse}
courseName="JS / Front-end Pre-school RU"
type="pre-school-ru"
/>,
<AboutCourse course={mockedPreSchoolCourse} courseName="JS / Front-end Pre-school RU" />,
);

const paragraph = await screen.findByText(/ΠŸΠΎΠ΄Π³ΠΎΡ‚ΠΎΠ²ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ этап ΠΏΠΎΠΌΠΎΠΆΠ΅Ρ‚ Ρ‚Π΅ΠΌ/i);
Expand Down
11 changes: 5 additions & 6 deletions src/widgets/about-course/ui/about-course/about-course.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ export const cx = classNames.bind(styles);

type AboutCourseProps = {
courseName: CourseNamesKeys;
type?: 'ru' | 'en' | 'pre-school-ru';
course: Course;
};

export const AboutCourse = ({ course, courseName, type = 'en' }: AboutCourseProps) => {
export const AboutCourse = ({ course, courseName }: AboutCourseProps) => {
const courseInfoList = contentMapAbout[courseName];

return (
<section className={cx('container')}>
<div className={cx('about-course', 'content')}>
<WidgetTitle>{introLocalizedContent[type].title}</WidgetTitle>
{introLocalizedContent[type]?.paragraph && (
<Paragraph>{introLocalizedContent[type].paragraph}</Paragraph>
<WidgetTitle>{introLocalizedContent[courseName].title}</WidgetTitle>
{introLocalizedContent[courseName]?.paragraph && (
<Paragraph>{introLocalizedContent[courseName].paragraph}</Paragraph>
)}
<AboutCourseGrid items={courseInfoList} />
<LinkCustom href={course.enroll} variant="primary" external>
{introLocalizedContent[type]?.linkLabel}
{introLocalizedContent[courseName]?.linkLabel}
</LinkCustom>
</div>
</section>
Expand Down
54 changes: 37 additions & 17 deletions src/widgets/hero-course/ui/hero-course.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { COURSE_TITLES } from 'data';
const mockedCourse: Course = {
id: '6',
title: COURSE_TITLES.NODE,
subTitle: 'Test Subtitle',
alias: COURSE_ALIASES.NODE,
iconSrc: MOCKED_IMAGE_PATH,
iconSmall: MOCKED_IMAGE_PATH,
Expand All @@ -28,29 +29,48 @@ const mockedCourse: Course = {
};

describe('HeroCourse component', () => {
beforeEach(() => {
renderWithRouter(<HeroCourse course={mockedCourse} />);
});
describe('Render general content', () => {
beforeEach(() => {
renderWithRouter(<HeroCourse course={mockedCourse} />);
});

it('renders the title and label correctly', async () => {
const titleElement = await screen.findByText('Node.js Course');
const labelElement = screen.getByText('planned');
it('renders the title and label correctly', async () => {
const titleElement = await screen.findByText('Node.js Course');
const labelElement = screen.getByText('planned');

expect(titleElement).toBeVisible();
expect(labelElement).toBeVisible();
});
expect(titleElement).toBeVisible();
expect(labelElement).toBeVisible();
});

it('renders enroll button with correct label and href', () => {
const buttonElement = screen.getByRole('link', { name: /enroll/i });

it('renders enroll button with correct label and href', () => {
const buttonElement = screen.getByRole('link', { name: /enroll/i });
expect(buttonElement).toBeVisible();
expect(buttonElement).toHaveAttribute('href', 'https://test.com');
});

expect(buttonElement).toBeVisible();
expect(buttonElement).toHaveAttribute('href', 'https://test.com');
it('renders the image with correct source', () => {
const imageElement = screen.getByRole('img', { name: /Node.js/i });

expect(imageElement).toBeInTheDocument();
expect(imageElement).toHaveAttribute('src', MOCKED_IMAGE_PATH.src);
});
});

it('renders the image with correct source', () => {
const imageElement = screen.getByRole('img', { name: /Node.js/i });
describe('Render subtitle', () => {
it('renders the subtitle when provided', async () => {
renderWithRouter(<HeroCourse course={mockedCourse} />);
const subtitleElement = await screen.findByText('Test Subtitle');

expect(subtitleElement).toBeVisible();
});

it('does not display subtitles if they are not provided', () => {
mockedCourse.subTitle = null;
SpaNb4 marked this conversation as resolved.
Show resolved Hide resolved
renderWithRouter(<HeroCourse course={mockedCourse} />);
const subtitleElement = screen.queryByText('Test Subtitle');

expect(imageElement).toBeInTheDocument();
expect(imageElement).toHaveAttribute('src', MOCKED_IMAGE_PATH.src);
expect(subtitleElement).toBeNull();
});
});
});
Loading
Loading