[bitnami/ghost] Revisit tests (#13755)

* [bitnami/ghost] Revisit tests

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Format and improve tests resiliency

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Update cypress params

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>
This commit is contained in:
Jose Antonio Carmona
2022-12-12 17:06:05 +01:00
committed by GitHub
parent 1f233bf566
commit b3b9d13f54
14 changed files with 75 additions and 150 deletions
+3 -2
View File
@@ -1,10 +1,11 @@
{
"env": {
"email": "user@example.com",
"email": "vim-tests@example.com",
"username": "bitnamiTest",
"password": "Complicated123!4"
},
"hosts": {
"bitnami-ghost.my": "{{ TARGET_IP }}"
"vmware-ghost.my": "{{ TARGET_IP }}"
},
"defaultCommandTimeout": 60000
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@@ -1,3 +0,0 @@
id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products
624dbfbd02708a014290a2af,loic@example.com,Loic,Sample note,true,,,2022-04-06T16:28:45.000Z,,,
624dbfdb02708a014290a2b2,marina@example.com,Marina,Bitnami engineer,true,,,2022-04-06T16:29:15.000Z,,,
1 id email name note subscribed_to_emails complimentary_plan stripe_customer_id created_at deleted_at labels products
2 624dbfbd02708a014290a2af loic@example.com Loic Sample note true 2022-04-06T16:28:45.000Z
3 624dbfdb02708a014290a2b2 marina@example.com Marina Bitnami engineer true 2022-04-06T16:29:15.000Z
@@ -1,6 +0,0 @@
{
"newPage": {
"title": "New trends",
"content": "Lorem ipsum dolor sit amet"
}
}
@@ -1,6 +1,6 @@
{
"newPost": {
"title": "The beginning of a new journey",
"title": "journeys",
"content": "I was amazed by the incredible views"
}
}
@@ -1,6 +0,0 @@
{
"admin": {
"fullname": "Lars Sanchez",
"bio": "British and greek!"
}
}
@@ -1,30 +1,21 @@
/// <reference types="cypress" />
import {
random,
getPageUrlFromTitle,
getUserFromEmail,
} from '../support/utils';
import { random } from '../support/utils';
it('allows to log in and out', () => {
cy.login();
cy.get("div[class*='avatar']").click();
cy.contains('Sign out').click();
cy.contains('Sign in');
});
it('allows to create and publish a new post', () => {
it('allows to create and publish a new post with an image', () => {
cy.login();
cy.visit('/ghost/#/posts');
cy.contains('New post').click();
cy.get('input[type="file"]').selectFile(
'cypress/fixtures/images/post_image.png',
cy.get('[type="file"]').selectFile(
'cypress/fixtures/images/test_image.jpeg',
{ force: true }
);
cy.fixture('posts').then(($posts) => {
cy.fixture('posts').then((posts) => {
cy.get('textarea[placeholder="Post title"]').type(
`${$posts.newPost.title}-${random}`
`${posts.newPost.title}-${random}`
);
cy.get('article div[contenteditable="true"]').type(`${$posts.newPost.content}-${random}`, {force: true});
cy.get('article div[contenteditable="true"]').type(posts.newPost.content, {
force: true,
});
});
// Publishing a post needs 3 steps
// Step 1: Open drop-down menu
@@ -37,86 +28,15 @@ it('allows to create and publish a new post', () => {
cy.get('div[class=gh-publish-cta]').within(() => {
cy.contains('Publish').click();
});
cy.contains('Its out there').should('be.visible');
cy.visit('/');
cy.fixture('posts').then(($posts) => {
cy.contains(`${$posts.newPost.title}-${random}`);
cy.get(`img[alt='${$posts.newPost.title}-${random}']`);
});
});
it('allows to create a new page', () => {
cy.login();
cy.visit('/ghost/#/pages');
cy.contains('New page').click();
cy.fixture('pages').then(($pages) => {
cy.get('textarea[placeholder="Page title"]').type(
`${$pages.newPage.title}-${random}`
);
// Clicking a different element to trigger save event
cy.get('article').click()
cy.contains('div[class=gh-editor-post-status]', 'Saved');
cy.get('article').type(`${$pages.newPage.content}-${random}`);
// Ensure content has been saved before publishing
cy.get('textarea[placeholder="Page title"]').click()
cy.contains('div[class=gh-editor-post-status]', 'Saved');
});
// Publishing a page needs 3 steps
// Step 1: Open drop down-menu
cy.contains('Publish').click();
// Step 2: Select the option from the menu
cy.get('div[class=gh-publish-cta]').within(() => {
cy.contains('Continue').click();
});
// Step 3: Confirmation pop-up
cy.get('div[class=gh-publish-cta]').within(() => {
cy.contains('Publish').click();
});
cy.contains('Its out there').should('be.visible');
cy.fixture('pages').then(($pages) => {
cy.visit(getPageUrlFromTitle(`${$pages.newPage.title}-${random}`));
cy.contains(`${$pages.newPage.title}-${random}`);
cy.contains(`${$pages.newPage.content}-${random}`);
});
});
it('allows to import members', () => {
cy.login();
cy.visit('/ghost/#/members/import');
cy.contains('h1', 'Import members').should('be.visible');
cy.get('input[type="file"]').selectFile('cypress/fixtures/members.csv', {
force: true,
});
cy.contains('button', 'Import').click();
cy.contains('Import complete');
cy.visit('/ghost/#/members/');
cy.fixture('members')
.then(($rawMembers) => {
// Get an arbitrary member from the collection
let membersArray = $rawMembers.split('\n');
membersArray.shift(); // Delete CSV column header
return membersArray[Math.floor(Math.random() * membersArray.length)];
})
.then(($randomMember) => {
const EMAIL_COLUMN_CSV = 1;
cy.contains($randomMember.split(',')[EMAIL_COLUMN_CSV]);
});
});
it('allows to change users settings', () => {
cy.login();
cy.visit(`/ghost/#/settings/staff/${getUserFromEmail()}`);
cy.fixture('user-settings').then(($us) => {
cy.get('input#user-name')
.clear()
.type(`${$us.admin.fullname}-${random}`, { force: true });
cy.get('textarea#user-bio')
.clear()
.type(`${$us.admin.bio}-${random}`, { force: true });
cy.contains('button', 'Save').click();
cy.visit(`/author/${getUserFromEmail()}`);
cy.contains(`${$us.admin.fullname}-${random}`);
cy.contains(`${$us.admin.bio}-${random}`);
cy.fixture('posts').then((posts) => {
// Avoid new tab
cy.contains('a', `${posts.newPost.title}-${random}`)
.invoke('attr', 'href')
.then((url) => {
cy.visit(url);
cy.contains(Cypress.env('username'));
cy.contains(posts.newPost.content);
cy.get(`img[alt='${posts.newPost.title}-${random}']`);
});
});
});
@@ -1,5 +1,5 @@
const COMMAND_DELAY = 2000;
const BASE_URL = 'http://bitnami-ghost.my';
const BASE_URL = 'http://vmware-ghost.my';
for (const command of ['click']) {
Cypress.Commands.overwrite(command, (originalFn, ...args) => {
@@ -19,20 +19,22 @@ for (const command of ['click']) {
//
// Further details: https://github.com/cypress-io/cypress/issues/20647
Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
return originalFn(`${BASE_URL}${url}`, options);
// Only replace relative URLs
const targetUrl = url.includes('://') ? url : `${BASE_URL}${url}`;
return originalFn(targetUrl, options);
});
Cypress.Commands.add(
'login',
(email = Cypress.env('email'), password = Cypress.env('password')) => {
cy.visit('/ghost/');
cy.get('input[type="email"]').should('be.enabled').type(email);
cy.get('input[type="password"]').should('be.enabled').type(password);
cy.get('[type="email"]').type(email);
cy.get('[type="password"]').type(password);
cy.contains('button', 'Sign in').click();
// In Ghost, logging is not considered as completed until the Dashboard view
// is visible. Navigating to any other site before that will lead to an error
// 500
cy.contains('Dashboard').should('be.visible');
cy.contains('h2', 'Dashboard').should('be.visible');
}
);
+1 -9
View File
@@ -1,11 +1,3 @@
/// <reference types="cypress" />
export let random = (Math.random() + 1).toString(36).substring(7);
export const getPageUrlFromTitle = (title) => {
return '/'.concat(title.toLocaleLowerCase().replace(' ', '-'));
};
export const getUserFromEmail = (email = Cypress.env('email')) => {
return email.substring(0, email.indexOf('@'));
};
export let random = (Math.random() + 1).toString(36).substring(7);
+22 -15
View File
@@ -1,20 +1,27 @@
http:
http://localhost:{{ .Vars.containerPorts.http }}:
status: 200
command:
which-ghost:
exec: which ghost
{{- $checkCmd := "ghost config get %s -d /opt/bitnami/ghost | grep -q %d" }}
{{- $dbCheck := printf $checkCmd "database.connection.database" .Vars.mysql.auth.database }}
{{- $userCheck := printf $checkCmd "database.connection.user" .Vars.mysql.auth.username }}
{{- $passCheck := printf $checkCmd "database.connection.password" .Vars.mysql.auth.password }}
check-db-config:
exec: ($dbCheck) && ($userCheck) && ($passCheck)
exit-status: 0
check-user-info:
exec: id
exit-status: 0
stdout:
- "/opt/bitnami/ghost/bin/ghost"
stderr: [ ]
timeout: 40000
- uid={{ .Vars.containerSecurityContext.runAsUser }}
- /groups=.*{{ .Vars.podSecurityContext.fsGroup }}/
file:
/opt/bitnami/ghost/content:
filetype: symlink
linked-to: /bitnami/ghost/content
exists: true
/bitnami/ghost/config.production.json:
mode: "0644"
filetype: file
exists: true
user:
ghost:
/bitnami/ghost:
exists: true
filetype: directory
mode: '2775'
owner: root
/var/run/secrets/kubernetes.io/serviceaccount:
exists: {{ .Vars.serviceAccount.automountServiceAccountToken }}
filetype: directory
mode: "3777"
+14
View File
@@ -0,0 +1,14 @@
containerPorts:
http: 2369
podSecurityContext:
fsGroup: 1002
containerSecurityContext:
runAsUser: 1002
mysql:
auth:
database: bitnami_test_ghost
username: bn_test_ghost
password: bitnami_test_password
serviceAccount:
create: true
automountServiceAccountToken: true
+4 -2
View File
@@ -22,7 +22,7 @@
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/ghost"
},
"runtime_parameters": "Z2hvc3RVc2VybmFtZTogdXNlcgpnaG9zdFBhc3N3b3JkOiBDb21wbGljYXRlZDEyMyE0Cmdob3N0RW1haWw6IHVzZXJAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiBiaXRuYW1pLWdob3N0Lm15CnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAo=",
"runtime_parameters": "Z2hvc3RVc2VybmFtZTogYml0bmFtaVRlc3QKZ2hvc3RQYXNzd29yZDogQ29tcGxpY2F0ZWQxMjMhNApnaG9zdEVtYWlsOiB2aW0tdGVzdHNAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiB2bXdhcmUtZ2hvc3QubXkKZ2hvc3RTa2lwSW5zdGFsbDogZmFsc2UKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogMjM2OQpwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICB0eXBlOiBMb2FkQmFsYW5jZXIKICBwb3J0czoKICAgIGh0dHA6IDgwCm15c3FsOgogIGVuYWJsZWQ6IHRydWUKICBhdXRoOgogICAgZGF0YWJhc2U6IGJpdG5hbWlfdGVzdF9naG9zdAogICAgdXNlcm5hbWU6IGJuX3Rlc3RfZ2hvc3QKICAgIHBhc3N3b3JkOiBiaXRuYW1pX3Rlc3RfcGFzc3dvcmQKc2VydmljZUFjY291bnQ6CiAgY3JlYXRlOiB0cnVlCiAgYXV0b21vdW50U2VydmljZUFjY291bnRUb2tlbjogdHJ1ZQ==",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
@@ -44,6 +44,7 @@
"resources": {
"path": "/.vib/ghost/goss"
},
"vars_file": "vars.yaml",
"remote": {
"workload": "deploy-ghost"
}
@@ -58,7 +59,8 @@
"endpoint": "lb-ghost-http",
"app_protocol": "HTTP",
"env": {
"email": "user@example.com",
"email": "vim-tests@example.com",
"username": "bitnamiTest",
"password": "Complicated123!4"
}
}
+4 -2
View File
@@ -22,7 +22,7 @@
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/ghost"
},
"runtime_parameters": "Z2hvc3RVc2VybmFtZTogdXNlcgpnaG9zdFBhc3N3b3JkOiBDb21wbGljYXRlZDEyMyE0Cmdob3N0RW1haWw6IHVzZXJAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiBiaXRuYW1pLWdob3N0Lm15CnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAo=",
"runtime_parameters": "Z2hvc3RVc2VybmFtZTogYml0bmFtaVRlc3QKZ2hvc3RQYXNzd29yZDogQ29tcGxpY2F0ZWQxMjMhNApnaG9zdEVtYWlsOiB2aW0tdGVzdHNAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiB2bXdhcmUtZ2hvc3QubXkKZ2hvc3RTa2lwSW5zdGFsbDogZmFsc2UKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogMjM2OQpwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICB0eXBlOiBMb2FkQmFsYW5jZXIKICBwb3J0czoKICAgIGh0dHA6IDgwCm15c3FsOgogIGVuYWJsZWQ6IHRydWUKICBhdXRoOgogICAgZGF0YWJhc2U6IGJpdG5hbWlfdGVzdF9naG9zdAogICAgdXNlcm5hbWU6IGJuX3Rlc3RfZ2hvc3QKICAgIHBhc3N3b3JkOiBiaXRuYW1pX3Rlc3RfcGFzc3dvcmQKc2VydmljZUFjY291bnQ6CiAgY3JlYXRlOiB0cnVlCiAgYXV0b21vdW50U2VydmljZUFjY291bnRUb2tlbjogdHJ1ZQ==",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
@@ -44,6 +44,7 @@
"resources": {
"path": "/.vib/ghost/goss"
},
"vars_file": "vars.yaml",
"remote": {
"workload": "deploy-ghost"
}
@@ -58,7 +59,8 @@
"endpoint": "lb-ghost-http",
"app_protocol": "HTTP",
"env": {
"email": "user@example.com",
"email": "vim-tests@example.com",
"username": "bitnamiTest",
"password": "Complicated123!4"
}
}