-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex_spec.rb
59 lines (47 loc) · 2.25 KB
/
index_spec.rb
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
require 'rails_helper'
RSpec.describe 'home page', type: :system do
context 'when navigating from the home page to the pandas index page' do
before do
page.goto('/', waitUntil: "domcontentloaded")
end
it 'renders the pandas index page with the expected content' do
page.wait_for_selector('header').owner_frame.get_by_text('Pandas').click
page.wait_for_load_state
header = page.wait_for_selector('h1')
expect(header.text_content).to eq('Our Pandas')
expect(page.title).to eq('Pandas | Rails + Vue ⚡️')
page.screenshot(path: actual_screenshot_path)
expect(actual_screenshot_path)
.to match_screenshot(
expected_screenshot_path(suffix: nil),
max_threshold_pct: 2.4
# update: true # Uncomment this whenever you want to update the expected screenshot
)
# Switch to customer prefers dark color scheme (aka dark mode)
page.emulate_media(colorScheme: 'dark')
# Test that the page looks correct in dark mode
page.screenshot(path: actual_screenshot_path(suffix: 'dark'))
expect(actual_screenshot_path(suffix: 'dark'))
.to match_screenshot(
expected_screenshot_path(suffix: 'dark'),
max_threshold_pct: 2.4
)
end
end
context "when viewing the pandas index page" do
before do
page.goto('/pandas')
page.wait_for_load_state
end
it "dynamically loads and mounts the Zap.vue component" do
header = page.wait_for_selector('h1')
expect(header.text_content).to eq('Our Pandas')
expect(page.content).not_to include('I was lazy loaded! ⚡️')
page.evaluate("document.querySelector('#lazy-load').scrollIntoView()") # Scroll to the #lazy-load div
# FIXME: for some reason the request to dynamically load the Zap.vue component hangs in a "pending" request state
# in the browser and so the content is never loaded. I'm not sure why this is happening. I've tried using
# page.wait_for_load_state and page.wait_for_selector but neither of those seem to help. Running this test with the meta data: { headless: false } has only confirmed the issue but I've not found a fix yet.
# expect(page.content).to include('I was lazy loaded! ⚡️')
end
end
end