-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathquery-monitor-plugin.test.js
More file actions
47 lines (38 loc) · 1.82 KB
/
query-monitor-plugin.test.js
File metadata and controls
47 lines (38 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* WordPress dependencies
*/
import { test, expect } from '@wordpress/e2e-test-utils-playwright';
test.describe( 'Query Monitor plugin', () => {
async function deactivateQueryMonitor( requestUtils ) {
await requestUtils.deactivatePlugin( 'query-monitor' );
const plugin = await requestUtils.rest( {
path: 'wp/v2/plugins/query-monitor/query-monitor',
} );
expect( plugin.status ).toBe( 'inactive' );
}
test.beforeEach( async ( { requestUtils }) => {
await deactivateQueryMonitor( requestUtils );
} );
test.afterEach( async ( { requestUtils }) => {
await deactivateQueryMonitor( requestUtils );
} );
test( 'should activate', async ( { admin, page } ) => {
// Activate the Query Monitor plugin on the plugins page.
await admin.visitAdminPage( '/plugins.php' );
await page.getByLabel( 'Activate Query Monitor', { exact: true } ).click();
await page.getByText( 'Plugin activated.', { exact: true } ).waitFor();
// Click on the Query Monitor menu item in the WordPress admin bar.
await page.locator('a[role="menuitem"][href="#qm-overview"][aria-expanded="false"]').click();
// Wait for the Query Monitor panel to open.
await page.locator( '#query-monitor-main' ).waitFor();
await page.getByRole( 'heading', { name: 'Query Monitor', exact: true } ).waitFor();
// Click on the Database Queries tab.
await page.getByRole( 'tab', { name: 'Database Queries' } ).click();
// Verify the first logged query.
const sqlCell = page.locator( '.qm-row-sql' ).first();
await expect( sqlCell ).toContainText( 'SELECT option_name, option_value' );
// Check that the query is logged with SQLite information.
await sqlCell.getByLabel( 'Toggle SQLite queries' ).click();
expect( page.locator('.qm-sqlite-query', { hasText: 'SELECT `option_name` , `option_value` FROM `wp_options`' }).first() ).toBeVisible();
} );
} );