fix friends page related cypress tests

This commit is contained in:
Nuwan 2024-04-11 00:21:53 +05:30
parent cdd12d621d
commit edb6bd0b90
5 changed files with 62 additions and 38 deletions

View File

@ -2,16 +2,14 @@
const showSidePanelContent = () => {
cy.get('[data-testid=profileSidePanel] h4').should('have.text', 'Test User1');
cy.get('[data-testid=profileSidePanel] .modal-body p').first().within(() => {
cy.get('[data-testid=profileSidePanel] .modal-body').first().within(() => {
cy.contains('Location: Denver, CO, 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').first().within(() => {
cy.get('[data-testid=biography]').contains('Biography of Test User1');
//instruments
@ -25,17 +23,14 @@ const showSidePanelContent = () => {
cy.get('[data-testid=bands]').contains('The Band');
//performance_samples
//cy.get('[data-testid=performance_samples]').contains('The Band')
cy.get('[data-testid=performance_samples]').contains('Test Recording1')//.should('have.attr', 'href').and('eq', 'https://www.jamkazam.com/test-recording1');
//online presence
cy.get('[data-testid=online_presences]').contains('Soundcloud').should('have.attr', 'href').and('eq', 'https://www.soundcloud.com/testuser');
cy.get('[data-testid=online_presences]').contains('Reverbnation').should('have.attr', 'href').and('eq', 'https://www.reverbnation.com/testuser');
cy.get('[data-testid=online_presences]').contains('Bandcamp').should('have.attr', 'href').and('eq', 'https://testuser.bandcamp.com');
cy.get('[data-testid=online_presences]').contains('Fandalism').should('have.attr', 'href').and('eq', 'https://www.fandalism.com/testuser');
cy.get('[data-testid=online_presences]').contains('Youtube').should('have.attr', 'href').and('eq', 'https://www.youtube.com/testuser');
cy.get('[data-testid=online_presences]').contains('Facebook').should('have.attr', 'href').and('eq', 'https://www.facebook.com/testuser');
cy.get('[data-testid=online_presences]').contains('Twitter').should('have.attr', 'href').and('eq', 'https://www.twitter.com/testuser');
});
};
const closeSidePanel = () => {
@ -103,7 +98,7 @@ describe('Friends page with data', () => {
cy.intercept('POST', /\S+\/filter\?offset=0/, { fixture: 'people_page1' }).as('getPeople_page1');
cy.intercept('POST', /\S+\/filter\?offset=10/, { fixture: 'people_page2' }).as('getPeople_page2');
cy.intercept('POST', /\S+\/filter\?offset=20/, { fixture: 'people_page3' }).as('getPeople_page3');
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'person' });
cy.intercept('GET', /\S+\/profile/, { fixture: 'person' });
});
describe('listing users', () => {
@ -127,7 +122,7 @@ describe('Friends page with data', () => {
cy.get('[data-testid=paginate-next-page]').should('not.exist');
});
it.only('show profiles', () => {
it('show profiles', () => {
cy.contains('Find New Friends').should('exist');
cy.contains('Update Search').should('exist');
cy.contains('Reset Filters').should('exist');
@ -183,7 +178,7 @@ describe('Friends page with data', () => {
.first()
.find('[data-testid=instrumentList]')
.within(() => {
cy.get('div').should('have.length', 4); //show only 4 instruments plus more link
cy.get('[data-testid=instrument]').should('have.length', 4); //show only 4 instruments plus more link
cy.contains('Acoustic Guitar: Expert');
cy.contains('Keyboard: Expert');
cy.contains('Ukulele: Expert');
@ -306,7 +301,7 @@ describe('Friends page with data', () => {
});
it('remove friend', () => {
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'friend' });
cy.intercept('GET', /\S+\/profile/, { fixture: 'friend' });
cy.intercept('DELETE', /\S+\/friends\S+/, { statusCode: 204, body: { ok: true } });
cy.visit('/friends');
@ -384,7 +379,7 @@ describe('Friends page with data', () => {
});
cy.get('button')
.contains('Cancel')
.contains('Close')
.should('not.be.disabled')
.click();
});
@ -436,7 +431,7 @@ describe('Friends page with data', () => {
.click();
cy.get('[data-testid=textMessageModal]').within(() => {
cy.get('button')
.contains('Cancel')
.contains('Close')
.should('not.be.disabled')
.click();
});

View File

@ -50,7 +50,6 @@
{ "id": "005a7c78-db8b-4f72-a51f-d64d579c22b3", "service_type": "facebook", "username": "testuser" },
{ "id": "005a7c78-db8b-4f72-a51f-d64d579c22b4", "service_type": "twitter", "username": "testuser" }
],
"performance_samples": [],
"genres": [
{ "genre_id": "classical", "player_type": "JamRuby::User", "genre_type": "profile" },
{ "genre_id": "blues", "player_type": "JamRuby::User", "genre_type": "free_sessions" }
@ -74,6 +73,16 @@
{ "description": "Acoustic Guitar", "proficiency_level": 3, "priority": 1, "instrument_id": "acoustic guitar" },
{ "description": "Keyboard", "proficiency_level": 3, "priority": 8, "instrument_id": "keyboard" }
],
"performance_samples": [
{
"id": "1",
"service_type": "youtube",
"claimed_recording": {
"id": "1",
"name": "Test Recording1"
}
}
],
"is_friend": false,
"is_following": false,
"is_liking": false,

View File

@ -12,8 +12,10 @@ const JKConnectButton = props => {
const [showConfirmModal, setShowConfirmModal] = useState(false);
useEffect(() => {
setIsFriend(user.is_friend);
setPendingFriendRequest(user.pending_friend_request);
if(user){
setIsFriend(user.is_friend);
setPendingFriendRequest(user.pending_friend_request);
}
}, [user]);
const queryString = useBrowserQuery();

View File

@ -24,7 +24,7 @@ const JKPersonInstrumentsList = ({ instruments, showIcons, showAll, toggleMoreDe
<div data-testid="instrumentList">
{instrumentsToShow &&
instrumentsToShow.map(instrument => (
<div key={instrument.instrument_id} className="text-nowrap mb-1 d-flex align-items-center">
<div key={instrument.instrument_id} className="text-nowrap mb-1 d-flex align-items-center" data-testid="instrument">
<div className="mr-1" style={{ width: "15%"}}>
<JKInstrumentIcon instrumentId={instrument.instrument_id} instrumentName={instrument.description} />
</div>

View File

@ -1,36 +1,54 @@
import React from 'react';
import { titleize } from '../../helpers/utils';
const JKProfilePerformanceSamples = ({samples}) => {
const JKProfilePerformanceSamples = ({ samples }) => {
const SAMPLE_TYPES = {
JAMKAZAM: { description: 'jamkazam' },
SOUNDCLOUD: { description: 'soundcloud' },
YOUTUBE: { description: 'youtube' }
};
const jamkasamSamples = samples.filter(sample => sample.claimed_recording && sample.service_type === SAMPLE_TYPES.JAMKAZAM.description);
const jamkazamSamples = samples.filter(
sample => sample.claimed_recording && sample.service_type === SAMPLE_TYPES.JAMKAZAM.description
);
const soundCloudSamples = samples.filter(sample => sample.claimed_recording && sample.service_type === SAMPLE_TYPES.SOUNDCLOUD.description);
const soundCloudSamples = samples.filter(
sample => sample.claimed_recording && sample.service_type === SAMPLE_TYPES.SOUNDCLOUD.description
);
const youTubeSamples = samples.filter(sample => sample.claimed_recording && sample.service_type === SAMPLE_TYPES.YOUTUBE.description);
const youTubeSamples = samples.filter(
sample => sample.claimed_recording && sample.service_type === SAMPLE_TYPES.YOUTUBE.description
);
return (
<div>
<strong>Jamkazam : </strong>
{jamkasamSamples.map(sample => (
<a href={`/recordings/${sample.claimed_recording.id}`}>{titleize(sample.claimed_recording.name)}</a>
))}
<br />
<strong>SoundCloud: </strong>
{soundCloudSamples.map(sample => (
<a href={`${sample.claimed_recording.id}`}>{titleize(sample.claimed_recording.name)}</a>
))}
<br />
<strong>Youtube : </strong>
{youTubeSamples.map(sample => (
<a href={`${sample.claimed_recording.id}`}>{titleize(sample.claimed_recording.name)}</a>
))}
</div>
<>
{jamkazamSamples.length > 0 && (
<div className='mb-2'>
<strong>JamKazam: </strong>
{jamkazamSamples.map(sample => (
<a className='mr-2' href={`/recordings/${sample.claimed_recording.id}`}>{titleize(sample.claimed_recording.name)}</a>
))}
</div>
)}
{soundCloudSamples.length > 0 && (
<div className='mb-2'>
<strong>SoundCloud: </strong>
{soundCloudSamples.map(sample => (
<a className='mr-2' href={`${sample.claimed_recording.id}`}>{titleize(sample.claimed_recording.name)}</a>
))}
</div>
)}
{youTubeSamples.length > 0 && (
<div>
<strong>YouTube: </strong>
{youTubeSamples.map(sample => (
<a className='mr-2' href={`${sample.claimed_recording.id}`}>{titleize(sample.claimed_recording.name)}</a>
))}
</div>
)}
</>
);
};