-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uncomment commented out ember integration tests
* adding an author * inviting an editor
- Loading branch information
Showing
12 changed files
with
230 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Ember from "ember"; | ||
import { module, test } from "qunit"; | ||
import startApp from "tahi/tests/helpers/start-app"; | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; | ||
|
||
TestHelper.mapFind = function(modelName, json) { | ||
let responseJson = {}; | ||
if ((/Task/).test(modelName)) { | ||
responseJson["tasks"] = json; | ||
} else { | ||
responseJson[Ember.String.pluralize(modelName)] = json; | ||
} | ||
return responseJson; | ||
}; | ||
|
||
|
||
let App, paper, phase, task; | ||
|
||
module("Integration: adding an author", { | ||
teardown() { | ||
Ember.run(function() { | ||
TestHelper.teardown(); | ||
App.destroy(); | ||
}); | ||
}, | ||
|
||
setup() { | ||
App = startApp(); | ||
TestHelper.setup(App); | ||
|
||
$.mockjax({url: "/api/admin/journals/authorization", status: 204}); | ||
$.mockjax({url: "/api/user_flows/authorization", status: 204}); | ||
$.mockjax({url: "/api/affiliations", status: 200, responseText: []}); | ||
|
||
phase = FactoryGuy.make("phase"); | ||
task = FactoryGuy.make("plos-authors-task", { phase: phase }); | ||
paper = FactoryGuy.make('paper', { phases: [phase], tasks: [task], editable: true }); | ||
} | ||
}); | ||
|
||
test("can add a new author", function(assert) { | ||
Ember.run(function() { | ||
let name = "James"; | ||
|
||
TestHelper.handleFind(task); | ||
TestHelper.handleCreate("plos-author"); | ||
|
||
visit(`/papers/${paper.id}/tasks/${task.id}`); | ||
click(".button-primary:contains('Add a New Author')"); | ||
fillIn(".author-name input:first", name); | ||
click(".author-contributions input:first"); | ||
click(".author-form-buttons .button-secondary:contains('done')"); | ||
|
||
andThen(function() { | ||
assert.ok(find(`.authors-overlay-item .author-name:contains('${name}')`).length); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import Ember from "ember"; | ||
import { module, test } from "qunit"; | ||
import startApp from "tahi/tests/helpers/start-app"; | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; | ||
|
||
|
||
TestHelper.mapFind = function(modelName, json) { | ||
let responseJson = {}; | ||
if ((/Task/).test(modelName)) { | ||
responseJson["tasks"] = json; | ||
} else { | ||
responseJson[Ember.String.pluralize(modelName)] = json; | ||
} | ||
return responseJson; | ||
}; | ||
|
||
let App, paper, phase, task, inviteeEmail; | ||
|
||
module("Integration: inviting an editor", { | ||
afterEach() { | ||
Ember.run(function() { | ||
TestHelper.teardown(); | ||
App.destroy(); | ||
}); | ||
}, | ||
|
||
beforeEach() { | ||
App = startApp(); | ||
TestHelper.setup(App); | ||
|
||
$.mockjax({url: "/api/admin/journals/authorization", status: 204}); | ||
$.mockjax({url: "/api/user_flows/authorization", status: 204}); | ||
$.mockjax({url: /\/api\/papers\/\d+\/manuscript_manager/, status: 204}); | ||
$.mockjax({url: "/api/formats", status: 200, responseText: { | ||
import_formats: [], | ||
export_formats: [] | ||
}}); | ||
|
||
inviteeEmail = window.currentUserData.user.email; | ||
$.mockjax({ | ||
url: /\/api\/filtered_users/, | ||
status: 200, | ||
contentType: "application/json", | ||
responseText: { | ||
filtered_users: [{ id: 1, full_name: "Aaron", email: inviteeEmail }] | ||
} | ||
}); | ||
|
||
phase = FactoryGuy.make("phase"); | ||
task = FactoryGuy.make("paper-editor-task", { phase: phase }); | ||
paper = FactoryGuy.make('paper', { phases: [phase], tasks: [task] }); | ||
TestHelper.handleFind(paper); | ||
} | ||
}); | ||
|
||
test("displays the email of the invitee", function(assert) { | ||
Ember.run(function() { | ||
TestHelper.handleFind(task); | ||
visit(`/papers/${paper.id}/workflow`); | ||
click("#manuscript-manager .card-content:contains('Assign Editors')"); | ||
pickFromSelect2(".overlay-main-work", inviteeEmail); | ||
|
||
TestHelper.handleCreate("invitation").andReturn({state: "invited"}); | ||
|
||
click(".invite-editor-button"); | ||
|
||
andThen(function() { | ||
assert.ok(find(`.overlay-main-work:contains('${inviteeEmail} has been invited to be Editor on this manuscript.')`)); | ||
}); | ||
}); | ||
}); | ||
|
||
test("can withdraw the invitation", function(assert) { | ||
Ember.run(function() { | ||
let invitation = FactoryGuy.make("invitation", {email: "[email protected]", state: "invited"}); | ||
task.set("invitation", invitation); | ||
TestHelper.handleFind(task); | ||
|
||
visit(`/papers/${paper.id}/workflow`); | ||
click("#manuscript-manager .card-content:contains('Assign Editors')"); | ||
|
||
andThen(function() { | ||
let msgEl = find(".invite-editor-text:contains('[email protected] has been invited to be Editor on this manuscript.')"); | ||
assert.ok(msgEl[0] !== undefined, "has pending invitation"); | ||
|
||
TestHelper.handleDelete("invitation", invitation.id); | ||
click(".button-primary:contains('Withdraw invitation')"); | ||
|
||
andThen(function() { | ||
assert.equal(task.get('invitation'), null); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define("invitation", { | ||
default: { | ||
state: "invited", | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define("journal", { | ||
sequences: { | ||
journalName: function(num) { | ||
return `PLOS Yeti ${num}`; | ||
} | ||
}, | ||
|
||
default: { | ||
name: FactoryGuy.generate("journalName"), | ||
paperTypes: ["Research"] | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define('paper-editor-task', { | ||
default: { | ||
title: 'Assign Editors', | ||
type: 'PaperEditorTask', | ||
completed: false, | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define("paper", { | ||
default: { | ||
journal: FactoryGuy.belongsTo("journal"), | ||
|
||
title: '', | ||
shortTitle: '', | ||
submitted: false, | ||
roles: [], | ||
relatedAtDate: "2014-09-28T13:54:58.028Z", | ||
editable: true, | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define("phase", { | ||
default: { | ||
position: 1, | ||
name: "Assign Editor", | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define("plos-author", { | ||
default: { | ||
paper: FactoryGuy.belongsTo("paper"), | ||
plos_authors_task: FactoryGuy.belongsTo("plos-authors-task"), | ||
|
||
first_name: "Adam", | ||
position: 1, | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import FactoryGuy from "ember-data-factory-guy"; | ||
|
||
FactoryGuy.define('plos-authors-task', { | ||
default: { | ||
title: 'Assign Editors', | ||
type: 'PlosAuthorsTask', | ||
completed: false, | ||
} | ||
}); |