123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 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: Toasting Error Handler', {
- beforeEach: function() {
- application = startApp();
- },
- afterEach: function() {
- Ember.$('#appModal').off();
- Ember.$('body').removeClass('modal-open');
- Ember.run(application, 'destroy');
- Ember.$.mockjax.clear();
- }
- });
- test('some unhandled error occured', function(assert) {
- assert.expect(1);
- Ember.$.mockjax({
- url: '/api/auth/',
- status: 500
- });
- visit('/');
- click('.navbar-guest-nav button.btn-default');
- fillIn('#appModal .form-group:first-child input', 'SomeFake');
- fillIn('#appModal .form-group:last-child input', 'pass1234');
- click('#appModal .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/',
- status: 0
- });
- visit('/');
- click('.navbar-guest-nav button.btn-default');
- fillIn('#appModal .form-group:first-child input', 'SomeFake');
- fillIn('#appModal .form-group:last-child input', 'pass1234');
- click('#appModal .btn-primary');
- andThen(function() {
- assert.equal(getToastMessage(), 'Lost connection with application.');
- });
- });
- test('not found', function(assert) {
- assert.expect(1);
- Ember.$.mockjax({
- url: '/api/auth/',
- status: 404,
- responseText: {
- 'detail': 'Not found'
- }
- });
- visit('/');
- click('.navbar-guest-nav button.btn-default');
- fillIn('#appModal .form-group:first-child input', 'SomeFake');
- fillIn('#appModal .form-group:last-child input', 'pass1234');
- click('#appModal .btn-primary');
- andThen(function() {
- assert.equal(getToastMessage(), 'Action link is invalid.');
- });
- });
- test('permission denied', function(assert) {
- assert.expect(1);
- Ember.$.mockjax({
- url: '/api/auth/',
- status: 403,
- responseText: {
- 'detail': 'Permission denied'
- }
- });
- visit('/');
- click('.navbar-guest-nav button.btn-default');
- fillIn('#appModal .form-group:first-child input', 'SomeFake');
- fillIn('#appModal .form-group:last-child input', 'pass1234');
- click('#appModal .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/',
- status: 403,
- responseText: {
- 'detail': 'Lorem ipsum dolor met.'
- }
- });
- visit('/');
- click('.navbar-guest-nav button.btn-default');
- fillIn('#appModal .form-group:first-child input', 'SomeFake');
- fillIn('#appModal .form-group:last-child input', 'pass1234');
- click('#appModal .btn-primary');
- andThen(function() {
- assert.equal(getToastMessage(), 'Lorem ipsum dolor met.');
- });
- });
|