|
@@ -0,0 +1,125 @@
|
|
|
+import Ember from 'ember';
|
|
|
+import { module, test } from 'qunit';
|
|
|
+import startApp from '../helpers/start-app';
|
|
|
+import getToastMessage from '../helpers/toast-message';
|
|
|
+
|
|
|
+var application;
|
|
|
+
|
|
|
+module('Acceptance: Application Error Handler', {
|
|
|
+ beforeEach: function() {
|
|
|
+ application = startApp();
|
|
|
+ },
|
|
|
+ afterEach: function() {
|
|
|
+ Ember.run(application, 'destroy');
|
|
|
+ Ember.$.mockjax.clear();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+test('some unhandled error occured', function(assert) {
|
|
|
+ assert.expect(1);
|
|
|
+
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/auth/login/',
|
|
|
+ status: 500
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/');
|
|
|
+
|
|
|
+ click('.guest-nav .btn-login');
|
|
|
+ fillIn('#loginModal .form-group:first-child input', 'SomeFake');
|
|
|
+ fillIn('#loginModal .form-group:last-child input', 'pass1234');
|
|
|
+ click('#loginModal .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(getToastMessage(), 'Unknown error has occured.');
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('app went away', function(assert) {
|
|
|
+ assert.expect(1);
|
|
|
+
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/auth/login/',
|
|
|
+ status: 0
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/');
|
|
|
+
|
|
|
+ click('.guest-nav .btn-login');
|
|
|
+ fillIn('#loginModal .form-group:first-child input', 'SomeFake');
|
|
|
+ fillIn('#loginModal .form-group:last-child input', 'pass1234');
|
|
|
+ click('#loginModal .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(getToastMessage(), 'Lost connection with application.');
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('not found', function(assert) {
|
|
|
+ assert.expect(1);
|
|
|
+
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/auth/login/',
|
|
|
+ status: 404,
|
|
|
+ responseText: {
|
|
|
+ 'detail': 'Not found'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/');
|
|
|
+
|
|
|
+ click('.guest-nav .btn-login');
|
|
|
+ fillIn('#loginModal .form-group:first-child input', 'SomeFake');
|
|
|
+ fillIn('#loginModal .form-group:last-child input', 'pass1234');
|
|
|
+ click('#loginModal .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(getToastMessage(), 'Action link is invalid.');
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('permission denied', function(assert) {
|
|
|
+ assert.expect(1);
|
|
|
+
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/auth/login/',
|
|
|
+ status: 403,
|
|
|
+ responseText: {
|
|
|
+ 'detail': 'Permission denied'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/');
|
|
|
+
|
|
|
+ click('.guest-nav .btn-login');
|
|
|
+ fillIn('#loginModal .form-group:first-child input', 'SomeFake');
|
|
|
+ fillIn('#loginModal .form-group:last-child input', 'pass1234');
|
|
|
+ click('#loginModal .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(getToastMessage(), "You don't have permission to perform this action.");
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('permission denied with reason', function(assert) {
|
|
|
+ assert.expect(1);
|
|
|
+
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/auth/login/',
|
|
|
+ status: 403,
|
|
|
+ responseText: {
|
|
|
+ 'detail': 'Lorem ipsum dolor met.'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/');
|
|
|
+
|
|
|
+ click('.guest-nav .btn-login');
|
|
|
+ fillIn('#loginModal .form-group:first-child input', 'SomeFake');
|
|
|
+ fillIn('#loginModal .form-group:last-child input', 'pass1234');
|
|
|
+ click('#loginModal .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(getToastMessage(), 'Lorem ipsum dolor met.');
|
|
|
+ });
|
|
|
+});
|