<commit_before>import Ember from 'ember';
import {module, test} from 'qunit';
import startApp from '../../helpers/start-app';
import { stubRequest } from '../../helpers/fake-server';
var application;

let claimUrls = ['/claims/user', '/claims/account', '/claims/app', '/claims/database'];

module('Acceptance: WelcomeFirstApp', {
  beforeEach: function() {
    application = startApp();
    claimUrls.forEach((claimUrl) => {
      stubRequest('post', claimUrl, function() {
        return [204, {}, ''];
      });
    });
  },
  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

test('visiting /welcome/first-app when not logged in', function(assert) {
  visit('/welcome/1/first-app');

  andThen(function() {
    assert.equal(currentPath(), 'login');
  });
});

test('visiting /welcome/first-app logged in with stacks', function(assert) {
  stubStacks();
  stubRequest('get', '/billing_details/1', (request) => request.notFound());
  stubOrganizations();
  stubOrganization();
  signInAndVisit('/welcome/first-app');

  andThen(function() {
    assert.equal(currentPath(), 'dashboard.catch-redirects.stack.apps.index');
  });
});

test('submitting a first app directs to payment info', function(assert) {
  var appHandle = 'my-app';

  stubRequest('get', '/billing_details/1', (request) => request.notFound());
  stubStacks({}, []);
  stubOrganizations();
  signInAndVisit('/welcome/1/first-app');

  fillIn('input[name="app-handle"]', appHandle);

  click('button:contains(Get Started)');
  andThen(function() {
    assert.equal(currentPath(), 'welcome.payment-info', 'redirected to payment info');
  });
});
<commit_msg>improve and fix test<commit_after>import Ember from 'ember';
import {module, test} from 'qunit';
import startApp from '../../helpers/start-app';
import { stubRequest } from '../../helpers/fake-server';
var application;

let claimUrls = ['/claims/user', '/claims/account', '/claims/app', '/claims/database'];

module('Acceptance: WelcomeFirstApp', {
  beforeEach: function() {
    application = startApp();
    claimUrls.forEach((claimUrl) => {
      stubRequest('post', claimUrl, function() {
        return [204, {}, ''];
      });
    });
  },
  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

test('visiting /welcome/first-app when not logged in', function(assert) {
  visit('/welcome/1/first-app');

  andThen(function() {
    assert.equal(currentPath(), 'login');
  });
});

test('visiting /welcome/1/first-app logged in with no billing detail', function(assert) {
  stubStacks();
  stubRequest('get', '/billing_details/1', (request) => request.notFound());
  stubOrganizations();
  stubOrganization();
  signInAndVisit('/welcome/1/first-app');

  andThen(function() {
    assert.equal(currentPath(), 'welcome.first-app', 'remain on welcome page');
  });
});

test('visiting /welcome/1/first-app logged in with billing detail and stacks redirects to stacks', function(assert) {
  stubStacks();
  stubBillingDetail({ id: 1 });
  stubOrganizations();
  stubOrganization();
  signInAndVisit('/welcome/1/first-app');

  andThen(function() {
    assert.equal(currentPath(), 'dashboard.catch-redirects.stack.apps.index', 'remain on welcome page');
  });
});

test('submitting a first app directs to payment info', function(assert) {
  var appHandle = 'my-app';

  stubRequest('get', '/billing_details/1', (request) => request.notFound());
  stubStacks({}, []);
  stubOrganizations();
  signInAndVisit('/welcome/1/first-app');

  fillIn('input[name="app-handle"]', appHandle);

  click('button:contains(Get Started)');
  andThen(function() {
    assert.equal(currentPath(), 'welcome.payment-info', 'redirected to payment info');
  });
});

{'fraction_non_alphanumeric': 0.19104155423637345, 'fraction_numerical': 0.005126821370750135, 'mean_word_length': 4.524590163934426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1679260', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1180, 'n_words': 236}