diff --git a/roles/web-app-docs/files/playwright/test-front-page.js b/roles/web-app-docs/files/playwright/test-front-page.js index 0db4636e0d..7317b915e6 100644 --- a/roles/web-app-docs/files/playwright/test-front-page.js +++ b/roles/web-app-docs/files/playwright/test-front-page.js @@ -1,27 +1,33 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("./timeouts"); -const { expectHstsWhenTls, gotoOnion } = require("./personas"); +const { expectHstsWhenTls } = require("./personas"); exports.register = function (shared) { - test("docs front page opens the latest commit under canonical domain with TLS", async ({ page }) => { - const response = await gotoOnion(page, `${shared.appBaseUrl}/`); - expect(response, "Expected docs response").toBeTruthy(); - expect(response.status(), "Expected docs front page status < 400").toBeLessThan(400); + test("docs front page opens the latest commit under canonical domain with TLS", async ({ request }) => { + const response = await request.get(`${shared.appBaseUrl}/`, { + maxRedirects: 0, + failOnStatusCode: false, + timeout: resolveTimeout(30_000), + }); + expect(response.status(), "Expected the front page to redirect").toBe(302); expect( response.url().includes(shared.canonicalDomain), `Expected canonical domain "${shared.canonicalDomain}" to back the docs URL`, ).toBe(true); - expect(new URL(response.url()).pathname, "Expected the front page to open the latest commit").toBe("/latest/"); + expect(response.headers()["location"], "Expected the front page to open the latest commit").toBe("/latest/"); expectHstsWhenTls(response.headers(), shared.appBaseUrl, "docs"); }); - test("latest commit is either the built Sphinx site or its running build", async ({ request }) => { - const response = await request.get(`${shared.appBaseUrl}/latest/`, { timeout: resolveTimeout(30_000) }); + test("the deployed working tree is either the built Sphinx site or its running build", async ({ request }) => { + const response = await request.get(`${shared.appBaseUrl}/deployed/`, { + failOnStatusCode: false, + timeout: resolveTimeout(30_000), + }); const body = await response.text(); expect([200, 202], "Expected the built site or the build page").toContain(response.status()); const built = response.status() === 200; - expect(body, "Expected the Sphinx site or the build page of the latest commit").toContain( - built ? 'data-current="latest"' : 'data-build="latest"', + expect(body, "Expected the Sphinx site or the build page of the deployed working tree").toContain( + built ? 'data-current="deployed"' : 'data-build="deployed"', ); expect(body, "Expected the project title or a progress bar").toContain(built ? "Infinito.Nexus" : " None: - self.assertIn("latest", self._queued()) + def test_the_fetch_queues_latest_behind_what_a_visitor_waits_for(self) -> None: + self.assertEqual(self._queued(), []) + self.assertIn("latest", self._queued("background")) + self.assertEqual(self.library.next_queued(), "latest") def test_a_current_version_is_not_queued_again(self) -> None: self.library._dequeue("latest") diff --git a/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py b/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py index d24e75a6a3..6f1d1f75cf 100644 --- a/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py +++ b/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py @@ -169,7 +169,7 @@ class TestLibrary(LibraryFixture): self.library.fetch() self.assertTrue( - (self.library.queue / "v1.0.0").exists(), + self.library.is_queued("v1.0.0"), "a tag is built on demand and then never revisited, so nothing else " "would ever notice its index predates the split", ) @@ -218,6 +218,7 @@ class TestLibrary(LibraryFixture): self.assertFalse((self.library.queue / "v9.9.9").exists()) def test_queue_is_served_oldest_request_first(self) -> None: + self.library.request("latest") self.library.request("v1.0.0") self.library.request("v1.2.0") os.utime(self.library.queue / "latest", (3000, 3000))