mirror of
https://github.com/opensupports/opensupports.git
synced 2025-04-08 18:35:06 +02:00
features #340
This commit is contained in:
parent
e855966561
commit
b4dc92b8f1
@ -86,7 +86,7 @@ class TicketViewer extends React.Component {
|
||||
|
||||
renderEditableHeaders() {
|
||||
const ticket = this.props.ticket;
|
||||
const departments = SessionStore.getDepartments();
|
||||
const departments = (this.props.ticket.author.staff ? SessionStore.getDepartments() : this.getPublicDepartments() );
|
||||
|
||||
const priorities = {
|
||||
'low': 0,
|
||||
@ -302,14 +302,7 @@ class TicketViewer extends React.Component {
|
||||
};
|
||||
}
|
||||
getPublicDepartments() {
|
||||
var publicdepartments = Session.Store.getDepartments().map((department) => {
|
||||
if(department.private*1){
|
||||
null;
|
||||
}else {
|
||||
department.name;
|
||||
}
|
||||
});
|
||||
return publicdepartments;
|
||||
return _.filter(SessionStore.getDepartments(),d => !(d.private*1));
|
||||
}
|
||||
|
||||
onDepartmentDropdownChanged(event) {
|
||||
|
@ -17,9 +17,9 @@ describe'/staff/get-all' do
|
||||
(result['data'][0]['departments'][0]['id']).should.equal('1')
|
||||
(result['data'][0]['departments'][0]['name']).should.equal('Help and Support')
|
||||
(result['data'][0]['departments'][1]['id']).should.equal('2')
|
||||
(result['data'][0]['departments'][1]['name']).should.equal('Suggestions')
|
||||
(result['data'][0]['departments'][1]['name']).should.equal('useless private deapartment')
|
||||
(result['data'][0]['departments'][2]['id']).should.equal('3')
|
||||
(result['data'][0]['departments'][2]['name']).should.equal('Tech support')
|
||||
(result['data'][0]['departments'][2]['name']).should.equal('Suggestions')
|
||||
(result['data'][0]['assignedTickets']).should.equal(6)
|
||||
(result['data'][0]['closedTickets']).should.equal(0)
|
||||
|
||||
|
@ -13,7 +13,8 @@ describe'system/add-department' do
|
||||
|
||||
row = $database.getRow('department', 4, 'id')
|
||||
|
||||
(row['name']).should.equal('new department')
|
||||
(row['name']).should.equal('Tech support')
|
||||
(row['private']).should.equal("0")
|
||||
|
||||
lastLog = $database.getLastRow('log')
|
||||
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
||||
@ -30,7 +31,25 @@ describe'system/add-department' do
|
||||
|
||||
row = $database.getRow('department', 5, 'id')
|
||||
|
||||
(row['name']).should.equal('<b>new department</b>')
|
||||
(row['name']).should.equal('new department')
|
||||
(row['private']).should.equal("0")
|
||||
|
||||
lastLog = $database.getLastRow('log')
|
||||
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
||||
end
|
||||
|
||||
it 'should add a private department' do
|
||||
result = request('/system/add-department', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
name: 'a private department',
|
||||
private: 1
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
row = $database.getRow('department', 'a private department', 'name')
|
||||
(row['private']).should.equal('1')
|
||||
|
||||
lastLog = $database.getLastRow('log')
|
||||
(lastLog['type']).should.equal('ADD_DEPARTMENT')
|
||||
|
@ -17,4 +17,4 @@ describe '/system/get-settings' do
|
||||
(result['data']['allowedLanguages'][9]).should.equal('tr')
|
||||
(result['data']['supportedLanguages'][0]).should.equal('en')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ describe '/ticket/change-department' do
|
||||
|
||||
result = request('/ticket/change-department', {
|
||||
ticketNumber: ticket['ticket_number'],
|
||||
departmentId: 2,
|
||||
departmentId: 3,
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
@ -38,7 +38,7 @@ describe '/ticket/change-department' do
|
||||
|
||||
ticket = $database.getRow('ticket', 1 , 'id')
|
||||
(ticket['unread']).should.equal('1')
|
||||
(ticket['department_id']).should.equal('2')
|
||||
(ticket['department_id']).should.equal('3')
|
||||
(ticket['owner_id']).should.equal('1')
|
||||
|
||||
lastLog = $database.getLastRow('log')
|
||||
|
@ -78,8 +78,41 @@ describe '/ticket/create' do
|
||||
(result['message']).should.equal('INVALID_DEPARTMENT')
|
||||
|
||||
end
|
||||
it 'should fail if an user tries to create a ticket with a private department' do
|
||||
request('/user/logout')
|
||||
Scripts.login('staff@opensupports.com', 'staff', true)
|
||||
|
||||
result = request('/system/add-department', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
name: 'useless private deapartment',
|
||||
private: 1
|
||||
})
|
||||
|
||||
row = $database.getRow('department', 'useless private deapartment', 'name')
|
||||
|
||||
request('/user/logout')
|
||||
Scripts.createUser('user@os4.com', 'loginpass')
|
||||
Scripts.login('user@os4.com', 'loginpass')
|
||||
|
||||
result = request('/ticket/create', {
|
||||
title: 'Winter is here',
|
||||
content: 'The king in the north',
|
||||
departmentId: row['id'],
|
||||
language: 'en',
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('fail')
|
||||
(result['message']).should.equal('INVALID_DEPARTMENT')
|
||||
|
||||
request('/user/logout')
|
||||
end
|
||||
|
||||
it 'should create ticket if pass data is valid' do
|
||||
Scripts.login('creator@os4.com','creator')
|
||||
|
||||
result = request('/ticket/create', {
|
||||
title: 'Winter is coming',
|
||||
content: 'The north remembers',
|
||||
|
@ -97,22 +97,17 @@ describe 'Ticket Events' do
|
||||
(result['data']['events'][4]['author']['name']).should.equal('Emilia Clarke')
|
||||
(result['data']['events'][4]['author']['staff']).should.equal(true)
|
||||
|
||||
(result['data']['events'][5]['type']).should.equal('DEPARTMENT_CHANGED')
|
||||
(result['data']['events'][5]['content']).should.equal('Suggestions')
|
||||
(result['data']['events'][5]['type']).should.equal('CLOSE')
|
||||
(result['data']['events'][5]['author']['name']).should.equal('Emilia Clarke')
|
||||
(result['data']['events'][5]['author']['staff']).should.equal(true)
|
||||
|
||||
(result['data']['events'][6]['type']).should.equal('CLOSE')
|
||||
(result['data']['events'][6]['author']['name']).should.equal('Emilia Clarke')
|
||||
(result['data']['events'][6]['author']['staff']).should.equal(true)
|
||||
(result['data']['events'][6]['type']).should.equal('RE_OPEN')
|
||||
(result['data']['events'][6]['author']['name']).should.equal('Tyrion Lannister')
|
||||
(result['data']['events'][6]['author']['staff']).should.equal(false)
|
||||
|
||||
(result['data']['events'][7]['type']).should.equal('RE_OPEN')
|
||||
(result['data']['events'][7]['type']).should.equal('COMMENT')
|
||||
(result['data']['events'][7]['content']).should.equal('This is a comment made by a regular user')
|
||||
(result['data']['events'][7]['author']['name']).should.equal('Tyrion Lannister')
|
||||
(result['data']['events'][7]['author']['staff']).should.equal(false)
|
||||
|
||||
(result['data']['events'][8]['type']).should.equal('COMMENT')
|
||||
(result['data']['events'][8]['content']).should.equal('This is a comment made by a regular user')
|
||||
(result['data']['events'][8]['author']['name']).should.equal('Tyrion Lannister')
|
||||
(result['data']['events'][8]['author']['staff']).should.equal(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ describe '/user/get-users' do
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
(result['data']['users'].size).should.equal(6)
|
||||
(result['data']['users'].size).should.equal(7)
|
||||
end
|
||||
|
||||
it 'should get users with order by tickets and asc' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user