From 37f6700ef36c0029e0e697d09d9641f94f4ce924 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 19 Sep 2024 20:59:39 +0200 Subject: [PATCH] Use latest demo-data event as prominent example in screenshots --- .../wordpress-org-screenshots/wporg.spec.ts | 83 +++++++++++++++++-- readme.md | 16 ++-- 2 files changed, 88 insertions(+), 11 deletions(-) diff --git a/.github/scripts/wordpress-org-screenshots/wporg.spec.ts b/.github/scripts/wordpress-org-screenshots/wporg.spec.ts index 9e47b2847..fcaf3728e 100644 --- a/.github/scripts/wordpress-org-screenshots/wporg.spec.ts +++ b/.github/scripts/wordpress-org-screenshots/wporg.spec.ts @@ -6,7 +6,8 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Screenshots for the wordpress.org/plugins repository', () => { let language: string, - local_code: string; + local_code: string, + latest_event_data = null; // set the file name of the screenshot basaed on the current locale // https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#filenames-2 @@ -16,10 +17,27 @@ test.describe( 'Screenshots for the wordpress.org/plugins repository', () => { local_code, '.png' ].join('').toLowerCase(); - } + } // List all comments. + test.beforeAll( async ( { requestUtils } ) => { + const latest_event = await requestUtils.rest( { + path: '/wp/v2/gatherpress_events', + method: 'GET', + params: { + per_page: 1, + status: 'publish' + }, + } ); + + if ( latest_event && Array.isArray( latest_event ) && latest_event.length > 0 ) { + // console.log('Latest Event:', latest_event[0]); + latest_event_data = latest_event[0]; + } else { + console.warn('No event found or the response was invalid.'); + } + // https://github.com/WordPress/gutenberg/blob/trunk/packages/e2e-test-utils-playwright/src/request-utils/site-settings.ts#L34-L35 language = ( await requestUtils.getSiteSettings() ).language; console.log('language', language); @@ -50,6 +68,61 @@ test.describe( 'Screenshots for the wordpress.org/plugins repository', () => { }); }); + // The test-description should match the caption for screenshot-# in the readme.md + test('Edit an event', async ({ + admin, + editor, + page, + }) => { + if (latest_event_data) { + + await admin.visitAdminPage( + 'post.php', + 'action=edit&post=' + latest_event_data.id + ); + + await editor.setPreferences( 'core/edit-post', { + welcomeGuide: false, + }); + + // Wait for 2 seconds + await page.waitForTimeout(2000); + + // https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1 + await expect(page).toHaveScreenshot( getFileName( 'screenshot-2' ), { + fullPage: true + }); + } + }); + + // The test-description should match the caption for screenshot-# in the readme.md + test('Quickedit an event', async ({ + admin, + editor, + page, + }) => { + if (latest_event_data) { + + await admin.visitAdminPage( + 'edit.php', + 'post_type=gatherpress_event' + ); + const tr = await page.locator( '#post-' + latest_event_data.id ); + // Make Quickedit visible. + await expect(tr).toBeVisible(); + + await tr.hover(); + // Open the Quickedit panel for the last event. + await tr.getByText('Quick Edit').click(); + // Wait for 2 seconds + await page.waitForTimeout(2000); + // https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1 + await expect(page).toHaveScreenshot( getFileName( 'screenshot-3' ), { + fullPage: true + }); + } + }); + // The test-description should match the caption for screenshot-# in the readme.md test('Create a new venue', async ({ admin, @@ -69,7 +142,7 @@ test.describe( 'Screenshots for the wordpress.org/plugins repository', () => { await page.waitForTimeout(2000); // https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1 - await expect(page).toHaveScreenshot( getFileName( 'screenshot-2' ), { + await expect(page).toHaveScreenshot( getFileName( 'screenshot-4' ), { fullPage: true }); }); @@ -88,7 +161,7 @@ test.describe( 'Screenshots for the wordpress.org/plugins repository', () => { await page.waitForTimeout(2000); // https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1 - await expect(page).toHaveScreenshot( getFileName( 'screenshot-3' ), { + await expect(page).toHaveScreenshot( getFileName( 'screenshot-5' ), { fullPage: true }); }); @@ -107,7 +180,7 @@ test.describe( 'Screenshots for the wordpress.org/plugins repository', () => { await page.waitForTimeout(2000); // https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1 - await expect(page).toHaveScreenshot( getFileName( 'screenshot-4' ), { + await expect(page).toHaveScreenshot( getFileName( 'screenshot-6' ), { fullPage: true }); }); diff --git a/readme.md b/readme.md index d57f7615e..57d2a6a10 100644 --- a/readme.md +++ b/readme.md @@ -204,12 +204,16 @@ As we continue to refine and develop the core plugin, we've created the [GatherP 1. Create a new event ![Create a new event](.wordpress-org/screenshot-1.png) -2. Create a new venue - ![Create a new venue](.wordpress-org/screenshot-2.png) -3. General Settings - ![General Settings](.wordpress-org/screenshot-3.png) -4. Leadership Settings - ![Leadership Settings](.wordpress-org/screenshot-4.png) +2. Edit an event + ![Edit an event](.wordpress-org/screenshot-2.png) +3. Quickedit an event + ![Quickedit an event](.wordpress-org/screenshot-3.png) +4. Create a new venue + ![Create a new venue](.wordpress-org/screenshot-4.png) +5. General Settings + ![General Settings](.wordpress-org/screenshot-5.png) +6. Leadership Settings + ![Leadership Settings](.wordpress-org/screenshot-6.png) ## Changelog