mirror of
https://github.com/bitnami/charts.git
synced 2026-02-28 15:37:42 +08:00
[bitnami/prestashop] Add Prestashop Helm Chart tests (#10735)
* [bitnami/prestashop] Add PrestaShop Helm Chart tests Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Delete unnecessary files Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Lint cypress.json Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Replace login test with order Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Replace install module goss test with list commands Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Update runtime_parameters to include email Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Fix typo Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Simplify some selectors by removing the element type Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com> * Use env vars for GOSS checks Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>
This commit is contained in:
committed by
GitHub
parent
5df164c1c4
commit
f195d99be7
14
.vib/prestashop/cypress/cypress.json
Normal file
14
.vib/prestashop/cypress/cypress.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"env": {
|
||||
"username": "user",
|
||||
"email": "user@example.com",
|
||||
"password": "ComplicatedPassword123!4"
|
||||
},
|
||||
"hosts": {
|
||||
"vmware-prestashop.my": "{{ TARGET_IP }}"
|
||||
},
|
||||
"defaultCommandTimeout": 30000,
|
||||
"viewportWidth": 1800,
|
||||
"viewportHeight": 800,
|
||||
"chromeWebSecurity": false
|
||||
}
|
||||
19
.vib/prestashop/cypress/cypress/fixtures/customers.json
Normal file
19
.vib/prestashop/cypress/cypress/fixtures/customers.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"shopper": {
|
||||
"firstName": "Tom",
|
||||
"lastName": "Chat",
|
||||
"email": "lechat@example.com",
|
||||
"address": {
|
||||
"street": "3401 Hillview Ave",
|
||||
"city": "Palo Alto",
|
||||
"state": "California",
|
||||
"zipcode": "94304"
|
||||
}
|
||||
},
|
||||
"newCustomer": {
|
||||
"firstName": "Maurice",
|
||||
"lastName": "Canard",
|
||||
"email": "lecanard@example.com",
|
||||
"password": "Sup3rComplicated!"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
6
.vib/prestashop/cypress/cypress/fixtures/products.json
Normal file
6
.vib/prestashop/cypress/cypress/fixtures/products.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"newProduct": {
|
||||
"name": "Painting: Wiedergeboren",
|
||||
"price": "13.0"
|
||||
}
|
||||
}
|
||||
130
.vib/prestashop/cypress/cypress/integration/prestashop_spec.js
Normal file
130
.vib/prestashop/cypress/cypress/integration/prestashop_spec.js
Normal file
@@ -0,0 +1,130 @@
|
||||
/// <reference types="cypress" />
|
||||
import { random } from './utils';
|
||||
|
||||
// Note: Interaction with the UI is preferred over cy.visit() as
|
||||
// PrestaShop requires to provide a token within the URL or else
|
||||
// a security warning page is shown.
|
||||
|
||||
it('allows a user to place an order and an admin to list it', () => {
|
||||
cy.visit('/');
|
||||
cy.get('div.product').first().click();
|
||||
cy.contains('Add to cart').click();
|
||||
cy.visit('/order');
|
||||
cy.fixture('customers').then((customers) => {
|
||||
cy.get('form#customer-form').within(() => {
|
||||
cy.get('input#field-id_gender-1').check();
|
||||
cy.get('input#field-firstname').type(customers.shopper.firstName);
|
||||
cy.get('input#field-lastname').type(customers.shopper.lastName);
|
||||
cy.get('input#field-email').type(`${random}${customers.shopper.email}`);
|
||||
cy.get('input[name="customer_privacy"]').check();
|
||||
cy.get('input[name="psgdpr"]').check();
|
||||
cy.contains('button', 'Continue').click();
|
||||
});
|
||||
cy.get('div.js-address-form').within(() => {
|
||||
cy.get('input#field-address1').type(customers.shopper.address.street);
|
||||
cy.get('input#field-city').type(customers.shopper.address.city);
|
||||
cy.get('select#field-id_state').select(customers.shopper.address.state);
|
||||
cy.get('input#field-postcode').type(customers.shopper.address.zipcode);
|
||||
cy.contains('button', 'Continue').click();
|
||||
});
|
||||
cy.get('form#js-delivery').within(() => {
|
||||
cy.contains('button', 'Continue').click();
|
||||
});
|
||||
cy.get('input#payment-option-1').click();
|
||||
cy.get('input[id*="conditions_to_approve"]').click();
|
||||
cy.contains('button', 'Place order').click();
|
||||
cy.contains('order is confirmed');
|
||||
cy.login();
|
||||
cy.contains('[href*="sell/orders"]', 'Orders').click();
|
||||
cy.contains('li#subtab-AdminOrders', 'Orders').click();
|
||||
cy.get('td[class*="column-reference"]').first().click();
|
||||
cy.contains(`${random}${customers.shopper.email}`);
|
||||
});
|
||||
});
|
||||
|
||||
it('allows registering a new product', () => {
|
||||
cy.login();
|
||||
cy.contains('[href*="catalog/products"]', 'Catalog').click();
|
||||
cy.contains('[href*="catalog/products"]', 'Products').click();
|
||||
cy.get('div.header-toolbar').within(() => {
|
||||
cy.contains('[href*="catalog/products/new"]', 'New product').click();
|
||||
});
|
||||
|
||||
cy.fixture('products').then((products) => {
|
||||
cy.get('input[placeholder="Enter your product name"]').type(
|
||||
`${products.newProduct.name} ${random}`
|
||||
);
|
||||
cy.get('input[type="file"][accept="image/*"]').selectFile(
|
||||
'cypress/fixtures/images/product_image.png',
|
||||
{ force: true }
|
||||
);
|
||||
cy.get('input#form_step1_price_shortcut').type(products.newProduct.price);
|
||||
cy.contains('input#submit', 'Save').click();
|
||||
cy.contains('Settings updated');
|
||||
|
||||
cy.contains('[href*="catalog/products"]', 'Products').click();
|
||||
cy.contains(`${products.newProduct.name} ${random}`);
|
||||
});
|
||||
});
|
||||
|
||||
it('allows registering a new customer', () => {
|
||||
cy.login();
|
||||
cy.contains('[href*="sell/customers"]', 'Customers').click();
|
||||
cy.contains('li#subtab-AdminCustomers', 'Customers').click();
|
||||
cy.get('div.header-toolbar').within(() => {
|
||||
cy.contains('[href*="customers/new"]', 'Add new customer').click();
|
||||
});
|
||||
|
||||
cy.fixture('customers').then((customers) => {
|
||||
cy.get('input#customer_first_name').type(customers.newCustomer.firstName);
|
||||
cy.get('input#customer_last_name').type(customers.newCustomer.lastName);
|
||||
cy.get('input#customer_email').type(
|
||||
`${random}.${customers.newCustomer.email}`
|
||||
);
|
||||
cy.get('input#customer_password').type(customers.newCustomer.password);
|
||||
cy.get('button#save-button').click();
|
||||
cy.contains('Successful creation');
|
||||
cy.contains(`${random}.${customers.newCustomer.email}`);
|
||||
});
|
||||
cy.clearCookies();
|
||||
cy.clearLocalStorage();
|
||||
});
|
||||
|
||||
it('has payments activated', () => {
|
||||
cy.login();
|
||||
cy.contains('[href*="payment/payment_methods"]', 'Payment').click();
|
||||
cy.contains('[href*="payment/payment_methods"]', 'Payment Methods').click();
|
||||
const DEFAULT_ACTIVE_PAY_METHODS = ['Bank transfer', 'Payments by check'];
|
||||
|
||||
cy.contains('div.card', 'Active payment').within(() => {
|
||||
DEFAULT_ACTIVE_PAY_METHODS.forEach((method) => {
|
||||
cy.contains(method);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('allows performing backups', () => {
|
||||
cy.login();
|
||||
cy.contains(
|
||||
'[href*="configure/advanced/system-information"]',
|
||||
'Advanced Parameters'
|
||||
).click();
|
||||
cy.contains('[href*="configure/advanced/sql-requests"]', 'Database').click();
|
||||
cy.contains('#subtab-AdminBackup', 'DB Backup').click();
|
||||
|
||||
cy.contains('button', 'create a new backup').click();
|
||||
// Perform a request instead of clicking the link, as Cypress would try to
|
||||
// navigate and eventually fail.
|
||||
cy.contains('a', 'Download the backup')
|
||||
.invoke('attr', 'href')
|
||||
.then((href) => {
|
||||
cy.log(href);
|
||||
cy.request({
|
||||
url: href,
|
||||
method: 'GET',
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
expect(response.headers['content-type']).to.eq('application/x-bzip2');
|
||||
});
|
||||
});
|
||||
});
|
||||
3
.vib/prestashop/cypress/cypress/integration/utils.js
Normal file
3
.vib/prestashop/cypress/cypress/integration/utils.js
Normal file
@@ -0,0 +1,3 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
export let random = (Math.random() + 1).toString(36).substring(7);
|
||||
51
.vib/prestashop/cypress/cypress/support/commands.js
Normal file
51
.vib/prestashop/cypress/cypress/support/commands.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const COMMAND_DELAY = 500;
|
||||
const BASE_URL = 'http://vmware-prestashop.my';
|
||||
|
||||
for (const command of ['click']) {
|
||||
Cypress.Commands.overwrite(command, (originalFn, ...args) => {
|
||||
const origVal = originalFn(...args);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(origVal);
|
||||
}, COMMAND_DELAY);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Due to a bug when using "hosts" in Cypress, we cannot set a "baseUrl" in the
|
||||
// cypress.json file. Workaround this by modifying the "visit" command to preprend
|
||||
// the base URL.
|
||||
//
|
||||
// Further details: https://github.com/cypress-io/cypress/issues/20647
|
||||
Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
|
||||
return originalFn(`${BASE_URL}${url}`, options);
|
||||
});
|
||||
|
||||
Cypress.Commands.add(
|
||||
'login',
|
||||
(email = Cypress.env('email'), password = Cypress.env('password')) => {
|
||||
cy.visit('/administration/index.php');
|
||||
cy.get('input#email').type(email);
|
||||
cy.get('input#passwd').type(password);
|
||||
cy.get('button#submit_login').click();
|
||||
cy.get('div#error').should('not.exist');
|
||||
cy.contains('Dashboard');
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('button[class*="onboarding-button-shut-down"]').length > 0) {
|
||||
cy.get('button[class*="onboarding-button-shut-down"]').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Cypress.on('uncaught:exception', (err, runnable) => {
|
||||
if (
|
||||
err.message.includes('has already been declared') ||
|
||||
err.message.includes('NavbarTransitionHandler is not defined')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
// we still want to ensure there are no other unexpected
|
||||
// errors, so we let them fail the test
|
||||
});
|
||||
20
.vib/prestashop/cypress/cypress/support/index.js
Normal file
20
.vib/prestashop/cypress/cypress/support/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
33
.vib/prestashop/goss/goss.yaml
Normal file
33
.vib/prestashop/goss/goss.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
command:
|
||||
apcu-caching-support:
|
||||
exec: /opt/bitnami/php/bin/php -i | grep --quiet apcu
|
||||
exit-status: 0
|
||||
stdout: [ ]
|
||||
stderr: [ ]
|
||||
timeout: 40000
|
||||
prestashop-version-ok:
|
||||
exec: cat /opt/bitnami/prestashop/app/AppKernel.php | grep --quiet $(echo $APP_VERSION | tr "-" ".")
|
||||
exit-status: 0
|
||||
stdout: [ ]
|
||||
stderr: [ ]
|
||||
timeout: 40000
|
||||
prestashop-cli-list-commands:
|
||||
exec: /opt/bitnami/php/bin/php /opt/bitnami/prestashop/bin/console prestashop:list:commands-and-queries
|
||||
exit-status: 0
|
||||
stdout:
|
||||
- "Class:"
|
||||
- "Type:"
|
||||
stderr: [ ]
|
||||
timeout: 40000
|
||||
file:
|
||||
/opt/bitnami/prestashop:
|
||||
filetype: symlink
|
||||
linked-to: /bitnami/prestashop
|
||||
exists: true
|
||||
/opt/bitnami/prestashop/app/config/parameters.php:
|
||||
mode: "0644"
|
||||
filetype: file
|
||||
exists: true
|
||||
contains:
|
||||
- {{ printf "/database_name.*%s/" .Env.PRESTASHOP_DATABASE_NAME }}
|
||||
- {{ printf "/database_user.*%s/" .Env.PRESTASHOP_DATABASE_USER }}
|
||||
@@ -17,6 +17,19 @@
|
||||
]
|
||||
},
|
||||
"verify": {
|
||||
"context": {
|
||||
"resources": {
|
||||
"url": "{SHA_ARCHIVE}",
|
||||
"path": "/bitnami/prestashop"
|
||||
},
|
||||
"runtime_parameters": "cHJlc3Rhc2hvcFVzZXJuYW1lOiB1c2VyCnByZXN0YXNob3BFbWFpbDogdXNlckBleGFtcGxlLmNvbQpwcmVzdGFzaG9wUGFzc3dvcmQ6IENvbXBsaWNhdGVkUGFzc3dvcmQxMjMhNApwcmVzdGFzaG9wSG9zdDogdm13YXJlLXByZXN0YXNob3AubXkKc2VydmljZToKICB0eXBlOiBMb2FkQmFsYW5jZXIKICBwb3J0czoKICAgIGh0dHA6IDgwCg==",
|
||||
"target_platform": {
|
||||
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
|
||||
"size": {
|
||||
"name": "S4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"action_id": "trivy",
|
||||
@@ -26,6 +39,38 @@
|
||||
"OS"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "health-check",
|
||||
"params": {
|
||||
"endpoint": "lb-prestashop-http",
|
||||
"app_protocol": "HTTP"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "goss",
|
||||
"params": {
|
||||
"resources": {
|
||||
"path": "/.vib/prestashop/goss"
|
||||
},
|
||||
"remote": {
|
||||
"workload": "deploy-prestashop"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "cypress",
|
||||
"params": {
|
||||
"resources": {
|
||||
"path": "/.vib/prestashop/cypress"
|
||||
},
|
||||
"endpoint": "lb-prestashop-http",
|
||||
"app_protocol": "HTTP",
|
||||
"env": {
|
||||
"username": "user",
|
||||
"password": "ComplicatedPassword123!4"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
]
|
||||
},
|
||||
"verify": {
|
||||
"context": {
|
||||
"resources": {
|
||||
"url": "{SHA_ARCHIVE}",
|
||||
"path": "/bitnami/prestashop"
|
||||
},
|
||||
"runtime_parameters": "cHJlc3Rhc2hvcFVzZXJuYW1lOiB1c2VyCnByZXN0YXNob3BFbWFpbDogdXNlckBleGFtcGxlLmNvbQpwcmVzdGFzaG9wUGFzc3dvcmQ6IENvbXBsaWNhdGVkUGFzc3dvcmQxMjMhNApwcmVzdGFzaG9wSG9zdDogdm13YXJlLXByZXN0YXNob3AubXkKc2VydmljZToKICB0eXBlOiBMb2FkQmFsYW5jZXIKICBwb3J0czoKICAgIGh0dHA6IDgwCg==",
|
||||
"target_platform": {
|
||||
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
|
||||
"size": {
|
||||
"name": "S4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"action_id": "trivy",
|
||||
@@ -24,6 +37,38 @@
|
||||
"threshold": "CRITICAL",
|
||||
"vuln_type": ["OS"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "health-check",
|
||||
"params": {
|
||||
"endpoint": "lb-prestashop-http",
|
||||
"app_protocol": "HTTP"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "goss",
|
||||
"params": {
|
||||
"resources": {
|
||||
"path": "/.vib/prestashop/goss"
|
||||
},
|
||||
"remote": {
|
||||
"workload": "deploy-prestashop"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "cypress",
|
||||
"params": {
|
||||
"resources": {
|
||||
"path": "/.vib/prestashop/cypress"
|
||||
},
|
||||
"endpoint": "lb-prestashop-http",
|
||||
"app_protocol": "HTTP",
|
||||
"env": {
|
||||
"username": "user",
|
||||
"password": "ComplicatedPassword123!4"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user