diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 00000000..bb90f766 --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,13 @@ +export default function RootLayout({ + children, + params: { locale }, +}: { + children: React.ReactNode; + params: { locale: string }; +}) { + return ( + + {children} + + ); +} diff --git a/components/Common/Faqs.tsx b/components/Common/Faqs.tsx index 955ed492..fca1542f 100644 --- a/components/Common/Faqs.tsx +++ b/components/Common/Faqs.tsx @@ -29,7 +29,7 @@ const Faqs = ({ faqs }: FaqsProps) => { {t('secondParagraph')}

-
+
{ {faq.question} - + {faq.answer} diff --git a/components/Common/inputs/SearchInput.tsx b/components/Common/Inputs/SearchInput.tsx similarity index 100% rename from components/Common/inputs/SearchInput.tsx rename to components/Common/Inputs/SearchInput.tsx diff --git a/components/Newbies/LinksSection.tsx b/components/Newbies/LinksSection.tsx index d5ecca79..8a2e254b 100644 --- a/components/Newbies/LinksSection.tsx +++ b/components/Newbies/LinksSection.tsx @@ -33,6 +33,7 @@ const LinksSection = () => {
{linksData.map((linkData, index) => ( ({ {options.map(item => item.linkPath ? ( (e.key === 'Escape' ? toggleDropdown() : null)} diff --git a/package.json b/package.json index 66a1d8ea..95d4789e 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "check-lint": "eslint . --ext ts --ext tsx --ext js", "format": "npx prettier --write . --config ./.prettierrc", "prepare": "husky install", - "test": "npx playwright test", + "test": "npx playwright test --ui", "test-result": "npx playwright show-report" }, "lint-staged": { diff --git a/tests/newbiesPage.spec.ts b/tests/newbiesPage.spec.ts new file mode 100644 index 00000000..0c9a791d --- /dev/null +++ b/tests/newbiesPage.spec.ts @@ -0,0 +1,77 @@ +import { test, expect } from '@playwright/test'; + +const BASE_URL = 'http://localhost:3000/he'; + +test.describe('Test Newbies page', () => { + test('should navigate to the Newbies page', async ({ page }) => { + await page.goto(BASE_URL); + await page.click('text="קהילה"'); + await page.click('[data-testid="Newbies"]'); + + await page.waitForNavigation(); + + const pageTitle = await page.title(); + expect(pageTitle).toContain('Newbies'); + }); + + test('should render NEWBIES', async ({ page }) => { + await page.goto(`${BASE_URL}/newbies`); + expect(await page.textContent('h1')).toContain('NEWBIES'); + }); + + test('External links contain correct URLs', async ({ page }) => { + await page.goto(`${BASE_URL}/newbies`); + + const linksData = [ + { + name: 'Maakaf_Logo', + link: 'https://github.com/UrielOfir/os-practice', + }, + { + name: 'Discord_Logo', + link: 'https://discord.com/invite/a2VyCjRk2M', + }, + { + name: 'WhatsApp_Logo', + link: 'https://chat.whatsapp.com/E5a59DtSaHNBwnczxVW1FY', + }, + ]; + + for (const linkData of linksData) { + const linkSelector = `[data-testid="NewbiesExternalLink-${linkData.name}"]`; + const linkExists = await page.waitForSelector(linkSelector); + expect(linkExists).toBeTruthy(); + + const linkElement = await page.$(linkSelector); + const linkURL = await linkElement?.getAttribute('href'); + expect(linkURL).toBe(linkData.link); + } + }); + + test('FAQ items are clickable and expandable', async ({ page }) => { + await page.goto(`${BASE_URL}/newbies`); + await page.waitForSelector('[data-testid="faq-section"]'); + + const faqItems = await page.$$('[data-testid^="faq-item-"]'); + + for (let i = 0; i < faqItems.length; i++) { + const faqItem = faqItems[i]; + + const trigger = await faqItem.$('[data-testid^="faq-trigger-"]'); + await trigger?.click(); + + await page.waitForSelector( + '[data-testid^="faq-content-"][aria-expanded="true"]' + ); + + const content = await faqItem.$('[data-testid^="faq-content-"]'); + expect(content).not.toBeNull(); + + await trigger?.click(); + + await page.waitForSelector( + '[data-testid^="faq-content-"][aria-expanded="false"]' + ); + } + }); +});