Skip to content

Commit

Permalink
Merge pull request #892 from carstingaxion/feature/use-latest-event-i…
Browse files Browse the repository at this point in the history
…n-screenshots

Use latest demo-data event as prominent example in screenshots
  • Loading branch information
mauteri authored Sep 23, 2024
2 parents 2e8f82b + 4f7b14f commit 552666a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 10 deletions.
83 changes: 79 additions & 4 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 @@ -18,8 +19,24 @@ test.describe( 'Screenshots for the wordpress.org/plugins repository', () => {
].join('').toLowerCase();
}


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 ) {
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 +67,64 @@ 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('Quick Edit 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 Quick Edit visible.
await expect(tr).toBeVisible();
await tr.hover();

// Open the Quick Edit panel for the last event.
await tr.getByText('Quick Edit').click();

Check failure on line 116 in .github/scripts/wordpress-org-screenshots/wporg.spec.ts

View workflow job for this annotation

GitHub Actions / screenshot (es_ES)

[chromium] › wporg.spec.ts:98:5 › Screenshots for the wordpress.org/plugins repository › Quick Edit an event

1) [chromium] › wporg.spec.ts:98:5 › Screenshots for the wordpress.org/plugins repository › Quick Edit an event TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for locator('#post-170').getByText('Quick Edit') 114 | 115 | // Open the Quick Edit panel for the last event. > 116 | await tr.getByText('Quick Edit').click(); | ^ 117 | 118 | // Wait for 2 seconds 119 | await page.waitForTimeout(2000); at /home/runner/work/gatherpress/gatherpress/.github/scripts/wordpress-org-screenshots/wporg.spec.ts:116:46

Check failure on line 116 in .github/scripts/wordpress-org-screenshots/wporg.spec.ts

View workflow job for this annotation

GitHub Actions / screenshot (nl_BE)

[chromium] › wporg.spec.ts:98:5 › Screenshots for the wordpress.org/plugins repository › Quick Edit an event

1) [chromium] › wporg.spec.ts:98:5 › Screenshots for the wordpress.org/plugins repository › Quick Edit an event TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for locator('#post-170').getByText('Quick Edit') 114 | 115 | // Open the Quick Edit panel for the last event. > 116 | await tr.getByText('Quick Edit').click(); | ^ 117 | 118 | // Wait for 2 seconds 119 | await page.waitForTimeout(2000); at /home/runner/work/gatherpress/gatherpress/.github/scripts/wordpress-org-screenshots/wporg.spec.ts:116:46

Check failure on line 116 in .github/scripts/wordpress-org-screenshots/wporg.spec.ts

View workflow job for this annotation

GitHub Actions / screenshot (it_IT)

[chromium] › wporg.spec.ts:98:5 › Screenshots for the wordpress.org/plugins repository › Quick Edit an event

1) [chromium] › wporg.spec.ts:98:5 › Screenshots for the wordpress.org/plugins repository › Quick Edit an event TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for locator('#post-170').getByText('Quick Edit') 114 | 115 | // Open the Quick Edit panel for the last event. > 116 | await tr.getByText('Quick Edit').click(); | ^ 117 | 118 | // Wait for 2 seconds 119 | await page.waitForTimeout(2000); at /home/runner/work/gatherpress/gatherpress/.github/scripts/wordpress-org-screenshots/wporg.spec.ts:116:46

// 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 +144,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 +163,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 +182,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. Quick Edit an event
![Quick Edit 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 552666a

Please sign in to comment.