jam-cloud/jam-ui/cypress/integration/friends/friends-list.spec.js

128 lines
3.7 KiB
JavaScript
Raw Normal View History

2021-08-11 08:12:32 +00:00
/// <reference types="cypress" />
describe('Friends page', () => {
beforeEach(() => {
cy.stubAuthenticate();
cy.intercept('POST', /\S+\/filter/, { fixture: 'people' });
});
2021-08-11 08:12:32 +00:00
describe('friends list', () => {
2021-08-11 08:12:32 +00:00
beforeEach(() => {
cy.visit('/friends');
});
2021-08-11 08:12:32 +00:00
it('lists musicians', () => {
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
//TODO: paginate
});
describe('details side panel', () => {
const showSidePanelContent = () => {
cy.get('[data-testid=profileSidePanel] h4').should('have.text', 'Test User1')
cy.get('[data-testid=profileSidePanel]')
.should('be.visible')
.contains('Biography of Test User1')
cy.get('[data-testid=profileSidePanel] .modal-body p')
.contains('Location: Denver, US')
.and('contain', 'Location: Denver, US')
.and('contain', 'Skill Level: Professional')
.and('contain', 'Joined JamKazam: 08-26-2021')
//instruments
cy.get('[data-testid=profileSidePanel] .modal-body').contains('Acoustic Guitar: Expert')
cy.get('[data-testid=profileSidePanel] .modal-body').contains('Keyboard: Expert')
//genres
cy.get('[data-testid=profileSidePanel] .modal-body').contains('classical, blues')
}
const closeMoreDetailsSidePanel = () => {
cy.get('[data-testid=profileSidePanel] .modal-header button.close').click()
}
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();
showSidePanelContent()
closeMoreDetailsSidePanel()
//open side panel by clicking more button
cy.get('[data-testid=peopleListTable] > tbody tr').first().find('[data-testid=btnMore]').click()
showSidePanelContent()
closeMoreDetailsSidePanel()
//open side panel by clicking more link
cy.get('[data-testid=peopleListTable] > tbody tr').first().find('[data-testid=linkMore]').click()
showSidePanelContent()
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
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')
});
})
describe('send message', () => {
2021-08-11 08:26:45 +00:00
})
});
2021-08-11 08:12:32 +00:00