Skip to content

Commit 1811f78

Browse files
authored
Remove hardcoded catid's in tests (#40988)
* Remove hardcoded catid's in tests * cs * slash
1 parent f467b74 commit 1811f78

File tree

22 files changed

+386
-186
lines changed

22 files changed

+386
-186
lines changed

tests/System/integration/administrator/components/com_banners/Banner.cy.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the banners form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_banners&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__banners WHERE name = 'Test banner'"));
48

59
it('can create a banner', () => {
@@ -12,16 +16,16 @@ describe('Test in backend that the banners form', () => {
1216
});
1317

1418
it('check redirection to list view', () => {
15-
cy.visit('administrator/index.php?option=com_banners&task=banner.add');
19+
cy.visit('/administrator/index.php?option=com_banners&task=banner.add');
1620
cy.intercept('index.php?option=com_banners&view=banners').as('listview');
1721
cy.clickToolbarButton('Cancel');
1822

1923
cy.wait('@listview');
2024
});
2125

2226
it('can edit a banner', () => {
23-
cy.db_createBanner({ name: 'Test Banner' }).then((id) => {
24-
cy.visit(`administrator/index.php?option=com_banners&task=banner.edit&id=${id}`);
27+
cy.db_createBanner({ name: 'Test Banner' }).then((banner) => {
28+
cy.visit(`/administrator/index.php?option=com_banners&task=banner.edit&id=${banner.id}`);
2529
cy.get('#jform_name').clear().type('Test banner edited');
2630
cy.clickToolbarButton('Save & Close');
2731

tests/System/integration/administrator/components/com_categories/Category.cy.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the category form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_categories&extension=com_content&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__categories WHERE title = 'Test category'"));
48

59
it('can create a category', () => {
@@ -13,7 +17,7 @@ describe('Test in backend that the category form', () => {
1317

1418
it('can change access level of a test category', () => {
1519
cy.db_createCategory({ title: 'Test category' }).then((id) => {
16-
cy.visit(`administrator/index.php?option=com_categories&task=category.edit&id=${id}&extension=com_content`);
20+
cy.visit(`/administrator/index.php?option=com_categories&task=category.edit&id=${id}&extension=com_content`);
1721
cy.get('#jform_access').select('Special');
1822
cy.clickToolbarButton('Save & Close');
1923

@@ -22,7 +26,7 @@ describe('Test in backend that the category form', () => {
2226
});
2327

2428
it('check redirection to list view', () => {
25-
cy.visit('administrator/index.php?option=com_categories&task=category.add&extension=com_content');
29+
cy.visit('/administrator/index.php?option=com_categories&task=category.add&extension=com_content&filter[published]=');
2630
cy.intercept('index.php?option=com_categories&view=categories&extension=com_content').as('listview');
2731
cy.clickToolbarButton('Cancel');
2832

tests/System/integration/administrator/components/com_contact/Contact.cy.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the contact form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_contact&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__contact_details WHERE name = 'Test contact'"));
48

59
it('can create a contact', () => {
@@ -12,8 +16,8 @@ describe('Test in backend that the contact form', () => {
1216
});
1317

1418
it('can change access level of a test contact', () => {
15-
cy.db_createContact({ name: 'Test contact' }).then((id) => {
16-
cy.visit(`administrator/index.php?option=com_contact&task=contact.edit&id=${id}`);
19+
cy.db_createContact({ name: 'Test contact' }).then((contact) => {
20+
cy.visit(`/administrator/index.php?option=com_contact&task=contact.edit&id=${contact.id}`);
1721
cy.get('#jform_access').select('Special');
1822
cy.clickToolbarButton('Save & Close');
1923

@@ -22,7 +26,7 @@ describe('Test in backend that the contact form', () => {
2226
});
2327

2428
it('check redirection to list view', () => {
25-
cy.visit('administrator/index.php?option=com_contact&task=contact.add');
29+
cy.visit('/administrator/index.php?option=com_contact&task=contact.add');
2630
cy.intercept('index.php?option=com_contact&view=contacts').as('listview');
2731
cy.clickToolbarButton('Cancel');
2832

tests/System/integration/administrator/components/com_content/Article.cy.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the article form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_content&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__content WHERE title = 'Test article'"));
48

59
it('can create an article', () => {
@@ -12,8 +16,8 @@ describe('Test in backend that the article form', () => {
1216
});
1317

1418
it('can change access level of a test article', () => {
15-
cy.db_createArticle({ title: 'Test article' }).then((id) => {
16-
cy.visit(`administrator/index.php?option=com_content&task=article.edit&id=${id}`);
19+
cy.db_createArticle({ title: 'Test article' }).then((article) => {
20+
cy.visit(`/administrator/index.php?option=com_content&task=article.edit&id=${article.id}`);
1721
cy.get('#jform_access').select('Special');
1822
cy.clickToolbarButton('Save & Close');
1923

@@ -22,7 +26,7 @@ describe('Test in backend that the article form', () => {
2226
});
2327

2428
it('check redirection to list view', () => {
25-
cy.visit('administrator/index.php?option=com_content&task=article.add');
29+
cy.visit('/administrator/index.php?option=com_content&task=article.add');
2630
cy.intercept('index.php?option=com_content&view=articles').as('listview');
2731
cy.clickToolbarButton('Cancel');
2832

tests/System/integration/administrator/components/com_fields/Field.cy.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the field form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_fields&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__fields WHERE title = 'Test field'"));
48

59
it('can create a field', () => {
@@ -12,7 +16,7 @@ describe('Test in backend that the field form', () => {
1216
});
1317

1418
it('check redirection to list view', () => {
15-
cy.visit('administrator/index.php?option=com_fields&task=field.add&context=com_content.article');
19+
cy.visit('/administrator/index.php?option=com_fields&task=field.add&context=com_content.article');
1620
cy.intercept('index.php?option=com_fields&view=fields&context=com_content.article').as('listview');
1721
cy.clickToolbarButton('Cancel');
1822

@@ -21,7 +25,7 @@ describe('Test in backend that the field form', () => {
2125

2226
it('can edit a field', () => {
2327
cy.db_createField({ title: 'Test field' }).then((id) => {
24-
cy.visit(`administrator/index.php?option=com_fields&task=field.edit&id=${id}&context=com_content.article`);
28+
cy.visit(`/administrator/index.php?option=com_fields&task=field.edit&id=${id}&context=com_content.article`);
2529
cy.get('#jform_title').clear().type('Test field edited');
2630
cy.clickToolbarButton('Save & Close');
2731

tests/System/integration/administrator/components/com_modules/Module.cy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the module form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_modules&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__modules WHERE title = 'Test module'"));
48

59
it('can create a module', () => {
@@ -17,10 +21,6 @@ describe('Test in backend that the module form', () => {
1721
cy.get('#jform_title').clear().type('Test module edited');
1822
cy.clickToolbarButton('Save & Close');
1923

20-
// This is needed as it can be that the backend list still has a filter active
21-
cy.visit('/administrator/index.php?option=com_modules&view=modules&filter=');
22-
cy.reload();
23-
2424
cy.contains('Test module edited');
2525
});
2626
});

tests/System/integration/administrator/components/com_newsfeeds/Newsfeed.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe('Test in backend that the newsfeed form', () => {
1313
});
1414

1515
it('can change access level of a test newsfeed', () => {
16-
cy.db_createNewsFeed({ name: 'Test newsfeed', link: 'https://newsfeedtesturl' }).then((id) => {
17-
cy.visit(`administrator/index.php?option=com_newsfeeds&task=newsfeed.edit&id=${id}`);
16+
cy.db_createNewsFeed({ name: 'Test newsfeed', link: 'https://newsfeedtesturl' }).then((feed) => {
17+
cy.visit(`/administrator/index.php?option=com_newsfeeds&task=newsfeed.edit&id=${feed.id}`);
1818
cy.get('#jform_access').select('Special');
1919
cy.clickToolbarButton('Save & Close');
2020

tests/System/integration/administrator/components/com_tags/Tag.cy.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
describe('Test in backend that the tag form', () => {
2-
beforeEach(() => cy.doAdministratorLogin());
2+
beforeEach(() => {
3+
cy.doAdministratorLogin();
4+
// Clear the filter
5+
cy.visit('/administrator/index.php?option=com_tags&filter=');
6+
});
37
afterEach(() => cy.task('queryDB', "DELETE FROM #__tags WHERE title = 'Test tag'"));
48

59
it('can create a tag', () => {
@@ -13,7 +17,7 @@ describe('Test in backend that the tag form', () => {
1317

1418
it('can edit a tag', () => {
1519
cy.db_createTag({ title: 'Test tag' }).then((id) => {
16-
cy.visit(`administrator/index.php?option=com_tags&task=tag.edit&id=${id}`);
20+
cy.visit(`/administrator/index.php?option=com_tags&task=tag.edit&id=${id}`);
1721
cy.get('#jform_title').clear().type('Test tag edited');
1822
cy.clickToolbarButton('Save & Close');
1923

@@ -22,7 +26,7 @@ describe('Test in backend that the tag form', () => {
2226
});
2327

2428
it('check redirection to list view', () => {
25-
cy.visit('administrator/index.php?option=com_tags&task=tag.add');
29+
cy.visit('/administrator/index.php?option=com_tags&task=tag.add');
2630
cy.intercept('index.php?option=com_tags&view=tags').as('listview');
2731
cy.clickToolbarButton('Cancel');
2832

tests/System/integration/administrator/components/com_users/User.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Test in backend that the user form', () => {
1818

1919
it('can edit a user', () => {
2020
cy.db_createUser().then((id) => {
21-
cy.visit(`administrator/index.php?option=com_users&task=user.edit&id=${id}`);
21+
cy.visit(`/administrator/index.php?option=com_users&task=user.edit&id=${id}`);
2222

2323
cy.get('#jform_name').clear().type('test edited');
2424
cy.get('#jform_username').clear().type('testedited');

tests/System/integration/api/com_banners/Banners.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ describe('Test that banners API endpoint', () => {
3030

3131
it('can update a banner', () => {
3232
cy.db_createBanner({ name: 'automated test banner' })
33-
.then((id) => cy.api_patch(`/banners/${id}`, { name: 'updated automated test banner' }))
33+
.then((banner) => cy.api_patch(`/banners/${banner.id}`, { name: 'updated automated test banner' }))
3434
.then((response) => cy.wrap(response).its('body').its('data').its('attributes')
3535
.its('name')
3636
.should('include', 'updated automated test banner'));
3737
});
3838

3939
it('can delete a banner', () => {
4040
cy.db_createBanner({ name: 'automated test banner', state: -2 })
41-
.then((id) => cy.api_delete(`/banners/${id}`));
41+
.then((banner) => cy.api_delete(`/banners/${banner.id}`));
4242
});
4343
});

0 commit comments

Comments
 (0)