select-kit refactoring

* better test helper
* more reliable tests
* more consistent use of data-value/data-name/title/aria-label everywhere: header and rows
This commit is contained in:
Joffrey JAFFEUX
2017-12-22 13:08:12 +01:00
committed by GitHub
parent 364e6fdd53
commit 315b9d796d
60 changed files with 827 additions and 641 deletions
@@ -13,15 +13,11 @@ QUnit.test("flagged posts", assert => {
});
QUnit.test("flagged posts - agree", assert => {
const agreeFlag = selectKit('.agree-flag');
visit("/admin/flags/active");
andThen(() => {
expandSelectKit('.agree-flag');
});
andThen(() => {
selectKitSelectRow('confirm-agree-keep', { selector: '.agree-flag'});
});
agreeFlag.expand().selectRowByValue('confirm-agree-keep');
andThen(() => {
assert.equal(find('.admin-flags .flagged-post').length, 0, 'post was removed');
@@ -29,15 +25,11 @@ QUnit.test("flagged posts - agree", assert => {
});
QUnit.test("flagged posts - agree + hide", assert => {
const agreeFlag = selectKit('.agree-flag');
visit("/admin/flags/active");
andThen(() => {
expandSelectKit('.agree-flag');
});
andThen(() => {
selectKitSelectRow('confirm-agree-hide', { selector: '.agree-flag'});
});
agreeFlag.expand().selectRowByValue('confirm-agree-hide');
andThen(() => {
assert.equal(find('.admin-flags .flagged-post').length, 0, 'post was removed');
@@ -45,15 +37,11 @@ QUnit.test("flagged posts - agree + hide", assert => {
});
QUnit.test("flagged posts - agree + deleteSpammer", assert => {
const agreeFlag = selectKit('.agree-flag');
visit("/admin/flags/active");
andThen(() => {
expandSelectKit('.agree-flag');
});
andThen(() => {
selectKitSelectRow('delete-spammer', { selector: '.agree-flag'});
});
agreeFlag.expand().selectRowByValue('delete-spammer');
click('.confirm-delete');
@@ -79,15 +67,11 @@ QUnit.test("flagged posts - defer", assert => {
});
QUnit.test("flagged posts - delete + defer", assert => {
const deleteFlag = selectKit('.delete-flag');
visit("/admin/flags/active");
andThen(() => {
expandSelectKit('.delete-flag');
});
andThen(() => {
selectKitSelectRow('delete-defer', { selector: '.delete-flag'});
});
deleteFlag.expand().selectRowByValue('delete-defer');
andThen(() => {
assert.equal(find('.admin-flags .flagged-post').length, 0);
@@ -95,15 +79,11 @@ QUnit.test("flagged posts - delete + defer", assert => {
});
QUnit.test("flagged posts - delete + agree", assert => {
const deleteFlag = selectKit('.delete-flag');
visit("/admin/flags/active");
andThen(() => {
expandSelectKit('.delete-flag');
});
andThen(() => {
selectKitSelectRow('delete-agree', { selector: '.delete-flag'});
});
deleteFlag.expand().selectRowByValue('delete-agree');
andThen(() => {
assert.equal(find('.admin-flags .flagged-post').length, 0);
@@ -111,15 +91,11 @@ QUnit.test("flagged posts - delete + agree", assert => {
});
QUnit.test("flagged posts - delete + deleteSpammer", assert => {
const deleteFlag = selectKit('.delete-flag');
visit("/admin/flags/active");
andThen(() => {
expandSelectKit('.delete-flag');
});
andThen(() => {
selectKitSelectRow('delete-spammer', { selector: '.delete-flag'});
});
deleteFlag.expand().selectRowByValue('delete-spammer');
click('.confirm-delete');
@@ -33,6 +33,10 @@ QUnit.test("suspend a user - cancel", assert => {
});
QUnit.test("suspend, then unsuspend a user", assert => {
const suspendUntilCombobox = selectKit('.suspend-until .combobox');
visit("/admin/flags/active");
visit("/admin/users/1234/regular");
andThen(() => {
@@ -43,11 +47,10 @@ QUnit.test("suspend, then unsuspend a user", assert => {
andThen(() => {
assert.equal(find('.perform-suspend[disabled]').length, 1, 'disabled by default');
expandSelectKit('.suspend-until .combobox');
selectKitSelectRow('tomorrow', { selector: '.suspend-until .combobox'});
});
suspendUntilCombobox.expand().selectRowByValue('tomorrow');
fillIn('.suspend-reason', "for breaking the rules");
fillIn('.suspend-message', "this is an email reason why");
andThen(() => {
@@ -1,27 +1,29 @@
import { acceptance } from "helpers/qunit-helpers";
import { acceptance } from 'helpers/qunit-helpers';
acceptance("CategoryChooser", {
acceptance('CategoryChooser', {
loggedIn: true,
settings: {
allow_uncategorized_topics: false
}
});
QUnit.test("does not display uncategorized if not allowed", assert => {
visit("/");
QUnit.test('does not display uncategorized if not allowed', assert => {
const categoryChooser = selectKit('.category-chooser');
visit('/');
click('#create-topic');
expandSelectKit('.category-chooser');
categoryChooser.expand();
andThen(() => {
assert.ok(selectKit('.category-chooser').rowByIndex(0).name() !== 'uncategorized');
assert.ok(categoryChooser.rowByIndex(0).name() !== 'uncategorized');
});
});
QUnit.test("prefill category when category_id is set", assert => {
visit("/new-topic?category_id=1");
QUnit.test('prefill category when category_id is set', assert => {
visit('/new-topic?category_id=1');
andThen(() => {
assert.equal(selectKit('.category-chooser').header.name(), 'bug');
assert.equal(selectKit('.category-chooser').header().value(), 1);
});
});
@@ -22,35 +22,38 @@ QUnit.test("default", assert => {
});
QUnit.test("removing a permission", assert => {
const availableGroups = selectKit(".available-groups");
visit("/c/bug");
click('.edit-category');
click('li.edit-category-security a');
click('.edit-category-tab-security .edit-permission');
expandSelectKit(".available-groups");
availableGroups.expand();
andThen(() => {
assert.notOk(exists(".available-groups .select-kit-row[data-value='everyone']"), 'everyone is already used and is not in the available groups');
assert.notOk(availableGroups.rowByValue('everyone').exists(), 'everyone is already used and is not in the available groups');
});
click('.edit-category-tab-security .permission-list li:first-of-type .remove-permission');
expandSelectKit(".available-groups");
availableGroups.expand();
andThen(() => {
assert.ok(exists(".available-groups .select-kit-row[data-value='everyone']"), 'everyone has been removed and appears in the available groups');
assert.ok(availableGroups.rowByValue('everyone').exists(), 'everyone has been removed and appears in the available groups');
});
});
QUnit.test("adding a permission", assert => {
const availableGroups = selectKit(".available-groups");
const permissionSelector = selectKit(".permission-selector");
visit("/c/bug");
click('.edit-category');
click('li.edit-category-security a');
click('.edit-category-tab-security .edit-permission');
expandSelectKit('.available-groups');
selectKitSelectRow('staff', { selector: '.available-groups' });
expandSelectKit('.permission-selector');
selectKitSelectRow('2', { selector: '.permission-selector' });
availableGroups.expand().selectRowByValue('staff');
permissionSelector.expand().selectRowByValue('2');
click('.edit-category-tab-security .add-permission');
andThen(() => {
@@ -65,21 +68,20 @@ QUnit.test("adding a permission", assert => {
});
QUnit.test("adding a previously removed permission", assert => {
const availableGroups = selectKit(".available-groups");
visit("/c/bug");
click('.edit-category');
click('li.edit-category-security a');
click('.edit-category-tab-security .edit-permission');
expandSelectKit(".available-groups");
click('.edit-category-tab-security .permission-list li:first-of-type .remove-permission');
andThen(() => {
assert.equal(find(".edit-category-tab-security .permission-list li").length, 0, 'it removes the permission from the list');
});
expandSelectKit('.available-groups');
selectKitSelectRow('everyone', { selector: '.available-groups' });
availableGroups.expand().selectRowByValue('everyone');
click('.edit-category-tab-security .add-permission');
andThen(() => {
@@ -59,6 +59,8 @@ QUnit.test("Error Saving", assert => {
});
QUnit.test("Subcategory list settings", assert => {
const categoryChooser = selectKit('.edit-category-tab-general .category-chooser');
visit("/c/bug");
click('.edit-category');
@@ -69,17 +71,15 @@ QUnit.test("Subcategory list settings", assert => {
});
click(".show-subcategory-list-field input[type=checkbox]");
andThen(() => {
assert.ok(visible(".subcategory-list-style-field"), "subcategory list style is shown if show subcategory list is checked");
});
click('.edit-category-general');
expandSelectKit('.edit-category-tab-general .category-chooser');
selectKitSelectRow(3, {selector: '.edit-category-tab-general .category-chooser'});
categoryChooser.expand().selectRowByValue(3);
click('.edit-category-settings');
andThen(() => {
assert.ok(!visible(".show-subcategory-list-field"), "show subcategory list isn't visible for child categories");
assert.ok(!visible(".subcategory-list-style-field"), "subcategory list style isn't visible for child categories");
@@ -262,8 +262,8 @@ QUnit.test("Composer can toggle between edit and reply", assert => {
QUnit.test("Composer can toggle between reply and createTopic", assert => {
visit("/t/this-is-a-test-topic/9");
click('.topic-post:eq(0) button.reply');
expandSelectKit('.toolbar-popup-menu-options');
selectKitSelectRow('toggleWhisper', { selector: '.toolbar-popup-menu-options'});
selectKit('.toolbar-popup-menu-options').expand().selectRowByValue('toggleWhisper');
andThen(() => {
assert.ok(
@@ -285,8 +285,7 @@ QUnit.test("Composer can toggle between reply and createTopic", assert => {
);
});
expandSelectKit('.toolbar-popup-menu-options');
selectKitSelectRow('toggleInvisible', { selector: '.toolbar-popup-menu-options'});
selectKit('.toolbar-popup-menu-options').expand().selectRowByValue('toggleInvisible');
andThen(() => {
assert.ok(
@@ -30,7 +30,7 @@ QUnit.test("update some fields", assert => {
savePreferences();
click(".preferences-nav .nav-notifications a");
selectDropdown('.control-group.notifications select.combobox', 1440);
selectKit('.control-group.notifications .combo-box.duration').expand().selectRowByValue(1440);
savePreferences();
click(".preferences-nav .nav-categories a");
@@ -72,4 +72,4 @@ QUnit.test("email", assert => {
andThen(() => {
assert.equal(find('.tip.bad').text().trim(), I18n.t('user.email.invalid'), 'it should display invalid email tip');
});
});
});
@@ -133,13 +133,13 @@ QUnit.test("update username through advanced search ui", assert => {
});
QUnit.test("update category through advanced search ui", assert => {
const categoryChooser = selectKit('.search-advanced-options .category-chooser');
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
expandSelectKit('.search-advanced-options .category-chooser');
selectKitFillInFilter('faq', { selector: '.search-advanced-options .category-chooser' });
selectKitSelectRow(4, { selector: '.search-advanced-options .category-chooser' });
categoryChooser.expand().fillInFilter('faq').selectRowByValue(4);
andThen(() => {
assert.ok(exists('.search-advanced-options .badge-category:contains("faq")'), 'has "faq" populated');
@@ -253,45 +253,47 @@ QUnit.test("update in:seen filter through advanced search ui", assert => {
});
QUnit.test("update in filter through advanced search ui", assert => {
const inSelector = selectKit('.search-advanced-options .select-kit#in');
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
expandSelectKit('.search-advanced-options .select-kit#in');
selectKitSelectRow('bookmarks', { selector: '.search-advanced-options .select-kit#in' });
fillIn('.search-advanced-options .select-kit#in', 'bookmarks');
inSelector.expand().selectRowByValue('bookmarks');
andThen(() => {
assert.ok(exists(selectKit('.search-advanced-options .select-kit#in').rowByName("I bookmarked").el), 'has "I bookmarked" populated');
assert.ok(inSelector.rowByName("I bookmarked").exists(), 'has "I bookmarked" populated');
assert.equal(find('.search input.full-page-search').val(), "none in:bookmarks", 'has updated search term to "none in:bookmarks"');
});
});
QUnit.test("update status through advanced search ui", assert => {
const statusSelector = selectKit('.search-advanced-options .select-kit#status');
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
expandSelectKit('.search-advanced-options .select-kit#status');
selectKitSelectRow('closed', { selector: '.search-advanced-options .select-kit#status' });
fillIn('.search-advanced-options .select-kit#status', 'closed');
statusSelector.expand().selectRowByValue('closed');
andThen(() => {
assert.ok(exists(selectKit('.search-advanced-options .select-kit#status').rowByName("are closed").el), 'has "are closed" populated');
assert.ok(statusSelector.rowByName("are closed").exists(), 'has "are closed" populated');
assert.equal(find('.search input.full-page-search').val(), "none status:closed", 'has updated search term to "none status:closed"');
});
});
QUnit.test("update post time through advanced search ui", assert => {
const postTimeSelector = selectKit('.search-advanced-options .select-kit#postTime');
visit("/search");
fillIn('.search input.full-page-search', 'none');
click('.search-advanced-btn');
fillIn('#search-post-date .date-picker', '2016-10-05');
expandSelectKit('.search-advanced-options .select-kit#postTime');
selectKitSelectRow('after', { selector: '.search-advanced-options .select-kit#postTime' });
fillIn('.search-advanced-options .select-kit#postTime', 'after');
postTimeSelector.expand().selectRowByValue('after');
andThen(() => {
assert.ok(exists(selectKit('.search-advanced-options .select-kit#postTime').rowByName("after").el), 'has "after" populated');
assert.ok(postTimeSelector.rowByName("after").exists(), 'has "after" populated');
assert.equal(find('.search input.full-page-search').val(), "none after:2016-10-05", 'has updated search term to "none after:2016-10-05"');
});
});
+26 -22
View File
@@ -87,22 +87,24 @@ QUnit.test("Search with context", assert => {
});
QUnit.test("Right filters are shown to anonymous users", assert => {
const inSelector = selectKit('.select-kit#in');
visit("/search?expanded=true");
expandSelectKit(".select-kit#in");
inSelector.expand();
andThen(() => {
assert.ok(exists('.select-kit#in .select-kit-row[data-value=first]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=pinned]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=unpinned]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=wiki]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=images]'));
assert.ok(inSelector.rowByValue('first').exists());
assert.ok(inSelector.rowByValue('pinned').exists());
assert.ok(inSelector.rowByValue('unpinned').exists());
assert.ok(inSelector.rowByValue('wiki').exists());
assert.ok(inSelector.rowByValue('images').exists());
assert.notOk(exists('.select-kit#in .select-kit-row[data-value=unseen]'));
assert.notOk(exists('.select-kit#in .select-kit-row[data-value=posted]'));
assert.notOk(exists('.select-kit#in .select-kit-row[data-value=watching]'));
assert.notOk(exists('.select-kit#in .select-kit-row[data-value=tracking]'));
assert.notOk(exists('.select-kit#in .select-kit-row[data-value=bookmarks]'));
assert.notOk(inSelector.rowByValue('unseen').exists());
assert.notOk(inSelector.rowByValue('posted').exists());
assert.notOk(inSelector.rowByValue('watching').exists());
assert.notOk(inSelector.rowByValue('tracking').exists());
assert.notOk(inSelector.rowByValue('bookmarks').exists());
assert.notOk(exists('.search-advanced-options .in-likes'));
assert.notOk(exists('.search-advanced-options .in-private'));
@@ -111,24 +113,26 @@ QUnit.test("Right filters are shown to anonymous users", assert => {
});
QUnit.test("Right filters are shown to logged-in users", assert => {
const inSelector = selectKit('.select-kit#in');
logIn();
Discourse.reset();
visit("/search?expanded=true");
expandSelectKit(".select-kit#in");
inSelector.expand();
andThen(() => {
assert.ok(exists('.select-kit#in .select-kit-row[data-value=first]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=pinned]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=unpinned]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=wiki]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=images]'));
assert.ok(inSelector.rowByValue('first').exists());
assert.ok(inSelector.rowByValue('pinned').exists());
assert.ok(inSelector.rowByValue('unpinned').exists());
assert.ok(inSelector.rowByValue('wiki').exists());
assert.ok(inSelector.rowByValue('images').exists());
assert.ok(exists('.select-kit#in .select-kit-row[data-value=unseen]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=posted]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=watching]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=tracking]'));
assert.ok(exists('.select-kit#in .select-kit-row[data-value=bookmarks]'));
assert.ok(inSelector.rowByValue('unseen').exists());
assert.ok(inSelector.rowByValue('posted').exists());
assert.ok(inSelector.rowByValue('watching').exists());
assert.ok(inSelector.rowByValue('tracking').exists());
assert.ok(inSelector.rowByValue('bookmarks').exists());
assert.ok(exists('.search-advanced-options .in-likes'));
assert.ok(exists('.search-advanced-options .in-private'));
@@ -2,32 +2,42 @@ import { acceptance } from 'helpers/qunit-helpers';
acceptance('Topic - Edit timer', { loggedIn: true });
QUnit.test('default', assert => {
const timerType = selectKit('.select-kit.timer-type');
const futureDateInputSelector = selectKit('.future-date-input-selector');
visit('/t/internationalization-localization');
click('.toggle-admin-menu');
click('.topic-admin-status-update button');
andThen(() => {
assert.equal(selectKit('.select-kit.timer-type').header.name(), 'Auto-Close Topic');
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().title(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().value(), null);
});
click('#private-topic-timer');
andThen(() => {
assert.equal(selectKit('.select-kit.timer-type').header.name(), 'Remind Me');
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
assert.equal(timerType.header().title(), 'Remind Me');
assert.equal(timerType.header().value(), 'reminder');
assert.equal(futureDateInputSelector.header().title(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().value(), null);
});
});
QUnit.test('autoclose - specific time', assert => {
const futureDateInputSelector = selectKit('.future-date-input-selector');
visit('/t/internationalization-localization');
click('.toggle-admin-menu');
click('.topic-admin-status-update button');
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('next_week', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('next_week');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Next week');
assert.equal(futureDateInputSelector.header().title(), 'Next week');
assert.equal(futureDateInputSelector.header().value(), 'next_week');
const regex = /will automatically close in/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
@@ -35,35 +45,44 @@ QUnit.test('autoclose - specific time', assert => {
});
QUnit.test('autoclose', assert => {
const futureDateInputSelector = selectKit('.future-date-input-selector');
visit('/t/internationalization-localization');
click('.toggle-admin-menu');
click('.topic-admin-status-update button');
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('next_week', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('next_week');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Next week');
assert.equal(futureDateInputSelector.header().title(), 'Next week');
assert.equal(futureDateInputSelector.header().value(), 'next_week');
const regex = /will automatically close in/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
});
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('pick_date_and_time', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('pick_date_and_time');
fillIn('.future-date-input .date-picker', '2099-11-24');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Pick date and time');
assert.equal(futureDateInputSelector.header().title(), 'Pick date and time');
assert.equal(futureDateInputSelector.header().value(), 'pick_date_and_time');
const regex = /will automatically close in/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
});
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('set_based_on_last_post', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('set_based_on_last_post');
fillIn('.future-date-input input[type=number]', '2');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Close based on last post');
assert.equal(futureDateInputSelector.header().title(), 'Close based on last post');
assert.equal(futureDateInputSelector.header().value(), 'set_based_on_last_post');
const regex = /This topic will close.*after the last reply/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
@@ -71,32 +90,39 @@ QUnit.test('autoclose', assert => {
});
QUnit.test('close temporarily', assert => {
const timerType = selectKit('.select-kit.timer-type');
const futureDateInputSelector = selectKit('.future-date-input-selector');
visit('/t/internationalization-localization');
click('.toggle-admin-menu');
click('.topic-admin-status-update button');
expandSelectKit('.select-kit.timer-type');
selectKitSelectRow('open', { selector: '.select-kit.timer-type' });
timerType.expand().selectRowByValue('open');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().title(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().value(), null);
});
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('next_week', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('next_week');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Next week');
assert.equal(futureDateInputSelector.header().title(), 'Next week');
assert.equal(futureDateInputSelector.header().value(), 'next_week');
const regex = /will automatically open in/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
});
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('pick_date_and_time', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('pick_date_and_time');
fillIn('.future-date-input .date-picker', '2099-11-24');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Pick date and time');
assert.equal(futureDateInputSelector.header().title(), 'Pick date and time');
assert.equal(futureDateInputSelector.header().value(), 'pick_date_and_time');
const regex = /will automatically open in/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
@@ -104,26 +130,32 @@ QUnit.test('close temporarily', assert => {
});
QUnit.test('schedule', assert => {
const timerType = selectKit('.select-kit.timer-type');
const categoryChooser = selectKit('.modal-body .category-chooser');
const futureDateInputSelector = selectKit('.future-date-input-selector');
visit('/t/internationalization-localization');
click('.toggle-admin-menu');
click('.topic-admin-status-update button');
expandSelectKit('.select-kit.timer-type');
selectKitSelectRow('publish_to_category', { selector: '.select-kit.timer-type' });
timerType.expand().selectRowByValue('publish_to_category');
andThen(() => {
assert.equal(selectKit('.modal-body .category-chooser').header.name(), 'uncategorized');
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
assert.equal(categoryChooser.header().title(), 'uncategorized');
assert.equal(categoryChooser.header().value(), null);
assert.equal(futureDateInputSelector.header().title(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().value(), null);
});
expandSelectKit('.modal-body .category-chooser');
selectKitSelectRow('7', { selector: '.modal-body .category-chooser' });
categoryChooser.expand().selectRowByValue('7');
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('next_week', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('next_week');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Next week');
assert.equal(futureDateInputSelector.header().title(), 'Next week');
assert.equal(futureDateInputSelector.header().value(), 'next_week');
const regex = /will be published to #dev/g;
const text = find('.future-date-input .topic-status-info').text().trim();
assert.ok(regex.test(text));
@@ -131,21 +163,26 @@ QUnit.test('schedule', assert => {
});
QUnit.test('auto delete', assert => {
const timerType = selectKit('.select-kit.timer-type');
const futureDateInputSelector = selectKit('.future-date-input-selector');
visit('/t/internationalization-localization');
click('.toggle-admin-menu');
click('.topic-admin-status-update button');
expandSelectKit('.select-kit.timer-type');
selectKitSelectRow('delete', { selector: '.select-kit.timer-type' });
timerType.expand().selectRowByValue('delete');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().title(), 'Select a timeframe');
assert.equal(futureDateInputSelector.header().value(), null);
});
expandSelectKit('.future-date-input-selector');
selectKitSelectRow('two_weeks', { selector: '.future-date-input-selector' });
futureDateInputSelector.expand().selectRowByValue('two_weeks');
andThen(() => {
assert.equal(selectKit('.future-date-input-selector').header.name(), 'Two Weeks');
assert.equal(futureDateInputSelector.header().title(), 'Two Weeks');
assert.equal(futureDateInputSelector.header().value(), 'two_weeks');
const regex = /will be automatically deleted/g;
const html = find('.future-date-input .topic-status-info').html().trim();
assert.ok(regex.test(html));
@@ -17,32 +17,24 @@ acceptance("Topic Notifications button", {
});
QUnit.test("Updating topic notification level", assert => {
visit("/t/internationalization-localization/280");
const notificationOptions = selectKit("#topic-footer-buttons .topic-notifications-options");
const notificationOptions = "#topic-footer-buttons .topic-notifications-options";
visit("/t/internationalization-localization/280");
andThen(() => {
assert.ok(
exists(`${notificationOptions}`),
notificationOptions.exists(),
"it should display the notification options button in the topic's footer"
);
});
expandSelectKit(notificationOptions);
selectKitSelectRow("3", { selector: notificationOptions});
notificationOptions.expand().selectRowByValue("3");
andThen(() => {
assert.equal(
selectKit(notificationOptions).selectedRow.name(),
"watching",
notificationOptions.selectedRow().name(),
"Watching",
"it should display the right notification level"
);
// This test is failing in headless mode
// assert.equal(
// find(`.timeline-footer-controls .select-kit-header`).data().name,
// 'Watching',
// 'it should display the right notification level in topic timeline'
// );
});
});
@@ -48,16 +48,13 @@ QUnit.test("Showing and hiding the edit controls", assert => {
});
QUnit.test("Updating the topic title and category", assert => {
const categoryChooser = selectKit('.title-wrapper .category-chooser');
visit("/t/internationalization-localization/280");
click('#topic-title .d-icon-pencil');
fillIn('#edit-title', 'this is the new title');
expandSelectKit('.title-wrapper .category-chooser');
selectKitSelectRow(4, {selector: '.title-wrapper .category-chooser'});
categoryChooser.expand().selectRowByValue(4);
click('#topic-title .submit-edit');
andThen(() => {
@@ -104,7 +101,7 @@ QUnit.test("Reply as new topic", assert => {
"it fills composer with the ring string"
);
assert.equal(
selectKit('.category-chooser').header.name(), "feature",
selectKit('.category-chooser').header().value(), "2",
"it fills category selector with the right category"
);
});