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

108 lines
3.1 KiB
JavaScript

/// <reference types="cypress" />
describe('Friends page', () => {
beforeEach(() => {
cy.stubAuthenticate();
cy.intercept('POST', /\S+\/filter/, { fixture: 'people' });
});
describe('friends list', () => {
beforeEach(() => {
cy.visit('/friends');
});
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');
});
//TODO: paginate
});
describe('details side panel', () => {
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();
cy.get('[data-testid=profileSidePanel]')
.should('be.visible')
.contains('Biography of Test User1');
closeMoreDetailsSidePanel()
//open side panel by clicking more button
cy.get('[data-testid=peopleListTable] > tbody tr').first().find('[data-testid=btnMore]').click()
cy.get('[data-testid=profileSidePanel]')
.should('be.visible')
.contains('Biography of Test User1');
closeMoreDetailsSidePanel()
//open side panel by clicking more link
cy.get('[data-testid=peopleListTable] > tbody tr').first().find('[data-testid=linkMore]').click()
cy.get('[data-testid=profileSidePanel]')
.should('be.visible')
.contains('Biography of Test User1');
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 } });
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', () => {
})
});
function closeMoreDetailsSidePanel(){
cy.get('[data-testid=profileSidePanel] .modal-header button.close').click()
}