Skip to content

Commit 9de6014

Browse files
committed
udpate test w/ stripped props
1 parent 2024db4 commit 9de6014

File tree

1 file changed

+46
-20
lines changed

1 file changed

+46
-20
lines changed

packages/common-ui/cypress/component/StudySessionTimer.cy.ts

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,92 @@ describe('StudySessionTimer', () => {
77
props: {
88
timeRemaining: 180,
99
sessionTimeLimit: 5,
10-
isActive: true,
11-
showTooltip: true,
1210
},
1311
});
1412

1513
// Check for the circular progress component
1614
cy.get('[role="progressbar"]').should('exist');
1715

18-
// Check for the formatted time text
16+
// Check for the formatted time text (visible in tooltip)
17+
cy.get('.v-tooltip').trigger('mouseenter');
1918
cy.contains('3:00 left!').should('exist');
20-
21-
// Verify the button is visible when active
22-
cy.get('button').should('exist');
23-
cy.get('.mdi-plus').should('exist');
2419
});
2520

2621
it('changes color when time is low', () => {
2722
cy.mount(StudySessionTimer, {
2823
props: {
2924
timeRemaining: 30, // 30 seconds (below 60 seconds threshold)
3025
sessionTimeLimit: 5,
31-
isActive: true,
32-
showTooltip: true,
3326
},
3427
});
3528

3629
// Check for orange color class
37-
cy.get('[role="progressbar"]').should('exist');
30+
cy.get('[role="progressbar"]')
31+
.should('have.class', 'orange')
32+
.or('have.class', 'orange-darken-3');
33+
34+
// Check for the time text
35+
cy.get('.v-tooltip').trigger('mouseenter');
3836
cy.contains('30 seconds left!').should('exist');
3937
});
4038

41-
it('emits add-time event when button is clicked', () => {
39+
it('shows button on hover and emits add-time event when clicked', () => {
4240
const onAddTime = cy.spy().as('onAddTime');
4341

4442
cy.mount(StudySessionTimer, {
4543
props: {
4644
timeRemaining: 180,
4745
sessionTimeLimit: 5,
48-
isActive: true,
49-
showTooltip: true,
50-
},
51-
attrs: {
52-
onAddTime,
46+
'onAdd-time': onAddTime,
5347
},
5448
});
5549

50+
// Button should not be visible initially
51+
cy.get('button').should('not.be.visible');
52+
53+
// Button should appear on hover
54+
cy.get('.timer-container').trigger('mouseenter');
55+
cy.get('button').should('be.visible');
56+
57+
// Click should emit event
5658
cy.get('button').click();
5759
cy.get('@onAddTime').should('have.been.called');
5860
});
5961

60-
it('does not show button when timer is not active', () => {
62+
it('does not show button when time is zero', () => {
6163
cy.mount(StudySessionTimer, {
6264
props: {
63-
timeRemaining: 180,
65+
timeRemaining: 0,
6466
sessionTimeLimit: 5,
65-
isActive: false,
66-
showTooltip: true,
6767
},
6868
});
6969

70+
// Even on hover, button should not appear
71+
cy.get('.timer-container').trigger('mouseenter');
7072
cy.get('button').should('not.exist');
7173
});
74+
75+
it('displays correct percentage for progress indicator', () => {
76+
cy.mount(StudySessionTimer, {
77+
props: {
78+
timeRemaining: 150, // 2.5 minutes
79+
sessionTimeLimit: 5, // 5 minutes
80+
},
81+
});
82+
83+
// Progress should be 50% (2.5 minutes of 5 minutes)
84+
cy.get('[role="progressbar"]').should('have.attr', 'aria-valuenow', '50');
85+
});
86+
87+
it('displays correct percentage when under 60 seconds', () => {
88+
cy.mount(StudySessionTimer, {
89+
props: {
90+
timeRemaining: 30, // 30 seconds
91+
sessionTimeLimit: 5, // 5 minutes
92+
},
93+
});
94+
95+
// Progress should be 50% (30 seconds of 60 seconds in the final minute)
96+
cy.get('[role="progressbar"]').should('have.attr', 'aria-valuenow', '50');
97+
});
7298
});

0 commit comments

Comments
 (0)