Skip to content

Commit ba11bcb

Browse files
Set API Key, wait for request and use test ids
1 parent c3f93b2 commit ba11bcb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/integration/bulkoptimization.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test.describe('bulkoptimization', () => {
182182
});
183183

184184
test('will only apply a conversion when images are already compressed but not converted', async ({ page }) => {
185-
// only optimize original size
185+
await setAPIKey(page, 'JPG123');
186186
await enableCompressionSizes(page, ['0']);
187187

188188
// upload 1 image and automaticly compress it, but not convert it yet
@@ -197,8 +197,12 @@ test.describe('bulkoptimization', () => {
197197

198198
// apply bulk optimization
199199
await page.goto('/wp-admin/upload.php?page=tiny-bulk-optimization');
200-
await page.locator('#id-start').click();
201-
await page.waitForLoadState('networkidle');
200+
await Promise.all([
201+
page.waitForResponse(res =>
202+
res.url().includes('admin-ajax.php') && res.status() === 200
203+
),
204+
page.locator('#id-start').click(),
205+
]);
202206

203207
// we are expecting 2 unoptimized images sizes = 2 conversion and 1 compression
204208
// expect two rows in the optimization items table
@@ -207,8 +211,8 @@ test.describe('bulkoptimization', () => {
207211

208212
// first row should have "1 compressed and 1 converted"
209213
// second row should have "1 converted"
210-
await expect(optimizationRows.first()).toContainText('1 compressed 1 converted');
211-
await expect(optimizationRows.nth(1)).toContainText('1 converted');
214+
await expect(page.getByTestId(`bulk-item-status-1`)).toContainText('1 compressed 1 converted');
215+
await expect(page.getByTestId(`bulk-item-status-0`)).toContainText('1 converted');
212216

213217
// this should have cost us 3 credits
214218
});

0 commit comments

Comments
 (0)