Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/submissions/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default class SubmissionsNew extends Controller {

if (result.value) {
ignoreList.clearIgnore();
if (submission.id) {
if (submission.id && submission.isDraft) {
await this.submissionHandler.deleteSubmission(submission);
ignoreList.ignore(submission.id);
}
Expand Down
3 changes: 2 additions & 1 deletion app/util/paginated-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export function grantsIndexSubmissionQuery(user: UserLike) {
filter: {
submission: `submissionStatus=out=cancelled;(${userMatch})`,
},
include: 'grants',
// grants are already cached from the first query — relationship linkage
// data in the response is sufficient for WarpDrive to resolve them
};
}

Expand Down
41 changes: 41 additions & 0 deletions tests/unit/controllers/submissions/new-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ module('Unit | Controller | submissions/new', (hooks) => {

const submission = {
id: 'sub:0',
isDraft: true,
};

const model = {
Expand Down Expand Up @@ -331,4 +332,44 @@ module('Unit | Controller | submissions/new', (hooks) => {
controller.send('abort');
swalStub.restore();
});

test('abort on a proxy submission should not delete non-draft submission but should still transition', async function (assert) {
assert.expect(3);

const submission = {
id: 'sub:0',
isDraft: false,
};

const model = {
newSubmission: submission,
};

controller.model = model as unknown as typeof controller.model;

const swalStub = Sinon.stub(Swal, 'fire').callsFake(() => {
assert.ok(true, 'swal dialog was shown');
return Promise.resolve({
value: 'moo',
});
});

let deleteSubmissionCalled = false;

controller.submissionHandler = {
deleteSubmission(_sub: unknown) {
deleteSubmissionCalled = true;
return Promise.resolve();
},
} as unknown as typeof controller.submissionHandler;
controller.router = {
transitionTo: (name: string) => {
assert.false(deleteSubmissionCalled, 'deleteSubmission should not be called for non-draft');
assert.strictEqual(name, 'submissions', 'should transition to submissions');
},
} as typeof controller.router;

controller.send('abort');
swalStub.restore();
});
});
Loading