discourse/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6

63 lines
2.0 KiB
Plaintext
Raw Normal View History

module("Acceptance: wizard");
2016-08-26 01:14:56 +08:00
test("Wizard starts", assert => {
visit("/");
andThen(() => {
assert.ok(exists('.wizard-column-contents'));
2016-08-26 01:14:56 +08:00
assert.equal(currentPath(), 'step');
});
});
2016-09-02 23:42:14 +08:00
test("Going back and forth in steps", assert => {
2016-08-26 01:14:56 +08:00
visit("/step/hello-world");
andThen(() => {
assert.ok(exists('.wizard-step'));
assert.ok(exists('.wizard-step-hello-world'), 'it adds a class for the step id');
assert.ok(exists('.wizard-progress'));
assert.ok(exists('.wizard-step-title'));
assert.ok(exists('.wizard-step-description'));
assert.ok(!exists('.invalid .field-full-name'), "don't show it as invalid until the user does something");
assert.ok(exists('.wizard-field .field-description'));
2016-08-26 01:14:56 +08:00
assert.ok(!exists('.wizard-btn.back'));
assert.ok(!exists('.wizard-field .field-error-description'));
2016-08-26 01:14:56 +08:00
});
// invalid data
click('.wizard-btn.next');
andThen(() => {
assert.ok(exists('.invalid .field-full-name'));
});
// server validation fail
fillIn('input.field-full-name', "Server Fail");
click('.wizard-btn.next');
andThen(() => {
assert.ok(exists('.invalid .field-full-name'));
assert.ok(exists('.wizard-field .field-error-description'));
2016-08-26 01:14:56 +08:00
});
// server validation ok
fillIn('input.field-full-name', "Evil Trout");
click('.wizard-btn.next');
andThen(() => {
assert.ok(!exists('.wizard-field .field-error-description'));
2016-08-26 01:14:56 +08:00
assert.ok(!exists('.wizard-step-title'));
assert.ok(!exists('.wizard-step-description'));
2016-09-02 23:42:14 +08:00
assert.ok(exists('select.field-snack'), "went to the next step");
assert.ok(exists('.preview-area'), "renders the component field");
2016-08-26 01:14:56 +08:00
assert.ok(!exists('.wizard-btn.next'));
assert.ok(exists('.wizard-btn.done'), 'last step shows a done button');
2016-08-26 01:14:56 +08:00
assert.ok(exists('.wizard-btn.back'), 'shows the back button');
});
click('.wizard-btn.back');
andThen(() => {
assert.ok(exists('.wizard-step-title'));
assert.ok(exists('.wizard-btn.next'));
assert.ok(!exists('.wizard-prev'));
});
});