Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fb3ec6e10a | |||
| acf642d7e6 | |||
| d5da2a91c8 | |||
| ebe664f984 |
@@ -14,4 +14,4 @@ jobs:
|
||||
secrets:
|
||||
GOTIFY_URL: ${{ secrets.GOTIFY_URL }}
|
||||
GOTIFY_TOKEN: ${{ secrets.GOTIFY_TOKEN }}
|
||||
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD || 'klz2026' }}
|
||||
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD || 'lassmichrein' }}
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
"valid-id": "off",
|
||||
"element-required-attributes": "off",
|
||||
"attribute-empty-style": "off",
|
||||
"element-permitted-content": "off"
|
||||
"element-permitted-content": "off",
|
||||
"element-required-content": "off",
|
||||
"element-permitted-parent": "off",
|
||||
"no-implicit-close": "off",
|
||||
"close-order": "off"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defaultJSXConverters, RichText } from '@payloadcms/richtext-lexical/react';
|
||||
import type { JSXConverters } from '@payloadcms/richtext-lexical/react';
|
||||
import Image from 'next/image';
|
||||
import { Suspense } from 'react';
|
||||
import { Suspense, Fragment } from 'react';
|
||||
|
||||
// Import all custom React components that were previously mapped via Markdown
|
||||
import StickyNarrative from '@/components/blog/StickyNarrative';
|
||||
@@ -36,9 +36,45 @@ import GallerySection from '@/components/home/GallerySection';
|
||||
import VideoSection from '@/components/home/VideoSection';
|
||||
import CTA from '@/components/home/CTA';
|
||||
|
||||
/**
|
||||
* Splits a text string on \n and intersperses <br /> elements.
|
||||
* This is needed because Lexical stores newlines as literal \n characters inside
|
||||
* text nodes (e.g. dash-lists typed in the editor), but HTML collapses whitespace.
|
||||
*/
|
||||
function textWithLineBreaks(text: string, key: string) {
|
||||
const parts = text.split('\n');
|
||||
if (parts.length === 1) return text;
|
||||
return parts.map((part, i) => (
|
||||
<Fragment key={`${key}-${i}`}>
|
||||
{part}
|
||||
{i < parts.length - 1 && <br />}
|
||||
</Fragment>
|
||||
));
|
||||
}
|
||||
|
||||
const jsxConverters: JSXConverters = {
|
||||
...defaultJSXConverters,
|
||||
// Let the default converters handle text nodes to preserve valid formatting
|
||||
// Handle Lexical linebreak nodes (explicit shift+enter)
|
||||
linebreak: () => <br />,
|
||||
// Custom text converter: preserve \n inside text nodes as <br />
|
||||
text: ({ node }: any) => {
|
||||
let content: React.ReactNode = node.text || '';
|
||||
// Split newlines first
|
||||
if (typeof content === 'string' && content.includes('\n')) {
|
||||
content = textWithLineBreaks(content, `t-${(node.text || '').slice(0, 8)}`);
|
||||
}
|
||||
// Apply Lexical formatting flags
|
||||
if (node.format) {
|
||||
if (node.format & 1) content = <strong>{content}</strong>;
|
||||
if (node.format & 2) content = <em>{content}</em>;
|
||||
if (node.format & 8) content = <u>{content}</u>;
|
||||
if (node.format & 4) content = <s>{content}</s>;
|
||||
if (node.format & 16) content = <code className="px-1.5 py-0.5 bg-neutral-100 rounded text-sm font-mono text-primary">{content}</code>;
|
||||
if (node.format & 32) content = <sub>{content}</sub>;
|
||||
if (node.format & 64) content = <sup>{content}</sup>;
|
||||
}
|
||||
return <>{content}</>;
|
||||
},
|
||||
// Use div instead of p for paragraphs to allow nested block elements (like the lists above)
|
||||
paragraph: ({ node, nodesToJSX }: any) => {
|
||||
return (
|
||||
@@ -57,16 +93,16 @@ const jsxConverters: JSXConverters = {
|
||||
const textContent = node.children ? node.children.map((c: any) => c.text || '').join('') : '';
|
||||
const id = textContent
|
||||
? textContent
|
||||
.toLowerCase()
|
||||
.replace(/ä/g, 'ae')
|
||||
.replace(/ö/g, 'oe')
|
||||
.replace(/ü/g, 'ue')
|
||||
.replace(/ß/g, 'ss')
|
||||
.replace(/[*_`]/g, '')
|
||||
.replace(/[^\w\s-]/g, '')
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
.toLowerCase()
|
||||
.replace(/ä/g, 'ae')
|
||||
.replace(/ö/g, 'oe')
|
||||
.replace(/ü/g, 'ue')
|
||||
.replace(/ß/g, 'ss')
|
||||
.replace(/[*_`]/g, '')
|
||||
.replace(/[^\w\s-]/g, '')
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
: undefined;
|
||||
|
||||
if (tag === 'h1')
|
||||
|
||||
@@ -116,7 +116,7 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostD
|
||||
category: doc.category || '',
|
||||
featuredImage:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
|
||||
? doc.featuredImage.url || doc.featuredImage.sizes?.card?.url
|
||||
: null,
|
||||
focalX:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
@@ -162,7 +162,7 @@ export async function getAllPosts(locale: string): Promise<PostData[]> {
|
||||
category: doc.category || '',
|
||||
featuredImage:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
|
||||
? doc.featuredImage.url || doc.featuredImage.sizes?.card?.url
|
||||
: null,
|
||||
focalX:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
"prepare": "husky",
|
||||
"preinstall": "npx only-allow pnpm"
|
||||
},
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.10",
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@parcel/watcher",
|
||||
|
||||
@@ -66,6 +66,12 @@ async function main() {
|
||||
|
||||
const page = await browser.newPage();
|
||||
|
||||
page.on('console', (msg) => console.log('💻 BROWSER CONSOLE:', msg.text()));
|
||||
page.on('pageerror', (error) => console.error('💻 BROWSER ERROR:', error.message));
|
||||
page.on('requestfailed', (request) => {
|
||||
console.error('💻 BROWSER REQUEST FAILED:', request.url(), request.failure()?.errorText);
|
||||
});
|
||||
|
||||
// 3. Authenticate through Gatekeeper login form
|
||||
console.log(`\n🛡️ Authenticating through Gatekeeper...`);
|
||||
try {
|
||||
@@ -98,7 +104,7 @@ async function main() {
|
||||
await page.goto(contactUrl, { waitUntil: 'networkidle0', timeout: 30000 });
|
||||
|
||||
// Ensure React has hydrated completely
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => { });
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => {});
|
||||
|
||||
// Ensure form is visible and interactive
|
||||
try {
|
||||
@@ -127,10 +133,17 @@ async function main() {
|
||||
|
||||
// Explicitly click submit and wait for navigation/state-change
|
||||
await Promise.all([
|
||||
page.waitForSelector('[role="alert"][aria-live="polite"]', { timeout: 15000 }),
|
||||
page.waitForSelector('[role="alert"]', { timeout: 15000 }),
|
||||
page.click('button[type="submit"]'),
|
||||
]);
|
||||
|
||||
const alertText = await page.$eval('[role="alert"]', (el) => el.textContent);
|
||||
console.log(` Alert text: ${alertText}`);
|
||||
|
||||
if (alertText?.includes('Failed') || alertText?.includes('went wrong')) {
|
||||
throw new Error(`Form submitted but showed error: ${alertText}`);
|
||||
}
|
||||
|
||||
console.log(`✅ Contact Form submitted successfully! (Success state verified)`);
|
||||
} catch (err: any) {
|
||||
console.error(`❌ Contact Form Test Failed: ${err.message}`);
|
||||
@@ -143,7 +156,7 @@ async function main() {
|
||||
await page.goto(productUrl, { waitUntil: 'networkidle0', timeout: 30000 });
|
||||
|
||||
// Ensure React has hydrated completely
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => { });
|
||||
await page.waitForNetworkIdle({ idleTime: 1000, timeout: 15000 }).catch(() => {});
|
||||
|
||||
// The product form uses dynamic IDs, so we select by input type in the specific form context
|
||||
try {
|
||||
@@ -170,10 +183,17 @@ async function main() {
|
||||
|
||||
// Submit and wait for success state
|
||||
await Promise.all([
|
||||
page.waitForSelector('[role="alert"][aria-live="polite"]', { timeout: 15000 }),
|
||||
page.waitForSelector('[role="alert"]', { timeout: 15000 }),
|
||||
page.click('form button[type="submit"]'),
|
||||
]);
|
||||
|
||||
const alertText = await page.$eval('[role="alert"]', (el) => el.textContent);
|
||||
console.log(` Alert text: ${alertText}`);
|
||||
|
||||
if (alertText?.includes('Failed') || alertText?.includes('went wrong')) {
|
||||
throw new Error(`Form submitted but showed error: ${alertText}`);
|
||||
}
|
||||
|
||||
console.log(`✅ Product Quote Form submitted successfully! (Success state verified)`);
|
||||
} catch (err: any) {
|
||||
console.error(`❌ Product Quote Form Test Failed: ${err.message}`);
|
||||
@@ -202,12 +222,16 @@ async function main() {
|
||||
console.log(` ✅ Deleted submission: ${doc.id}`);
|
||||
} catch (delErr: any) {
|
||||
// Log but don't fail, 403s on Directus / Payload APIs for guest Gatekeeper sessions are normal
|
||||
console.warn(` ⚠️ Cleanup attempt on ${doc.id} returned an error, typically due to API Auth separation: ${delErr.message}`);
|
||||
console.warn(
|
||||
` ⚠️ Cleanup attempt on ${doc.id} returned an error, typically due to API Auth separation: ${delErr.message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
if (err.response?.status === 403) {
|
||||
console.warn(` ⚠️ Cleanup fetch failed with 403 Forbidden. This is expected if the runner lacks admin API credentials. Test submissions remain in the database.`);
|
||||
console.warn(
|
||||
` ⚠️ Cleanup fetch failed with 403 Forbidden. This is expected if the runner lacks admin API credentials. Test submissions remain in the database.`,
|
||||
);
|
||||
} else {
|
||||
console.error(` ❌ Cleanup fetch failed: ${err.message}`);
|
||||
}
|
||||
|
||||
@@ -76,19 +76,31 @@ describe('OG Image Generation', () => {
|
||||
await verifyImageResponse(response);
|
||||
}, 30000);
|
||||
|
||||
it('should generate dynamic blog post OG image', async ({ skip }) => {
|
||||
it('should generate dynamic blog post OG image with featured photo', async ({ skip }) => {
|
||||
if (!isServerUp) skip();
|
||||
// Assuming 'hello-world' or a newly created post slug.
|
||||
// If it 404s, it still tests the routing, though 200 is expected for an actual post.
|
||||
const url = `${BASE_URL}/de/blog/hello-world/opengraph-image`;
|
||||
const response = await fetch(url);
|
||||
// Even if the post "hello-world" doesn't exist and returns 404 in some environments,
|
||||
// we should at least check it doesn't 500. We'll accept 200 or 404 as valid "working" states
|
||||
// vs a 500 compilation/satori error.
|
||||
expect([200, 404]).toContain(response.status);
|
||||
|
||||
if (response.status === 200) {
|
||||
await verifyImageResponse(response);
|
||||
// Discover a real blog slug from the sitemap
|
||||
const sitemapRes = await fetch(`${BASE_URL}/sitemap.xml`);
|
||||
const sitemapXml = await sitemapRes.text();
|
||||
const blogMatch = sitemapXml.match(/<loc>[^<]*\/de\/blog\/([^<]+)<\/loc>/);
|
||||
const slug = blogMatch ? blogMatch[1] : null;
|
||||
|
||||
if (!slug) {
|
||||
console.log('⚠️ No blog post found in sitemap, skipping dynamic OG test');
|
||||
skip();
|
||||
return;
|
||||
}
|
||||
|
||||
const url = `${BASE_URL}/de/blog/${slug}/opengraph-image`;
|
||||
const response = await fetch(url);
|
||||
await verifyImageResponse(response);
|
||||
|
||||
// Verify the image is substantially large (>50KB) to confirm it actually
|
||||
// contains the featured photo and isn't just a tiny fallback/text-only image
|
||||
const buffer = await response.clone().arrayBuffer();
|
||||
expect(
|
||||
buffer.byteLength,
|
||||
`OG image for "${slug}" is suspiciously small (${buffer.byteLength} bytes) — likely missing featured photo`,
|
||||
).toBeGreaterThan(50000);
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user