Skip to content

Commit

Permalink
Use latest demo-data event as prominent example in screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion committed Sep 19, 2024
1 parent 6f71369 commit 37f6700
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 11 deletions.
83 changes: 78 additions & 5 deletions .github/scripts/wordpress-org-screenshots/wporg.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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
});
});
Expand All @@ -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
});
});
Expand All @@ -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
});
});
Expand Down
16 changes: 10 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 37f6700

Please sign in to comment.