management()->create(); $this->actingAs($user); $this->job = CustomerJobModel::factory()->create([ 'customer_id' => CustomerModel::factory()->create()->id, 'responsible_user_id' => $user->id, 'status' => 'order', 'instructions' => str_repeat("Ohjeen rivi.\n", 60), ]); $workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole(); TaskModel::factory()->count(12)->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id]); }); it('keeps the header at the top of the window and focus below it on desktop', function () { visit(route('jobs.show', $this->job->id))->on()->desktop() ->assertScript('getComputedStyle(document.getElementById("app-header")).position', 'sticky') ->assertScript('getComputedStyle(document.documentElement).scrollPaddingTop === document.getElementById("app-header").offsetHeight + "px"', true) ->assertScript('window.scrollTo(0, document.body.scrollHeight); window.scrollY > 0', true) ->assertScript('document.getElementById("app-header").getBoundingClientRect().top', 0) // From the bottom of the page, focusing the tasks heading scrolls it back up: it must land below the header. ->assertScript('document.getElementById("tasks-heading").getBoundingClientRect().bottom < 0', true) ->assertScript('(() => { document.getElementById("tasks-heading").focus(); return document.getElementById("tasks-heading").getBoundingClientRect().top >= document.getElementById("app-header").getBoundingClientRect().bottom; })()', true); }); it('lets the header scroll with the page on a phone', function () { visit(route('jobs.show', $this->job->id))->on()->mobile() ->assertScript('getComputedStyle(document.getElementById("app-header")).position', 'static') ->assertScript('getComputedStyle(document.documentElement).scrollPaddingTop', '0px'); });