Skip to content

Commit

Permalink
Tests: remove "test" docstring prefix (#1052)
Browse files Browse the repository at this point in the history
The fact that each test case description starts with `"test"` is an
artifact of the pre-Playwright test suite. Prior to Playwright, test
cases were inferred from function names that started with `"test"`.

Since Playwright doesn't impose those same expectations, the prefix can
be omitted.
  • Loading branch information
seanpdoyle authored Oct 31, 2023
1 parent 725fd51 commit 0613595
Show file tree
Hide file tree
Showing 22 changed files with 349 additions and 349 deletions.
4 changes: 2 additions & 2 deletions src/tests/functional/async_script_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ test.beforeEach(async ({ page }) => {
await readEventLogs(page)
})

test("test does not emit turbo:load when loaded asynchronously after DOMContentLoaded", async ({ page }) => {
test("does not emit turbo:load when loaded asynchronously after DOMContentLoaded", async ({ page }) => {
const events = await readEventLogs(page)

assert.deepEqual(events, [])
})

test("test following a link when loaded asynchronously after DOMContentLoaded", async ({ page }) => {
test("following a link when loaded asynchronously after DOMContentLoaded", async ({ page }) => {
await page.click("#async-link")

assert.equal(await visitAction(page), "advance")
Expand Down
18 changes: 9 additions & 9 deletions src/tests/functional/autofocus_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test.beforeEach(async ({ page }) => {
await page.goto("/src/tests/fixtures/autofocus.html")
})

test("test autofocus first autofocus element on load", async ({ page }) => {
test("autofocus first autofocus element on load", async ({ page }) => {
await nextBeat()
assert.ok(
await hasSelector(page, "#first-autofocus-element:focus"),
Expand All @@ -18,7 +18,7 @@ test("test autofocus first autofocus element on load", async ({ page }) => {
)
})

test("test autofocus first [autofocus] element on visit", async ({ page }) => {
test("autofocus first [autofocus] element on visit", async ({ page }) => {
await page.goto("/src/tests/fixtures/navigation.html")
await page.click("#autofocus-link")
await nextBeat()
Expand All @@ -33,7 +33,7 @@ test("test autofocus first [autofocus] element on visit", async ({ page }) => {
)
})

test("test navigating a frame with a descendant link autofocuses [autofocus]:first-of-type", async ({ page }) => {
test("navigating a frame with a descendant link autofocuses [autofocus]:first-of-type", async ({ page }) => {
await page.click("#frame-inner-link")
await nextBeat()

Expand All @@ -47,7 +47,7 @@ test("test navigating a frame with a descendant link autofocuses [autofocus]:fir
)
})

test("test autofocus visible [autofocus] element on visit with inert elements", async ({ page }) => {
test("autofocus visible [autofocus] element on visit with inert elements", async ({ page }) => {
await page.click("#autofocus-inert-link")
await nextBeat()

Expand Down Expand Up @@ -77,7 +77,7 @@ test("test autofocus visible [autofocus] element on visit with inert elements",
)
})

test("test navigating a frame with a link targeting the frame autofocuses [autofocus]:first-of-type", async ({
test("navigating a frame with a link targeting the frame autofocuses [autofocus]:first-of-type", async ({
page
}) => {
await page.click("#frame-outer-link")
Expand All @@ -93,7 +93,7 @@ test("test navigating a frame with a link targeting the frame autofocuses [autof
)
})

test("test navigating a frame with a turbo-frame targeting the frame autofocuses [autofocus]:first-of-type", async ({
test("navigating a frame with a turbo-frame targeting the frame autofocuses [autofocus]:first-of-type", async ({
page
}) => {
await page.click("#drives-frame-target-link")
Expand All @@ -109,7 +109,7 @@ test("test navigating a frame with a turbo-frame targeting the frame autofocuses
)
})

test("test receiving a Turbo Stream message with an [autofocus] element when the activeElement is the document", async ({ page }) => {
test("receiving a Turbo Stream message with an [autofocus] element when the activeElement is the document", async ({ page }) => {
await page.evaluate(() => {
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur()
Expand All @@ -128,7 +128,7 @@ test("test receiving a Turbo Stream message with an [autofocus] element when the
)
})

test("test autofocus from a Turbo Stream message does not leak a placeholder [id]", async ({ page }) => {
test("autofocus from a Turbo Stream message does not leak a placeholder [id]", async ({ page }) => {
await page.evaluate(() => {
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur()
Expand All @@ -147,7 +147,7 @@ test("test autofocus from a Turbo Stream message does not leak a placeholder [id
)
})

test("test receiving a Turbo Stream message with an [autofocus] element when an element within the document has focus", async ({ page }) => {
test("receiving a Turbo Stream message with an [autofocus] element when an element within the document has focus", async ({ page }) => {
await page.evaluate(() => {
window.Turbo.renderStreamMessage(`
<turbo-stream action="append" targets="body">
Expand Down
6 changes: 3 additions & 3 deletions src/tests/functional/cache_observer_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test } from "@playwright/test"
import { assert } from "chai"
import { hasSelector, nextBody } from "../helpers/page"

test("test removes temporary elements", async ({ page }) => {
test("removes temporary elements", async ({ page }) => {
await page.goto("/src/tests/fixtures/cache_observer.html")

assert.equal(await page.textContent("#temporary"), "data-turbo-temporary")
Expand All @@ -15,7 +15,7 @@ test("test removes temporary elements", async ({ page }) => {
assert.notOk(await hasSelector(page, "#temporary"))
})

test("test removes temporary elements with deprecated turbo-cache=false selector", async ({ page }) => {
test("removes temporary elements with deprecated turbo-cache=false selector", async ({ page }) => {
await page.goto("/src/tests/fixtures/cache_observer.html")

assert.equal(await page.textContent("#temporary-with-deprecated-selector"), "data-turbo-cache=false")
Expand All @@ -28,7 +28,7 @@ test("test removes temporary elements with deprecated turbo-cache=false selector
assert.notOk(await hasSelector(page, "#temporary-with-deprecated-selector"))
})

test("test following a redirect renders [data-turbo-temporary] elements before the cache removes", async ({ page }) => {
test("following a redirect renders [data-turbo-temporary] elements before the cache removes", async ({ page }) => {
await page.goto("/src/tests/fixtures/navigation.html")
await page.click("#redirect-to-cache-observer")
await nextBody(page)
Expand Down
12 changes: 6 additions & 6 deletions src/tests/functional/drive_disabled_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ test.beforeEach(async ({ page }) => {
await page.goto(path)
})

test("test drive disabled by default; click normal link", async ({ page }) => {
test("drive disabled by default; click normal link", async ({ page }) => {
await page.click("#drive_disabled")
await nextBody(page)

assert.equal(pathname(page.url()), path)
assert.equal(await visitAction(page), "load")
})

test("test drive disabled by default; click link inside data-turbo='true'", async ({ page }) => {
test("drive disabled by default; click link inside data-turbo='true'", async ({ page }) => {
await page.click("#drive_enabled")
await nextBody(page)

assert.equal(pathname(page.url()), path)
assert.equal(await visitAction(page), "advance")
})

test("test drive disabled by default; submit form inside data-turbo='true'", async ({ page }) => {
test("drive disabled by default; submit form inside data-turbo='true'", async ({ page }) => {
await setLocalStorageFromEvent(page, "turbo:submit-start", "formSubmitted", "true")

await page.click("#no_submitter_drive_enabled a#requestSubmit")
Expand All @@ -44,17 +44,17 @@ test("test drive disabled by default; submit form inside data-turbo='true'", asy
assert.equal(await searchParams(page.url()).get("greeting"), "Hello from a redirect")
})

test("test drive disabled by default; links within <turbo-frame> navigate with Turbo", async ({ page }) => {
test("drive disabled by default; links within <turbo-frame> navigate with Turbo", async ({ page }) => {
await page.click("#frame a")
await nextEventOnTarget(page, "frame", "turbo:frame-render")
})

test("test drive disabled by default; forms within <turbo-frame> navigate with Turbo", async ({ page }) => {
test("drive disabled by default; forms within <turbo-frame> navigate with Turbo", async ({ page }) => {
await page.click("#frame button")
await nextEventOnTarget(page, "frame", "turbo:frame-render")
})

test("test drive disabled by default; slot within <turbo-frame> navigate with Turbo", async ({ page }) => {
test("drive disabled by default; slot within <turbo-frame> navigate with Turbo", async ({ page }) => {
await page.click("#frame-navigation-with-slot")
await nextEventOnTarget(page, "frame", "turbo:frame-render")
})
6 changes: 3 additions & 3 deletions src/tests/functional/drive_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ test.beforeEach(async ({ page }) => {
await page.goto(path)
})

test("test drive enabled by default; click normal link", async ({ page }) => {
test("drive enabled by default; click normal link", async ({ page }) => {
await page.click("#drive_enabled")
await nextBody(page)
assert.equal(pathname(page.url()), path)
})

test("test drive to external link", async ({ page }) => {
test("drive to external link", async ({ page }) => {
await page.route("https://example.com", async (route) => {
await route.fulfill({ body: "Hello from the outside world" })
})
Expand All @@ -26,7 +26,7 @@ test("test drive to external link", async ({ page }) => {
assert.equal(await page.textContent("body"), "Hello from the outside world")
})

test("test drive enabled by default; click link inside data-turbo='false'", async ({ page }) => {
test("drive enabled by default; click link inside data-turbo='false'", async ({ page }) => {
await page.click("#drive_disabled")
await nextBody(page)

Expand Down
18 changes: 9 additions & 9 deletions src/tests/functional/form_mode_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,63 @@ import { test } from "@playwright/test"
import { getFromLocalStorage, setLocalStorageFromEvent } from "../helpers/page"
import { assert } from "chai"

test("test form submission with form mode off", async ({ page }) => {
test("form submission with form mode off", async ({ page }) => {
await gotoPageWithFormMode(page, "off")
await page.click("#turbo-enabled-form button")

assert.notOk(await formSubmitStarted(page))
})

test("test form submission without submitter with form mode off", async ({ page }) => {
test("form submission without submitter with form mode off", async ({ page }) => {
await gotoPageWithFormMode(page, "off")
await page.press("#turbo-enabled-form-without-submitter [type=text]", "Enter")

assert.notOk(await formSubmitStarted(page))
})

test("test form submission with form mode off from submitter outside form", async ({ page }) => {
test("form submission with form mode off from submitter outside form", async ({ page }) => {
await gotoPageWithFormMode(page, "off")
await page.click("button[form=turbo-enabled-form]")

assert.notOk(await formSubmitStarted(page))
})

test("test form submission with form mode optin and form not enabled", async ({ page }) => {
test("form submission with form mode optin and form not enabled", async ({ page }) => {
await gotoPageWithFormMode(page, "optin")
await page.click("#form button")

assert.notOk(await formSubmitStarted(page))
})

test("test form submission without submitter with form mode optin and form not enabled", async ({ page }) => {
test("form submission without submitter with form mode optin and form not enabled", async ({ page }) => {
await gotoPageWithFormMode(page, "optin")
await page.press("#form-without-submitter [type=text]", "Enter")

assert.notOk(await formSubmitStarted(page))
})

test("test form submission with form mode optin and form not enabled from submitter outside form", async ({ page }) => {
test("form submission with form mode optin and form not enabled from submitter outside form", async ({ page }) => {
await gotoPageWithFormMode(page, "optin")
await page.click("button[form=form]")

assert.notOk(await formSubmitStarted(page))
})

test("test form submission with form mode optin and form enabled", async ({ page }) => {
test("form submission with form mode optin and form enabled", async ({ page }) => {
await gotoPageWithFormMode(page, "optin")
await page.click("#turbo-enabled-form button")

assert.ok(await formSubmitStarted(page))
})

test("test form submission without submitter with form mode optin and form enabled", async ({ page }) => {
test("form submission without submitter with form mode optin and form enabled", async ({ page }) => {
await gotoPageWithFormMode(page, "optin")
await page.press("#turbo-enabled-form-without-submitter [type=text]", "Enter")

assert.ok(await formSubmitStarted(page))
})

test("test form submission with form mode optin and form enabled from submitter outside form", async ({ page }) => {
test("form submission with form mode optin and form enabled from submitter outside form", async ({ page }) => {
await gotoPageWithFormMode(page, "optin")
await page.click("button[form=turbo-enabled-form]")

Expand Down
Loading

0 comments on commit 0613595

Please sign in to comment.