### Multisynq Examples Page SEO Metadata Configuration Source: https://multisynq.io/examples This snippet defines the essential SEO metadata for the Multisynq examples page, including the page title, description, Open Graph properties for social media sharing, and Twitter card details. This configuration helps search engines and social platforms display relevant information when the page is shared or indexed. ```APIDOC Page Metadata: - title: "Examples - Multisynq" - description: "Explore interactive demonstrations of Multisynq's capabilities across different frameworks and use cases." - og:title: "Examples - Multisynq" - og:description: "Explore interactive demonstrations of Multisynq's capabilities across different frameworks and use cases." - og:image: "https://multisynq.io/og-image.png" - twitter:card: "summary_large_image" - twitter:title: "Examples - Multisynq" - twitter:description: "Explore interactive demonstrations of Multisynq's capabilities across different frameworks and use cases." ``` -------------------------------- ### Verify Code Examples are Runnable in Playwright Source: https://multisynq.io/docs This Playwright test navigates to a page, identifies 'Run' or 'Try' buttons associated with code examples, clicks the first one, and waits for execution. It then checks for the presence and visibility of an output or result area, ensuring code examples are functional. ```JavaScript await page.goto('/essentials/collaboration'); // Look for "Run" or "Try it" buttons const runButtons = page.locator('button:has-text("Run"), button:has-text("Try"), .run-button'); const runCount = await runButtons.count(); if (runCount > 0) { const firstRunButton = runButtons.first(); await expect(firstRunButton).toBeVisible(); await firstRunButton.click(); // Wait for execution await page.waitForTimeout(1000); // Look for output or result area const output = page.locator('.output, .result, .console, [data-output]'); const outputCount = await output.count(); if (outputCount > 0) { await expect(output.first()).toBeVisible(); } } ``` -------------------------------- ### SVG Paths for 'Start within a few Minutes' Illustration Source: https://multisynq.io/synqer These SVG path data strings define the visual elements for an illustration related to the 'Start within a few Minutes' feature. They represent geometric shapes or lines used in a graphical animation. ```SVG M320,162.5 L319.7,0 M320,162.5 L261.1,60.8 M320,162.5 L157.5,69 M320,162.5 L76.1,162.9 M320,162.5 L218.3,221.4 M320,162.5 L226.5,325 M320,162.5 L320.3,325 M320,162.5 L378.9,264.2 M320,162.5 L482.5,256 M320,162.5 L563.9,162.1 M320,162.5 L421.7,103.6 M320,162.5 L413.5,0 ``` -------------------------------- ### Test Sidebar Navigation Visibility and Functionality with Playwright Source: https://multisynq.io/docs This Playwright test suite verifies the visibility and functionality of the sidebar navigation. It first asserts that the sidebar element is visible on the page. Then, it checks for the presence of key navigation sections like 'Getting Started', 'Quickstart', 'Essentials', 'API Reference', and 'React Together', ensuring the main navigation structure is rendered correctly. ```JavaScript test.describe('Sidebar Navigation', () => { test('sidebar is visible and functional', async ({ page }) => { // Check if sidebar exists const sidebar = page.locator('[data-testid="sidebar"], .sidebar, nav'); await expect(sidebar).toBeVisible(); // Check for main navigation sections await expect(page.locator('text=Getting Started, text=Quickstart')).toBeVisible(); await expect(page.locator('text=Essentials, text=API Reference')).toBeVisible(); await expect(page.locator('text=React Together')).toBeVisible(); }); test('navigation links work correctly', async ({ page }) => { // Test Quickstart navigation await page.click('text=Quickstart'); await expect(page).toHaveURL(/.*\/quickstart/); await expect(page.locator('h1')).toContainText('Quickstart'); // Test API Reference navigation await page.click('text=API Reference'); await expect(page).toHaveURL(/.*\/api-reference/); // Test Model API page await page.click('text=Model'); await expect(page).toHaveURL(/.*\/api-reference\/model/); await expect(page.locator('h1')).toContainText('Model'); }); }); ``` -------------------------------- ### Playwright: Test Suite for Documentation Page Loading and Content Validation Source: https://multisynq.io/docs This comprehensive Playwright test suite verifies the successful loading and content integrity of various documentation pages. It defines arrays of page paths categorized by type (core, essential, API, React Together) and then iterates through them, asserting that each page loads with a 200 status, has the correct title, displays main content, contains expected descriptive text, and loads within a specified performance threshold (3 seconds). For essential guide pages, it also checks for the presence of code examples. ```javascript import { test, expect } from '@playwright/test'; /** * Test suite for verifying all documentation pages load correctly * Tests page loading, basic content presence, and response times */ // Core documentation pages const corePages = [ { path: '/', title: 'Multisynq Documentation', description: 'Welcome to Multisynq' }, { path: '/quickstart', title: 'Quickstart', description: 'Start building' }, { path: '/development', title: 'Development', description: 'Development setup' } ]; // Essential guides pages const essentialPages = [ { path: '/essentials/sync', title: 'Real-time Synchronization', description: 'Learn how Multisynq achieves' }, { path: '/essentials/collaboration', title: 'Collaborative Editing', description: 'Build real-time collaborative' }, { path: '/essentials/chat', title: 'Real-time Chat', description: 'Build chat applications' }, { path: '/essentials/whiteboard', title: 'Shared Whiteboard', description: 'Create collaborative drawing' }, { path: '/essentials/scaling', title: 'Scaling Applications', description: 'Learn how to scale' }, { path: '/essentials/conflicts', title: 'Conflict Resolution', description: 'Understand how Multisynq handles' } ]; // API reference pages const apiPages = [ { path: '/api-reference/introduction', title: 'API Reference', description: 'Complete reference for the Multisynq' }, { path: '/api-reference/model', title: 'Model', description: 'The Model class is the core' }, { path: '/api-reference/view', title: 'View', description: 'The View class handles user interface' }, { path: '/api-reference/session', title: 'Session', description: 'Session management' } ]; // React Together pages const reactTogetherPages = [ { path: '/react-together', title: 'React Together', description: 'React Together documentation' }, { path: '/react-together/getting-started', title: 'Getting Started', description: 'Get started with React Together' }, { path: '/react-together/hooks/useStateTogether', title: 'useStateTogether', description: 'Share state between users' }, { path: '/react-together/hooks/useConnectedUsers', title: 'useConnectedUsers', description: 'Track connected users' }, { path: '/react-together/hooks/useChat', title: 'useChat', description: 'Add real-time chat' }, { path: '/react-together/components/ReactTogether', title: 'ReactTogether', description: 'Main component for React Together' } ]; // All pages combined const allPages = [...corePages, ...essentialPages, ...apiPages, ...reactTogetherPages]; test.describe('Page Loading Tests', () => { test.describe('Core Pages', () => { for (const page of corePages) { test(`${page.path} loads successfully`, async ({ page: playwright }) => { const response = await playwright.goto(page.path); // Check response status expect(response?.status()).toBe(200); // Check page title await expect(playwright).toHaveTitle(new RegExp(page.title, 'i')); // Check main content is present await expect(playwright.locator('main')).toBeVisible(); // Check for description in page content await expect(playwright.locator('body')).toContainText(page.description); // Performance check - page should load within 3 seconds const loadTime = Date.now(); await playwright.waitForLoadState('networkidle'); const totalTime = Date.now() - loadTime; expect(totalTime).toBeLessThan(3000); }); } }); test.describe('Essential Guides', () => { for (const page of essentialPages) { test(`${page.path} loads successfully`, async ({ page: playwright }) => { const response = await playwright.goto(page.path); expect(response?.status()).toBe(200); await expect(playwright).toHaveTitle(new RegExp(page.title, 'i')); await expect(playwright.locator('main')).toBeVisible(); await expect(playwright.locator('body')).toContainText(page.description); // Check for code examples on essential pages const codeBlocks = playwright.locator('pre code, .language-javascript, .language-js'); const codeCount = await codeBlocks.count(); expect(codeCount).toBeGreaterThan(0); }); } }); test.describe('API Reference', () => { for (const page of apiPages) { test(`${page.path} loads successfully`, async ({ page: playwright }) => { const response = await playwright.goto(page.path); expect(response?.status()).toBe(200); await expect(playwright).toHaveTitle(new RegExp(page.title, 'i')); await expect(playwright.locator('main')).toBeVisible(); await expect(playwright.locator('body')).toContainText(page.description); }); } }); test.describe('React Together Pages', () => { for (const page of reactTogetherPages) { test(`${page.path} loads successfully`, async ({ page: playwright }) => { const response = await playwright.goto(page.path); expect(response?.status()).toBe(200); await expect(playwright).toHaveTitle(new RegExp(page.title, 'i')); await expect(playwright.locator('main')).toBeVisible(); await expect(playwright.locator('body')).toContainText(page.description); }); } }); }); ``` -------------------------------- ### Verify Syntax Highlighting in Code Blocks with Playwright Source: https://multisynq.io/docs This Playwright test checks if code blocks on a documentation page correctly apply syntax highlighting. It navigates to a page with code examples and then inspects the first few code blocks for the presence of common syntax highlighting CSS classes (e.g., `hljs-keyword`, `token-string`). ```JavaScript test('code blocks support syntax highlighting', async ({ page }) => { await page.goto('/api-reference/model'); const codeBlocks = page.locator('pre code'); const codeCount = await codeBlocks.count(); for (let i = 0; i < Math.min(codeCount, 3); i++) { const codeBlock = codeBlocks.nth(i); const syntaxElements = codeBlock.locator('.hljs-keyword, .hljs-string, .hljs-comment, .token-keyword, .token-string'); const syntaxCount = await syntaxElements.count(); if (syntaxCount > 0) { console.log(`Code block ${i} has ${syntaxCount} syntax highlighted elements`); } } }); ``` -------------------------------- ### Playwright Test Configuration File Source: https://multisynq.io/docs This JavaScript configuration file (`playwright.config.js`) sets up Playwright for running end-to-end tests. It defines parallel execution, CI/CD specific settings (retries, workers, reporter), base URL, trace collection, screenshot/video capture on failure, and configures projects for various desktop and mobile browsers. It also includes a `webServer` setup for running a local development server before tests. ```JavaScript import { defineConfig, devices } from '@playwright/test'; /** * @see https://playwright.dev/docs/test-configuration */ export default defineConfig({ testDir: './tests', /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: process.env.CI ? 'github' : 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ baseURL: process.env.DOCS_BASE_URL || 'http://localhost:3000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', /* Take screenshot on failure */ screenshot: 'only-on-failure', /* Record video on failure */ video: 'retain-on-failure', }, /* Configure projects for major browsers */ projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, { name: 'firefox', use: { ...devices['Desktop Firefox'] }, }, { name: 'webkit', use: { ...devices['Desktop Safari'] }, }, /* Test against mobile viewports. */ { name: 'Mobile Chrome', use: { ...devices['Pixel 5'] }, }, { name: 'Mobile Safari', use: { ...devices['iPhone 12'] }, }, /* Test against branded browsers. */ { name: 'Microsoft Edge', use: { ...devices['Desktop Edge'], channel: 'msedge' }, }, { name: 'Google Chrome', use: { ...devices['Desktop Chrome'], channel: 'chrome' }, }, ], /* Run your local dev server before starting the tests */ webServer: { command: 'npm run docs:dev', url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, timeout: 120 * 1000, // 2 minutes for docs to start }, /* Global timeout for each test */ timeout: 30 * 1000, // 30 seconds per test /* Global timeout for the entire test run */ globalTimeout: 15 * 60 * 1000, // 15 minutes total /* Expect timeout for assertions */ expect: { timeout: 10 * 1000, // 10 seconds for assertions }, /* Test output directory */ outputDir: 'test-results/', /* Maximum number of test failures */ maxFailures: process.env.CI ? 5 : undefined, }); ``` -------------------------------- ### Test Keyboard Navigation Throughout Site with Playwright Source: https://multisynq.io/docs This Playwright test assesses the site's keyboard navigation by simulating 'Tab' key presses multiple times. It navigates to the '/quickstart' page and then tabs through interactive elements, collecting their tag names and roles. The test asserts that a sufficient number of interactive elements (e.g., links, buttons, inputs) are found, indicating proper keyboard navigability. ```JavaScript test('keyboard navigation works throughout site', async ({ page }) => { await page.goto('/quickstart'); // Tab through interactive elements const interactiveElements = []; for (let i = 0; i < 10; i++) { await page.keyboard.press('Tab'); const focusedElement = page.locator(':focus'); const tagName = await focusedElement.evaluate(el => el.tagName); const role = await focusedElement.getAttribute('role'); if (tagName && ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT'].includes(tagName)) { interactiveElements.push({ tagName, role }); } } // Should have found some interactive elements expect(interactiveElements.length).toBeGreaterThan(2); console.log('Interactive elements found:', interactiveElements); }); ``` -------------------------------- ### React-like Component for Loading Spinner and Redirect Message Source: https://multisynq.io/docs/client/index.html This snippet defines a UI component, likely rendered by a framework like Next.js (indicated by `self.__next_f.push`), that displays a loading spinner and a 'Redirecting to documentation...' message. It uses inline styles for layout and a CSS `@keyframes` rule for the spinning animation, providing visual feedback during page redirection. ```HTML
Redirecting to documentation...