Skip to content

Commit 1407596

Browse files
authored
feat: add test for new single_video resource page (#1574)
* Add video resource test * fix conversation test
1 parent ae54e80 commit 1407596

File tree

3 files changed

+65
-5
lines changed

3 files changed

+65
-5
lines changed

components/common/ProgressStatus.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const ProgressStatus = (props: ProgressStatusProps) => {
1717

1818
if (status === PROGRESS_STATUS.STARTED) {
1919
return (
20-
<Box sx={{ ...iconTextRowStyle, marginTop: '0 !important' }}>
20+
<Box data-testid="progress-status" sx={{ ...iconTextRowStyle, marginTop: '0 !important' }}>
2121
<DonutLargeIcon color="error" />
2222
<Typography>{tS('started')}</Typography>
2323
</Box>
2424
);
2525
}
2626
if (status === PROGRESS_STATUS.COMPLETED) {
2727
return (
28-
<Box sx={{ ...iconTextRowStyle, marginTop: '0 !important' }}>
28+
<Box data-testid="progress-status" sx={{ ...iconTextRowStyle, marginTop: '0 !important' }}>
2929
<CheckCircleIcon color="error" />
3030
<Typography>{tS('completed')}</Typography>
3131
</Box>

cypress/integration/tests/conversations.cy.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('Conversations Flow', () => {
77
cy.createUser({ emailInput: email, passwordInput: password });
88
});
99

10-
it('Should allow a user to navigate to Courses, select a conversation, log in, play audio, and submit feedback.', () => {
10+
it('Should allow a user to navigate to Courses, select a conversation, log in and play audio', () => {
1111
// User visits the home page
1212
cy.visit('/');
1313

@@ -28,7 +28,7 @@ describe('Conversations Flow', () => {
2828
cy.get('#email').type(email);
2929
cy.get('#password').type(password);
3030
cy.get('button[type=submit]').click();
31-
cy.wait(2000); // wait to ensure user is redirected to the session
31+
cy.wait(2000); // wait to ensure user is redirected to the conversation
3232

3333
// User plays the conversation
3434
cy.get('audio')
@@ -39,7 +39,6 @@ describe('Conversations Flow', () => {
3939
audio.playbackRate = 6;
4040
audio.play();
4141
});
42-
cy.wait(2000); // wait to ensure user plays the session
4342
});
4443

4544
after(() => {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
describe('Videos Flow', () => {
2+
const email = `cypresstestemail+${Date.now()}@chayn.co`;
3+
const password = 'testtesttest';
4+
5+
before(() => {
6+
cy.cleanUpTestState();
7+
cy.createUser({ emailInput: email, passwordInput: password });
8+
});
9+
10+
it('Should allow a user to navigate to Courses, select a video, log in and play video', () => {
11+
// User visits the home page
12+
cy.visit('/');
13+
14+
// User clicks on Courses
15+
cy.get(`[qa-id=secondary-nav-courses-button]`, { timeout: 10000 }).should('exist').click();
16+
17+
// User clicks on a conversation
18+
cy.contains('What is somatics?', {
19+
timeout: 10000,
20+
})
21+
.should('exist')
22+
.click();
23+
24+
// User is prompted to login
25+
cy.get('a[qa-id="dialogLoginButton"]').click();
26+
27+
// User logs in
28+
cy.get('#email').type(email);
29+
cy.get('#password').type(password);
30+
cy.get('button[type=submit]').click();
31+
cy.wait(2000); // wait to ensure user is redirected to the video
32+
33+
// User plays the short video
34+
cy.get('.react-player__preview', { timeout: 10000 }).should('be.visible').click();
35+
cy.wait(2000); // wait to ensure user plays the video
36+
37+
cy.get('[data-testid="progress-status"]', { timeout: 10000 }).should('be.visible');
38+
cy.get('[data-testid="team-member-card"]').should('exist');
39+
40+
// Feedback form appears
41+
cy.contains('h2', 'How was this session?').should('be.visible');
42+
43+
// Click the Send button and check for error message
44+
cy.get('button').contains('Send').click();
45+
cy.contains('p', 'Please select a rating before sending.').should('be.visible');
46+
47+
// User selects a rating
48+
cy.get('input[name="feedback-radio-buttons"]').first().check();
49+
50+
// User submits feedback
51+
cy.contains('button', 'Send').click();
52+
cy.wait(2000);
53+
54+
// Confirmation message appears
55+
cy.contains('h3', 'Thank you for submitting your feedback').should('exist');
56+
});
57+
58+
after(() => {
59+
cy.logout();
60+
});
61+
});

0 commit comments

Comments
 (0)