29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-29 00:23:41 +00:00

Test not featured articles (#40164)

* Test not featured articles

* cs

* strict

* fix

---------
This commit is contained in:
Allon Moritz 2023-03-28 18:32:06 +02:00 committed by GitHub
parent 7e84e7c1c5
commit 2180f283b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 8 deletions

View File

@ -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');
});

View File

@ -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();
@ -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();

View File

@ -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: '*',
@ -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;