Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- { wp: 60, php: 74 }
- { wp: 63, php: 80 }
- { wp: 67, php: 82 }
- { wp: 68, php: 83 }
- { wp: 69, php: 83 }
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion config/docker/68-83.Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions config/docker/69-83.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM wordpress:6.9-php8.3-apache
3 changes: 0 additions & 3 deletions config/mysql/additional.cnf

This file was deleted.

2 changes: 1 addition & 1 deletion config/wp-version.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
60_74=wordpress:6.0-php7.4-apache
63_80=wordpress:6.3-php8.0-apache
67_82=wordpress:6.7-php8.2-apache
68_83=wordpress:6.8-php8.3-apache
69_83=wordpress:6.9-php8.3-apache
6 changes: 4 additions & 2 deletions test/integration/compression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ test.describe('compression', () => {
await page.goto('/wp-admin/upload.php');

await page.getByRole('button', { name: 'Compress', exact: true }).click();
await expect(page.getByText('2 sizes compressed')).toBeVisible();
// check interval is 5s so wait atleast 6s
await expect(page.getByText('2 sizes compressed')).toBeVisible({ timeout: 6000 });
});

test('compress button in edit screen should compress webp images', async () => {
Expand All @@ -167,7 +168,8 @@ test.describe('compression', () => {
await page.goto('/wp-admin/upload.php');

await page.getByRole('button', { name: 'Compress', exact: true }).click();
await expect(page.getByText('3 sizes compressed')).toBeVisible();
// check interval is 5s so wait atleast 6s
await expect(page.getByText('3 sizes compressed')).toBeVisible({ timeout: 6000 });
});

test('compress button should compress uncompressed sizes', async () => {
Expand Down
20 changes: 12 additions & 8 deletions test/integration/conversion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ test.describe('conversion', () => {

test('will display the optimized image on a page', async () => {
const media = await uploadMedia(page, 'input-example.jpg');
const postURL = await newPost(page, {
title: 'test',
content: `<figure class="wp-block-image size-large" id="tinytest"><img src="${media}" alt="" class="wp-image-209"/></figure>`,
}, WPVersion);

await page.goto(postURL);

const picture = await page.locator('picture:has(source[srcset*="input-example.avif"][type="image/avif"])');
const postID = await newPost(
page,
{
title: 'test',
content: `<figure class="wp-block-image size-large" id="tinytest"><img src="${media}" alt="" class="wp-image-209"/></figure>`,
},
WPVersion
);

await page.goto(`/?p=${postID}`);

const picture = await page.locator('picture:has(source[srcset*="input-example.avif"][type="image/avif"])');
await expect(picture).toBeVisible();
});
});
23 changes: 10 additions & 13 deletions test/integration/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ export async function uploadMedia(page: Page, file: string): Promise<string> {
await page.getByLabel('Upload').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, `../fixtures/${file}`));
await Promise.all([
page.waitForURL('**/wp-admin/upload.php**', { waitUntil: 'load' }),
page.locator('#html-upload').click(),
]);

await Promise.all([page.waitForURL('**/wp-admin/upload.php**', { waitUntil: 'load' }), page.locator('#html-upload').click()]);

await page.goto('/wp-admin/upload.php?mode=list');

const row = await page.locator('table.wp-list-table tbody > tr').first();
Expand All @@ -23,10 +20,7 @@ export async function uploadMedia(page: Page, file: string): Promise<string> {

const rowID = await row.getAttribute('id');
const attachmentID = rowID?.split('-')[1];
await Promise.all([
page.waitForURL(new RegExp(`/wp-admin/post\\.php\\?post=${attachmentID}&action=edit$`), { waitUntil: 'load' }),
page.goto(`/wp-admin/post.php?post=${attachmentID}&action=edit`),
]);
await Promise.all([page.waitForURL(new RegExp(`/wp-admin/post\\.php\\?post=${attachmentID}&action=edit$`), { waitUntil: 'load' }), page.goto(`/wp-admin/post.php?post=${attachmentID}&action=edit`)]);

return page.locator('input[name="attachment_url"]').inputValue();
}
Expand Down Expand Up @@ -260,13 +254,16 @@ export async function newPost(page: Page, options: NewPostOptions, WPVersion: nu
}, content);
await page.getByRole('button', { name: 'Publish', exact: true }).click();
await page.getByLabel('Editor publish').getByRole('button', { name: 'Publish', exact: true }).click();
await page.getByLabel('Editor publish').getByRole('link', { name: 'View Post' }).click();
} else {
await page.locator('#content-html').click();
await page.locator('#content').fill(content);
await page.locator('#publish').click();
await page.getByRole('link', { name: 'View Post' }).first().click();
}

return page.url();
await page.waitForURL('**/wp-admin/post.php**');
const url = new URL(page.url());
const postID = url.searchParams.get('post');
if (!postID) {
throw new Error('unable to get post id from url');
}
return postID;
}