1
- import { describe , test , expect } from '../../vendor/ tangible/template-system/framework/ playwright/index.js '
1
+ import { describe , test , expect } from '@ tangible/env/ playwright'
2
2
3
3
/**
4
- * Tests to exercise the frontend and admin features of the Template System .
4
+ * Tests to exercise the frontend and admin features of Tangible Blocks .
5
5
*
6
- * To interact with pages, locate elements by user-visible locators like
6
+ * Note: To interact with pages, locate elements by user-visible locators like
7
7
* accessible role, instead of CSS selectors which can change.
8
8
*
9
9
* @see https://playwright.dev/docs/locators#locating-elements
@@ -22,17 +22,13 @@ describe('Admin', () => {
22
22
} )
23
23
24
24
const plugins = [
25
- [ 'Loops & Logic' , 'tangible-loops-and-logic/tangible-loops-and-logic' ] ,
26
- [ 'E2E' , 'e2e-plugin/index' ] ,
27
-
28
- [ 'Advanced Custom Fields' , 'advanced-custom-fields/acf' ] ,
25
+ [ 'Tangible Loops & Logic' , 'tangible-loops-and-logic/tangible-loops-and-logic' ] ,
26
+ [ 'Tangible E2E' , 'tangible-e2e-plugin/index' ] ,
29
27
[ 'Elementor' , 'elementor/elementor' ] ,
30
28
[ 'Beaver Builder' , 'beaver-builder-lite-version/fl-builder' ] ,
31
- // ['WP Fusion Lite', 'wp-fusion-lite/wp-fusion-lite']
32
29
]
33
30
34
31
for ( const [ pluginTitle , pluginBasename ] of plugins ) {
35
-
36
32
test ( `${ pluginTitle } installed` , async ( { admin, page, requestUtils } ) => {
37
33
await admin . visitAdminPage ( '/' )
38
34
@@ -41,66 +37,42 @@ describe('Admin', () => {
41
37
// })
42
38
// expect(plugins).toContain(pluginBasename)
43
39
// console.log('plugins', plugins)
44
- try {
45
- const result = await requestUtils . rest ( {
46
- path : `wp/v2/plugins/${ pluginBasename } ` ,
47
- } )
48
- // console.log('plugin', result)
49
-
50
- expect ( result . plugin ) . toBe ( pluginBasename )
51
- } catch ( e ) {
52
- if ( e . code === 'rest_plugin_not_found' ) {
53
- console . log ( `Optional plugin ${ pluginTitle } is not installed` )
54
- } else {
55
- console . error ( e )
56
- }
57
- }
40
+
41
+ const result = await requestUtils . rest ( {
42
+ path : `wp/v2/plugins/${ pluginBasename } ` ,
43
+ } )
44
+ // console.log('plugin', result)
45
+
46
+ expect ( result . plugin ) . toBe ( pluginBasename )
58
47
} )
59
48
60
- test ( `Activate ${ pluginTitle } ` , async ( {
61
- admin,
62
- page,
63
- request,
64
- requestUtils,
65
- } ) => {
49
+ test ( `Activate ${ pluginTitle } ` , async ( { admin, page, request, requestUtils } ) => {
66
50
await admin . visitAdminPage ( 'plugins.php' )
67
51
68
52
// See if plugin is active or not
69
- const pluginClasses = await page . evaluate (
70
- ( { pluginBasename } ) => {
71
- const $row = document . querySelector (
72
- `[data-plugin="${ pluginBasename } .php"]` ,
73
- )
74
- if ( ! $row ) return [ ]
75
- return [ ...$row ?. classList ]
76
- } ,
77
- { pluginBasename } ,
78
- )
79
-
80
- if ( pluginTitle !== 'Template System' && ! pluginClasses . length ) {
81
- return
82
- }
53
+ const pluginClasses = await page . evaluate ( ( { pluginBasename } ) => {
54
+ const $row = document . querySelector (
55
+ `[data-plugin="${ pluginBasename } .php"]`
56
+ )
57
+ return [ ...$row . classList ]
58
+ } , { pluginBasename } )
83
59
84
60
if ( ! pluginClasses . includes ( 'active' ) ) {
85
61
await expect ( pluginClasses ) . toContain ( 'inactive' )
86
62
87
63
// Find the Activate link
88
64
89
- const activateLink = await page . evaluate (
90
- ( { pluginBasename } ) => {
91
- const $row = document . querySelector (
92
- `[data-plugin="${ pluginBasename } .php"]` ,
93
- )
94
- const $activate = $row . querySelector ( 'a.edit' )
95
- return $activate ?. href
96
- } ,
97
- { pluginBasename } ,
98
- )
65
+ const activateLink = await page . evaluate ( ( { pluginBasename } ) => {
66
+ const $row = document . querySelector (
67
+ `[data-plugin="${ pluginBasename } .php"]`
68
+ )
69
+ const $activate = $row . querySelector ( 'a.edit' )
70
+ return $activate ?. href
71
+ } , { pluginBasename } )
99
72
100
73
await expect ( activateLink ) . toBeTruthy ( )
101
74
102
75
// Make a POST request
103
-
104
76
await request . post ( activateLink )
105
77
}
106
78
@@ -239,5 +211,4 @@ test('Code editor', async ({ admin, page }) => {
239
211
( ) => Boolean ( window . Tangible && window . Tangible . TemplateSystem && window . Tangible . TemplateSystem . CodeEditor )
240
212
) ) . toBe ( true )
241
213
242
-
243
214
} )
0 commit comments