-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from dancier/add-chat-tests
add some first tests to chat
- Loading branch information
Showing
12 changed files
with
430 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
describe('Chat', () => { | ||
beforeEach(() => { | ||
cy.setupRequestMocking(); | ||
cy.login(); | ||
}); | ||
|
||
it('shows "no chats" hint when there are no chats', () => { | ||
cy.intercept('GET', '/chats', { fixture: 'chat/get-chats/0-chats.json' }); | ||
cy.visit('/chat'); | ||
cy.findByText(/Du hast noch keine Chats/i).should('be.visible'); | ||
}); | ||
|
||
describe('when prompted to open a chat with a specific user', () => { | ||
it('creates and opens a new chat when it doesnt exist', () => { | ||
let chatCreated = false; | ||
cy.intercept('GET', '/chats', (req) => { | ||
if (!chatCreated) { | ||
req.reply({ fixture: 'chat/get-chats/0-chats.json' }); | ||
} else { | ||
req.reply({ fixture: 'chat/get-chats/1-chats.json' }); | ||
} | ||
}); | ||
cy.intercept('POST', 'https://test-dancer.dancier.net/dancers', { | ||
fixture: 'chat/post-dancers/all-details.json', | ||
}); | ||
cy.intercept('POST', '/chats', (req) => { | ||
chatCreated = true; | ||
req.reply({ id: '1' }); | ||
}); | ||
cy.intercept('GET', '/chats/1/messages', []); | ||
|
||
cy.visit('/chat?participantId=1'); | ||
cy.findByTestId('chat-list-selected-entry') | ||
.should('be.visible') | ||
.should('include.text', 'Username 1'); | ||
}); | ||
|
||
it('opens a previously created chat', () => { | ||
cy.intercept('GET', '/chats', { fixture: 'chat/get-chats/1-chats.json' }); | ||
cy.intercept('GET', '/chats/1/messages', []); | ||
cy.intercept('POST', 'https://test-dancer.dancier.net/dancers', { | ||
fixture: 'chat/post-dancers/all-details.json', | ||
}); | ||
|
||
cy.visit('/chat?participantId=1'); | ||
cy.findByTestId('chat-list-selected-entry') | ||
.should('be.visible') | ||
.should('include.text', 'Username 1'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"chatId": "1", | ||
"participantIds": [ | ||
"0", | ||
"1" | ||
], | ||
"lastActivity": "2023-12-24T11:04:27.293757Z", | ||
"lastMessage": null, | ||
"createdAt": "2023-12-17T20:18:19.621132Z" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"id": "0", | ||
"size": 110, | ||
"gender": "MALE", | ||
"dancerName": "1001-test", | ||
"birthDate": "1981-02-01", | ||
"ableTo": [ | ||
{ | ||
"dance": "Standard", | ||
"level": "BASIC", | ||
"leading": "LEAD" | ||
} | ||
], | ||
"wantsTo": [ | ||
{ | ||
"dance": "Standard", | ||
"level": "NO_EXPERIENCE", | ||
"leading": "FOLLOW" | ||
} | ||
], | ||
"email": "1001-test@dancier.net", | ||
"zipCode": "89188", | ||
"city": "Merklingen", | ||
"country": "GER", | ||
"profileImageHash": "9e82d8b082863e4707d17810c760175e9f93a9a254d2521d3b26d063fe0a7750", | ||
"aboutMe": "Hallo, ich bin der Dominik. Ich spiele gerne Karten und mache auch sonst allerlei Sachen. Manchmal trinke ich Kaffee, aber nur am Wochenende, meistens trinke ich Tee, damit das klar ist. Jojo, das ist töfte, oder?\n\nBla blub, es ist cool ich zu sein. Nein wirklich, es ist super. Jemand anderes zu sen" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"0": { | ||
"id": "0", | ||
"dancerName": "Username 0", | ||
"city": "Stadt 0", | ||
"profileImageHash": null | ||
}, | ||
"1": { | ||
"id": "1", | ||
"dancerName": "Username 1", | ||
"city": "Stadt 1", | ||
"profileImageHash": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.