5
5
use Acquia \DrupalEnvironmentDetector \AcquiaDrupalEnvironmentDetector ;
6
6
use Drupal \FunctionalJavascriptTests \WebDriverTestBase ;
7
7
use Drupal \Tests \acquia_cms_headless \Traits \HeadlessNextJsTrait ;
8
+ use Drupal \user \Entity \Role ;
8
9
9
10
/**
10
11
* Base class for the Headless Content administrator browser tests.
@@ -26,6 +27,9 @@ class HeadlessContentTest extends WebDriverTestBase {
26
27
protected static $ modules = [
27
28
'acquia_cms_headless ' ,
28
29
'node ' ,
30
+ 'block ' ,
31
+ 'media_library ' ,
32
+ 'entity_clone ' ,
29
33
];
30
34
31
35
/**
@@ -54,6 +58,12 @@ protected function setUp(): void {
54
58
}
55
59
parent ::setUp ();
56
60
$ account = $ this ->drupalCreateUser ();
61
+ // Create an administrator role with is_admin set to true.
62
+ Role::create ([
63
+ 'id ' => 'administrator ' ,
64
+ 'label ' => 'Administrator ' ,
65
+ 'is_admin ' => TRUE ,
66
+ ])->save ();
57
67
$ account ->addRole ('administrator ' );
58
68
$ account ->save ();
59
69
$ this ->drupalLogin ($ account );
@@ -66,12 +76,7 @@ protected function setUp(): void {
66
76
// Set up a content type.
67
77
$ this ->drupalCreateContentType ([
68
78
'type ' => 'test ' ,
69
- 'name ' => 'Test ' ,
70
- 'third_party_settings ' => [
71
- "acquia_cms_common " => [
72
- "workflow_id " => "editorial " ,
73
- ],
74
- ],
79
+ 'name ' => 'Test '
75
80
]);
76
81
// Enable pure headless mode.
77
82
$ this ->enableHeadlessMode ();
@@ -85,7 +90,7 @@ protected function setUp(): void {
85
90
* Content admin test.
86
91
*/
87
92
public function testContentAdmin (): void {
88
- // Visit content page.
93
+ // Visit the content page.
89
94
$ this ->drupalGet ("admin/content " );
90
95
91
96
// Validating the primary menu tabs on admin content page.
@@ -114,32 +119,32 @@ public function testContentAdmin(): void {
114
119
$ assertSession = $ this ->assertSession ();
115
120
$ assertSession ->pageTextContains ('Headless Test Page ' );
116
121
// @todo Below commented test is failing in 3.0-rc8 version of Gin theme.
117
- // Howere this was working in 3.0-rc5 will be fixed in ACMS-3456.
118
- /*
122
+ // However this was working in 3.0-rc5 will be fixed in ACMS-3456.
119
123
$ assertSession ->linkNotExists ('View ' );
120
124
$ nodePageMenus = [
121
125
'API ' => '/jsonapi/node/test/ ' . $ node ->uuid (),
122
126
'Edit ' => '/node/ ' . $ nid . '/edit ' ,
123
127
'Preview ' => '/node/ ' . $ nid . '/site-preview ' ,
128
+ 'Delete ' => '/node/ ' . $ nid . '/delete ' ,
124
129
'Revisions ' => '/node/ ' . $ nid . '/revisions ' ,
125
130
'Clone ' => '/entity_clone/node/ ' . $ nid ,
126
131
];
127
- $menuList = $this->cssSelect('ul.tabs--primary li');
132
+ $ menuList = $ this ->cssSelect ('#block-local-tasks ul li ' );
133
+ dump ($ menuList );
128
134
// Check the total count of node tabs.
129
135
$ this ->assertCount (6 , $ menuList );
130
136
$ menuOrder = [];
131
137
foreach ($ menuList as $ menu ) {
132
- $tabTitle = str_replace(' (active tab)', '', $menu->getText());
133
- if ($tabTitle) {
134
- $menuOrder[] = $tabTitle;
135
- }
138
+ $ tabTitle = str_replace (' (active tab) ' , '' , $ menu ->getText ());
139
+ if ($ tabTitle ) {
140
+ $ menuOrder [] = $ tabTitle ;
141
+ }
136
142
}
137
143
// Assertion for menu order.
138
144
$ this ->assertEquals ($ menuOrder , array_keys ($ nodePageMenus ));
139
- Assertion test for tabs of node page.
145
+ // Assertion test for tabs of node page.
140
146
$ this ->assertTabMenus ($ nodePageMenus , $ path );
141
- */
142
- // Assert delete buton.
147
+ // Assert delete button.
143
148
$ deleteButton = $ this ->getSession ()->getPage ()->findLink ('Delete ' );
144
149
$ this ->assertEquals ('Delete ' , $ deleteButton ->getText ());
145
150
$ this ->assertEquals ('/node/ ' . $ nid . '/delete ' , $ deleteButton ->getAttribute ('href ' ));
0 commit comments