Skip to content

Commit 6377720

Browse files
authored
Merge pull request #120 from serenity-js/docs/integration-docker
Docs/integration docker
2 parents 3a60beb + 30675fc commit 6377720

File tree

6 files changed

+223
-0
lines changed

6 files changed

+223
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { useEffect, useRef, useState } from 'react';
2+
import CodeBlock from '@theme/CodeBlock';
3+
4+
/**
5+
* Usage example:
6+
*
7+
* ```mdx
8+
* <DynamicCodeBlock
9+
* lang="bash"
10+
* title="Install from the command line"
11+
* highlight="1"
12+
* >
13+
* {`docker pull ghcr.io/serenity-js/playwright:v`}<PlaywrightVersion />{`-noble`}
14+
* </DynamicCodeBlock>
15+
* ```
16+
*
17+
* @param children
18+
* @param lang
19+
* @param title
20+
* @param highlight
21+
* @constructor
22+
*/
23+
export default function DynamicCodeBlock({ children, lang, title, highlight }) {
24+
const tempRef = useRef(null);
25+
const [ plainText, setPlainText ] = useState('');
26+
27+
useEffect(() => {
28+
if (tempRef.current) {
29+
// Extract innerText after slight delay to ensure children fully rendered
30+
const timer = setTimeout(() => {
31+
setPlainText(tempRef.current.innerText || '');
32+
}, 0);
33+
return () => clearTimeout(timer);
34+
}
35+
}, [ children ]);
36+
37+
const metastring = highlight ? `{${ highlight }}` : '';
38+
39+
return (
40+
<>
41+
{/* Offscreen positioned container to render and extract text */ }
42+
<div
43+
ref={ tempRef }
44+
style={ {
45+
position: 'absolute',
46+
left: -9999,
47+
top: 0,
48+
whiteSpace: 'pre-wrap',
49+
pointerEvents: 'none',
50+
userSelect: 'text',
51+
height: 0,
52+
overflow: 'hidden',
53+
} }
54+
aria-hidden="true"
55+
>
56+
{ children }
57+
</div>
58+
59+
{/* Render the extracted plainText in CodeBlock */ }
60+
<CodeBlock
61+
className={ lang ? `language-${ lang }` : undefined }
62+
title={ title }
63+
metastring={ metastring }
64+
>
65+
{ plainText }
66+
</CodeBlock>
67+
</>
68+
);
69+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react'
2+
import { usePluginData } from '@docusaurus/core/lib/client/exports/useGlobalData';
3+
4+
export interface SupportedIntegrationVersionProps {
5+
format?: 'exact' | 'original';
6+
name?: string;
7+
}
8+
9+
export default function SupportedIntegrationVersion({ format = 'original', name }: SupportedIntegrationVersionProps) {
10+
11+
const pluginData = usePluginData('docusaurus-plugin-serenity-js-presets') as {
12+
integrationsOfInterest?: string[];
13+
integrations?: Record<string, string>;
14+
packages?: Record<string, string>;
15+
};
16+
17+
// const integrationsOfInterest = pluginData?.integrationsOfInterest || [];
18+
const integrations = pluginData?.integrations || {};
19+
20+
if (! name) {
21+
console.warn('SupportedIntegrationVersion: name prop is required when format="version"');
22+
return <span>N/A</span>;
23+
}
24+
const originalVersion = integrations[name];
25+
if (! originalVersion) {
26+
return <span>N/A</span>;
27+
}
28+
29+
if (format === 'exact') {
30+
// Extract the version number from the range (e.g., "^1.56.1" -> "1.56.1")
31+
const versionMatch = originalVersion.match(/[\d.]+/);
32+
return <span>{ versionMatch ? versionMatch[0] : originalVersion }</span>;
33+
}
34+
35+
return <span>{ originalVersion }</span>;
36+
}
37+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Docker
3+
---
4+
export const PlaywrightVersion = () => <SupportedIntegrationVersion name="playwright-core" format="exact" />;
5+
6+
# Docker
7+
8+
Serenity/JS Docker images enable you to run Serenity/JS tests in containerised environments,
9+
including CI/CD pipelines, cloud development environments, and local development setups.
10+
11+
## Using Serenity/JS Docker Images
12+
13+
Learn how to integrate Serenity/JS Docker images with your workflow:
14+
15+
- [GitHub Actions](/handbook/integration/github-actions/)
16+
- [GitHub Codespaces](/handbook/integration/github-codespaces/)
17+
- [GitLab CI](/handbook/integration/gitlab-ci/)
18+
19+
## Available Images
20+
21+
The Serenity/JS Docker images are maintained in the [serenity-js/serenity-js-docker](https://github.com/serenity-js/serenity-js-docker) repository
22+
and published through the [Serenity/JS GitHub Container Registry](https://github.com/orgs/serenity-js/packages).
23+
24+
### Serenity/JS Playwright
25+
26+
**Recommended for**: [Playwright Test](/handbook/test-runners/playwright-test/),
27+
[Cucumber.js with Playwright](/handbook/test-runners/cucumber/), and [WebdriverIO](/handbook/test-runners/webdriverio/) projects using modern browsers.
28+
29+
The Serenity/JS Playwright Docker image provides a complete testing environment with all **Playwright browser engines**, plus the latest stable **Chrome** and **Edge** browsers.
30+
Image versions follow Playwright's versioning convention to ensure compatibility.
31+
32+
<DynamicCodeBlock lang="bash" title="Install from the command line" >
33+
{`docker pull ghcr.io/serenity-js/playwright:v`}<PlaywrightVersion />{`-noble`}
34+
</DynamicCodeBlock>
35+
36+
**📦 [View all versions](https://github.com/serenity-js/serenity-js-docker/pkgs/container/playwright)**
37+
38+
#### What's Included
39+
40+
**Browsers:**
41+
- Microsoft Edge (Stable)
42+
- Google Chrome (Stable)
43+
- Playwright Chromium Engine
44+
- Playwright Chromium Headless Shell
45+
- Playwright Firefox Engine
46+
- Playwright WebKit Engine
47+
48+
**Runtimes:**
49+
- Node.js 24
50+
- OpenJDK Java Runtime Environment
51+
52+
**Operating System:**
53+
- Ubuntu 24.04 LTS (Noble Numbat)
54+
- Git
55+
- cURL
56+
- OpenSSH Client
57+
- Playwright system dependencies
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: GitHub Codespaces
3+
---
4+
5+
# GitHub Codespaces
6+
7+
<ArticleComingSoon />

src/plugins/presets/index.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,55 @@ export default async function pluginPresets(
3737
return {
3838
name: 'docusaurus-plugin-serenity-js-presets',
3939

40+
async loadContent() {
41+
// module-manager preset
42+
const paths = await glob(input, { onlyFiles: false, globstar: true, absolute: true });
43+
44+
const packages = {};
45+
let integrations = {};
46+
47+
for (const pathToPackageJSON of paths) {
48+
const serenityPackage = JSON.parse(fs.readFileSync(pathToPackageJSON).toString('utf8'));
49+
50+
const dependencies = {
51+
...serenityPackage.dependencies,
52+
...serenityPackage.peerDependencies,
53+
};
54+
55+
const packageIntegrations = Object.keys(dependencies)
56+
.filter(dependency => options.integrationsOfInterest.includes(dependency))
57+
.reduce((acc, key) => {
58+
acc[key] = dependencies[key];
59+
return acc;
60+
}, {});
61+
62+
integrations = {
63+
...integrations,
64+
...packageIntegrations,
65+
}
66+
67+
packages[serenityPackage.name] = serenityPackage.version;
68+
}
69+
70+
return {
71+
engines: rootPackageJson.engines,
72+
packages,
73+
integrations,
74+
integrationsOfInterest: options.integrationsOfInterest,
75+
caching,
76+
sampling,
77+
};
78+
},
79+
80+
async contentLoaded({ content, actions }) {
81+
const { setGlobalData } = actions;
82+
setGlobalData({
83+
integrationsOfInterest: content.integrationsOfInterest,
84+
integrations: content.integrations,
85+
packages: content.packages,
86+
});
87+
},
88+
4089
async postBuild({ siteConfig, routesPaths, outDir, head }) {
4190

4291
// module-manager preset

src/theme/MDXComponents.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import ArticleComingSoon from '@site/src/components/ArticleComingSoon'
33
import BrowserWindow from '@site/src/components/BrowserWindow'
44
import CurrentNodeVersion from '@site/src/components/CurrentNodeVersion'
55
import DependencyTypeDescription from '@site/src/components/DependencyTypeDescription'
6+
import DynamicCodeBlock from '@site/src/components/DynamicCodeBlock';
67
import Figure from '@site/src/components/Figure'
78
import NpmLink from '@site/src/components/NpmLink'
89
import SupportedNodeVersions from '@site/src/components/SupportedNodeVersions'
910
import SemanticVersionRangeDescription from '@site/src/components/SemanticVersionRangeDescription'
11+
import SupportedIntegrationVersion from '@site/src/components/SupportedIntegrationVersion';
1012
import CodeBlock from '@theme/CodeBlock';
1113
import Image from '@theme/IdealImage';
1214
import MDXComponents from '@theme-original/MDXComponents'
@@ -22,11 +24,13 @@ export default {
2224
CurrentNodeVersion,
2325
CodeBlock,
2426
DependencyTypeDescription,
27+
DynamicCodeBlock,
2528
Image,
2629
NpmLink,
2730
Tabs,
2831
TabItem,
2932
SemanticVersionRangeDescription,
33+
SupportedIntegrationVersion,
3034
SupportedNodeVersions,
3135
Figure
3236
}

0 commit comments

Comments
 (0)