Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('Test that the articles category menu item type ', () => {
.then(() => {
cy.doFrontendLogin();
cy.visit('/');
cy.get('a:contains(article 1)').click();
cy.get('.com-content-article a:contains(Edit)').click();
cy.get('a:contains(automated test)').click();
cy.get('a:contains(New Article)').click();

cy.get('#adminForm').should('exist');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
describe('Test that the featured articles menu item type', () => {
it('can display an article', () => {
cy.db_createArticle({ title: 'automated test article' }).then(() => {
cy.db_createArticle({ title: 'automated test article', featured: 1 }).then(() => {
cy.visit('/');

cy.contains('automated test article');
});
});

it('can not display not featured articles article', () => {
cy.db_createArticle({ title: 'automated test article', featured: 0 }).then(() => {
cy.visit('/');

cy.contains('automated test article').should('not.exist');
});
});

it('can navigate to the article', () => {
cy.db_createArticle({ title: 'automated test article' }).then(() => {
cy.db_createArticle({ title: 'automated test article', featured: 1 }).then(() => {
cy.visit('/');
cy.get('.item-title a').click();

Expand All @@ -17,7 +25,7 @@ describe('Test that the featured articles menu item type', () => {
});

it('can navigate to the category', () => {
cy.db_createArticle({ title: 'automated test article' }).then(() => {
cy.db_createArticle({ title: 'automated test article', featured: 1 }).then(() => {
cy.visit('/');
cy.get('.category-name a').click();

Expand Down
11 changes: 8 additions & 3 deletions tests/System/support/commands/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ function createInsertQuery(table, values) {
return query;
}

Cypress.Commands.add('db_createArticle', (article) => {
Cypress.Commands.add('db_createArticle', (articleData) => {
const defaultArticleOptions = {
title: 'test article',
alias: 'test-article',
catid: 2,
introtext: '',
fulltext: '',
featured: 0,
state: 1,
access: 1,
language: '*',
Expand All @@ -35,9 +36,13 @@ Cypress.Commands.add('db_createArticle', (article) => {
metadata: '',
};

return cy.task('queryDB', createInsertQuery('content', { ...defaultArticleOptions, ...article }))
const article = { ...defaultArticleOptions, ...articleData };

return cy.task('queryDB', createInsertQuery('content', article))
.then(async (info) => {
await cy.task('queryDB', `INSERT INTO #__content_frontpage (content_id, ordering) VALUES ('${info.insertId}', '1')`);
if (article.featured === 1) {
await cy.task('queryDB', `INSERT INTO #__content_frontpage (content_id, ordering) VALUES ('${info.insertId}', '1')`);
}
await cy.task('queryDB', `INSERT INTO #__workflow_associations (item_id, stage_id, extension) VALUES (${info.insertId}, 1, 'com_content.article')`);

return info.insertId;
Expand Down