Skip to content

Commit

Permalink
Created e2e tests for dialogUpdate with invalid and valid activities
Browse files Browse the repository at this point in the history
  • Loading branch information
Fargekritt committed Sep 12, 2024
1 parent 8aee9ce commit 8015d7d
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tests/k6/tests/serviceowner/all-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -17,4 +18,5 @@ export default function() {
dialogCreateInvalidActionCount();
dialogCreatePatchDelete();
dialogSearch();
dialogUpdateActivity();
}
7 changes: 3 additions & 4 deletions tests/k6/tests/serviceowner/dialogCreateActivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
expectStatusFor,
postSO,
purgeSO,
uuidv4,
uuidv7,
setActivities,
addActivity
Expand All @@ -18,9 +17,9 @@ export default function () {
let dialog = dialogToInsert();
let activities = [{
'id': uuidv7(),
'type': 'dialogOpened',
'performedBy': {
'actorType': 'ServiceOwner'
'type': 'dialogopened',
'performedby': {
'actortype': 'serviceowner'
}
}]

Expand Down
115 changes: 115 additions & 0 deletions tests/k6/tests/serviceowner/dialogUpdateActivity.js
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);
})
})
}

0 comments on commit 8015d7d

Please sign in to comment.