2021-08-11 08:12:32 +00:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
2021-09-27 13:53:40 +00:00
|
|
|
describe('Friends page without data', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
cy.stubAuthenticate();
|
|
|
|
|
cy.intercept('POST', /\S+\/filter/,
|
|
|
|
|
{
|
|
|
|
|
"musicians": []
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('shows no records alert', () => {
|
|
|
|
|
cy.visit('/friends');
|
|
|
|
|
cy.contains('No Records!')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('Friends page with data', () => {
|
2021-08-26 17:23:24 +00:00
|
|
|
beforeEach(() => {
|
2021-09-23 14:04:43 +00:00
|
|
|
cy.stubAuthenticate({ id: '2'}); //currentUser id is 2 - people.yaml fixture
|
2021-08-26 17:23:24 +00:00
|
|
|
cy.intercept('POST', /\S+\/filter/, { fixture: 'people' });
|
|
|
|
|
});
|
2021-08-11 08:12:32 +00:00
|
|
|
|
2021-08-26 17:23:24 +00:00
|
|
|
describe('friends list', () => {
|
2021-08-11 08:12:32 +00:00
|
|
|
beforeEach(() => {
|
2021-08-26 17:23:24 +00:00
|
|
|
cy.visit('/friends');
|
|
|
|
|
});
|
2021-08-11 08:12:32 +00:00
|
|
|
|
2021-09-23 14:04:43 +00:00
|
|
|
it('lists musician users', () => {
|
2021-08-26 17:23:24 +00:00
|
|
|
cy.contains('Find New Friends').should('exist');
|
|
|
|
|
cy.contains('Update Search').should('exist');
|
|
|
|
|
cy.contains('Reset Filters').should('exist');
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.should('have.length', 20)
|
|
|
|
|
.first()
|
|
|
|
|
.contains('Test User1');
|
|
|
|
|
});
|
2021-08-11 08:12:32 +00:00
|
|
|
|
2021-08-26 17:23:24 +00:00
|
|
|
//TODO: paginate
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-23 14:20:54 +00:00
|
|
|
describe('details side panel', () => {
|
2021-08-31 18:25:15 +00:00
|
|
|
|
|
|
|
|
const showSidePanelContent = () => {
|
|
|
|
|
cy.get('[data-testid=profileSidePanel] h4').should('have.text', 'Test User1')
|
2021-09-23 14:04:43 +00:00
|
|
|
cy.get('[data-testid=profileSidePanel] .modal-body p').within(() => {
|
|
|
|
|
cy.contains('Location: Denver, US')
|
|
|
|
|
.and('contain', 'Location: Denver, US')
|
|
|
|
|
.and('contain', 'Skill Level: Professional')
|
|
|
|
|
.and('contain', 'Joined JamKazam: 08-26-2021')
|
|
|
|
|
.and('contain', 'Last Active:')
|
|
|
|
|
.and('contain', 'Latency to Me:')
|
|
|
|
|
cy.get('.latency-badge').contains('UNKNOWN')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid=profileSidePanel] .modal-body').within(() => {
|
|
|
|
|
cy.get('[data-testid=biography]').contains('Biography of Test User1')
|
|
|
|
|
|
|
|
|
|
//instruments
|
|
|
|
|
cy.get('[data-testid=instruments]').contains('Acoustic Guitar: Expert')
|
|
|
|
|
cy.get('[data-testid=instruments]').contains('Keyboard: Expert')
|
|
|
|
|
|
|
|
|
|
//genres
|
|
|
|
|
cy.get('[data-testid=genres]').contains('classical, blues')
|
|
|
|
|
|
|
|
|
|
//bands
|
|
|
|
|
cy.get('[data-testid=bands]').contains('The Band')
|
|
|
|
|
|
|
|
|
|
//performance_samples
|
|
|
|
|
//cy.get('[data-testid=performance_samples]').contains('The Band')
|
|
|
|
|
|
|
|
|
|
//online presence
|
|
|
|
|
cy.get('[data-testid=online_presences]')
|
|
|
|
|
.contains('Soundcloud')
|
|
|
|
|
cy.get('[data-testid=online_presences]')
|
|
|
|
|
.contains('Reverbnation')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
2021-08-31 18:25:15 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closeMoreDetailsSidePanel = () => {
|
|
|
|
|
cy.get('[data-testid=profileSidePanel] .modal-header button.close').click()
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 17:23:24 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
|
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'person' });
|
|
|
|
|
cy.visit('/friends');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('shows profile side panel', () => {
|
|
|
|
|
//open side panel by clicking name
|
|
|
|
|
cy.contains('Test User1').click();
|
2021-08-31 18:25:15 +00:00
|
|
|
showSidePanelContent()
|
2021-08-26 17:23:24 +00:00
|
|
|
closeMoreDetailsSidePanel()
|
|
|
|
|
|
|
|
|
|
//open side panel by clicking more button
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr').first().find('[data-testid=btnMore]').click()
|
2021-08-31 18:25:15 +00:00
|
|
|
showSidePanelContent()
|
2021-08-26 17:23:24 +00:00
|
|
|
closeMoreDetailsSidePanel()
|
|
|
|
|
|
|
|
|
|
//open side panel by clicking more link
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr').first().find('[data-testid=linkMore]').click()
|
2021-08-31 18:25:15 +00:00
|
|
|
showSidePanelContent()
|
2021-08-26 17:23:24 +00:00
|
|
|
closeMoreDetailsSidePanel()
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('making friendship', () => {
|
|
|
|
|
|
|
|
|
|
it('add friend', () => {
|
|
|
|
|
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'person' });
|
|
|
|
|
cy.intercept('POST', /\S+\/friend_requests/, { statusCode: 201, body: { ok: true } });
|
2021-08-11 08:26:45 +00:00
|
|
|
|
2021-08-26 17:23:24 +00:00
|
|
|
cy.visit('/friends');
|
|
|
|
|
cy.contains('Test User1').click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid=profileSidePanel]')
|
|
|
|
|
.find('[data-testid=connect]')
|
|
|
|
|
.should('not.be.disabled')
|
|
|
|
|
.click();
|
|
|
|
|
cy.get('[data-testid=profileSidePanel]')
|
|
|
|
|
.find('[data-testid=connect]')
|
|
|
|
|
.should('be.disabled');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('remove friend', () => {
|
|
|
|
|
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'friend' });
|
|
|
|
|
cy.intercept('DELETE', /\S+\/friends\S+/, { statusCode: 204, body: { ok: true } });
|
|
|
|
|
|
|
|
|
|
cy.visit('/friends');
|
|
|
|
|
cy.contains('Test User1').click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid=profileSidePanel]')
|
|
|
|
|
.find('[data-testid=disconnect]')
|
|
|
|
|
.should('exist')
|
|
|
|
|
.should('not.be.disabled')
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid=profileSidePanel]')
|
|
|
|
|
.find('[data-testid=disconnect]')
|
|
|
|
|
.should('not.exist');
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid=profileSidePanel]')
|
|
|
|
|
.find('[data-testid=connect]')
|
|
|
|
|
.should('be.exist')
|
|
|
|
|
.should('not.be.disabled')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2021-09-23 14:04:43 +00:00
|
|
|
describe('chat window', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
cy.visit('/friends');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('is not disabled for friends', () => {
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.eq(0)
|
|
|
|
|
.find('[data-testid=message]').should('not.be.disabled').trigger('mouseover')
|
|
|
|
|
cy.contains('Send a message').should('exist')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('is disabled for non friends', () => {
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.eq(1)
|
|
|
|
|
.find('[data-testid=message]').should('be.disabled')
|
|
|
|
|
//cy.contains('You can message this user once you are friends').should('exist')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('lists text messages', () => {
|
|
|
|
|
//initially show the most recent messages on openning chat window modal
|
|
|
|
|
let numberOfMessages = 10
|
|
|
|
|
cy.fixture('text_messages_page1').then((json) => {
|
|
|
|
|
cy.intercept('GET', /\S+\/text_messages\S+/, json).as('getTextMessages');
|
|
|
|
|
})
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.eq(0)
|
|
|
|
|
.find('[data-testid=message]').click()
|
|
|
|
|
cy.wait('@getTextMessages')
|
|
|
|
|
cy.get('[data-testid=textMessageModal]').should('be.visible').within(() => {
|
|
|
|
|
cy.get('.text-message-row').should('have.length', numberOfMessages)
|
|
|
|
|
|
|
|
|
|
//display previous messages by scrolling up
|
|
|
|
|
const messageFixtures = [
|
|
|
|
|
'text_messages_page2',
|
|
|
|
|
'text_messages_page3'
|
|
|
|
|
]
|
|
|
|
|
// messageFixtures.forEach((fixture) => {
|
|
|
|
|
// cy.fixture(fixture).then((json) => {
|
|
|
|
|
// cy.intercept('GET', /\S+\/text_messages\S+/, json)
|
|
|
|
|
// cy.get('.modal-body .ScrollbarsCustom').trigger('mouseover').scrollTo('bottom')
|
|
|
|
|
// cy.get('.modal-body .ScrollbarsCustom').trigger('mouseover').scrollTo('top')
|
|
|
|
|
// numberOfMessages = numberOfMessages + 10
|
|
|
|
|
// cy.get('.text-message-row').should('have.length', numberOfMessages)
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
cy.get('button').contains('Close').should('not.be.disabled').click()
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
cy.get('[data-testid=textMessageModal]').should('not.be.visible')
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('sends message by clicking send button', () => {
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.eq(0)
|
|
|
|
|
.find('[data-testid=message]').click()
|
|
|
|
|
cy.get('[data-testid=textMessageModal]').within(() => {
|
|
|
|
|
cy.get('button').contains('Send').should('be.disabled')
|
|
|
|
|
cy.get('textarea').type('Hello')
|
|
|
|
|
cy.get('button').contains('Send').should('not.be.disabled').click()
|
|
|
|
|
cy.get('textarea').should('have.value', '')
|
|
|
|
|
cy.get('button').contains('Send').should('be.disabled')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('sends message by pressing enter key', () => {
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.eq(0)
|
|
|
|
|
.find('[data-testid=message]').click()
|
|
|
|
|
cy.get('[data-testid=textMessageModal]').within(() => {
|
|
|
|
|
cy.get('button').contains('Send').should('be.disabled')
|
|
|
|
|
cy.get('textarea').type('Hello{enter}')
|
|
|
|
|
cy.get('textarea').should('have.value', '')
|
|
|
|
|
cy.get('button').contains('Send').should('be.disabled')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('goes away by clicking close button', () => {
|
|
|
|
|
cy.get('[data-testid=peopleListTable] > tbody tr')
|
|
|
|
|
.eq(0)
|
|
|
|
|
.find('[data-testid=message]').click()
|
|
|
|
|
cy.get('[data-testid=textMessageModal]').within(() => {
|
|
|
|
|
cy.get('button').contains('Close').should('not.be.disabled').click()
|
|
|
|
|
})
|
|
|
|
|
cy.get('[data-testid=textMessageModal]').should('not.be.visible')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it.skip('shows received message by other user', () => {
|
|
|
|
|
//TODO: this should be test in e2e test (without faking backend api intractions)
|
|
|
|
|
})
|
|
|
|
|
|
2021-08-11 08:26:45 +00:00
|
|
|
|
|
|
|
|
})
|
2021-08-26 17:23:24 +00:00
|
|
|
});
|
2021-08-11 08:12:32 +00:00
|
|
|
|
2021-08-31 18:25:15 +00:00
|
|
|
|