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

Lints the cypress system tests #40076

Merged
merged 6 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 9 additions & 1 deletion build/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,13 @@
"error",
"as-needed"
]
}
},
"overrides": [
{
"files": ["tests/**/*.cy.js"],
"rules": {
"no-undef": ["off"]
}
}
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build:com_media:dev": "set NODE_ENV=DEVELOPMENT && node build/build.js --com-media",
"watch": "node build/build.js --watch",
"watch:com_media": "node build/build.js --watch-com-media",
"lint:js": "eslint --config build/.eslintrc --ignore-pattern '/media/' --ext .es6.js,.es6,.vue .",
"lint:js": "eslint --config build/.eslintrc --ignore-pattern '/media/' --ext .es6.js,.es6,.vue,.cy.js .",
"lint:css": "stylelint --config build/.stylelintrc.json \"administrator/components/com_media/resources/**/*.scss\" \"administrator/templates/**/*.scss\" \"build/media_source/**/*.scss\" \"templates/**/*.scss\" \"installation/template/**/*.scss\"",
"install": "node build/build.js --prepare",
"update": "node build/build.js --copy-assets && node build/build.js --build-pages && node build/build.js --compile-js && node build/build.js --compile-css && node build/build.js --compile-bs && set NODE_ENV=PRODUCTION && node build/build.js --com-media",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

describe('Test com_content Category features', () => {
beforeEach(() => {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
})
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'));
});

it('Category', function () {
cy.createContentCategory('Category title')
})
})
it('Category', () => {
cy.createContentCategory('Category title');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

describe('Test com_content Field features', () => {
beforeEach(() => {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
})
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'));
});

it('Field', function () {
cy.createField('text', 'Field title')
cy.trashField('Field title', 'Field trashed')
cy.deleteField('Field title', 'Field deleted')
})
})
it('Field', () => {
cy.createField('text', 'Field title');
cy.trashField('Field title', 'Field trashed');
cy.deleteField('Field title', 'Field deleted');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@

describe('Test com_content List features', () => {
beforeEach(() => {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
})
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'));
});

it('loads without PHP notices and warnings', function () {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.checkForPhpNoticesOrWarnings()
})
it('loads without PHP notices and warnings', () => {
cy.visit('administrator/index.php?option=com_content&view=articles');
cy.checkForPhpNoticesOrWarnings();
});

it('executes CRUD on articles', () => {
const testArticle = {
'title': 'Test Article',
'alias': 'test-article',
'state': 1
}
title: 'Test Article',
alias: 'test-article',
state: 1,
};

cy.visit('administrator/index.php?option=com_content&view=articles')
cy.createArticle(testArticle)
cy.featureArticle(testArticle.title)
cy.publishArticle(testArticle.title)
cy.unPublishArticle(testArticle.title)
cy.trashArticle(testArticle.title)
cy.deleteArticle(testArticle.title)
})
})
cy.visit('administrator/index.php?option=com_content&view=articles');
cy.createArticle(testArticle);
cy.featureArticle(testArticle.title);
cy.publishArticle(testArticle.title);
cy.unPublishArticle(testArticle.title);
cy.trashArticle(testArticle.title);
cy.deleteArticle(testArticle.title);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

describe('Test com_menu features', () => {
beforeEach(() => {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
})
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'));
});

it('creates a new menu', function () {
cy.visit('administrator/index.php?option=com_menus&view=menus')
cy.checkForPhpNoticesOrWarnings()
cy.get('h1.page-title').should('contain', 'Menus')
cy.clickToolbarButton('New')
cy.get('h1.page-title').should('contain', 'Menus: Add')
cy.checkForPhpNoticesOrWarnings()
cy.get('#jform_title').type('Test Menu')
cy.get('#jform_menutype').type('Test')
cy.get('#jform_menudescription').type('Automated Testing')
cy.clickToolbarButton('Save')
cy.get('#system-message-container').contains('Menu saved').should('exist')
})
})
it('creates a new menu', () => {
cy.visit('administrator/index.php?option=com_menus&view=menus');
cy.checkForPhpNoticesOrWarnings();
cy.get('h1.page-title').should('contain', 'Menus');
cy.clickToolbarButton('New');
cy.get('h1.page-title').should('contain', 'Menus: Add');
cy.checkForPhpNoticesOrWarnings();
cy.get('#jform_title').type('Test Menu');
cy.get('#jform_menutype').type('Test');
cy.get('#jform_menudescription').type('Automated Testing');
cy.clickToolbarButton('Save');
cy.get('#system-message-container').contains('Menu saved').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,117 +3,115 @@

describe('Test com_users features', () => {
beforeEach(() => {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'));
cy.user = {
"username": "testUser",
"password": "joomla17082005",
"name": "Test Bot",
"email": "Testbot@example.com"
}
})

it('disables sending mails', function () {
cy.visit('administrator/index.php?option=com_config')
cy.contains('button', 'Server').click()

cy.log('**Disable sending mails**')

cy.visit('administrator/index.php?option=com_config')

cy.contains('.page-title', 'Global Configuration').scrollIntoView()
cy.get("div[role='tablist'] button[aria-controls='page-server']").click()
cy.get('#jform_mailonline0').scrollIntoView().click()

cy.intercept('index.php?option=com_config*').as('config_save')
cy.clickToolbarButton('save')
cy.wait('@config_save')
cy.contains('.page-title', 'Global Configuration').should('exist')
cy.contains('#system-message-container', 'Configuration saved.').should('exist')

cy.log('--Disable sending mails--')
})

it('creates a new user', function () {
cy.visit('administrator/index.php?option=com_users&view=users')
cy.checkForPhpNoticesOrWarnings()
cy.get('h1.page-title').should('contain.text', 'Users')
cy.intercept('index.php?option=com_users&view=user*').as('useredit')
cy.clickToolbarButton('New')
cy.wait('@useredit')
cy.checkForPhpNoticesOrWarnings()

cy.get('#jform_name').clear().type(cy.user.name)
cy.get('#jform_username').clear().type(cy.user.username)
cy.get('#jform_email').clear().type(cy.user.email)
cy.get('#jform_password').clear().type(cy.user.password)
cy.get('#jform_password2').clear().type(cy.user.password)
cy.intercept('index.php?option=com_users&view=users').as('userlist')
cy.clickToolbarButton('Save & Close')
cy.wait('@userlist')
cy.get('h1.page-title').should('contain.text', 'Users')
cy.get('#system-message-container').contains('User saved').should('exist')
cy.checkForPhpNoticesOrWarnings()
})

it('edits a user', function () {
cy.visit('administrator/index.php?option=com_users&view=users')
cy.get('h1.page-title').should('contain.text', 'Users')
cy.intercept('index.php?option=com_users&view=user*').as('usereditview')
cy.contains('a', cy.user.name).click()
cy.wait('@usereditview')

cy.checkForPhpNoticesOrWarnings()
cy.contains('button', 'Account Details')
cy.get('#jform_name').clear().type(cy.user.name)
cy.get('#jform_username').clear().type(cy.user.username)
cy.get('#jform_password').clear().type(cy.user.password)
cy.get('#jform_password2').clear().type(cy.user.password)
cy.get('#jform_email').clear().type(cy.user.email)

cy.intercept('administrator/index.php?option=com_users&view=user').as('usereditview')
cy.clickToolbarButton('Save')
cy.wait('@usereditview')

cy.get('#system-message-container').contains('User saved.').should('exist')
cy.checkForPhpNoticesOrWarnings()
})

it('deletes a user', function () {
cy.visit('administrator/index.php?option=com_users&view=users')
cy.get('h1.page-title').should('contain.text', 'Users')

cy.searchForItem(cy.user.username)
cy.checkAllResults()
cy.clickToolbarButton('Action')

cy.contains('Delete').click()

cy.on("window:confirm", (s) => {
return true;
});

cy.get('#system-message-container').contains('User deleted.').should('exist')
cy.checkForPhpNoticesOrWarnings()
})

it('enables sending mails', function () {
cy.visit('administrator/index.php?option=com_config')
cy.contains('button', 'Server').click()

cy.log('**Enable sending mails**')

cy.visit('administrator/index.php?option=com_config')

cy.contains('.page-title', 'Global Configuration').scrollIntoView()
cy.get("div[role='tablist'] button[aria-controls='page-server']").click()
cy.get('#jform_mailonline1').scrollIntoView().click()

cy.intercept('index.php?option=com_config*').as('config_save')
cy.clickToolbarButton('save')
cy.wait('@config_save')
cy.contains('.page-title', 'Global Configuration').should('exist')
cy.contains('#system-message-container', 'Configuration saved.').should('exist')

cy.log('--Enable sending mails--')
})
})
username: 'testUser',
password: 'joomla17082005',
name: 'Test Bot',
email: 'Testbot@example.com',
};
});

it('disables sending mails', () => {
cy.visit('administrator/index.php?option=com_config');
cy.contains('button', 'Server').click();

cy.log('**Disable sending mails**');

cy.visit('administrator/index.php?option=com_config');

cy.contains('.page-title', 'Global Configuration').scrollIntoView();
cy.get("div[role='tablist'] button[aria-controls='page-server']").click();
cy.get('#jform_mailonline0').scrollIntoView().click();

cy.intercept('index.php?option=com_config*').as('config_save');
cy.clickToolbarButton('save');
cy.wait('@config_save');
cy.contains('.page-title', 'Global Configuration').should('exist');
cy.contains('#system-message-container', 'Configuration saved.').should('exist');

cy.log('--Disable sending mails--');
});

it('creates a new user', () => {
cy.visit('administrator/index.php?option=com_users&view=users');
cy.checkForPhpNoticesOrWarnings();
cy.get('h1.page-title').should('contain.text', 'Users');
cy.intercept('index.php?option=com_users&view=user*').as('useredit');
cy.clickToolbarButton('New');
cy.wait('@useredit');
cy.checkForPhpNoticesOrWarnings();

cy.get('#jform_name').clear().type(cy.user.name);
cy.get('#jform_username').clear().type(cy.user.username);
cy.get('#jform_email').clear().type(cy.user.email);
cy.get('#jform_password').clear().type(cy.user.password);
cy.get('#jform_password2').clear().type(cy.user.password);
cy.intercept('index.php?option=com_users&view=users').as('userlist');
cy.clickToolbarButton('Save & Close');
cy.wait('@userlist');
cy.get('h1.page-title').should('contain.text', 'Users');
cy.get('#system-message-container').contains('User saved').should('exist');
cy.checkForPhpNoticesOrWarnings();
});

it('edits a user', () => {
cy.visit('administrator/index.php?option=com_users&view=users');
cy.get('h1.page-title').should('contain.text', 'Users');
cy.intercept('index.php?option=com_users&view=user*').as('usereditview');
cy.contains('a', cy.user.name).click();
cy.wait('@usereditview');

cy.checkForPhpNoticesOrWarnings();
cy.contains('button', 'Account Details');
cy.get('#jform_name').clear().type(cy.user.name);
cy.get('#jform_username').clear().type(cy.user.username);
cy.get('#jform_password').clear().type(cy.user.password);
cy.get('#jform_password2').clear().type(cy.user.password);
cy.get('#jform_email').clear().type(cy.user.email);

cy.intercept('administrator/index.php?option=com_users&view=user').as('usereditview');
cy.clickToolbarButton('Save');
cy.wait('@usereditview');

cy.get('#system-message-container').contains('User saved.').should('exist');
cy.checkForPhpNoticesOrWarnings();
});

it('deletes a user', () => {
cy.visit('administrator/index.php?option=com_users&view=users');
cy.get('h1.page-title').should('contain.text', 'Users');

cy.searchForItem(cy.user.username);
cy.checkAllResults();
cy.clickToolbarButton('Action');

cy.contains('Delete').click();

cy.on('window:confirm', () => true);

cy.get('#system-message-container').contains('User deleted.').should('exist');
cy.checkForPhpNoticesOrWarnings();
});

it('enables sending mails', () => {
cy.visit('administrator/index.php?option=com_config');
cy.contains('button', 'Server').click();

cy.log('**Enable sending mails**');

cy.visit('administrator/index.php?option=com_config');

cy.contains('.page-title', 'Global Configuration').scrollIntoView();
cy.get("div[role='tablist'] button[aria-controls='page-server']").click();
cy.get('#jform_mailonline1').scrollIntoView().click();

cy.intercept('index.php?option=com_config*').as('config_save');
cy.clickToolbarButton('save');
cy.wait('@config_save');
cy.contains('.page-title', 'Global Configuration').should('exist');
cy.contains('#system-message-container', 'Configuration saved.').should('exist');

cy.log('--Enable sending mails--');
});
});
10 changes: 5 additions & 5 deletions tests/cypress/integration/administrator/general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// <reference types="cypress" />

describe('Test general features of Joomla Backend', () => {
it('Login/Logout in Frontend', function () {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
cy.doAdministratorLogout()
})
})
it('Login/Logout in Frontend', () => {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'));
cy.doAdministratorLogout();
});
});
Loading