Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system test com_messages webservice #42100

Open
wants to merge 7 commits into
base: 4.4-dev
Choose a base branch
from
Open
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
86 changes: 86 additions & 0 deletions tests/System/integration/api/com_messages/Messages.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
describe('Test that messages API endpoint', () => {
afterEach(() => cy.task('queryDB', "DELETE FROM #__users WHERE username = 'automated_test_username'"));

it('can create a message', () => {
cy.api_post('/users', {
block: '0',
email: '[email protected]',
groups: [
'8',
],
id: '0',
lastResetTime: '',
lastvisitDate: '',
name: 'automated test user',
params: {
admin_language: '',
admin_style: '',
editor: '',
helpsite: '',
language: '',
timezone: '',
},
password: 'qwertyqwerty123',
password2: 'qwertyqwerty123',
registerDate: '',
requireReset: '0',
resetCount: '0',
sendEmail: '1',
username: 'automated_test_username',
})
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('id')
.then((id) => cy.api_post('/messages', {
user_id_from: id,
user_id_to: 3,
state: 0,
subject: 'subject automated test',
message: `message automated test${id}`,
})))
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('message')
.should('include', 'message automated test'));
});

it('can deliver a list of messages', () => {
cy.api_get('/messages')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('subject')
.should('include', 'subject automated test'));
});

it('can deliver a single message', () => {
cy.api_get('/messages')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => {
cy.api_get(`/messages/${id}`)
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('subject')
.should('include', 'subject automated test'));
});
});

it('can modify a single message', () => {
cy.api_get('/messages')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => {
const updateMessage = {
state: 1,
};
cy.api_patch(`/messages/${id}`, updateMessage)
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
.its('state')
.should('equal', 1));
});
});

it('can delete a message', () => {
cy.api_get('/messages')
.then((response) => cy.wrap(response).its('body').its('data.0').its('attributes')
.its('id'))
.then((id) => cy.api_delete(`/messages/${id}`))
.then((response) => cy.wrap(response).its('status').should('equal', 204));
});
});