11import catalogPage from 'codecrafters-frontend/tests/pages/catalog-page' ;
22import courseOverviewPage from 'codecrafters-frontend/tests/pages/course-overview-page' ;
33import coursePage from 'codecrafters-frontend/tests/pages/course-page' ;
4+ import fieldComparator from 'codecrafters-frontend/utils/field-comparator' ;
45import testScenario from 'codecrafters-frontend/mirage/scenarios/test' ;
56import window from 'ember-window-mock' ;
67import { module , test } from 'qunit' ;
78import { setupAnimationTest } from 'ember-animated/test-support' ;
89import { setupApplicationTest } from 'codecrafters-frontend/tests/helpers' ;
910import { setupWindowMock } from 'ember-window-mock/test-support' ;
1011import { 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' ;
1312
1413module ( 'Acceptance | course-page | test-results-bar | resize' , function ( hooks ) {
1514 setupApplicationTest ( hooks ) ;
@@ -20,9 +19,6 @@ module('Acceptance | course-page | test-results-bar | resize', function (hooks)
2019 testScenario ( this . server ) ;
2120 signIn ( this . owner , this . server ) ;
2221
23- const fakeActionCableConsumer = new FakeActionCableConsumer ( ) ;
24- this . owner . register ( 'service:action-cable-consumer' , fakeActionCableConsumer , { instantiate : false } ) ;
25-
2622 let currentUser = this . server . schema . users . first ( ) ;
2723 let python = this . server . schema . languages . findBy ( { name : 'Python' } ) ;
2824 let redis = this . server . schema . courses . findBy ( { slug : 'redis' } ) ;
@@ -42,37 +38,39 @@ module('Acceptance | course-page | test-results-bar | resize', function (hooks)
4238 await catalogPage . clickOnCourse ( 'Build your own Redis' ) ;
4339 await courseOverviewPage . clickOnStartCourse ( ) ;
4440 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
41+ await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) ) ; // Wait for CSS animation to complete
4542
46- const desiredHeight = 500 ;
47- let testResultsBarHeight = coursePage . testResultsBar . height ;
43+ let previousHeight = coursePage . testResultsBar . height ;
44+ const desiredHeight = previousHeight - 50 ;
4845
46+ // Don't know where the +1 comes from, could be border-related
4947 await coursePage . testResultsBar . resizeHandler . mouseDown ( { button : 2 } ) ;
50- await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight } ) ;
48+ await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight + 1 } ) ;
5149 await coursePage . testResultsBar . resizeHandler . mouseUp ( ) ;
5250
53- assert . strictEqual ( testResultsBarHeight , coursePage . testResultsBar . height , 'Right mouse button should not resize test results bar' ) ;
51+ assert . strictEqual ( previousHeight , coursePage . testResultsBar . height , 'Right mouse button should not resize test results bar' ) ;
5452
53+ // Don't know where the +1 comes from, could be border-related
5554 await coursePage . testResultsBar . resizeHandler . mouseDown ( { button : 0 } ) ;
56- await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight } ) ;
55+ await coursePage . testResultsBar . resizeHandler . mouseMove ( { clientY : window . innerHeight - desiredHeight + 1 } ) ;
5756 await coursePage . testResultsBar . resizeHandler . mouseUp ( ) ;
5857
59- testResultsBarHeight = coursePage . testResultsBar . height ;
60- assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Left mouse button should resize test results bar' ) ;
58+ assert . notStrictEqual ( previousHeight , coursePage . testResultsBar . height , 'Test results bar should be resized' ) ;
59+ assert . strictEqual ( desiredHeight , coursePage . testResultsBar . height , 'Left mouse button should resize test results bar' ) ;
60+
61+ previousHeight = coursePage . testResultsBar . height ;
6162
6263 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
6364 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
65+ await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) ) ; // Wait for CSS animation to complete
6466
65- testResultsBarHeight = coursePage . testResultsBar . height ;
66- assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Test results bar maintains the height after closing and expanding again' ) ;
67+ assert . strictEqual ( previousHeight , coursePage . testResultsBar . height , 'Test results bar maintains the height after closing and expanding again' ) ;
6768 } ) ;
6869
6970 test ( 'can resize test results bar using touch' , async function ( assert ) {
7071 testScenario ( this . server ) ;
7172 signIn ( this . owner , this . server ) ;
7273
73- const fakeActionCableConsumer = new FakeActionCableConsumer ( ) ;
74- this . owner . register ( 'service:action-cable-consumer' , fakeActionCableConsumer , { instantiate : false } ) ;
75-
7674 let currentUser = this . server . schema . users . first ( ) ;
7775 let python = this . server . schema . languages . findBy ( { name : 'Python' } ) ;
7876 let redis = this . server . schema . courses . findBy ( { slug : 'redis' } ) ;
@@ -96,15 +94,17 @@ module('Acceptance | course-page | test-results-bar | resize', function (hooks)
9694
9795 const desiredHeight = 500 ;
9896
97+ // Don't know where the +1 comes from, could be border-related
9998 await coursePage . testResultsBar . resizeHandler . touchStart ( ) ;
100- await coursePage . testResultsBar . resizeHandler . touchMove ( { touches : [ { clientY : window . innerHeight - desiredHeight } ] } ) ;
99+ await coursePage . testResultsBar . resizeHandler . touchMove ( { touches : [ { clientY : window . innerHeight - desiredHeight + 1 } ] } ) ;
101100 await coursePage . testResultsBar . resizeHandler . touchEnd ( ) ;
102101
103102 let testResultsBarHeight = coursePage . testResultsBar . height ;
104103 assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Test results bar should be resized using touch' ) ;
105104
106105 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
107106 await coursePage . testResultsBar . clickOnBottomSection ( ) ;
107+ await new Promise ( ( resolve ) => setTimeout ( resolve , 200 ) ) ; // Wait for CSS animation to complete
108108
109109 testResultsBarHeight = coursePage . testResultsBar . height ;
110110 assert . strictEqual ( testResultsBarHeight , desiredHeight , 'Test results bar maintains the height after closing and expanding again' ) ;
0 commit comments