diff --git a/tests/k6/tests/serviceowner/all-tests.js b/tests/k6/tests/serviceowner/all-tests.js index 33ded10ca..354216354 100644 --- a/tests/k6/tests/serviceowner/all-tests.js +++ b/tests/k6/tests/serviceowner/all-tests.js @@ -7,6 +7,7 @@ import { default as dialogCreateExternalResource } from './dialogCreateExternalR import { default as dialogCreateInvalidActionCount } from './dialogCreateInvalidActionCount.js'; import { default as dialogCreatePatchDelete } from './dialogCreatePatchDelete.js'; import { default as dialogSearch } from './dialogSearch.js'; +import { default as dialogUpdateActivity } from './dialogUpdateActivity.js'; export default function() { authentication(); @@ -17,4 +18,5 @@ export default function() { dialogCreateInvalidActionCount(); dialogCreatePatchDelete(); dialogSearch(); + dialogUpdateActivity(); } diff --git a/tests/k6/tests/serviceowner/dialogCreateActivity.js b/tests/k6/tests/serviceowner/dialogCreateActivity.js index b7d4ec41f..950e3d95e 100644 --- a/tests/k6/tests/serviceowner/dialogCreateActivity.js +++ b/tests/k6/tests/serviceowner/dialogCreateActivity.js @@ -4,7 +4,6 @@ import { expectStatusFor, postSO, purgeSO, - uuidv4, uuidv7, setActivities, addActivity @@ -18,9 +17,9 @@ export default function () { let dialog = dialogToInsert(); let activities = [{ 'id': uuidv7(), - 'type': 'dialogOpened', - 'performedBy': { - 'actorType': 'ServiceOwner' + 'type': 'dialogopened', + 'performedby': { + 'actortype': 'serviceowner' } }] diff --git a/tests/k6/tests/serviceowner/dialogUpdateActivity.js b/tests/k6/tests/serviceowner/dialogUpdateActivity.js new file mode 100644 index 000000000..98dc608df --- /dev/null +++ b/tests/k6/tests/serviceowner/dialogUpdateActivity.js @@ -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); + }) + }) +}