[TASK] Acceptance tests: Don't restart browser
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Language / LanguageCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Language;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
18
19 /**
20 * Language tests
21 */
22 class LanguageCest
23 {
24 /**
25 * @param Admin $I
26 */
27 public function _before(Admin $I)
28 {
29 $I->useExistingSession();
30 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
31 $I->switchToIFrame('list_frame');
32 $I->waitForText('Web Content Management System');
33 $I->switchToIFrame();
34
35 $I->see('Languages');
36 $I->click('Languages');
37
38 // Increase duration for notification viewing, avoids vanish before the message is tested
39 $I->executeJS('TYPO3.Notification.duration = 100;');
40
41 // switch to content iframe
42 $I->switchToIFrame('list_frame');
43 }
44
45 /**
46 * @param Admin $I
47 */
48 public function showsHeadingAndListsInstalledLanguages(Admin $I)
49 {
50 $I->see('Installed Languages');
51
52 $I->wantTo('See the table of languages');
53 $I->waitForElementVisible('#typo3-language-list');
54 }
55
56 /**
57 * @param Admin $I
58 */
59 public function filterInstalledLanguages(Admin $I)
60 {
61 $I->wantTo('Filter the list of translations with a valid language');
62 $I->fillField('#typo3-language-searchfield', 'Danish');
63 $I->canSeeNumberOfElements('#typo3-language-list tbody tr', 1);
64 $I->seeElement('#language-da');
65
66 $I->fillField('#typo3-language-searchfield', '');
67
68 $I->wantTo('Filter the list of translations with an valid locale');
69 $I->fillField('#typo3-language-searchfield', 'pt_BR');
70 $I->canSeeNumberOfElements('#typo3-language-list tbody tr', 1);
71 $I->seeElement('#language-pt_BR');
72 $I->see('Brazilian Portuguese');
73 }
74
75 /**
76 * @param Admin $I
77 */
78 public function activateAndDeactivateALanguage(Admin $I)
79 {
80 $I->wantTo('Install a language');
81
82 $I->seeElement('#language-pt_BR');
83 $I->seeElement('#language-pt_BR.disabled');
84 $I->click('#language-pt_BR td a.activateLanguageLink');
85 $I->seeElement('#language-pt_BR.enabled');
86
87 $this->seeAlert($I, 'Success', 'Language was successfully activated.');
88
89 $I->click('#language-pt_BR td a.deactivateLanguageLink');
90 $I->seeElement('#language-pt_BR.disabled');
91
92 $this->seeAlert($I, 'Success', 'Language was successfully deactivated.');
93 }
94
95 /**
96 * @param Admin $I
97 */
98 public function downloadALanguage(Admin $I)
99 {
100 $I->wantTo('Download a language with no selection and see error message');
101
102 $I->click('a[data-action="updateActiveLanguages"]');
103 $this->seeAlert($I, 'Error', 'No language activated. Please activate at least one language.');
104
105 // Download only a single translation for a specific extension for performance reasons
106 $I->wantTo('Download a single translation for a selected language');
107
108 $I->seeElement('#language-pt_BR');
109 $I->seeElement('#language-pt_BR.disabled');
110 $I->click('#language-pt_BR td a.activateLanguageLink');
111
112 $I->selectOption('.t3-js-jumpMenuBox', 'Translation Overview');
113 $I->waitForElementVisible('#typo3-translation-list');
114 $I->click('#extension-beuser td a.updateTranslationLink');
115 $I->waitForElement('#extension-beuser td:nth-child(3).complete');
116 $this->seeAlert($I, 'Success', 'The translation update has been successfully completed.');
117 }
118
119 /**
120 * @param Admin $I
121 */
122 public function showsHeadingAndListsTranslationOverview(Admin $I)
123 {
124 $I->wantToTest('Select Translation Overview');
125 $I->selectOption('.t3-js-jumpMenuBox', 'Translation Overview');
126 $I->waitForElementVisible('#typo3-translation-list');
127 $I->see('Translation Overview');
128 }
129
130 /**
131 * @param Admin $I
132 */
133 public function filterTranslationOverview(Admin $I)
134 {
135 $I->wantToTest('Select Translation Overview and Filter');
136 $I->selectOption('.t3-js-jumpMenuBox', 'Translation Overview');
137 $I->waitForElementVisible('#typo3-translation-list');
138
139 $I->wantTo('Filter the list of translations with a valid Extension');
140 $I->fillField('#typo3-language-searchfield', 'TYPO3 Core');
141 $I->canSeeNumberOfElements('#typo3-translation-list tbody tr', 1);
142
143 $I->wantTo('Filter the list of translations with an invalid Extension');
144 $I->fillField('#typo3-language-searchfield', 'TYPO3 FooBar');
145 $I->canSeeNumberOfElements('#typo3-translation-list tbody tr', 1);
146 }
147
148 /**
149 * @param Admin $I
150 * @param string $alertTitle
151 * @param string $alertMessage
152 */
153 protected function seeAlert(Admin $I, $alertTitle, $alertMessage)
154 {
155 // switch back to body
156 $I->switchToIFrame();
157
158 $I->wait(1);
159 $I->waitForElement('//div[contains(@role, "alert")]', 2);
160 $I->see($alertTitle);
161 $I->see($alertMessage);
162
163 // switch to content iframe
164 $I->switchToIFrame('list_frame');
165 }
166 }