Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 161 additions & 2 deletions tests/e2e/specs/pattern/Inquiry.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,141 @@ const getMessages = () => {
});
};

const expectedResponseShortExt = {
ext_03: {
key: '1',
label: 'radio1',
},
ext_04: {
key: '1',
label: 'select1',
},
ext_05: [
{
key: '1',
label: 'check1',
},
{
key: '3',
label: 'check3',
},
],
ext_11: [
{
ROW: {
key: 'col1',
label: 'COLUMN_1'
},
COL: {
key: 'row1',
label: 'ROW_1'
}
},
{
ROW: {
key: 'col2',
label: 'COLUMN_2'
},
COL: {
key: 'row2',
label: 'ROW_2'
}
},
{
ROW: {
key: 'col3',
label: 'COLUMN_3'
},
COL: {
key: 'row3',
label: 'ROW_3'
}
},
],
ext_12: [
{
ROW: {
key: 'col1',
label: 'COLUMN_1'
},
COL: [
{
key: 'row1',
label: 'ROW_1'
}
]
},
{
ROW: {
key: 'col2',
label: 'COLUMN_2'
},
COL: [
{
key: 'row1',
label: 'ROW_1'
},
{
key: 'row2',
label: 'ROW_2'
},
]
},
{
ROW: {
key: 'col3',
label: 'COLUMN_3'
},
COL: [
{
key: 'row1',
label: 'ROW_1'
},
{
key: 'row2',
label: 'ROW_2'
},
{
key: 'row3',
label: 'ROW_3'
}
]
},
],
};
const sendMessageShortExt = () => {
/** @type {import('../../../../generated/services/InquiriesService').InquiriesService.postInquiriesServiceRcmsApi1Inquiry1MessagesSendRequest} */
const requestData = {
requestBody: {
name: 'Inquiry Test',
from_mail: 'email@example.com',
body: 'test',
inquiry_category_id: 1,
ext_01: 'string1',
ext_03: '1',
ext_04: '1',
ext_05: ['1', '3'],
ext_11: {
col1: 'row1',
col2: 'row2',
col3: 'row3',
},
ext_12: {
col1: ['row1'],
col2: ['row1', 'row2'],
col3: ['row1', 'row2', 'row3'],
},
validate_only: false,
},
};
return executeRequest({
cy,
query: 'inquiry send',
requestData,
timeout: 15000,
});
};

const sendMessageWithoutRequiredTargetCols = [
'inquiry_category_id',
'ext_01',
Expand Down Expand Up @@ -135,6 +270,27 @@ const sendMessageMalformed = ({ targetCol }) => {

describe('Inquiry', () => {

it('send message with short ext', async () => {
login();
const insertRes = await sendMessageShortExt();
const addedId = insertRes.id;

const getMessageBy = async id => {
try {
return (await getMessages()).list.find(
msg => msg.inquiry_bn_id === id
);
} catch(e) {
throw Error(`the created message is not found.\nid: ${id}\n${e}`)
}
};
const sentMessage = await getMessageBy(addedId);
expect(sentMessage).to.exist;
Object.keys(expectedResponseShortExt).forEach(key => {
expect(sentMessage[key], key).to.deep.equal(expectedResponseShortExt[key]);
});
});

sendMessageWithoutRequiredTargetCols.forEach(target => {
it('send message without required ' + target + ' -> error', async () => {
login();
Expand All @@ -143,7 +299,9 @@ describe('Inquiry', () => {
errorResponse = JSON.parse(e.message);
})
expect(errorResponse.status).to.equal(400, target);
expect(errorResponse.body.errors[0]).to.include('Required property missing: ' + target);
// expect(errorResponse.body.errors[0]).to.include('Required property missing: ' + target);
expect(errorResponse.body.errors[0].code).to.equal('required');

});
})

Expand All @@ -155,7 +313,8 @@ describe('Inquiry', () => {
errorResponse = JSON.parse(e.message);
});
expect(errorResponse.status).to.equal(400);
expect(errorResponse.body.errors[0]).to.include('properties:'+target, target);
// expect(errorResponse.body.errors[0]).to.include('properties:'+target, target);
expect(errorResponse.body.errors[0].code).to.equal('invalid');
});
});

Expand Down
Loading