1+ import FakeActionCableConsumer from 'codecrafters-frontend/tests/support/fake-action-cable-consumer' ;
12import catalogPage from 'codecrafters-frontend/tests/pages/catalog-page' ;
23import courseOverviewPage from 'codecrafters-frontend/tests/pages/course-overview-page' ;
34import coursePage from 'codecrafters-frontend/tests/pages/course-page' ;
5+ import fieldComparator from 'codecrafters-frontend/utils/field-comparator' ;
46import testScenario from 'codecrafters-frontend/mirage/scenarios/test' ;
57import window from 'ember-window-mock' ;
68import { module , test } from 'qunit' ;
79import { setupAnimationTest } from 'ember-animated/test-support' ;
810import { setupApplicationTest } from 'codecrafters-frontend/tests/helpers' ;
911import { setupWindowMock } from 'ember-window-mock/test-support' ;
1012import { signIn } from 'codecrafters-frontend/tests/support/authentication-helpers' ;
11- import FakeActionCableConsumer from 'codecrafters-frontend/tests/support/fake-action-cable-consumer' ;
12- import fieldComparator from 'codecrafters-frontend/utils/field-comparator' ;
1313
1414module ( 'Acceptance | course-page | test-results-bar | resize' , function ( hooks ) {
1515 setupApplicationTest ( hooks ) ;
@@ -20,9 +20,6 @@ module('Acceptance | course-page | test-results-bar | resize', function (hooks)
2020 testScenario ( this . server ) ;
2121 signIn ( this . owner , this . server ) ;
2222
23- const fakeActionCableConsumer = new FakeActionCableConsumer ( ) ;
24- this . owner . register ( 'service:action-cable-consumer' , fakeActionCableConsumer , { instantiate : false } ) ;
25-
2623 let currentUser = this . server . schema . users . first ( ) ;
2724 let python = this . server . schema . languages . findBy ( { name : 'Python' } ) ;
2825 let redis = this . server . schema . courses . findBy ( { slug : 'redis' } ) ;
@@ -42,37 +39,39 @@ module('Acceptance | course-page | test-results-bar | resize', function (hooks)
4239 await catalogPage . clickOnCourse ( 'Build your own Redis' ) ;
4340 await courseOverviewPage . clickOnStartCourse ( ) ;
4441 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
42+ await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) ) ; // Wait for CSS animation to complete
4543
46- const desiredHeight = 500 ;
47- let testResultsBarHeight = coursePage . testResultsBar . height ;
44+ let previousHeight = coursePage . testResultsBar . height ;
45+ const desiredHeight = previousHeight - 50 ;
4846
47+ // Don't know where the +1 comes from, could be border-related
4948 await coursePage . testResultsBar . resizeHandler . mouseDown ( { button : 2 } ) ;
50- await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight } ) ;
49+ await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight + 1 } ) ;
5150 await coursePage . testResultsBar . resizeHandler . mouseUp ( ) ;
5251
53- assert . strictEqual ( testResultsBarHeight , coursePage . testResultsBar . height , 'Right mouse button should not resize test results bar' ) ;
52+ assert . strictEqual ( previousHeight , coursePage . testResultsBar . height , 'Right mouse button should not resize test results bar' ) ;
5453
54+ // Don't know where the +1 comes from, could be border-related
5555 await coursePage . testResultsBar . resizeHandler . mouseDown ( { button : 0 } ) ;
56- await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight } ) ;
56+ await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight + 1 } ) ;
5757 await coursePage . testResultsBar . resizeHandler . mouseUp ( ) ;
5858
59- testResultsBarHeight = coursePage . testResultsBar . height ;
60- assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Left mouse button should resize test results bar' ) ;
59+ assert . notStrictEqual ( previousHeight , coursePage . testResultsBar . height , 'Test results bar should be resized' ) ;
60+ assert . strictEqual ( desiredHeight , coursePage . testResultsBar . height , 'Left mouse button should resize test results bar' ) ;
61+
62+ previousHeight = coursePage . testResultsBar . height ;
6163
6264 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
6365 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
66+ await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) ) ; // Wait for CSS animation to complete
6467
65- testResultsBarHeight = coursePage . testResultsBar . height ;
66- assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Test results bar maintains the height after closing and expanding again' ) ;
68+ assert . strictEqual ( previousHeight , coursePage . testResultsBar . height , 'Test results bar maintains the height after closing and expanding again' ) ;
6769 } ) ;
6870
6971 test ( 'can resize test results bar using touch' , async function ( assert ) {
7072 testScenario ( this . server ) ;
7173 signIn ( this . owner , this . server ) ;
7274
73- const fakeActionCableConsumer = new FakeActionCableConsumer ( ) ;
74- this . owner . register ( 'service:action-cable-consumer' , fakeActionCableConsumer , { instantiate : false } ) ;
75-
7675 let currentUser = this . server . schema . users . first ( ) ;
7776 let python = this . server . schema . languages . findBy ( { name : 'Python' } ) ;
7877 let redis = this . server . schema . courses . findBy ( { slug : 'redis' } ) ;
@@ -96,15 +95,17 @@ module('Acceptance | course-page | test-results-bar | resize', function (hooks)
9695
9796 const desiredHeight = 500 ;
9897
98+ // Don't know where the +1 comes from, could be border-related
9999 await coursePage . testResultsBar . resizeHandler . touchStart ( ) ;
100- await coursePage . testResultsBar . resizeHandler . touchMove ( { touches : [ { clientY : window . innerHeight - desiredHeight } ] } ) ;
100+ await coursePage . testResultsBar . resizeHandler . touchMove ( { touches : [ { clientY : window . innerHeight - desiredHeight + 1 } ] } ) ;
101101 await coursePage . testResultsBar . resizeHandler . touchEnd ( ) ;
102102
103103 let testResultsBarHeight = coursePage . testResultsBar . height ;
104104 assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Test results bar should be resized using touch' ) ;
105105
106106 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
107107 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
108+ await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) ) ; // Wait for CSS animation to complete
108109
109110 testResultsBarHeight = coursePage . testResultsBar . height ;
110111 assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Test results bar maintains the height after closing and expanding again' ) ;
0 commit comments