-
Notifications
You must be signed in to change notification settings - Fork 1
/
73-loop-does-not-work-directly-after-app-start.cy.ts
150 lines (128 loc) · 6.2 KB
/
73-loop-does-not-work-directly-after-app-start.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright (c) 2024 Marcel Suter - Replayer
*
* This source code is licensed under the AGPL license found in the
* LICENSE file in the root of this projects source tree.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/
import { mediaSourceUrls } from './../../fixtures/all-types-of-media-urls';
mediaSourceUrls.forEach((mediaSourceUrl) => {
describe('testing the issue "Loop does not work directly after app start #73" for regression', () => {
it(`should loop for the "loop track" play mode (using an ${mediaSourceUrl.name} source)`, () => {
// ARRANGE (set loop track play mode)
cy.load(`/#/play?media=${mediaSourceUrl.url}`);
cy.consentIfYouTube(mediaSourceUrl.url);
// Select the loop track mode
cy.get(
'div[data-cy="select-playback-mode"] button[data-cy="dropdown-menu-trigger"]',
).click();
cy.get('button[data-cy="select-loop-track"]').click();
// ACT (go to the end and wait for a loop)
cy.get('button[data-cy="toggle-playback"]').first().click();
cy.get('input[type=range]')
.as('range')
.invoke('val', mediaSourceUrl.duration - 2.0)
.trigger('change');
//Wait potentially slow loading of media
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(4000);
// ASSERT (that the loop occurred, and track is still playing)
cy.get('input[type=range]')
.invoke('val') // call the val() method to extract the value
.then((val) => +(val ?? '')) // convert it to a number
.should('be.lessThan', 5); // also compare it to a number
cy.get(
'[data-cy="media-controls-bar"] [data-cy="playback-indicator"]',
).should('have.attr', 'data-tooltip', 'Track is playing');
});
it(`should loop for the "loop track" play mode even after an app restart (using an ${mediaSourceUrl.name} source)`, () => {
// ARRANGE (set loop track play mode)
cy.load(`/#/play?media=${mediaSourceUrl.url}`);
cy.consentIfYouTube(mediaSourceUrl.url);
// Select the loop track mode
cy.get(
'div[data-cy="select-playback-mode"] button[data-cy="dropdown-menu-trigger"]',
).click();
cy.get('button[data-cy="select-loop-track"]').click();
// ACT restart
cy.loadEmpty();
// ACT (go to the end and wait for a loop)
cy.get('button[data-cy="toggle-playback"]').first().click();
cy.get('input[type=range]')
.as('range')
.invoke('val', mediaSourceUrl.duration - 2.0)
.trigger('change');
//Wait potentially slow loading of media
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(4000);
// ASSERT (that the loop occurred, and track is still playing)
cy.get('input[type=range]')
.invoke('val') // call the val() method to extract the value
.then((val) => +(val ?? '')) // convert it to a number
.should('be.lessThan', 5); // also compare it to a number
cy.get(
'[data-cy="media-controls-bar"] [data-cy="playback-indicator"]',
).should('have.attr', 'data-tooltip', 'Track is playing');
});
it(`should loop for the "loop cue" play mode (using a ${mediaSourceUrl.name} source)`, () => {
// ARRANGE (set cue track play mode)
cy.load(
`/#/play?${mediaSourceUrl.duration - 2.0}=ending-cue&media=${
mediaSourceUrl.url
}`,
);
cy.consentIfYouTube(mediaSourceUrl.url);
// Select the loop cue mode
cy.get(
'div[data-cy="select-playback-mode"] button[data-cy="dropdown-menu-trigger"]',
).click();
cy.get('button[data-cy="select-loop-cue"]').click();
// ACT (press the ending cue and wait for a loop)
cy.get('button[title="Play from ending-cue"]').click();
//Wait potentially slow loading of media
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(4000);
// ASSERT (that the loop occurred)
cy.get(
'[data-cy="media-controls-bar"] [data-cy="playback-indicator"]',
).should('have.attr', 'data-tooltip', 'Track is playing');
});
});
});
describe('testing the issue "Loop does not work directly after app start #73", for the complilation loop mode, with audio', () => {
it('should loop for the "loop compilation" play mode', () => {
// ARRANGE (load 2-track compilation and start playback)
cy.loadFile('cypress/fixtures/2-tracks-with-anechoic-voices.rex');
cy.get('button[data-cy="toggle-playback"]')
.eq(1 /*second track*/)
.click();
// Select the loop compilation mode
cy.get(
'div[data-cy="select-playback-mode"] button[data-cy="dropdown-menu-trigger"]',
)
.filter(':visible') // because here, the two track have their own menu
.click();
cy.get('button[data-cy="select-loop-compilation"]')
.filter(':visible') // because here, the two track have their own menu
.click();
// ACT (go to the ending and wait for a move to the subsequent track)
cy.get('input[type=range]')
.filter(':visible') // because here, the two track have their own menu
.first()
.as('range')
.invoke('val', 2)
.trigger('change');
//Wait potentially slow loading of media
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(4000);
// ASSERT (that the first track was selected next)
cy.get('#media-player-panel [data-cy="track-name"]')
.filter(':visible')
.should('have.text', 'female');
});
});