refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View File

@@ -0,0 +1,5 @@
{
"firstname": "Jane",
"lastname": "Florentina",
"email": "jane@example.com"
}

View File

@@ -0,0 +1,232 @@
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
}
},
{
"id": 3,
"name": "Clementine Bauch",
"username": "Samantha",
"email": "Nathan@yesenia.net",
"address": {
"street": "Douglas Extension",
"suite": "Suite 847",
"city": "McKenziehaven",
"zipcode": "59590-4157",
"geo": {
"lat": "-68.6102",
"lng": "-47.0653"
}
},
"phone": "1-463-123-4447",
"website": "ramiro.info",
"company": {
"name": "Romaguera-Jacobson",
"catchPhrase": "Face to face bifurcated interface",
"bs": "e-enable strategic applications"
}
},
{
"id": 4,
"name": "Patricia Lebsack",
"username": "Karianne",
"email": "Julianne.OConner@kory.org",
"address": {
"street": "Hoeger Mall",
"suite": "Apt. 692",
"city": "South Elvis",
"zipcode": "53919-4257",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "493-170-9623 x156",
"website": "kale.biz",
"company": {
"name": "Robel-Corkery",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
},
{
"id": 5,
"name": "Chelsey Dietrich",
"username": "Kamren",
"email": "Lucio_Hettinger@annie.ca",
"address": {
"street": "Skiles Walks",
"suite": "Suite 351",
"city": "Roscoeview",
"zipcode": "33263",
"geo": {
"lat": "-31.8129",
"lng": "62.5342"
}
},
"phone": "(254)954-1289",
"website": "demarco.info",
"company": {
"name": "Keebler LLC",
"catchPhrase": "User-centric fault-tolerant solution",
"bs": "revolutionize end-to-end systems"
}
},
{
"id": 6,
"name": "Mrs. Dennis Schulist",
"username": "Leopoldo_Corkery",
"email": "Karley_Dach@jasper.info",
"address": {
"street": "Norberto Crossing",
"suite": "Apt. 950",
"city": "South Christy",
"zipcode": "23505-1337",
"geo": {
"lat": "-71.4197",
"lng": "71.7478"
}
},
"phone": "1-477-935-8478 x6430",
"website": "ola.org",
"company": {
"name": "Considine-Lockman",
"catchPhrase": "Synchronised bottom-line interface",
"bs": "e-enable innovative applications"
}
},
{
"id": 7,
"name": "Kurtis Weissnat",
"username": "Elwyn.Skiles",
"email": "Telly.Hoeger@billy.biz",
"address": {
"street": "Rex Trail",
"suite": "Suite 280",
"city": "Howemouth",
"zipcode": "58804-1099",
"geo": {
"lat": "24.8918",
"lng": "21.8984"
}
},
"phone": "210.067.6132",
"website": "elvis.io",
"company": {
"name": "Johns Group",
"catchPhrase": "Configurable multimedia task-force",
"bs": "generate enterprise e-tailers"
}
},
{
"id": 8,
"name": "Nicholas Runolfsdottir V",
"username": "Maxime_Nienow",
"email": "Sherwood@rosamond.me",
"address": {
"street": "Ellsworth Summit",
"suite": "Suite 729",
"city": "Aliyaview",
"zipcode": "45169",
"geo": {
"lat": "-14.3990",
"lng": "-120.7677"
}
},
"phone": "586.493.6943 x140",
"website": "jacynthe.com",
"company": {
"name": "Abernathy Group",
"catchPhrase": "Implemented secondary concept",
"bs": "e-enable extensible e-tailers"
}
},
{
"id": 9,
"name": "Glenna Reichert",
"username": "Delphine",
"email": "Chaim_McDermott@dana.io",
"address": {
"street": "Dayna Park",
"suite": "Suite 449",
"city": "Bartholomebury",
"zipcode": "76495-3109",
"geo": {
"lat": "24.6463",
"lng": "-168.8889"
}
},
"phone": "(775)976-6794 x41206",
"website": "conrad.com",
"company": {
"name": "Yost and Sons",
"catchPhrase": "Switchable contextually-based project",
"bs": "aggregate real-time technologies"
}
},
{
"id": 10,
"name": "Clementina DuBuque",
"username": "Moriah.Stanton",
"email": "Rey.Padberg@karina.biz",
"address": {
"street": "Kattie Turnpike",
"suite": "Suite 198",
"city": "Lebsackbury",
"zipcode": "31428-2261",
"geo": {
"lat": "-38.2386",
"lng": "57.2232"
}
},
"phone": "024-648-3804",
"website": "ambrose.net",
"company": {
"name": "Hoeger LLC",
"catchPhrase": "Centralized empowering task-force",
"bs": "target end-to-end models"
}
}
]

View File

@@ -0,0 +1,11 @@
describe('Login', function () {
it('should not let user sign in with a non-existing account', function () {
cy.visit('/');
cy.get('input[name=email]').type('impossibru@test.com');
cy.get('input[name=password]').type('testtest');
cy.get('button[type=submit]').click();
cy.get('.alert').should('exist');
});
});

View File

@@ -0,0 +1,43 @@
var faker = require('faker');
describe('Signup', function () {
// @TODO: get emails from Mailtrap with their API and click on the confirmation
// link
//
// it('should sign up and logout', function () {
// cy.visit('/register')
// cy.get('input[name=email]').type('test@test.com')
// cy.get('input[name=first_name]').type('test')
// cy.get('input[name=last_name]').type('test')
// cy.get('input[name=password]').type('testtest')
// cy.get('input[name=password_confirmation]').type('testtest')
// cy.get('input[name=policy]').click()
// cy.get('button[type=submit]').click()
// cy.url().should('include', '/dashboard')
// cy.get('[data-cy=header-link-logout]').click()
// cy.contains('Login to your account')
// })
//it('should block registration if policy is not accepted', function () {
// cy.register(faker.name.firstName(), faker.name.lastName(), faker.internet.password(), faker.internet.email(), false);
// cy.get('.alert').should('exist');
//});
it('should block registration if email is already used', function () {
const email = faker.internet.email();
// test email address
cy.register(faker.name.firstName(), faker.name.lastName(), faker.internet.password(), email, true);
cy.get('.alert').should('not.exist');
cy.get('[data-cy=header-link-logout]').click();
cy.register(faker.name.firstName(), faker.name.lastName(), faker.internet.password(), email, true);
cy.get('.alert').should('exist');
});
});

View File

@@ -0,0 +1,35 @@
describe('Activities', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage an activity', function () {
cy.url().should('include', '/people/h:');
cy.get('[cy-name=activities-blank-state]').should('be.visible');
// add an activity
cy.createActivity();
// edit an activity
cy.get('[cy-name=activities-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (item) {
cy.get('[cy-name=edit-activity-button-'+item+']').click();
cy.get('[name=summary]').clear();
cy.get('[name=summary]').type('This is another summary');
cy.get('[cy-name=save-activity-button]').click();
cy.get('[cy-name=activity-body-'+item+']').should('exist');
cy.get('[cy-name=activity-body-'+item+']').should('contain', 'This is another summary');
// delete an activity
cy.get('[cy-name=delete-activity-button-'+item+']').click();
cy.wait(10);
cy.get('[cy-name=confirm-delete-activity]').should('be.visible').click();
cy.get('[cy-name=activities-blank-state]').should('be.visible');
cy.get('[cy-name=activity-body-'+item+']').should('not.exist');
});
});
});

View File

@@ -0,0 +1,38 @@
var _ = require('lodash');
describe('Calls', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a call', function () {
cy.url().should('include', '/people/h:');
cy.get('[cy-name=calls-blank-state]').should('exist');
cy.get('[cy-name=log-call-form]').should('not.be.visible');
cy.get('[cy-name=last-talked-to]').should('contain', 'unknown');
// add a call
cy.get('[cy-name=add-call-button]').click();
cy.get('[cy-name=log-call-form]').should('be.visible');
cy.get('[cy-name=save-call-button]').click();
cy.get('[cy-name=calls-blank-state]').should('not.exist');
cy.get('[cy-name=last-talked-to]').should('not.contain', 'unknown');
cy.get('[cy-name=calls-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (items) {
let item = _.last(items.split(','));
cy.get('[cy-name=call-body-'+item+']').should('exist');
cy.get('[cy-name=call-body-'+item+']').should('contain', 'John');
// delete a call
cy.get('[cy-name=delete-call-button-'+item+']').should('be.visible');
cy.get('[cy-name=delete-call-button-'+item+']').click();
cy.get('[cy-name=delete-call-confirm-button-'+item+']').should('be.visible');
cy.get('[cy-name=delete-call-confirm-button-'+item+']').click();
cy.get('[cy-name=calls-blank-state]').should('exist');
cy.get('[cy-name=last-talked-to]').should('contain', 'unknown');
});
});
});

View File

@@ -0,0 +1,95 @@
describe('Contacts', function () {
beforeEach(function () {
cy.login();
});
it('lets you add a contact', function () {
cy.createContact('John', 'Doe', 'Man');
cy.url().should('include', '/people/h:');
cy.get('h1').should('contain', 'John Doe');
});
it('lets you add two contacts in a row', function () {
cy.createContact('John', 'Doe', 'Man', 'save_and_add_another');
cy.url().should('include', '/people/add');
});
it('requires at least a firstname to add a contact', function () {
cy.visit('/people');
cy.get('#button-add-contact').click();
cy.get('button[name=save]').click();
cy.url().should('include', '/people/add');
cy.get('input[name=first_name]').type('John');
cy.get('select[name=gender]').select('Man');
cy.get('button[name=save]').click();
cy.url().should('include', '/people/h:');
cy.get('h1').should('contain', 'John');
});
it('lets you edit a contact', function () {
cy.createContact('John', 'Doe', 'Man');
cy.get('#button-edit-contact').click();
cy.url().should('include', '/edit');
cy.get('input[name=firstname]').should('have.value', 'John');
cy.get('input[name=lastname]').should('have.value', 'Doe');
//TO FIX cy.get('select[name=gender]').should('have.text', 'Man')
cy.get('input[name=firstname]').clear();
cy.get('input[name=firstname]').type('Jane');
cy.get('input[name=lastname]').clear();
cy.get('button[name=save]').click();
cy.url().should('include', '/people/h:');
cy.get('h1').should('contain', 'Jane');
});
it('lets you delete a contact', function () {
cy.createContact('John', 'Doe', 'Man');
cy.visit('/people');
cy.get('.people-list-item').should('contain', 'John Doe');
// this gets the first content of the list
cy.get('tr.people-list-item.bg-white.pointer').click();
cy.get('#link-delete-contact').click();
// cypress auto accepts window alerts (confirm or alert)
cy.url().should('include', '/people');
cy.visit('/people');
cy.get('.people-list-item').should('not.contain', 'John');
});
it('lets you add a contact as favorite', function () {
cy.createContact('John', 'Doe', 'Man');
cy.visit('/people');
// this gets the first content of the list
cy.get('tr.people-list-item.bg-white.pointer').click();
// tests if the favorite button can be toggled
cy.get('[cy-name=set-favorite]').should('be.visible');
cy.get('[cy-name=set-favorite]').click();
cy.get('[cy-name=set-favorite]').should('not.be.visible');
cy.get('[cy-name=unset-favorite]').should('be.visible');
cy.get('[cy-name=unset-favorite]').click();
cy.get('[cy-name=set-favorite]').should('be.visible');
// test to see if a contact appears on top of the contact list if favorited
cy.get('[cy-name=set-favorite]').click();
cy.visit('/dashboard');
cy.createContact('Abc', 'Abc', 'Man');
cy.visit('/people');
cy.get('.people-list-item span').should('contain', 'John Doe');
cy.get('.people-list-item svg').should('be.visible');
cy.get('.people-list-item').should('contain', 'Abc Abc');
});
});

View File

@@ -0,0 +1,27 @@
describe('Conversations', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a conversation', function () {
cy.get('[cy-name=conversation-blank-state]').should('be.visible');
// add a conversation
cy.visit('/people');
// this gets the first content of the list
cy.get('tr.people-list-item.bg-white.pointer').click();
cy.get('[cy-name=add-conversation-button]').should('be.visible');
cy.get('[cy-name=add-conversation-button]').click();
cy.url().should('include', '/conversations/create');
cy.get('[name=contactFieldTypeId]').select('Phone');
cy.get('[name=content_1]').type('This is a message');
cy.get('[cy-name=save-conversation-button]').click();
cy.url().should('include', '/people/h:');
cy.get('[cy-name=conversation-blank-state]').should('not.be.visible');
});
});

View File

@@ -0,0 +1,46 @@
describe('Debts', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a debt', function () {
cy.url().should('include', '/people/h:');
cy.get('[cy-name=debt-blank-state]').should('be.visible');
// add a debt
cy.get('[cy-name=add-debt-button]').should('be.visible');
cy.get('[cy-name=add-debt-button]').click();
cy.url().should('include', '/debts/create');
cy.get('[name=amount]').type('123');
cy.get('[cy-name=save-debt-button]').click();
cy.url().should('include', '/people/h:');
cy.get('[cy-name=debt-blank-state]').should('not.be.visible');
cy.get('[cy-name=debts-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (item) {
cy.get('[cy-name=debt-item-'+item+']').should('exist');
cy.get('[cy-name=debt-item-'+item+']').should('contain', '123');
// edit a debt
cy.get('[cy-name=edit-debt-button-'+item+']').click();
cy.url().should('include', '/edit');
cy.get('[name=amount]').clear();
cy.get('[name=amount]').type('234');
cy.get('[cy-name=save-debt-button]').click();
cy.get('[cy-name=debt-item-'+item+']').should('exist');
cy.get('[cy-name=debt-item-'+item+']').should('contain', '234');
// delete a debt
cy.get('[cy-name=delete-debt-button-'+item+']').click();
cy.get('[cy-name=confirm-delete-debt]').should('be.visible').click();
cy.get('[cy-name=debt-blank-state]').should('be.visible');
cy.get('[cy-name=debt-item-'+item+']').should('not.exist');
});
});
});

View File

@@ -0,0 +1,50 @@
/*
Gift page has change recently a lot, let rewrite this test later ...
###
describe('Gifts', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a gift', function () {
cy.url().should('include', '/people/h:');
// add a gift
cy.get('[cy-name=add-gift-button]').should('be.visible');
cy.get('[cy-name=add-gift-button]').click();
cy.url().should('include', '/gifts/create');
cy.get('[name=name]').type('This is a gift');
cy.get('[cy-name=save-gift-button]').click();
cy.url().should('include', '/people/h:');
cy.get('[cy-name=gift-ideas-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (item) {
cy.get('[cy-name=gift-idea-item-'+item+']').should('exist');
cy.get('[cy-name=gift-idea-item-'+item+']').should('contain', 'This is a gift');
// edit a gift
cy.get('[cy-name=edit-gift-button-'+item+']').click();
cy.url().should('include', '/gifts/'+item+'/edit');
cy.get('[name=name]').clear();
cy.get('[name=name]').type('This is another gift');
cy.get('[cy-name=save-gift-button]').click();
cy.get('[cy-name=gift-idea-item-'+item+']').should('exist');
cy.get('[cy-name=gift-idea-item-'+item+']').should('contain', 'This is another gift');
// delete an gift
cy.get('[cy-name=delete-gift-button-'+item+']').click();
cy.get('[cy-name=modal-delete-gift-button-'+item+']').click();
cy.get('[cy-name=activities-blank-state]').should('be.visible');
cy.get('[cy-name=gift-idea-item-'+item+']').should('not.exist');
});
});
});
*/

View File

@@ -0,0 +1,65 @@
describe('Introduction', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
cy.createContact('Jane', 'Doe', 'Woman');
cy.createContact('Joe', 'Shmoe', 'Man');
});
it('lets you fill first met without an introducer', function () {
cy.url().should('include', '/people/h:');
cy.get('.introductions a[href$="introductions/edit"]').click();
cy.url().should('include', '/introductions/edit');
cy.get('textarea[name=first_met_additional_info]').type('Lorem ipsum');
cy.get('button.btn-primary[type=submit]').click();
cy.url().should('include', '/people/h:');
cy.get('.alert-success');
cy.get('.introductions').contains('Lorem ipsum');
});
it('lets you save first met', function () {
cy.url().should('include', '/people/h:');
cy.get('.introductions a[href$="introductions/edit"]').click();
cy.url().should('include', '/introductions/edit');
cy.get('textarea[name=first_met_additional_info]').type('Lorem ipsum');
cy.get('#metThrough > .v-select input').click();
cy.get('#metThrough ul[role="listbox"]').contains('John Doe');
cy.get('#metThrough ul[role="listbox"]').contains('Jane Doe');
cy.get('#metThrough ul[role="listbox"]').contains('Joe Shmoe');
cy.get('#metThrough ul[role="listbox"]').contains('John Doe').click();
cy.get('button.btn-primary[type=submit]').click();
cy.url().should('include', '/people/h:');
cy.get('.alert-success');
cy.get('.introductions').contains('Lorem ipsum');
cy.get('.introductions').contains('John Doe');
});
it('lets you search first met', function () {
cy.url().should('include', '/people/h:');
cy.get('.introductions a[href$="introductions/edit"]').click();
cy.url().should('include', '/introductions/edit');
cy.get('textarea[name=first_met_additional_info]').type('Lorem ipsum');
cy.get('#metThrough input[type=search]').type('John');
cy.get('#metThrough ul[role="listbox"]').contains('John Doe');
cy.get('#metThrough ul[role="listbox"]').should('not.contain', 'Joe Shmoe');
cy.get('#metThrough ul[role="listbox"]').should('not.contain', 'Jane Doe');
cy.get('#metThrough ul[role="listbox"]').contains('John Doe').click();
cy.get('button.btn-primary[type=submit]').click();
cy.url().should('include', '/people/h:');
cy.get('.introductions').contains('Lorem ipsum');
cy.get('.introductions').contains('John Doe');
});
});

View File

@@ -0,0 +1,45 @@
describe('Notes', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a note', function () {
cy.url().should('include', '/people/h:');
cy.get('[cy-name=add-note-button]').should('not.be.visible');
// add a note
cy.get('[cy-name=add-note-textarea]').click();
cy.get('[cy-name=add-note-button]').should('be.visible');
cy.get('[cy-name=add-note-textarea]').type('This is a note');
cy.get('[cy-name=add-note-button]').click();
cy.get('[cy-name=notes-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (item) {
cy.get('[cy-name=note-body-'+item+']').should('contain', 'This is a note');
cy.get('[cy-name=edit-note-body-'+item+']').should('not.be.visible');
// edit a note
cy.get('[cy-name=edit-note-button-'+item+']').click();
cy.get('[cy-name=edit-note-body-'+item+']').should('be.visible');
cy.get('[cy-name=edit-note-body-'+item+']').clear();
cy.get('[cy-name=edit-note-body-'+item+']').type('This is another note');
cy.get('[cy-name=edit-mode-note-button-'+item+']').click();
cy.get('[cy-name=edit-note-body-'+item+']').should('not.be.visible');
cy.get('[cy-name=note-body-'+item+']').should('contain', 'This is another note');
// delete a note
cy.get('[cy-name=modal-delete-note]').should('not.be.visible');
cy.get('[cy-name=delete-note-button-'+item+']').click();
cy.get('[cy-name=modal-delete-note]').should('be.visible');
cy.get('[cy-name=delete-mode-note-button-'+item+']').click();
cy.get('[cy-name=note-body-'+item+']').should('not.exist');
});
});
});

View File

@@ -0,0 +1,31 @@
describe('Tasks', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a task', function () {
cy.url().should('include', '/people/h:');
cy.get('[cy-name=task-blank-state]').should('be.visible');
// add a task
cy.get('[cy-name=add-task-button]').click();
cy.get('[cy-name=task-add-view]').should('be.visible');
cy.get('[cy-name=task-add-title]').type('This is a task');
cy.get('[cy-name=save-task-button]').click();
cy.get('[cy-name=tasks-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (item) {
cy.get('[cy-name=task-item-'+item+']').should('exist');
cy.get('[cy-name=task-item-'+item+']').should('contain', 'This is a task');
// edit a task
cy.get('[cy-name=task-toggle-edit-mode]').click();
cy.get('[cy-name=task-delete-button-'+item+']').click();
cy.get('[cy-name=task-blank-state]').should('be.visible');
});
});
});

View File

@@ -0,0 +1,73 @@
describe('Journal entries', function () {
beforeEach(function () {
cy.login();
cy.createContact('John', 'Doe', 'Man');
});
it('lets you manage a journal entry', function () {
cy.visit('/journal');
cy.get('[cy-name=journal-blank-state]').should('be.visible');
// add a journal entry
cy.get('[cy-name=add-entry-button]').should('be.visible');
cy.get('[cy-name=add-entry-button]').click();
cy.url().should('include', '/journal/add');
cy.get('[name=entry]').type('This is an entry');
cy.get('[cy-name=save-entry-button]').click();
cy.url().should('include', '/journal');
cy.get('[cy-name=journal-blank-state]').should('not.be.visible');
cy.get('[cy-name=journal-entries-body]').should('be.visible')
.invoke('attr', 'cy-items').then(function (item) {
cy.get('[cy-name=journal-entries-body]')
.invoke('attr', 'cy-object-items').then(function (objItem) {
cy.get('[cy-name=entry-body-'+item+']').should('exist');
cy.get('[cy-name=entry-body-'+item+']').should('contain', 'This is an entry');
// delete a journal entry
cy.get('[cy-name=entry-delete-button-'+objItem+']').click();
cy.url().should('include', '/journal');
cy.get('[cy-name=entry-body-'+item+']').should('not.exist');
});
});
});
it('creates a journal entry when creating an activity', function () {
cy.createActivity();
cy.visit('/journal');
cy.get('[cy-name=journal-blank-state]').should('not.be.visible');
cy.get('[cy-name=journal-entries-body]').should('be.visible').then((entries) => {
let item = entries[0].getAttribute('cy-items');
let objItem = entries[0].getAttribute('cy-object-items');
cy.get('[cy-name=entry-body-'+item+']').should('exist');
cy.get('[cy-name=entry-body-'+item+']').should('contain', 'This is a summary');
cy.get('[cy-name=entry-delete-button-'+objItem+']').should('not.exist');
});
});
it('lets you rate your day', function () {
cy.visit('/journal');
cy.get('[cy-name=journal-blank-state]').should('be.visible');
cy.get('[cy-name=sad-reaction-button]').click();
cy.wait(10);
cy.get('[cy-name=comment]').should('be.visible');
cy.get('[cy-name=save-entry-button]').click();
cy.get('[cy-name=journal-entries-body]').should('be.visible').then((entries) => {
let item = entries[0].getAttribute('cy-items');
cy.get('[cy-name=entry-body-'+item+']').should('exist');
cy.get('[cy-name=entry-delete-button-'+item+']').should('exist');
});
});
});

View File

@@ -0,0 +1,134 @@
var _ = require('lodash');
describe('Settings: activity types', function () {
it('doesn\'t let you manage activity types if user is not premium', function () {
cy.login();
cy.visit('/settings/personalization');
cy.get('[cy-name=activity-type-premium-message]').should('be.visible');
cy.get('[cy-name=activity-type-edit-button]').should('not.exist');
});
it('lets you manage an activity type category and activity type', function () {
cy.login();
cy.visit('/');
// set account as premium
cy.get('body').invoke('attr', 'data-account-id').then(function ($accountId) {
cy.setPremium($accountId);
});
// make sure that going premium removes restrictions
cy.visit('/settings/personalization');
cy.get('[cy-name=activity-type-premium-message]').should('not.be.visible');
cy.get('[cy-name=activity-types]').should('contain', 'played a sport together');
// add an activity type category
cy.get('[cy-name=add-activity-type-category-button]').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=add-category-name]').type('This is an activity type category');
cy.get('[cy-name=add-activity-type-category-save-button]').click();
cy.wait(10);
cy.get('[cy-name=activity-types]').should('contain', 'This is an activity type category');
cy.get('[cy-name=activity-type-categories]').invoke('attr', 'cy-items').then((items) => {
let item = _.last(items.split(','));
// edit an activity type category
cy.get('[cy-name=activity-type-category-edit-button-'+item+']').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=update-category-name]').clear();
cy.get('[name=update-category-name]').type('This is still an activity type category');
cy.get('[cy-name=update-activity-type-category-button]').click();
cy.get('[cy-name=activity-types]').should('contain', 'This is still an activity type category');
// add an activity type
cy.get('[cy-name=add-activity-type-button-for-category-'+item+']').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=add-type-name]').type('This is activity type 1');
cy.get('[cy-name=add-type-button]').click();
cy.get('[cy-name=activity-types]').should('contain', 'This is activity type 1');
// edit an activity type
cy.get('[cy-name=activity-types-'+item+']').invoke('attr', 'cy-items').then((items) => {
let aitem = _.last(items.split(','));
cy.get('[cy-name=activity-type-edit-button-'+aitem+']').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=update-type-name]').clear();
cy.get('[name=update-type-name]').type('This is modified activity type 1');
cy.get('[cy-name=update-type-button]').click();
cy.wait(10);
cy.get('[cy-name=activity-types]').should('contain', 'This is modified activity type 1');
});
// delete an activity type
cy.get('[cy-name=add-activity-type-button-for-category-'+item+']').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=add-type-name]').type('This is activity type 2');
cy.get('[cy-name=add-type-button]').click();
cy.get('[cy-name=activity-types]').should('contain', 'This is activity type 2');
cy.get('[cy-name=activity-types-'+item+']').invoke('attr', 'cy-items').then((items) => {
let aitem = _.last(items.split(','));
cy.get('[cy-name=activity-type-delete-button-'+aitem+']').click();
cy.get('[cy-name=delete-type-button]').click();
cy.get('[cy-name=activity-types]').should('not.contain', 'This is activity type 2');
});
// now delete the activity type category and make sure it also deletes
// the activity type that belonged to it
cy.get('[cy-name=activity-type-category-delete-button-'+item+']').click();
cy.get('[cy-name=delete-category-button]').click();
cy.get('[cy-name=activity-types]').should('not.contain', 'This is still an activity type category');
cy.get('[cy-name=activity-types]').should('not.contain', 'This is modified activity type 1');
});
});
it('lets you add an activity type and use it', function () {
cy.login();
cy.visit('/');
// set account as premium
cy.get('body').invoke('attr', 'data-account-id').then(function ($accountId) {
cy.setPremium($accountId);
});
// make sure that going premium removes restrictions
cy.visit('/settings/personalization');
cy.get('[cy-name=activity-type-premium-message]').should('not.be.visible');
cy.get('[cy-name=activity-types]').should('contain', 'played a sport together');
// add an activity type category
cy.get('[cy-name=add-activity-type-category-button]').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=add-category-name]').type('This is an activity type category');
cy.get('[cy-name=add-activity-type-category-save-button]').click();
cy.get('[cy-name=activity-types]').should('contain', 'This is an activity type category');
cy.get('[cy-name=activity-type-categories]').invoke('attr', 'cy-items').then((items) => {
let item = _.last(items.split(','));
// edit an activity type category
cy.get('[cy-name=activity-type-category-edit-button-'+item+']').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=update-category-name]').clear();
cy.get('[name=update-category-name]').type('This is still an activity type category');
cy.get('[cy-name=update-activity-type-category-button]').click();
cy.get('[cy-name=activity-types]').should('contain', 'This is still an activity type category');
// add an activity type
cy.get('[cy-name=add-activity-type-button-for-category-'+item+']').click();
cy.get('.sweet-modal-overlay').should('be.visible');
cy.get('[name=add-type-name]').type('This is activity type 1');
cy.get('[cy-name=add-type-button]').click();
cy.get('[cy-name=activity-types]').should('contain', 'This is activity type 1');
// make sure the activity type exists on the Add activity page
cy.createContact('John', 'Doe', 'Man');
cy.get('[cy-name=add-activity-button]').click();
cy.get('[cy-name=activities_add_category]').click();
cy.get('[name=activity-type-list]').should('contain', 'This is activity type 1');
});
});
});

17
tests/cypress/plugins/index.js vendored Normal file
View File

@@ -0,0 +1,17 @@
// ***********************************************************
// 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)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

25
tests/cypress/support/commands.js vendored Normal file
View File

@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

24
tests/cypress/support/helpers/app.js vendored Normal file
View File

@@ -0,0 +1,24 @@
Cypress.Commands.add('login', () => {
cy.exec('php artisan setup:frontendtestuser').then((result) => {
cy.visit('/_dusk/login/'+result.stdout+'/');
});
});
Cypress.Commands.add('setPremium', (accountId) => {
cy.exec('php artisan account:setpremium ' + accountId);
});
Cypress.Commands.add('register', (firstName, lastName, password, email, policy) => {
cy.visit('/register');
cy.get('.alert').should('not.exist');
cy.get('input[name=email]').type(email);
cy.get('input[name=first_name]').type(firstName);
cy.get('input[name=last_name]').type(lastName);
cy.get('input[name=password]').type(password);
cy.get('input[name=password_confirmation]').type(password);
if (policy) {
cy.get('input[name=policy]').click();
}
cy.get('button[type=submit]').click();
});

View File

@@ -0,0 +1,34 @@
Cypress.Commands.add('createContact', (firstname, lastname, gender, action = 'save') => {
cy.visit('/people');
cy.get('#button-add-contact').click();
cy.get('input[name=first_name]').type(firstname);
cy.get('input[name=last_name]').type(lastname);
cy.get('select[name=gender]').select(gender);
cy.get('button[name=' + action + ']').click();
});
Cypress.Commands.add('createActivity', () => {
cy.visit('/people');
// this gets the first content of the list
cy.get('tr.clickable.people-list-item.bg-white.pointer').click();
cy.get('[cy-name=add-activity-button]').should('be.visible');
cy.get('[cy-name=add-activity-button]').click();
//cy.url().should('include', '/activities/add/h:');
cy.get('[name=summary]').type('This is a summary');
cy.get('[cy-name=save-activity-button]').click();
cy.url().should('include', '/people/h:');
cy.get('[cy-name=activities-blank-state]').should('not.be.visible');
cy.get('[cy-name=activities-body]').should('be.visible').then((activities) => {
let item = activities[0].getAttribute('cy-items');
cy.get('[cy-name=activity-body-'+item+']').should('exist');
cy.get('[cy-name=activity-body-'+item+']').should('contain', 'This is a summary');
});
});

22
tests/cypress/support/index.js vendored Normal file
View File

@@ -0,0 +1,22 @@
// ***********************************************************
// 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';
import './helpers/app';
import './helpers/contacts';
// Alternatively you can use CommonJS syntax:
// require('./commands')