-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created e2e tests for dialogUpdate with invalid and valid activities
- Loading branch information
1 parent
8aee9ce
commit 8015d7d
Showing
3 changed files
with
120 additions
and
4 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 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 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,115 @@ | ||
import { | ||
describe, | ||
expect, | ||
expectStatusFor, | ||
postSO, | ||
putSO, | ||
purgeSO, | ||
uuidv7, | ||
setActivities, | ||
addActivity, | ||
setTitle | ||
} from '../../common/testimports.js' | ||
import {default as dialogToInsert} from './testdata/01-create-dialog.js'; | ||
|
||
export default function () { | ||
let dialogIds = []; | ||
let dialogs = []; | ||
let currentDialog = 0; | ||
let dialogAmount = 4; | ||
describe('Arrange: Create some dialogs to test against', () => { | ||
|
||
|
||
for (let i = 0; i < dialogAmount; i++) { | ||
let d = dialogToInsert(); | ||
setTitle(d, "e2e-test-dialog #" + (i + 1), "nn_NO"); | ||
setActivities(d); | ||
let r = postSO('dialogs', d); | ||
expectStatusFor(r).to.equal(201); | ||
dialogs.push(d) | ||
dialogIds.push(r.json()); | ||
} | ||
|
||
}) | ||
|
||
describe('Update dialog with invalid transmissionOpened activity', () => { | ||
let dialog = dialogs[currentDialog]; | ||
dialog.id = dialogIds[currentDialog]; | ||
currentDialog++; | ||
let activities = [{ | ||
'id': uuidv7(), | ||
'type': 'transmissionOpened', | ||
'performedBy': { | ||
'actorType': 'ServiceOwner' | ||
} | ||
}] | ||
setActivities(dialog, activities); | ||
|
||
let response = putSO('dialogs/' + dialog.id, dialog); | ||
expectStatusFor(response).to.equal(400); | ||
}) | ||
|
||
|
||
describe('Update dialog with invalid dialogOpened activity', () => { | ||
let dialog = dialogs[currentDialog]; | ||
dialog.id = dialogIds[currentDialog]; | ||
currentDialog++; | ||
let transmissionId = uuidv7(); | ||
dialog.transmissionId = transmissionId; | ||
let activities = [{ | ||
'id': uuidv7(), | ||
'type': 'dialogOpened', | ||
'transmissionId': transmissionId, | ||
'performedBy': { | ||
'actorType': 'ServiceOwner' | ||
} | ||
}] | ||
setActivities(dialog, activities); | ||
|
||
let response = putSO('dialogs/' + dialog.id, dialog); | ||
expectStatusFor(response).to.equal(400); | ||
}) | ||
|
||
describe('Update dialog with transmissionOpened activity', () => { | ||
let dialog = dialogs[currentDialog]; | ||
dialog.id = dialogIds[currentDialog]; | ||
currentDialog++; | ||
let transmissionId = uuidv7(); | ||
dialog.transmissions[0].id = transmissionId; | ||
let activities = [{ | ||
'id': uuidv7(), | ||
'type': 'transmissionOpened', | ||
'transmissionId': transmissionId, | ||
'performedBy': { | ||
'actorType': 'ServiceOwner' | ||
} | ||
}] | ||
setActivities(dialog, activities); | ||
|
||
let response = putSO('dialogs/' + dialog.id, dialog); | ||
expectStatusFor(response).to.equal(204); | ||
}) | ||
|
||
describe('Update dialog with dialogOpened activity', () => { | ||
let dialog = dialogs[currentDialog]; | ||
dialog.id = dialogIds[currentDialog]; | ||
currentDialog++; | ||
let activities = [{ | ||
'id': uuidv7(), | ||
'type': 'dialogOpened', | ||
'performedBy': { | ||
'actorType': 'ServiceOwner' | ||
} | ||
}] | ||
setActivities(dialog, activities); | ||
|
||
let response = putSO('dialogs/' + dialog.id, dialog); | ||
expectStatusFor(response).to.equal(204); | ||
}) | ||
describe('Cleanup', () => { | ||
dialogIds.forEach((d) => { | ||
let r = purgeSO('dialogs/' + d); | ||
expectStatusFor(r).to.equal(204); | ||
}) | ||
}) | ||
} |