diff --git a/.vib/wordpress/cypress/cypress.json b/.vib/wordpress/cypress/cypress.json index 85a72440fb..ff4601a43c 100644 --- a/.vib/wordpress/cypress/cypress.json +++ b/.vib/wordpress/cypress/cypress.json @@ -2,14 +2,7 @@ "baseUrl": "http://localhost/", "env": { "username": "test_user", - "password": "ComplicatedPassword123!4", - "wordpressBlogname": "Test_Users's Blog!", - "wordpressEmail": "test_user_email@email.com", - "smtpMailServer": "mail.server.com", - "smtpPort": "120", - "smtpUser": "test_mail_user", - "wordpressFirstName": "TestName", - "wordpressLastName": "TestLastName" + "password": "ComplicatedPassword123!4" }, "defaultCommandTimeout": 30000 } diff --git a/.vib/wordpress/cypress/cypress/fixtures/admins.json b/.vib/wordpress/cypress/cypress/fixtures/admins.json new file mode 100644 index 0000000000..ccc2faabbb --- /dev/null +++ b/.vib/wordpress/cypress/cypress/fixtures/admins.json @@ -0,0 +1,5 @@ +{ + "defaultAdmin": { + "email": "test_user_email@email.com" + } +} diff --git a/.vib/wordpress/cypress/cypress/fixtures/comments.json b/.vib/wordpress/cypress/cypress/fixtures/comments.json new file mode 100644 index 0000000000..6fbfa78c3f --- /dev/null +++ b/.vib/wordpress/cypress/cypress/fixtures/comments.json @@ -0,0 +1,6 @@ +{ + "newComment": { + "commenter": "A WordPress Commenter", + "comment": "This is a test comment." + } +} diff --git a/.vib/wordpress/cypress/cypress/fixtures/helloworld.json b/.vib/wordpress/cypress/cypress/fixtures/helloworld.json deleted file mode 100644 index fea9b009c0..0000000000 --- a/.vib/wordpress/cypress/cypress/fixtures/helloworld.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "title": "Hello world!", - "content": "Welcome to WordPress.", - "commenter": "A WordPress Commenter", - "comment": "This is a test comment." -} \ No newline at end of file diff --git a/.vib/wordpress/cypress/cypress/fixtures/user.json b/.vib/wordpress/cypress/cypress/fixtures/user.json deleted file mode 100644 index 53f9d703fb..0000000000 --- a/.vib/wordpress/cypress/cypress/fixtures/user.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "username": "randomuser", - "password": "randompassword", - "email": "randomuser@foo.bar" -} \ No newline at end of file diff --git a/.vib/wordpress/cypress/cypress/fixtures/users.json b/.vib/wordpress/cypress/cypress/fixtures/users.json new file mode 100644 index 0000000000..fdb6487ed4 --- /dev/null +++ b/.vib/wordpress/cypress/cypress/fixtures/users.json @@ -0,0 +1,6 @@ +{ + "randomUser": { + "userEmail": "random@email.com", + "userName": "Random" + } +} diff --git a/.vib/wordpress/cypress/cypress/integration/wordpress_spec.js b/.vib/wordpress/cypress/cypress/integration/wordpress_spec.js index 61e9de886c..a3f6893cfd 100644 --- a/.vib/wordpress/cypress/cypress/integration/wordpress_spec.js +++ b/.vib/wordpress/cypress/cypress/integration/wordpress_spec.js @@ -2,88 +2,30 @@ import { random } from './utils'; -it('contains the sample blogpost and a comment', () => { +it('allows login/logout', () => { + cy.login(); + cy.get('#login_error').should('not.exist'); + cy.visit('wp-login.php?loggedout=true&wp_lang=en_US'); + cy.contains('.message', 'logged out'); +}); + +it('allows adding a comment to the sample blogpost', () => { cy.visit('/'); cy.get('.wp-block-query'); cy.get('.wp-block-post-title a').click(); - cy.fixture('helloworld').then((hw) => { - cy.contains('.wp-block-post-title', hw.title); - cy.contains('.wp-block-post-content', hw.content); + + cy.fixture('comments').then((comment) => { + cy.get('.commentlist').should('have.length', 1); + cy.contains('.comment-author', comment.newComment.commenter); + cy.get('#comment').type(`${comment.newComment.comment}.${random}`); + }); + cy.fixture('users').then((user) => { + cy.get('#author').type(user.randomUser.userName); + cy.get('#email').type(user.randomUser.userEmail); }); - cy.get('.wp-block-post-title').click(); - cy.get('.commentlist').should('have.length', 1); - cy.fixture('helloworld').then((hw) => { - cy.get('.comment-author').should('contain.text', hw.commenter); - - cy.fixture('helloworld').then((hw) => { - cy.get('#comment').type(hw.comment).should('have.value', hw.comment); - }); - - cy.fixture('user').then((user) => { - cy.get('#author').type(user.username).should('have.value', user.username); - cy.get('#email').type(user.email).should('have.value', user.email); - }); - - cy.get('#submit').click(); - }); -}); - -it('disallows login to an invalid user', () => { - cy.clearCookies(); - cy.visit('/wp-login.php'); - cy.fixture('user').then((user) => { - cy.get('#user_login') - .type(user.username) - .should('have.value', user.username); // Since login can be flaky, leaving additional asserts - cy.get('#user_pass') - .type(user.password) - .should('have.value', user.password); - }); - cy.get('#wp-submit').click(); - cy.fixture('user').then((user) => { - cy.get('#login_error').should( - 'contain.text', - `The username ${user.username} is not registered on this site.` - ); - }); -}); - -it('disallows login to a valid user with wrong password', () => { - cy.clearCookies(); - cy.visit('/wp-login.php'); - cy.get('#user_login') - .type(Cypress.env('username')) - .should('have.value', Cypress.env('username')); - cy.fixture('user').then((user) => { - cy.get('#user_pass') - .type(user.password) - .should('have.value', user.password); - }); - cy.get('#wp-submit').click(); - cy.get('#login_error').should( - 'contain.text', - `Error: The password you entered for the username ${Cypress.env( - 'username' - )} is incorrect. Lost your password?` - ); -}); - -it('checks the blog name and user email configuration', () => { - cy.login(); - cy.visit('/wp-admin/options-general.php'); - cy.get('#new_admin_email').should( - 'have.value', - Cypress.env('wordpressEmail') - ); - cy.get('#blogname').should('have.value', Cypress.env('wordpressBlogname')); -}); - -it('checks if admin can edit a site', () => { - cy.login(); - cy.visit('/wp-admin/index.php'); - cy.contains('Open site editor').click(); - cy.url().should('include', '/wp-admin/site-editor.php'); + cy.get('#submit').click(); + cy.contains('your comment will be visible after it has been approved'); }); it('checks if admin can create a post', () => { @@ -95,32 +37,20 @@ it('checks if admin can create a post', () => { .clear() .type(`Test Hello World!${random}`); cy.get('.editor-post-save-draft').click(); - cy.get('.editor-post-saved-state').and('have.text', 'Saved'); + cy.contains('.editor-post-saved-state', 'Saved'); }); -/* TEMPORARILY SHUTTING DOWN THIS TEST DUE TO MAINTENANCE */ - -it.skip('checks the SMTP configuration', () => { +it('shows the SMTP configuration', () => { cy.login(); cy.visit('/wp-admin/admin.php?page=wp-mail-smtp'); - cy.reload(); - cy.contains('div', 'WP Mail SMTP'); - cy.get('#wp-mail-smtp-setting-smtp-host').should( - 'have.value', - Cypress.env('smtpMailServer') - ); - cy.get('#wp-mail-smtp-setting-smtp-port').should( - 'have.value', - Cypress.env('smtpPort') - ); - cy.get('#wp-mail-smtp-setting-smtp-user').should( - 'have.value', - Cypress.env('smtpUser') - ); - cy.get('#wp-mail-smtp-setting-from_name').should( - 'have.value', - `${Cypress.env('wordpressFirstName')} ${Cypress.env('wordpressLastName')}` - ); + cy.contains('WP Mail SMTP'); + cy.contains('Email Test').click(); + cy.fixture('admins').then((admin) => { + cy.get('#wp-mail-smtp-setting-test_email').should( + 'have.value', + `${admin.defaultAdmin.email}` + ); + }); }); it('allows the upload of a file', () => { @@ -134,9 +64,3 @@ it('allows the upload of a file', () => { ); cy.get('.attachment'); }); - -it('allows to log out', () => { - cy.login(); - cy.visit('wp-login.php?loggedout=true&wp_lang=en_US'); - cy.contains('.message', 'logged out'); -}); diff --git a/.vib/wordpress/cypress/cypress/plugins/index.js b/.vib/wordpress/cypress/cypress/plugins/index.js deleted file mode 100644 index 59b2bab6e4..0000000000 --- a/.vib/wordpress/cypress/cypress/plugins/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} diff --git a/.vib/wordpress/cypress/cypress/support/commands.js b/.vib/wordpress/cypress/cypress/support/commands.js index 74abb93a5d..9c265c86ba 100644 --- a/.vib/wordpress/cypress/cypress/support/commands.js +++ b/.vib/wordpress/cypress/cypress/support/commands.js @@ -1,7 +1,6 @@ // Added to slow down Cypress test execution without using hardcoded waits. If removed, there will be false positives. const COMMAND_DELAY = 1000; -const TYPE_DELAY = 100; for (const command of ['click']) { Cypress.Commands.overwrite(command, (originalFn, ...args) => { @@ -15,6 +14,8 @@ for (const command of ['click']) { }); } +const TYPE_DELAY = 100; + for (const command of ['type']) { Cypress.Commands.overwrite(command, (originalFn, ...args) => { const origVal = originalFn(...args); @@ -22,7 +23,7 @@ for (const command of ['type']) { return new Promise((resolve) => { setTimeout(() => { resolve(origVal); - }, COMMAND_DELAY); + }, TYPE_DELAY); }); }); } diff --git a/.vib/wordpress/vib-publish.json b/.vib/wordpress/vib-publish.json index 512a3ce180..23873194f4 100644 --- a/.vib/wordpress/vib-publish.json +++ b/.vib/wordpress/vib-publish.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/wordpress" }, - "runtime_parameters": "d29yZHByZXNzVXNlcm5hbWU6IHRlc3RfdXNlcgp3b3JkcHJlc3NQYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0CndvcmRwcmVzc0VtYWlsOiB0ZXN0X3VzZXJfZW1haWxAZW1haWwuY29tCndvcmRwcmVzc0ZpcnN0TmFtZTogVGVzdE5hbWUKd29yZHByZXNzTGFzdE5hbWU6IFRlc3RMYXN0TmFtZQp3b3JkcHJlc3NCbG9nTmFtZTogVGVzdF9Vc2VycydzIEJsb2chCnNtdHBIb3N0OiBtYWlsLnNlcnZlci5jb20Kc210cFBvcnQ6IDEyMApzbXRwVXNlcjogdGVzdF9tYWlsX3VzZXIKc210cFBhc3N3b3JkOiB0ZXN0X21haWxfcGFzc3dvcmQKbWFyaWFkYjoKICBhdXRoOgogICAgZGF0YWJhc2U6IHRlc3Rfd29yZHByZXNzX2RhdGFiYXNlCiAgICB1c2VybmFtZTogdGVzdF93b3JkcHJlc3NfdXNlcm5hbWUKICAgIHBhc3N3b3JkOiB0ZXN0X3dvcmRwcmVzc19wYXNzd29yZApjb250YWluZXJTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIHJ1bkFzVXNlcjogMTAwMgogIHJ1bkFzTm9uUm9vdDogdHJ1ZQp3b3JkcHJlc3NUYWJsZVByZWZpeDogd29yZHByZXNzXw==", + "runtime_parameters": "d29yZHByZXNzVXNlcm5hbWU6IHRlc3RfdXNlcgp3b3JkcHJlc3NQYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0CndvcmRwcmVzc0VtYWlsOiB0ZXN0X3VzZXJfZW1haWxAZW1haWwuY29tCndvcmRwcmVzc0ZpcnN0TmFtZTogVGVzdE5hbWUKd29yZHByZXNzTGFzdE5hbWU6IFRlc3RMYXN0TmFtZQpzbXRwSG9zdDogbWFpbC5zZXJ2ZXIuY29tCnNtdHBQb3J0OiAxMjAKc210cFVzZXI6IHRlc3RfbWFpbF91c2VyCnNtdHBQYXNzd29yZDogdGVzdF9tYWlsX3Bhc3N3b3JkCm1hcmlhZGI6CiAgYXV0aDoKICAgIGRhdGFiYXNlOiB0ZXN0X3dvcmRwcmVzc19kYXRhYmFzZQogICAgdXNlcm5hbWU6IHRlc3Rfd29yZHByZXNzX3VzZXJuYW1lCiAgICBwYXNzd29yZDogdGVzdF93b3JkcHJlc3NfcGFzc3dvcmQKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKICBydW5Bc05vblJvb3Q6IHRydWUKd29yZHByZXNzVGFibGVQcmVmaXg6IHdvcmRwcmVzc18K", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { diff --git a/.vib/wordpress/vib-verify.json b/.vib/wordpress/vib-verify.json index ed1d4394de..a4334c7f23 100644 --- a/.vib/wordpress/vib-verify.json +++ b/.vib/wordpress/vib-verify.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/wordpress" }, - "runtime_parameters": "d29yZHByZXNzVXNlcm5hbWU6IHRlc3RfdXNlcgp3b3JkcHJlc3NQYXNzd29yZDogQ29tc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oKICAgIGRhdGFiYXNlOiB0ZXN0X3dvcmRwcmVzc19kYXRhYmFzZQogICAgdXNlcm5hbWU6IHRlc3Rfd29yZHByZXNzX3VzZXJuYW1lCiAgICBwYXNzd29yZDogdGVzdF93b3JkcHJlc3NfcGFzc3dvcmQKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKICBydW5Bc05vblJvb3Q6IHRydWUKd29yZHByZXNzVGFibGVQcmVmaXg6IHdvcmRwcmVzc18K", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": {