2
include( "WikiEditorConstants.php" );
4
* This test case will be handling the Wiki Tool bar Dialog functions
6
* @author : BhagyaG - Calcey
8
class WikiDialogs_Links_Setup extends SeleniumTestCase {
11
function doOpenLink() {
12
$this->open( $this->getUrl() . '/index.php' );
13
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
16
// Expand advance tool bar section if its not
17
function doExpandAdvanceSection() {
18
if ( !$this->isTextPresent( TEXT_HEADING ) ) {
19
$this->click( LINK_ADVANCED );
23
// Log out from the application
25
$this->open( $this->getUrl() . '/index.php' );
26
if ( $this->isTextPresent( TEXT_LOGOUT ) ) {
27
$this->click( LINK_LOGOUT );
28
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
29
$this->assertEquals( TEXT_LOGOUT_CONFIRM, $this->getText( LINK_LOGIN ) );
30
$this->open( $this->getUrl() . '/index.php' );
31
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
35
// Create a temporary fixture page
36
function doCreateInternalTestPageIfMissing() {
37
$this->type( INPUT_SEARCH_BOX, WIKI_INTERNAL_LINK );
38
$this->click( BUTTON_SEARCH );
39
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
40
$this->click( LINK_START . WIKI_INTERNAL_LINK );
41
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
42
$location = $this->getLocation() . "\n";
43
if ( strpos( $location, '&redlink=1' ) !== false ) {
44
$this->type( TEXT_EDITOR, "Test fixture page. No real content here" );
45
$this->click( BUTTON_SAVE_WATCH );
46
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
47
$this->assertTrue( $this->isTextPresent( WIKI_INTERNAL_LINK ),
48
$this->getText( TEXT_PAGE_HEADING ) );
52
// Create a temporary new page
53
function doCreateNewPageTemporary() {
54
$this->type( INPUT_SEARCH_BOX, WIKI_TEMP_NEWPAGE );
55
$this->click( BUTTON_SEARCH );
56
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
57
$this->click( LINK_START . WIKI_TEMP_NEWPAGE );
58
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
61
// Add a internal link and verify
62
function verifyInternalLink() {
63
$this->type( TEXT_EDITOR, "" );
64
$this->click( LINK_ADDLINK );
65
$this->waitForPopup( 'addLink', WIKI_TEST_WAIT_TIME );
66
$this->type( TEXT_LINKNAME, ( WIKI_INTERNAL_LINK ) );
67
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXISTS ), 'Element ' . ICON_PAGEEXISTS . 'Not found' );
68
$this->assertEquals( "on", $this->getValue( OPT_INTERNAL ) );
69
$this->click( BUTTON_INSERTLINK );
70
$this->click( LINK_PREVIEW );
71
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
72
$this->assertEquals( ( WIKI_INTERNAL_LINK ), $this->getText( LINK_START . WIKI_INTERNAL_LINK ) );
73
$this->click( LINK_START . WIKI_INTERNAL_LINK );
74
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
75
$this->assertTrue( $this->isTextPresent( WIKI_INTERNAL_LINK ), $this->getText( TEXT_PAGE_HEADING ) );
78
// Add a internal link with different display text and verify
79
function verifyInternalLinkWithDisplayText() {
80
$this->type( TEXT_EDITOR, "" );
81
$this->click( LINK_ADDLINK );
82
$this->waitForPopup( 'addLink', WIKI_TEST_WAIT_TIME );
83
$this->type( TEXT_LINKNAME, WIKI_INTERNAL_LINK );
84
$this->type ( TEXT_LINKDISPLAYNAME, WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT );
85
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXISTS ) );
86
$this->assertEquals( "on", $this->getValue( OPT_INTERNAL ) );
87
$this->click( BUTTON_INSERTLINK );
88
$this->click( LINK_PREVIEW );
89
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
90
$this->assertEquals( WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT,
91
$this->getText( LINK_START . WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT ) );
92
$this->click( LINK_START . WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT );
93
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
94
$this->assertTrue( $this->isTextPresent( WIKI_INTERNAL_LINK ), $this->getText( TEXT_PAGE_HEADING ) );
98
// Add a internal link with blank display text and verify
99
function verifyInternalLinkWithBlankDisplayText() {
100
$this->type( TEXT_EDITOR, "" );
101
$this->click( LINK_ADDLINK );
102
$this->waitForPopup( 'addLink', WIKI_TEST_WAIT_TIME );
103
$this->type( TEXT_LINKNAME, WIKI_INTERNAL_LINK );
104
$this->type( TEXT_LINKDISPLAYNAME, "" );
105
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXISTS ) );
106
$this->assertEquals( "on", $this->getValue( OPT_INTERNAL ) );
107
$this->click( BUTTON_INSERTLINK );
108
$this->click( LINK_PREVIEW );
109
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
110
$this->assertEquals( WIKI_INTERNAL_LINK, $this->getText( LINK_START . WIKI_INTERNAL_LINK ) );
111
$this->click( LINK_START . WIKI_INTERNAL_LINK );
112
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
113
$this->assertEquals( WIKI_INTERNAL_LINK, $this->getText( TEXT_PAGE_HEADING ) );
117
// Add external link and verify
118
function verifyExternalLink() {
119
$this->type( LINK_PREVIEW, "" );
120
$this->click( LINK_ADDLINK );
121
$this->type( TEXT_LINKNAME, WIKI_EXTERNAL_LINK );
122
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXTERNAL ) );
123
$this->assertEquals( "on", $this->getValue( OPT_EXTERNAL ) );
124
$this->click( BUTTON_INSERTLINK );
125
$this->click( LINK_PREVIEW );
126
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
127
$this->assertEquals( WIKI_EXTERNAL_LINK, $this->getText( LINK_START . WIKI_EXTERNAL_LINK ) );
129
$this->click( LINK_START . WIKI_EXTERNAL_LINK );
130
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
131
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE, $this->getTitle() );
134
// Add external link with different display text and verify
135
function verifyExternalLinkWithDisplayText() {
136
$this->type( TEXT_EDITOR, "" );
137
$this->click( LINK_ADDLINK );
138
$this->type( TEXT_LINKNAME, WIKI_EXTERNAL_LINK );
139
$this->type( TEXT_LINKDISPLAYNAME, WIKI_EXTERNAL_LINK_TITLE );
140
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXTERNAL ) );
141
$this->assertEquals( "on", $this->getValue( OPT_EXTERNAL ) );
142
$this->click( BUTTON_INSERTLINK );
143
$this->click( LINK_PREVIEW );
144
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
145
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE, $this->getText( LINK_START . WIKI_EXTERNAL_LINK_TITLE ) );
146
$this->click( LINK_START . ( WIKI_EXTERNAL_LINK_TITLE ) );
147
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
148
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE , $this->getTitle() );
151
// Add external link with Blank display text and verify
152
function verifyExternalLinkWithBlankDisplayText() {
153
$this->type( TEXT_EDITOR, "" );
154
$this->click( LINK_ADDLINK );
155
$this->type( TEXT_LINKNAME, WIKI_EXTERNAL_LINK );
156
$this->type( TEXT_LINKDISPLAYNAME, "" );
157
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXTERNAL ) );
158
$this->assertEquals( "on", $this->getValue( OPT_EXTERNAL ) );
159
$this->click( BUTTON_INSERTLINK );
160
$this->click( LINK_PREVIEW );
161
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
162
$this->assertEquals( "[1]", $this->getText( LINK_START . "[1]" ) );
163
$this->click( LINK_START . "[1]" );
164
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
165
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE, $this->getTitle() );
168
// Add a table and verify
169
function verifyCreateTable() {
171
$WIKI_TABLE_COL = "5";
172
$this->doExpandAdvanceSection();
173
$this->type( TEXT_EDITOR, "" );
174
$this->click( LINK_ADDTABLE );
175
$this->click( CHK_SORT );
176
$this->type( TEXT_ROW, $WIKI_TABLE_ROW );
177
$this->type( TEXT_COL, $WIKI_TABLE_COL );
178
$this->click( BUTTON_INSERTABLE );
179
$this->click( CHK_SORT );
180
$this->click( LINK_PREVIEW );
181
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
182
$WIKI_TABLE_ROW = $WIKI_TABLE_ROW + 1;
183
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_OTHER .
184
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
185
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
186
TEXT_VALIDATE_TABLE_PART3 ) );
189
// Add a table and verify only with head row
190
function verifyCreateTableWithHeadRow() {
192
$WIKI_TABLE_COL = "4";
193
$this->doExpandAdvanceSection();
194
$this->type( TEXT_EDITOR, "" );
195
$this->click( LINK_ADDTABLE );
196
$this->click( CHK_BOARDER );
197
$this->type( TEXT_ROW, $WIKI_TABLE_ROW );
198
$this->type( TEXT_COL, $WIKI_TABLE_COL );
199
$this->click( BUTTON_INSERTABLE );
200
$this->click( LINK_PREVIEW );
201
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
202
$WIKI_TABLE_ROW = $WIKI_TABLE_ROW + 1;
203
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_OTHER .
204
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
205
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
206
TEXT_VALIDATE_TABLE_PART3 ) );
209
// Add a table and verify only with borders
210
function verifyCreateTableWithBorders() {
211
$WIKI_TABLE_ROW = "4";
212
$WIKI_TABLE_COL = "6";
213
$this->type( TEXT_EDITOR, "" );
214
$this->click( LINK_ADDTABLE );
215
$this->click( CHK_HEADER );
216
$this->type( TEXT_ROW, $WIKI_TABLE_ROW );
217
$this->type( TEXT_COL, $WIKI_TABLE_COL );
218
$this->click( BUTTON_INSERTABLE );
219
$this->click( CHK_HEADER );
220
$this->click( LINK_PREVIEW );
221
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
222
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_OTHER .
223
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
224
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
225
TEXT_VALIDATE_TABLE_PART3 ) );
228
// Add a table and verify only with sort row
229
function verifyCreateTableWithSortRow() {
230
$WIKI_TABLE_ROW = "2";
231
$WIKI_TABLE_COL = "5";
232
$this->type( TEXT_EDITOR, "" );
233
$this->click( LINK_ADDTABLE );
234
$this->click( CHK_HEADER );
235
$this->click( CHK_BOARDER );
236
$this->click( CHK_SORT );
237
$this->type( TEXT_ROW, $WIKI_TABLE_ROW );
238
$this->type( TEXT_COL, $WIKI_TABLE_COL );
239
$this->click( BUTTON_INSERTABLE );
240
$this->click( CHK_HEADER );
241
$this->click( CHK_BOARDER );
242
$this->click( CHK_SORT );
243
$this->click( LINK_PREVIEW );
244
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
245
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_WITHALLFEATURES .
246
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
247
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
248
TEXT_VALIDATE_TABLE_PART3 ) );
251
// Add a table without headers,borders and sort rows
252
function verifyCreateTableWithNoSpecialEffects() {
253
$WIKI_TABLE_ROW = "6";
254
$WIKI_TABLE_COL = "2";
256
$this->doExpandAdvanceSection();
257
$this->type( TEXT_EDITOR, "" );
258
$this->click( LINK_ADDTABLE );
259
$this->click( CHK_BOARDER );
260
$this->click( CHK_HEADER );
261
$this->type( TEXT_ROW, $WIKI_TABLE_ROW );
262
$this->type( TEXT_COL, $WIKI_TABLE_COL );
263
$this->click( BUTTON_INSERTABLE );
264
$this->click( CHK_BOARDER );
265
$this->click( CHK_HEADER );
266
$this->click( INK_PREVIEW );
267
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
268
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_OTHER .
269
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
270
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
271
TEXT_VALIDATE_TABLE_PART3 ) );
274
// Add a table with headers,borders and sort rows
275
function verifyCreateTableWithAllSpecialEffects() {
277
$WIKI_TABLE_COL = "2";
278
$this->doExpandAdvanceSection();
279
$this->type( TEXT_EDITOR, "" );
280
$this->click( LINK_ADDTABLE );
281
$this->click( CHK_SORT );
282
$this->type( TEXT_ROW, $WIKI_TABLE_ROW );
283
$this->type( TEXT_COL, $WIKI_TABLE_COL );
284
$this->click( BUTTON_INSERTABLE );
285
$this->click( CHK_SORT );
286
$this->click( LINK_PREVIEW );
287
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
288
$WIKI_TABLE_ROW = $WIKI_TABLE_ROW + 1;
289
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_WITHALLFEATURES .
290
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
291
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
292
TEXT_VALIDATE_TABLE_PART3 ) );
b'\\ No newline at end of file'