Skip to content

Commit

Permalink
Moved e2e test to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
Fargekritt committed Sep 12, 2024
1 parent d715f99 commit 8aee9ce
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 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 @@ -2,6 +2,7 @@
import { default as authentication } from './authentication.js';
import { default as authorization } from './authorization.js';
import { default as concurrency } from './concurrency.js';
import { default as dialogCreateActivity } from './dialogCreateActivity.js';
import { default as dialogCreateExternalResource } from './dialogCreateExternalResource.js';
import { default as dialogCreateInvalidActionCount } from './dialogCreateInvalidActionCount.js';
import { default as dialogCreatePatchDelete } from './dialogCreatePatchDelete.js';
Expand All @@ -11,6 +12,7 @@ export default function() {
authentication();
authorization();
concurrency();
dialogCreateActivity();
dialogCreateExternalResource();
dialogCreateInvalidActionCount();
dialogCreatePatchDelete();
Expand Down
120 changes: 120 additions & 0 deletions tests/k6/tests/serviceowner/dialogCreateActivity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import {
describe,
expect,
expectStatusFor,
postSO,
purgeSO,
uuidv4,
uuidv7,
setActivities,
addActivity
} from '../../common/testimports.js'
import {default as dialogToInsert} from './testdata/01-create-dialog.js';

export default function () {
let dialogIds = [];
describe('Perform dialog create with activity type (dialogOpened)', () => {
// Setup
let dialog = dialogToInsert();
let activities = [{
'id': uuidv7(),
'type': 'dialogOpened',
'performedBy': {
'actorType': 'ServiceOwner'
}
}]

setActivities(dialog, activities);

// Act
let r = postSO('dialogs', dialog);

// Assert
expectStatusFor(r).to.equal(201);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
dialogIds.push(r.json());
});

describe('Perform dialog create with invalid activity type (transmissionOpened)', () => {
// Setup
let dialog = dialogToInsert();
let activities = [{
'id': uuidv7(),
'type': 'transmissionOpened',
'performedBy': {
'actorType': 'ServiceOwner'
}
}]

setActivities(dialog, activities);

// Act
let r = postSO('dialogs', dialog);

// Assert
expectStatusFor(r).to.equal(400);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.have.property('errors');
});


describe('Perform dialog create with activity type (transmissionOpened)', () => {
// Setup
let dialog = dialogToInsert();
let transmissionId = uuidv7();
dialog.transmissions[0].id = transmissionId;

let activities = [{
'id': uuidv7(),
'type': 'transmissionOpened',
'transmissionId': transmissionId,
'performedBy': {
'actorType': 'ServiceOwner'
}
}]

setActivities(dialog, activities);

// Act
let r = postSO('dialogs', dialog);

// Assert
expectStatusFor(r).to.equal(201);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
dialogIds.push(r.json());
});
describe('Perform dialog create with invalid activity type (dialogOpened)', () => {
// Setup
let dialog = dialogToInsert();
let transmissionId = uuidv7();
dialog.transmissions[0].id = transmissionId;

let activities = [{
'id': uuidv7(),
'type': 'DialogOpened',
'transmissionId': transmissionId,
'performedBy': {
'actorType': 'ServiceOwner'
}
}]

setActivities(dialog, activities);

// Act
let r = postSO('dialogs', dialog);

// Assert
expectStatusFor(r).to.equal(400);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.have.property('errors');
});

describe('Purge dialogs', () => {
dialogIds.forEach((d) => {
let r = purgeSO("dialogs/" + d);
expect(r.status, 'response status').to.equal(204);
});
})
}

0 comments on commit 8aee9ce

Please sign in to comment.