Skip to content

Playwright #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ tests/coverage/
tests/playwright-results/
tests/playwright-report/
tests/playwright/.env.local
tests/playwright/.auth/
node_modules/
vendor/

2 changes: 1 addition & 1 deletion includes/MslsMetaBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function render_options( $type, $msls_id ): string {
*
* @return string
*/
public function render_option( $post_id, $msls_id ) {
public function render_option( str $post_id, $msls_id ) {
return sprintf(
'<option value="%s" %s>%s</option>',
$post_id,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"devDependencies": {
"@playwright/test": "^1.44.0",
"@types/node": "^20.12.11",
"@wordpress/e2e-test-utils": "^11.0.0",
"@wordpress/scripts": "^27.9.0",
"dotenv": "^16.4.5"
}
Expand Down
12 changes: 5 additions & 7 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { defineConfig, devices } from '@playwright/test';
import * as dotenv from "dotenv";

dotenv.config({ path: __dirname + '/tests/playwright/.env.local' });

export default defineConfig({
testDir: './tests/playwright/',
Expand All @@ -12,20 +15,15 @@ export default defineConfig({
['json', { outputFile: './tests/playwright-report/test-results.json' }]
],
use: {
baseURL: 'https://msls.co',
trace: 'on-first-retry',
},
projects: [
{
name: 'setup',
testMatch: 'tests/playwright/auth.setup.ts',
},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
storageState: 'tests/playwright/.auth/user.json',
},
dependencies: ['setup'],
},
],
]
});
5 changes: 3 additions & 2 deletions tests/playwright/.env.local.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
user_login=set_a_username
user_pass=set_a_password
WP_USERNAME=set_a_username
WP_PASSWORD=set_a_password
WP_BASE_URL=https://your_server
12 changes: 10 additions & 2 deletions tests/playwright/admin-dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { loginUser } from '@wordpress/e2e-test-utils';
import { test, expect } from '@playwright/test';

test.describe.configure({ mode: 'parallel' });

test.beforeEach(async ({page}) => {
page.goto('/wp-login.php?jetpack-sso-show-default-form=1' );

await loginUser(process.env.WP_USERNAME, process.env.WP_PASSWORD);
});

test('test edit posts', async ({ page }) => {
await page.goto('https://msls.co/wp-admin/edit.php');
page.goto('/wp-admin/edit.php' );

const mslscol = await page.locator('#mslscol');
await expect(mslscol).toHaveAttribute('scope', 'col');
});

test('test edit pages', async ({ page }) => {
await page.goto('https://msls.co/wp-admin/edit.php?post_type=page');
page.goto('/wp-admin/edit.php?post_type=page' );

const mslscol = await page.locator('#mslscol');
await expect(mslscol).toHaveAttribute('scope', 'col');
Expand Down
16 changes: 0 additions & 16 deletions tests/playwright/auth.setup.ts

This file was deleted.

6 changes: 3 additions & 3 deletions tests/playwright/homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { test, expect } from '@playwright/test';

test('test', async ({ page }) => {
await page.goto('https://msls.co/');
await page.goto('/');

await expect(page).toHaveTitle(/Multisite Language Switcher - WordPress multilingual/);

await page.getByRole('link', { name: 'de_DE' }).click();
await page.getByRole('link', { name: 'de_DE' }).first().click();
await expect(page).toHaveTitle(/Multisite Language Switcher - WordPress mehrsprachig/);

await page.getByRole('link', { name: 'en_GB' }).click();
await page.getByRole('link', { name: 'en_GB' }).first().click();
await expect(page).toHaveTitle(/Multisite Language Switcher - WordPress multilingual/);
});
Loading