Merge "Bug 44855, Bug 37743: Improved vector button styles for jquery.ui"
[lhc/web/wiklou.git] / tests / selenium / suites / AddContentToNewPageTestCase.php
1 <?php
2 /**
3 * Selenium server manager
4 *
5 * @file
6 * @ingroup Testing
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 */
25
26 class AddContentToNewPageTestCase extends SeleniumTestCase {
27 // Add bold text and verify output
28 public function testAddBoldText() {
29 $this->getExistingPage();
30 $this->clickEditLink();
31 $this->loadWikiEditor();
32 $this->clearWikiEditor();
33 $this->click( "//*[@id='mw-editbutton-bold']" );
34 $this->clickShowPreviewBtn();
35 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
36
37 // Verify bold text displayed on mediawiki preview
38 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/b" ) );
39 $this->assertTrue( $this->isTextPresent( "Bold text" ) );
40 }
41
42 // Add italic text and verify output
43 public function testAddItalicText() {
44 $this->getExistingPage();
45 $this->clickEditLink();
46 $this->loadWikiEditor();
47 $this->clearWikiEditor();
48 $this->click( "//*[@id='mw-editbutton-italic']" );
49 $this->clickShowPreviewBtn();
50 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
51
52 // Verify italic text displayed on mediawiki preview
53 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/i" ) );
54 $this->assertTrue( $this->isTextPresent( "Italic text" ) );
55 }
56
57 // Add internal link for a new page and verify output in the preview
58 public function testAddInternalLinkNewPage() {
59 $this->getExistingPage();
60 $this->clickEditLink();
61 $this->loadWikiEditor();
62 $this->clearWikiEditor();
63 $this->click( "//*[@id='mw-editbutton-link']" );
64 $this->clickShowPreviewBtn();
65 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
66
67 // Verify internal link displayed on mediawiki preview
68 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
69 $correct = strstr( $source, "Link title" );
70 $this->assertEquals( $correct, true );
71
72 $this->click( SeleniumTestConstants::LINK_START . "Link title" );
73 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
74
75 // Verify internal link open as a new page - editing mode
76 $source = $this->getText( "firstHeading" );
77 $correct = strstr( $source, "Editing Link title" );
78 $this->assertEquals( $correct, true );
79 }
80
81 // Add external link and verify output in the preview
82 public function testAddExternalLink() {
83 $this->getExistingPage();
84 $this->clickEditLink();
85 $this->loadWikiEditor();
86 $this->clearWikiEditor();
87 $this->click( "//*[@id='mw-editbutton-extlink']" );
88 $this->type( SeleniumTestConstants::TEXT_EDITOR, "[http://www.google.com Google]" );
89 $this->clickShowPreviewBtn();
90 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
91
92 // Verify external links displayed on mediawiki preview
93 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
94 $correct = strstr( $source, "Google" );
95 $this->assertEquals( $correct, true );
96
97 $this->click( SeleniumTestConstants::LINK_START . "Google" );
98 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
99
100 // Verify external link opens
101 $source = $this->getTitle();
102 $correct = strstr( $source, "Google" );
103 $this->assertEquals( $correct, true );
104 }
105
106 // Add level 2 headline and verify output in the preview
107 public function testAddLevel2HeadLine() {
108 $this->getExistingPage();
109 $this->clickEditLink();
110 $this->loadWikiEditor();
111 $this->clearWikiEditor();
112 $this->click( "mw-editbutton-headline" );
113 $this->clickShowPreviewBtn();
114 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
115 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/h2" ) );
116
117 // Verify level 2 headline displayed on mediawiki preview
118 $source = $this->getText( "//*[@id='Headline_text']" );
119 $correct = strstr( $source, "Headline text" );
120 $this->assertEquals( $correct, true );
121 }
122
123 // Add text with ignore wiki format and verify output the preview
124 public function testAddNoWikiFormat() {
125 $this->getExistingPage();
126 $this->clickEditLink();
127 $this->loadWikiEditor();
128 $this->clearWikiEditor();
129 $this->click( "//*[@id='mw-editbutton-nowiki']" );
130 $this->clickShowPreviewBtn();
131 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
132
133 // Verify ignore wiki format text displayed on mediawiki preview
134 $source = $this->getText( "//div[@id='wikiPreview']/p" );
135 $correct = strstr( $source, "Insert non-formatted text here" );
136 $this->assertEquals( $correct, true );
137 }
138
139 // Add signature and verify output in the preview
140 public function testAddUserSignature() {
141 $this->getExistingPage();
142 $this->clickEditLink();
143 $this->loadWikiEditor();
144 $this->clearWikiEditor();
145 $this->click( "mw-editbutton-signature" );
146 $this->clickShowPreviewBtn();
147 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
148
149 // Verify signature displayed on mediawiki preview
150 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
151 $username = $this->getText( "//*[@id='pt-userpage']/a" );
152 $correct = strstr( $source, $username );
153 $this->assertEquals( $correct, true );
154 }
155
156 // Add horizontal line and verify output in the preview
157 public function testHorizontalLine() {
158 $this->getExistingPage();
159 $this->clickEditLink();
160 $this->loadWikiEditor();
161 $this->clearWikiEditor();
162 $this->click( "mw-editbutton-hr" );
163
164 $this->clickShowPreviewBtn();
165 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
166
167 // Verify horizontal line displayed on mediawiki preview
168 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" ) );
169 $this->deletePage( "new" );
170 }
171 }