Skip to content

Commit 95dc3d1

Browse files
committed
Working on playwright tests
1 parent 1c5a0af commit 95dc3d1

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

tests/playwright/.env.local.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
username=set_a_username
2-
password=set_a_password
1+
user_login=set_a_username
2+
user_pass=set_a_password
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe.configure({ mode: 'parallel' });
4+
test('test edit posts', async ({ page }) => {
5+
await page.goto('https://msls.co/wp-admin/edit.php');
6+
7+
const mslscol = await page.locator('#mslscol');
8+
await expect(mslscol).toHaveAttribute('scope', 'col');
9+
});
10+
11+
test('test edit pages', async ({ page }) => {
12+
await page.goto('https://msls.co/wp-admin/edit.php?post_type=page');
13+
14+
const mslscol = await page.locator('#mslscol');
15+
await expect(mslscol).toHaveAttribute('scope', 'col');
16+
});

tests/playwright/auth.setup.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { test as setup } from '@playwright/test';
1+
import { test as setup, expect } from '@playwright/test';
22
import dotenv from 'dotenv';
33

44
const authFile = 'tests/playwright/.auth/user.json';
55

6-
setup('authenticate', async ({ request }) => {
7-
dotenv.config({ path: 'tests/playwright/.env.local' });
8-
await request.post('https://msls.co/wp-login.php', {
9-
form: {
10-
'log': 'user',
11-
'pwd': 'password'
12-
}
13-
});
14-
await request.storageState({ path: authFile });
6+
setup('authenticate', async ({ page }) => {
7+
dotenv.config({ path: 'tests/playwright/.env.local'});
8+
9+
await page.goto('https://msls.co/wp-login.php?jetpack-sso-show-default-form=1');
10+
11+
await page.locator('#user_login').fill(process.env.user_login as string);
12+
await page.locator('#user_pass').fill(process.env.user_pass as string);
13+
await page.locator('#wp-submit').click();
14+
15+
await page.context().storageState({ path: authFile });
1516
});

0 commit comments

Comments
 (0)