mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Fixed splitting string into characters (#18480)
- quite funny because it's such a sneaky thing to discover
- this code actually results in looping over
`'xxxxx<,t,e,s,t,f,o,o,t,>'` and not an array of characters
- adding brackets fixes that
---
<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 584ab6c</samp>
Fix a bug in the code injection test case for the admin settings app.
Ensure that the test code is properly padded and split by using
parentheses in the string concatenations.
---------
Co-authored-by: Jono Mingard <reason.koan@gmail.com>
This commit is contained in:
parent
bc3ad1a798
commit
8a4e81fadd
3 changed files with 13 additions and 9 deletions
|
@ -11,8 +11,8 @@ test.describe('Code injection settings', async () => {
|
|||
const {lastApiRequests} = await mockApi({page, requests: {
|
||||
...globalDataRequests,
|
||||
editSettings: {method: 'PUT', path: '/settings/', response: updatedSettingsResponse([
|
||||
{key: 'codeinjection_head', value: '<testhead />'},
|
||||
{key: 'codeinjection_foot', value: '<testfoot />'}
|
||||
{key: 'codeinjection_head', value: 'testhead'},
|
||||
{key: 'codeinjection_foot', value: 'testfoot'}
|
||||
])}
|
||||
}});
|
||||
|
||||
|
@ -21,24 +21,27 @@ test.describe('Code injection settings', async () => {
|
|||
const section = page.getByTestId('code-injection');
|
||||
|
||||
await section.getByRole('button', {name: 'Edit'}).click();
|
||||
// Click on the CodeMirror content to make sure it's loaded
|
||||
await section.getByTestId('header-code').locator('.cm-content').click();
|
||||
|
||||
for (const character of PADDING + '<testhead>'.split('')) {
|
||||
for (const character of (PADDING + 'testhead').split('')) {
|
||||
await page.keyboard.press(character);
|
||||
}
|
||||
|
||||
await section.getByRole('tab', {name: 'Site footer'}).click();
|
||||
await section.getByTestId('footer-code').click();
|
||||
await section.getByTestId('footer-code').locator('.cm-content').click();
|
||||
|
||||
for (const character of PADDING + '<testfoot>'.split('')) {
|
||||
for (const character of (PADDING + 'testfoot').split('')) {
|
||||
await page.keyboard.press(character);
|
||||
}
|
||||
|
||||
await section.getByRole('button', {name: 'Save'}).click();
|
||||
await expect(section.getByRole('button', {name: 'Save'})).toBeHidden();
|
||||
|
||||
expect(lastApiRequests.editSettings?.body).toMatchObject({
|
||||
settings: [
|
||||
{key: 'codeinjection_head', value: /<testhead>$/},
|
||||
{key: 'codeinjection_foot', value: /<testfoot>$/}
|
||||
{key: 'codeinjection_head', value: /testhead$/},
|
||||
{key: 'codeinjection_foot', value: /testfoot$/}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
@ -80,6 +83,7 @@ test.describe('Code injection settings', async () => {
|
|||
}
|
||||
|
||||
await section.getByRole('button', {name: 'Save'}).click();
|
||||
await expect(section.getByRole('button', {name: 'Save'})).toBeHidden();
|
||||
|
||||
expect(lastApiRequests.editSettings?.body).toMatchObject({
|
||||
settings: [
|
||||
|
|
|
@ -22,7 +22,7 @@ test.describe('Facebook settings', async () => {
|
|||
const fileChooser = await fileChooserPromise;
|
||||
await fileChooser.setFiles(`${__dirname}/../../utils/images/image.png`);
|
||||
|
||||
await expect(section.getByRole('img')).toBeVisible();
|
||||
await expect(section.locator('img[src="http://example.com/image.png"]')).toBeVisible();
|
||||
|
||||
await section.getByLabel('Facebook title').fill('Facetitle');
|
||||
await section.getByLabel('Facebook description').fill('Facescription');
|
||||
|
|
|
@ -22,7 +22,7 @@ test.describe('Twitter settings', async () => {
|
|||
const fileChooser = await fileChooserPromise;
|
||||
await fileChooser.setFiles(`${__dirname}/../../utils/images/image.png`);
|
||||
|
||||
await expect(section.getByRole('img')).toBeVisible();
|
||||
await expect(section.locator('img[src="http://example.com/image.png"]')).toBeVisible();
|
||||
|
||||
await section.getByLabel('X title').fill('Twititle');
|
||||
await section.getByLabel('X description').fill('Twitscription');
|
||||
|
|
Loading…
Reference in a new issue