Skip to content

Commit

Permalink
fix: playwright test
Browse files Browse the repository at this point in the history
chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright

chore: debug playwright
  • Loading branch information
preda-bogdan committed Dec 22, 2022
1 parent b05d204 commit 5a37a78
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: yarn run test:e2e:playwright
run: yarn run test:e2e:playwright specs/tpc/tpc-notice-install.spec.ts
1 change: 1 addition & 0 deletions bin/envs/sample-data/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
wp --allow-root plugin is-installed wordpress-importer && wp --allow-root plugin update wordpress-importer || wp --allow-root plugin install wordpress-importer
wp --allow-root plugin install templates-patterns-collection
##Setup core content.
wp --allow-root plugin activate wordpress-importer
curl -O https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml
Expand Down
95 changes: 51 additions & 44 deletions e2e-tests/specs/tpc/tpc-notice-install.spec.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
import { test, expect } from '@playwright/test';
import { loginWithRequest } from '../../utils';

test('test', async ({ page }) => {
await loginWithRequest('/wp-admin/index.php', page);

if (page.url().includes('wp-login.php')) {
//throw new Error('Not logged in');
await page.getByLabel('Username or Email Address').fill('admin');
await page.getByLabel('Password').fill('admin');
await page.getByRole('button', { name: 'Log In' }).click();
}

await expect(page).toHaveURL(/wp-admin\/index.php/);

await expect(page.locator('button.install-now')).toContainText(
'Try one of our ready to use Starter Sites'
);
await expect(page.locator('button.install-now')).toBeVisible();
await page.locator('button.install-now').click();

await expect(page.locator('button.install-now')).toContainText(
/(Activating|Installing)/
);

await page.waitForNavigation();

await expect(page).toHaveURL(
/wp-admin\/themes.php\?page=tiob-starter-sites&onboarding=yes/
);

await expect(page.locator('a.tab')).toContainText([
'All Categories',
'Free',
'Business',
'Portfolio',
'WooCommerce',
'Blog',
'Personal',
'Other',
]);

await page.goto('/wp-admin/index.php');

await expect(page).toHaveURL(/wp-admin\/index.php/);

await expect(page.locator('button.install-now')).not.toBeVisible();
test.describe('Dashboard Notice', () => {
test('Starter Sites Plugin install from Dashboard Notice', async ({
page,
}) => {
await loginWithRequest('/wp-admin/index.php', page);

if (page.url().includes('wp-login.php')) {
//throw new Error('Not logged in');
await page.getByLabel('Username or Email Address').fill('admin');
await page.getByLabel('Password').fill('admin');
await page.getByRole('button', { name: 'Log In' }).click();
}

await expect(page).toHaveURL(/wp-admin\/index.php/);

await expect(page.locator('button.install-now')).toContainText(
'Try one of our ready to use Starter Sites'
);
await expect(page.locator('button.install-now')).toBeVisible();

await Promise.all([
page.waitForNavigation({
url: /wp-admin\/themes.php\?page=tiob-starter-sites&onboarding=yes/,
}),
page.locator('button.install-now').click(),
expect(page.locator('button.install-now')).toContainText(
/(Activating|Installing)/
),
]);

await expect(page).toHaveURL(
/wp-admin\/themes.php\?page=tiob-starter-sites&onboarding=yes/
);

await expect(page.locator('a.tab')).toContainText([
'All Categories',
'Free',
'Business',
'Portfolio',
'WooCommerce',
'Blog',
'Personal',
'Other',
]);

await page.goto('/wp-admin/index.php');

await expect(page).toHaveURL(/wp-admin\/index.php/);

await expect(page.locator('button.install-now')).not.toBeVisible();
});
});

0 comments on commit 5a37a78

Please sign in to comment.