Skip to content

Commit b8846ea

Browse files
committed
[TASK] Generate the screenshots of the root page chapter (#931)
The screenshots of "How to create a root page" were taken by hand and showed an older backend. Take them from the screenshot instance, so they follow the Core version of the branch. A hidden root page, created as in the backend with its generated site configuration, provides the new page of the chapter. The error page needs the detailed error output of a development system. Releases: main, 14.3 Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> (cherry picked from commit fd0dad2)
1 parent 3df7b59 commit b8846ea

17 files changed

Lines changed: 170 additions & 19 deletions

File tree

‎AGENTS.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ To add a screenshot:
4040
shows where the module is in the menu: the group named in `menu`,
4141
`Sites` by default, stays open and every other group is collapsed.
4242
Its page tree is hidden unless `pageTree: true`, and an `until`
43-
element ends the image below the part that matters. Use `prepare`
44-
for clicks before the screenshot.
43+
element ends the image below the part that matters, or an
44+
`untilOutside` element outside of the module frame, such as a
45+
context menu. Use `prepare` for clicks before the screenshot.
4546
3. Take only that screenshot, then all of them once, and commit the
4647
images that changed. A run keeps an image that differs from the old
4748
one in fewer than 10 pixels, because a new image is never exactly the

‎Build/Screenshots/create-records.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@
5858
]);
5959
$uids['startPage'] = (int)$connection->lastInsertId();
6060

61+
// The root page that the chapter "How to create a root page" creates in the
62+
// backend, after the start page. A new page is hidden. The DataHandler
63+
// creates its site configuration, "autogenerated-<uid>", as for a page
64+
// created in the backend.
65+
$dataHandler = $process(['pages' => ['NEW1' => [
66+
'pid' => -$uids['startPage'],
67+
'title' => 'New site',
68+
'is_siteroot' => 1,
69+
'hidden' => 1,
70+
]]]);
71+
$uids['newSite'] = (int)$dataHandler->substNEWwithIDs['NEW1'];
72+
6173
// The uids differ between TYPO3 versions, so screenshots.mjs reads them here
6274
GeneralUtility::mkdir_deep(Environment::getVarPath());
6375
file_put_contents(Environment::getVarPath() . '/screenshot-records.json', json_encode($uids, JSON_PRETTY_PRINT) . "\n");

‎Build/Screenshots/run.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ ${PHP_RUN} .Build/bin/typo3 setup --no-interaction --force \
2323
${PHP_RUN} .Build/bin/typo3 extension:setup
2424
# The PHP web server provides no SERVER_NAME to compare the host with
2525
${PHP_RUN} .Build/bin/typo3 configuration:set SYS/trustedHostsPattern '.*'
26+
# The detailed error page of a development system, which TYPO3 shows to a
27+
# developer's address only. The browser runs in a container of its own,
28+
# whose address is not 127.0.0.1.
29+
${PHP_RUN} .Build/bin/typo3 configuration:set SYS/devIPmask '*'
30+
${PHP_RUN} .Build/bin/typo3 configuration:set SYS/displayErrors 1
2631
${PHP_RUN} php Build/Screenshots/create-records.php
2732
${PHP_RUN} .Build/bin/typo3 cache:flush
2833

‎Build/Screenshots/screenshots.mjs‎

Lines changed: 129 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,46 @@ const moduleUrl = (path, id) => `${baseUrl}/typo3/module/${path}${id === undefin
2121
const margin = 12;
2222

2323
// The uids of the records that create-records.php created
24-
const { startPage } = JSON.parse(readFileSync('../../var/screenshot-records.json', 'utf8'));
24+
const { startPage, newSite } = JSON.parse(readFileSync('../../var/screenshot-records.json', 'utf8'));
25+
26+
// The Content > Layout module
27+
const layoutUrl = (id) => moduleUrl('web/layout', id);
28+
// A new page on the root level of the page tree
29+
const newRootPageUrl = `${baseUrl}/typo3/record/edit?edit[pages][0]=new`;
30+
// The frontend of the hidden root page, at the base of its generated site
31+
// configuration. The logged in administrator sees hidden pages.
32+
const newSiteFrontend = `${baseUrl}/autogenerated-${newSite}/`;
33+
34+
// A page of the page tree, which is outside of the module frame. The
35+
// top node, the root level, has the uid 0.
36+
const treeNode = (uid) => `#typo3-pagetree-tree .node[data-id="${uid}"]`;
37+
// The open context menu, which is outside of the module frame
38+
const contextMenu = '.context-menu >> visible=true';
39+
40+
// Opens the context menu of a page in the page tree
41+
const openPageMenu = async (frame, uid) => {
42+
await frame.page().locator(`${treeNode(uid)} .node-contentlabel`).click({ button: 'right' });
43+
await frame.page().locator(contextMenu).first().waitFor();
44+
await frame.page().waitForTimeout(500);
45+
// The menu focuses its first item, which would look selected
46+
await frame.page().evaluate(() => document.activeElement?.blur());
47+
};
48+
49+
// Marks an element that the text names, with a frame the given number of
50+
// pixels around it. An element between close neighbours, such as a tab or
51+
// an entry of a menu, is marked inside, with a negative number, as a frame
52+
// outside of it would be cut.
53+
const outline = (locator, offset = 3) => locator.evaluate((element, space) => {
54+
element.style.outline = '3px solid #ff8700';
55+
element.style.outlineOffset = `${space}px`;
56+
}, offset);
57+
58+
// An entry of the open context menu
59+
const menuItem = (label) => `${contextMenu} >> .context-menu-item[aria-label="${label}"]`;
60+
61+
// A field of a form, found by its name: the backend runs without debug
62+
// mode, which would show the field names
63+
const field = (name) => `.form-group:has([name$="[${name}]"]):not(:has(.form-group))`;
2564

2665
// The Sites > Setup module, which lists the site configurations
2766
const sitesUrl = moduleUrl('site/configuration');
@@ -66,6 +105,83 @@ const screenshots = {
66105
window: true,
67106
until: '.form-section:has([name$="[dependencies]"])',
68107
},
108+
// The context menu of the root level of the page tree, with "New subpage"
109+
'FirstProject/CreateRootPage/CreateNewPage': {
110+
width: 1000,
111+
url: layoutUrl(startPage),
112+
pageTree: true,
113+
menu: 'Content',
114+
prepare: async (frame) => {
115+
await openPageMenu(frame, 0);
116+
await outline(frame.page().locator(menuItem('New subpage')).first(), -3);
117+
},
118+
window: true,
119+
untilOutside: contextMenu,
120+
},
121+
// The form of a new page on the root level, on the tab with the checkbox
122+
// "Use as Root Page", which is checked
123+
'FirstProject/CreateRootPage/SetRootPage': {
124+
width: 1000,
125+
url: newRootPageUrl,
126+
tab: 'Behavior',
127+
menu: 'Content',
128+
prepare: async (frame) => {
129+
// The title is required, and the form marks the tab of an empty one
130+
await frame.getByRole('tab', { name: /General/ }).first().click();
131+
await frame.locator(`${field('title')} input[data-formengine-input-name]`).first().fill('New site');
132+
const tab = frame.getByRole('tab', { name: 'Behavior', exact: true });
133+
await tab.click();
134+
await frame.locator(`${field('is_siteroot')} input[type="checkbox"]`).first().check();
135+
await outline(tab, -3);
136+
// Space between the frame and the label and the switch
137+
await outline(frame.locator(field('is_siteroot')).first(), 8);
138+
await frame.locator('h1').first().click();
139+
await frame.page().waitForTimeout(500);
140+
},
141+
window: true,
142+
until: field('is_siteroot'),
143+
// Below the frame around the field
144+
untilSpace: 16,
145+
},
146+
// The new root page in the page tree, hidden as every new page
147+
'FirstProject/CreateRootPage/PageCreated': {
148+
width: 1000,
149+
url: layoutUrl(newSite),
150+
pageTree: true,
151+
menu: 'Content',
152+
window: true,
153+
until: 'h1',
154+
},
155+
// The list of the root pages without a site configuration in the Sites
156+
// module
157+
'FirstProject/CreateRootPage/PageWithoutSiteConfig': {
158+
url: sitesUrl,
159+
from: 'h2:has-text("Pages without a site configuration")',
160+
to: `table:has(${pageWithoutSite(startPage)})`,
161+
},
162+
// The detailed error page of a root page whose site has no sets and no
163+
// TypoScript record: the exception and its message. The file below it
164+
// would show the path of the checkout.
165+
'FirstProject/CreateRootPage/NoTypoScriptFound': {
166+
url: layoutUrl(newSite),
167+
frontend: newSiteFrontend,
168+
frontendElement: '.trace-head',
169+
},
170+
// The context menu of the hidden root page, with the pointer on "Enable"
171+
'FirstProject/CreateRootPage/EnablePage': {
172+
width: 1000,
173+
url: layoutUrl(newSite),
174+
pageTree: true,
175+
menu: 'Content',
176+
hover: true,
177+
prepare: async (frame) => {
178+
await openPageMenu(frame, newSite);
179+
await frame.page().locator(menuItem('Enable')).first().hover();
180+
await frame.page().waitForTimeout(300);
181+
},
182+
window: true,
183+
untilOutside: contextMenu,
184+
},
69185
};
70186

71187
// Hides the page tree, unless the screenshot needs it, and collapses the
@@ -237,6 +353,9 @@ for (const name of names) {
237353
// The page in the frontend, cut to the element named
238354
await page.goto(screenshot.frontend);
239355
await page.waitForLoadState('networkidle');
356+
if (process.env.DUMP) {
357+
writeFileSync(`../../var/${name.replaceAll('/', '_')}-frontend.html`, await page.content());
358+
}
240359
const box = await page.locator(screenshot.frontendElement).first().boundingBox();
241360
await save(name, await page.screenshot({
242361
clip: { x: box.x - margin, y: box.y - margin, width: box.width + 2 * margin, height: box.height + 2 * margin },
@@ -250,12 +369,17 @@ for (const name of names) {
250369
}
251370
if (screenshot.window) {
252371
// The whole backend. It ends below the element named in "until", so the
253-
// image takes no more room on the page than it needs.
372+
// image takes no more room on the page than it needs. "untilOutside"
373+
// names an element outside of the module frame, such as a context menu.
374+
// "untilSpace" is the space below the element, for a frame around it.
254375
let clip = screenshot.clip && { x: 0, y: 0, ...screenshot.clip };
255-
if (screenshot.until) {
256-
const until = await frame.locator(screenshot.until).last().boundingBox();
376+
if (screenshot.until || screenshot.untilOutside) {
377+
const until = screenshot.untilOutside
378+
? await page.locator(screenshot.untilOutside).last().boundingBox()
379+
: await frame.locator(screenshot.until).last().boundingBox();
257380
const viewport = page.viewportSize();
258-
clip = { x: 0, y: 0, width: viewport.width, height: Math.min(until.y + until.height + 4, viewport.height) };
381+
const space = screenshot.untilSpace ?? 4;
382+
clip = { x: 0, y: 0, width: viewport.width, height: Math.min(until.y + until.height + space, viewport.height) };
259383
}
260384
await save(name, await page.screenshot({ clip }));
261385
continue;

‎Documentation/FirstProject/CreateRootPage.rst‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ module on the left-hand side of the screen.
4646
Click on the :guilabel:`Layout` module to open
4747
the page tree.
4848

49-
.. figure:: /Images/ManualScreenshots/CreateRootPage/CreateNewPage.png
49+
.. figure:: /Images/GeneratedScreenshots/FirstProject/CreateRootPage/CreateNewPage.png
5050
:zoom: gallery
51-
:alt: The "Content > Layout" module in the TYPO3 backend with a context menu to create a new page
51+
:alt: Page tree of the module "Content > Layout" with the context menu of
52+
the top node "Getting Started", which has the entries "New
53+
subpage" (marked), "More options...", and "History/Undo"
5254

5355
* In the page tree, right-click on the "root level" or the top node of the page
5456
tree (if no pages exist yet, this will likely be labeled as "site" or similar).
@@ -70,9 +72,10 @@ Now, you need to configure the new page:
7072
* Under the :guilabel:`Behavior` tab, look for the checkbox called
7173
"Use as Root Page". Ensure this is checked.
7274

73-
.. figure:: /Images/ManualScreenshots/CreateRootPage/SetRootPage.png
75+
.. figure:: /Images/GeneratedScreenshots/FirstProject/CreateRootPage/SetRootPage.png
7476
:zoom: gallery
75-
:alt: Page properties, tab "Behaviour", highlighting the "Use as root page"
77+
:alt: Form "Create new Standard Page" on the tab "Behavior" (marked), with
78+
the checkbox "Use as Root Page" (marked) switched on
7679

7780
.. _create-root-page-save:
7881

@@ -84,9 +87,11 @@ Once you have filled in the necessary information and selected the
8487
form. Your new root page will now appear in the page tree on the left.
8588
The page is only visible in the backend at this point
8689

87-
.. figure:: /Images/ManualScreenshots/CreateRootPage/PageCreated.png
90+
.. figure:: /Images/GeneratedScreenshots/FirstProject/CreateRootPage/PageCreated.png
8891
:zoom: gallery
89-
:alt: Backend module "Content > Layout" with a newly created but still disabled root page
92+
:alt: Module "Content > Layout" with the new root page "New site" below
93+
"Camino" and "Start page" in the page tree. The icon of "New site"
94+
has a red sign, as the page is disabled.
9095

9196
The root page is disabled, therefore it is marked with the red icon.
9297
You can enable it in the context menu.
@@ -100,9 +105,10 @@ All sites must have a `site configuration <https://docs.typo3.org/permalink/t3st
100105
If you have created a new page in the root of the page tree add a new configuration
101106
or edit the auto generated one:
102107

103-
.. figure:: /Images/ManualScreenshots/CreateRootPage/PageWithoutSiteConfig.png
108+
.. figure:: /Images/GeneratedScreenshots/FirstProject/CreateRootPage/PageWithoutSiteConfig.png
104109
:zoom: gallery
105-
:alt: Pages without site configuration in the TYPO3 Backend - Button "Add a new site configuration for this site"
110+
:alt: List "Pages without a site configuration" with the root page "Start
111+
page" and its button "Add new site configuration for this site"
106112

107113
You can find the auto-generated site configuration for your root page in
108114
the module :guilabel:`Sites > Setup`
@@ -122,9 +128,11 @@ The site needs a theme, also known as a "site package" in the TYPO3 world. Learn
122128
you will see a message like the one below when trying to display
123129
the page in the frontend:
124130

125-
.. figure:: /Images/ManualScreenshots/CreateRootPage/NoTypoScriptFound.png
131+
.. figure:: /Images/GeneratedScreenshots/FirstProject/CreateRootPage/NoTypoScriptFound.png
126132
:zoom: gallery
127-
:alt: Error message: No TypoScript record found!
133+
:alt: Error "#1607585445 InternalServerErrorException" with the
134+
message "No site configuration or TypoScript template record
135+
found!"
128136

129137
Error message when no site package is installed or configured
130138

@@ -140,8 +148,9 @@ Enable the page when you are ready
140148

141149
:guilabel:`Enable` the page as newly created pages are hidden by default.
142150

143-
.. figure:: /Images/ManualScreenshots/CreateRootPage/EnablePage.png
151+
.. figure:: /Images/GeneratedScreenshots/FirstProject/CreateRootPage/EnablePage.png
144152
:zoom: gallery
145-
:alt: A disabled root page and its context menu
153+
:alt: Context menu of the disabled root page "New site" in the page tree,
154+
with the pointer on the entry "Enable"
146155

147156
Right click on the newly created page and choose `Enable` from the context menu. The red icon should disappear.
46.2 KB
Loading
70.7 KB
Loading
18.2 KB
Loading
35.7 KB
Loading
13.7 KB
Loading

0 commit comments

Comments
 (0)