File: copy-code.goml

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 893,176 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (54 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (4)
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
// Checks that the "copy code" button is not triggering JS error and its display
// isn't broken.
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"

define-function: (
    "check-copy-button",
    [],
    block {
        // First we ensure that there are no "copy code" currently existing.
        assert-count: (".example-wrap .copy-button", 0)
        move-cursor-to: ".example-wrap"
        assert-count: (".example-wrap .copy-button", 1)
        // We now ensure it's only displayed when the example is hovered.
        assert-css: (".example-wrap .copy-button", { "visibility": "visible" })
        move-cursor-to: ".search-input"
        assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
        // Checking that the copy button has the same size as the "copy path" button.
        compare-elements-size: (
            "#copy-path",
            ".example-wrap:nth-of-type(1) .copy-button",
            ["height", "width"],
        )
    },
)

call-function: ("check-copy-button", {})
// Checking that the run button and the copy button have the same height and same width.
compare-elements-size: (
    ".example-wrap:nth-of-type(1) .test-arrow",
    ".example-wrap:nth-of-type(1) .copy-button",
    ["height", "width"],
)
// ... and the same y position.
compare-elements-position: (
    ".example-wrap:nth-of-type(1) .test-arrow",
    ".example-wrap:nth-of-type(1) .copy-button",
    ["y"],
)
store-size: (".example-wrap:nth-of-type(1) .copy-button", {
    "height": copy_height,
    "width": copy_width,
})
assert: |copy_height| > 0 && |copy_width| > 0

// Checking same things for the copy button when there is no run button.
go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html"
call-function: ("check-copy-button", {})
// Ensure there is no run button.
assert-count: (".example-wrap .test-arrow", 0)
// Check it's the same size without a run button.
assert-size: (".example-wrap:nth-of-type(1) .copy-button", {
    "height": |copy_height|,
    "width": |copy_width|,
})