Skip to content

Commit

Permalink
label assignment e2e mostly complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Amund Myrbostad committed Sep 27, 2024
1 parent ac8a9aa commit d4ef702
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public SearchDialogLabelAssigmentLogEndpoint(ISender sender)
}
public override void Configure()
{
Get("dialogs/{dialogId}/labels");
Get("dialogs/{dialogId}/labellog");
Policies(AuthorizationPolicy.EndUser);
Group<EndUserGroup>();

Expand Down
1 change: 1 addition & 0 deletions tests/k6/common/testimports.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export { customConsole } from './console.js';
export { getServiceOwnerTokenFromGenerator, getEnduserTokenFromGenerator } from './token.js';
export {
getEU,
postEU,
getSO,
postSO,
postSOAsync,
Expand Down
4 changes: 2 additions & 2 deletions tests/k6/tests/enduser/all-tests.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated, see "scripts" directory
import { default as dialogDetails } from './dialogDetails.js';
import { default as dialogSearch } from './dialogSearch.js';
import { default as dialogSystemLabel } from './dialogSystemLabel.js';
import { default as dialogSystemLabelLog } from './dialogSystemLabelLog.js';
import { default as parties } from './parties.js';

export default function() {
dialogDetails();
dialogSearch();
dialogSystemLabel();
dialogSystemLabelLog();
parties();
}
10 changes: 0 additions & 10 deletions tests/k6/tests/enduser/dialogSystemLabel.js

This file was deleted.

62 changes: 62 additions & 0 deletions tests/k6/tests/enduser/dialogSystemLabelLog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
describe, expect, expectStatusFor, getEU, postEU, postSO, putSO, purgeSO, uuidv7
} from '../../common/testimports.js'

import {default as dialogToInsert} from '../serviceowner/testdata/01-create-dialog.js';
import {getDefaultEnduserOrgNo, getDefaultEnduserSsn} from '../../common/token.js';

export default function () {
//Lag 1 dialog, gjør forandriger på den, sjekk om det er log
let dialogId;
let dialog;
describe('Arrange: Create a dialog to test against', () => {
let d = dialogToInsert();
let r = postSO("dialogs", d);
expectStatusFor(r).to.equal(201);
dialogId = r.json();
dialog = d;
});

describe('Update label as enduser', () => {
let body = {
'label': 'systemlabel:Bin'
}
let response = postEU('dialogs/' + dialogId + '/labels', body);
expectStatusFor(response).to.equal(204);
response = getEU('dialogs/' + dialogId + '/labellog');
expectStatusFor(response).to.equal(200);
expect(response, 'response').to.have.validJsonBody();
console.log(response.json());
expect(response.json(), 'response body').to.have.lengthOf(1);
});

describe('Changing labels trigger 2 logs', () => {

let body = {
'label': 'systemlabel:Archive'
}
let response = postEU('dialogs/' + dialogId + '/labels', body);
expectStatusFor(response).to.equal(204);
response = getEU('dialogs/' + dialogId + '/labellog');
expectStatusFor(response).to.equal(200);
expect(response, 'response').to.have.validJsonBody();
console.log(response.json());
expect(response.json(), 'response body').to.have.lengthOf(3);
})

describe('Dialog update set system label to default', () => {
dialog.progress ="60";
let response = putSO('dialogs/' + dialogId,dialog);
expectStatusFor(response).to.equal(204);
response = getEU('dialogs/' + dialogId + '/labellog');
expectStatusFor(response).to.equal(200);
expect(response, 'response').to.have.validJsonBody();
console.log(response.json());
expect(response.json(), 'response body').to.have.lengthOf(4);
})

describe('Cleanup', () => {
let response = purgeSO("dialogs/" + dialogId);
expectStatusFor(response).to.equal(204);
})
}

0 comments on commit d4ef702

Please sign in to comment.