Skip to content

Commit

Permalink
fixed e2e deletePortfolioTaxonomyTerms function and added logsEnabled…
Browse files Browse the repository at this point in the history
… for archive tests
  • Loading branch information
Fellan-91 committed Jan 29, 2025
1 parent d5e1894 commit 5cf4636
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/e2e/specs/archive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { deleteAllPortfolio } from '../utils/delete-all-portfolio';
import { findAsyncSequential } from '../utils/find-async-sequential';
import { getWordpressImages } from '../utils/get-wordpress-images';

const logsEnabled = process.env.LOGS || false;

test.describe('archive pages', () => {
test.beforeEach(async ({ admin, page, requestUtils }) => {
await setPermalinkSettings(admin, page, 'Post name');
Expand Down Expand Up @@ -56,8 +58,14 @@ test.describe('archive pages', () => {
try {
// Get all terms for the specified taxonomy
const terms = await requestUtils.rest({
path: `/wp/v2/${taxonomy}?context=view`,
params: { per_page: 100 }, // Adjust as necessary for your needs
path: `/wp/v2/${taxonomy}`,
method: 'GET',
params: {
// Adjust as necessary for your needs
per_page: 100,
context: 'view',
hide_empty: false,
},
});

// Check if the response is an error
Expand Down Expand Up @@ -641,9 +649,11 @@ test.describe('archive pages', () => {
(t) => t.name.toLowerCase() === name.toLowerCase()
);
if (term) {
console.log(
`Term "${name}" already exists with ID: ${term.id}`
);
if (logsEnabled) {
console.log(
`Term "${name}" already exists with ID: ${term.id}`
);
}
return term.id; // Return the existing term ID
}

Expand Down Expand Up @@ -757,7 +767,7 @@ test.describe('archive pages', () => {

// Increment the date for the next post
currentDate.setMinutes(currentDate.getMinutes() + 1);
} else {
} else if (logsEnabled) {
console.log(`Post "${post.title}" already exists.`);
}
}
Expand Down

0 comments on commit 5cf4636

Please sign in to comment.