@sharadox/test-web-library 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/LICENCA.md +76 -0
  2. package/LICENSE.md +76 -0
  3. package/NOTICE.md +3 -0
  4. package/README.md +51 -2
  5. package/distribution/installability-suite/index.d.ts +9 -0
  6. package/distribution/installability-suite/index.d.ts.map +1 -0
  7. package/distribution/installability-suite/index.js +18 -0
  8. package/distribution/installability-suite/index.js.map +1 -0
  9. package/distribution/preference-suite/index.d.ts +27 -0
  10. package/distribution/preference-suite/index.d.ts.map +1 -0
  11. package/distribution/preference-suite/index.js +80 -0
  12. package/distribution/preference-suite/index.js.map +1 -0
  13. package/distribution/preference-suite/type.d.ts +43 -0
  14. package/distribution/preference-suite/type.d.ts.map +1 -0
  15. package/distribution/preference-suite/type.js +2 -0
  16. package/distribution/preference-suite/type.js.map +1 -0
  17. package/distribution/search-engine-suite/index.d.ts +14 -0
  18. package/distribution/search-engine-suite/index.d.ts.map +1 -0
  19. package/distribution/search-engine-suite/index.js +33 -0
  20. package/distribution/search-engine-suite/index.js.map +1 -0
  21. package/distribution/search-engine-suite/type.d.ts +18 -0
  22. package/distribution/search-engine-suite/type.d.ts.map +1 -0
  23. package/distribution/search-engine-suite/type.js +2 -0
  24. package/distribution/search-engine-suite/type.js.map +1 -0
  25. package/distribution/visual-snapshot/index.d.ts +8 -0
  26. package/distribution/visual-snapshot/index.d.ts.map +1 -0
  27. package/distribution/visual-snapshot/index.js +20 -0
  28. package/distribution/visual-snapshot/index.js.map +1 -0
  29. package/distribution/visual-snapshot/type.d.ts +7 -0
  30. package/distribution/visual-snapshot/type.d.ts.map +1 -0
  31. package/distribution/visual-snapshot/type.js +2 -0
  32. package/distribution/visual-snapshot/type.js.map +1 -0
  33. package/llms.txt +9 -0
  34. package/package.json +81 -3
package/LICENCA.md ADDED
@@ -0,0 +1,76 @@
1
+ # Licença Sharadox de Código Aberto
2
+
3
+ Versão 0.1.0
4
+
5
+ O texto em língua portuguesa é o único texto original e vinculativo desta licença. A tradução para inglês (`LICENSE.md`) é meramente informativa; em caso de divergência prevalece o texto em português.
6
+
7
+ ## 1. Definições
8
+
9
+ Para efeitos desta licença:
10
+
11
+ 1. **«Obra»** — o programa de computador, a sua documentação e quaisquer outros conteúdos disponibilizados pelo Licenciante ao abrigo desta licença, em código-fonte ou em qualquer outra forma.
12
+ 2. **«Licenciante»** — o titular dos direitos de autor identificado no aviso de direitos de autor que acompanha a Obra.
13
+ 3. **«Licenciado»** — qualquer pessoa, singular ou coletiva, que exerça os direitos concedidos por esta licença.
14
+ 4. **«Obra Derivada»** — qualquer obra baseada na Obra ou que a incorpore, total ou parcialmente, com ou sem modificações, incluindo traduções, adaptações e programas que a integrem.
15
+ 5. **«Aviso»** — o aviso de direitos de autor do Licenciante e a indicação de que a Obra está licenciada ao abrigo desta licença, incluindo a respetiva versão.
16
+
17
+ ## 2. Concessão de direitos
18
+
19
+ 1. Nos termos desta licença, o Licenciante concede ao Licenciado uma licença mundial, gratuita, não exclusiva e por todo o prazo de proteção dos direitos de autor para:
20
+ 1. utilizar a Obra para qualquer finalidade, incluindo finalidades comerciais;
21
+ 2. reproduzir a Obra, total ou parcialmente, por qualquer meio e sob qualquer forma;
22
+ 3. modificar, traduzir, adaptar e transformar a Obra e criar Obras Derivadas;
23
+ 4. distribuir, publicar, comunicar ao público, colocar à disposição, vender e sublicenciar a Obra e as Obras Derivadas.
24
+ 2. Na medida em que o Licenciante seja titular de patentes necessariamente infringidas pela Obra tal como por si disponibilizada, concede igualmente ao Licenciado, nos mesmos termos, uma licença para utilizar essas patentes no exercício dos direitos previstos no número anterior.
25
+ 3. Esta licença não transmite a titularidade de quaisquer direitos, que permanecem do Licenciante.
26
+
27
+ ## 3. Condições
28
+
29
+ O exercício dos direitos concedidos fica sujeito às seguintes condições:
30
+
31
+ 1. Todas as cópias da Obra, ou de partes substanciais da mesma, e todas as Obras Derivadas distribuídas devem incluir o Aviso e uma cópia desta licença ou uma ligação estável para o seu texto.
32
+ 2. Quem distribuir uma versão modificada da Obra deve indicar de forma visível que a mesma foi modificada, não podendo apresentá-la como versão original do Licenciante.
33
+ 3. O Licenciado pode licenciar as suas próprias modificações ao abrigo de outros termos, desde que a parte da Obra que delas faça parte continue sujeita às condições desta licença.
34
+
35
+ ## 4. Nomes e marcas
36
+
37
+ Esta licença não concede qualquer direito sobre o nome, as marcas, os logótipos ou outros sinais distintivos do Licenciante, incluindo a designação «Sharadox», salvo na medida estritamente necessária para cumprir o dever de incluir o Aviso. É proibido utilizá-los para promover ou sugerir o apoio do Licenciante a Obras Derivadas ou a quaisquer produtos ou serviços sem autorização prévia e escrita.
38
+
39
+ ## 5. Exclusão de garantias
40
+
41
+ A Obra é disponibilizada «tal como está» e «conforme disponível», sem qualquer garantia, expressa ou tácita, incluindo, designadamente, garantias de comerciabilidade, de adequação a um fim específico, de ausência de erros ou de não violação de direitos de terceiros, na medida máxima permitida pela lei aplicável.
42
+
43
+ ## 6. Limitação de responsabilidade
44
+
45
+ 1. Na medida máxima permitida pela lei aplicável, o Licenciante não é responsável por quaisquer danos, diretos ou indiretos, incluindo lucros cessantes, perda de dados ou interrupção de atividade, resultantes da utilização ou da impossibilidade de utilização da Obra, ainda que tenha sido avisado da possibilidade da sua ocorrência.
46
+ 2. Nada nesta licença exclui ou limita a responsabilidade do Licenciante nos casos em que tal exclusão ou limitação não seja permitida por lei, designadamente por atos praticados com dolo ou culpa grave, nos termos do artigo 809.º e do n.º 2 do artigo 800.º do Código Civil, nem afeta os direitos que a lei imperativamente reconheça aos consumidores.
47
+
48
+ ## 7. Cessação
49
+
50
+ 1. Os direitos concedidos por esta licença cessam automaticamente se o Licenciado violar qualquer das suas condições.
51
+ 2. Os direitos são repostos se a violação for sanada no prazo de 30 dias a contar do momento em que o Licenciado dela tome conhecimento, salvo se o Licenciante tiver entretanto comunicado por escrito a sua oposição.
52
+ 3. A cessação não afeta as licenças validamente concedidas pelo Licenciado a terceiros que cumpram esta licença.
53
+
54
+ ## 8. Lei aplicável e foro
55
+
56
+ 1. Esta licença rege-se pela lei portuguesa, designadamente pelo Código do Direito de Autor e dos Direitos Conexos, aprovado pelo Decreto-Lei n.º 63/85, de 14 de março, e pelo Decreto-Lei n.º 252/94, de 20 de outubro, relativo à proteção jurídica dos programas de computador.
57
+ 2. Para a resolução de quaisquer litígios emergentes desta licença é competente o Tribunal Judicial da Comarca de Faro, sem prejuízo das normas imperativas de competência aplicáveis, nomeadamente as que protegem os consumidores.
58
+
59
+ ## 9. Versões da licença
60
+
61
+ O Licenciante pode publicar novas versões desta licença, identificadas por um número de versão. A Obra fica sujeita à versão indicada no Aviso. O Licenciado pode, se o Aviso o permitir, optar por qualquer versão posterior.
62
+
63
+ ## 10. Disposições finais
64
+
65
+ 1. Se alguma disposição desta licença for considerada inválida ou ineficaz, as restantes mantêm-se em vigor, devendo a disposição afetada ser interpretada de forma a aproximar-se, tanto quanto possível, da intenção original.
66
+ 2. A não exigência, em qualquer momento, do cumprimento de uma disposição desta licença não constitui renúncia ao direito de o exigir posteriormente.
67
+
68
+ ## Como aplicar esta licença
69
+
70
+ Inclua na Obra um ficheiro `LICENCA.md` com este texto, a tradução `LICENSE.md` e o seguinte aviso, preenchendo o ano e o titular:
71
+
72
+ ```
73
+ Direitos de autor © <ano> <titular>.
74
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
75
+ https://github.com/Sharadox/sharadox-open-source-license
76
+ ```
package/LICENSE.md ADDED
@@ -0,0 +1,76 @@
1
+ # Sharadox Open Source Licence
2
+
3
+ Version 0.1.0
4
+
5
+ This is an informative English translation. The Portuguese text (`LICENCA.md`) is the only original and binding text of this licence; if the two differ, the Portuguese text prevails.
6
+
7
+ ## 1. Definitions
8
+
9
+ For the purposes of this licence:
10
+
11
+ 1. **"Work"** — the computer program, its documentation and any other content made available by the Licensor under this licence, in source code or in any other form.
12
+ 2. **"Licensor"** — the copyright holder identified in the copyright notice that accompanies the Work.
13
+ 3. **"Licensee"** — any natural or legal person exercising the rights granted by this licence.
14
+ 4. **"Derivative Work"** — any work based on or incorporating the Work, in whole or in part, with or without modifications, including translations, adaptations and programs that integrate it.
15
+ 5. **"Notice"** — the Licensor's copyright notice and the statement that the Work is licensed under this licence, including its version.
16
+
17
+ ## 2. Grant of rights
18
+
19
+ 1. Under this licence, the Licensor grants the Licensee a worldwide, royalty-free, non-exclusive licence, for the whole term of copyright protection, to:
20
+ 1. use the Work for any purpose, including commercial purposes;
21
+ 2. reproduce the Work, in whole or in part, by any means and in any form;
22
+ 3. modify, translate, adapt and transform the Work and create Derivative Works;
23
+ 4. distribute, publish, communicate to the public, make available, sell and sublicense the Work and Derivative Works.
24
+ 2. To the extent the Licensor holds patents necessarily infringed by the Work as made available by it, the Licensor also grants the Licensee, on the same terms, a licence to use those patents in exercising the rights in the previous paragraph.
25
+ 3. This licence does not transfer ownership of any rights, which remain with the Licensor.
26
+
27
+ ## 3. Conditions
28
+
29
+ The exercise of the rights granted is subject to the following conditions:
30
+
31
+ 1. Every copy of the Work, or of substantial parts of it, and every distributed Derivative Work must include the Notice and a copy of this licence or a stable link to its text.
32
+ 2. Anyone distributing a modified version of the Work must state visibly that it has been modified and may not present it as the Licensor's original version.
33
+ 3. The Licensee may license their own modifications under other terms, provided the part of the Work included in them remains subject to the conditions of this licence.
34
+
35
+ ## 4. Names and trademarks
36
+
37
+ This licence grants no rights to the Licensor's name, trademarks, logos or other distinctive signs, including the name "Sharadox", except as strictly necessary to comply with the duty to include the Notice. Using them to promote or suggest the Licensor's endorsement of Derivative Works or of any products or services without prior written permission is prohibited.
38
+
39
+ ## 5. Disclaimer of warranties
40
+
41
+ The Work is provided "as is" and "as available", without any warranty, express or implied, including in particular warranties of merchantability, fitness for a particular purpose, absence of errors or non-infringement of third-party rights, to the maximum extent permitted by applicable law.
42
+
43
+ ## 6. Limitation of liability
44
+
45
+ 1. To the maximum extent permitted by applicable law, the Licensor is not liable for any damages, direct or indirect, including loss of profits, loss of data or business interruption, arising from the use of or inability to use the Work, even if advised of the possibility of such damages.
46
+ 2. Nothing in this licence excludes or limits the Licensor's liability where such exclusion or limitation is not permitted by law, in particular for acts committed with intent or gross negligence, under article 809 and article 800(2) of the Portuguese Civil Code, nor does it affect rights that the law mandatorily grants to consumers.
47
+
48
+ ## 7. Termination
49
+
50
+ 1. The rights granted by this licence terminate automatically if the Licensee breaches any of its conditions.
51
+ 2. The rights are reinstated if the breach is remedied within 30 days of the Licensee becoming aware of it, unless the Licensor has meanwhile objected in writing.
52
+ 3. Termination does not affect licences validly granted by the Licensee to third parties who comply with this licence.
53
+
54
+ ## 8. Governing law and jurisdiction
55
+
56
+ 1. This licence is governed by Portuguese law, in particular the Code of Copyright and Related Rights, approved by Decree-Law no. 63/85 of 14 March, and Decree-Law no. 252/94 of 20 October on the legal protection of computer programs.
57
+ 2. The Judicial Court of the District of Faro has jurisdiction over any dispute arising from this licence, without prejudice to applicable mandatory rules of jurisdiction, in particular those protecting consumers.
58
+
59
+ ## 9. Licence versions
60
+
61
+ The Licensor may publish new versions of this licence, identified by a version number. The Work is subject to the version stated in the Notice. If the Notice allows it, the Licensee may choose any later version.
62
+
63
+ ## 10. Final provisions
64
+
65
+ 1. If any provision of this licence is held invalid or unenforceable, the remaining provisions stay in force, and the affected provision shall be interpreted as closely as possible to its original intent.
66
+ 2. Failure to enforce any provision of this licence at any time does not waive the right to enforce it later.
67
+
68
+ ## How to apply this licence
69
+
70
+ Include in the Work a `LICENCA.md` file with the Portuguese text, this translation as `LICENSE.md`, and the following notice, filling in the year and holder:
71
+
72
+ ```
73
+ Direitos de autor © <ano> <titular>.
74
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
75
+ https://github.com/Sharadox/sharadox-open-source-license
76
+ ```
package/NOTICE.md ADDED
@@ -0,0 +1,3 @@
1
+ Direitos de autor © 2026 Micael Pires (Sharadox).
2
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
3
+ https://github.com/Sharadox/sharadox-open-source-license
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # @sharadox/test-web-library
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Playwright](https://playwright.dev) helpers and shared end-to-end suites, so every site runs the same checks with one call each:
4
+
5
+ - **`prepareVisualSnapshot(page, url)`:** a frozen clock, fonts loaded, every reveal-on-scroll triggered and animations settled before a full-page screenshot.
6
+ - **`describeSearchEngine`:** every page's language, heading, canonical address, hreflang default, share image, Twitter card and JSON-LD graph, plus the sitemap, robots and manifest routes.
7
+ - **`describeInstallability(path)`:** Chromium reports no installability errors.
8
+ - **`describeLocaleMemory`:** `/` follows the browser's language until the visitor picks one, then remembers it.
9
+ - **`describeStyleMemory`:** a style group starts on its default and remembers the visitor's choice.
10
+ - **`describeConsent`:** Deny lasts for the visit, manual choices are kept, and the preferences link reopens the panel.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ pnpm add -D @playwright/test @sharadox/test-web-library
16
+ ```
17
+
18
+ ## Use
19
+
20
+ ```ts
21
+ // src/app/[locale]/search-engine-end-to-end-test.ts
22
+ import { describeSearchEngine } from "@sharadox/test-web-library/search-engine-suite";
23
+
24
+ describeSearchEngine({
25
+ origin: "https://sharadox.com",
26
+ structuredDataTypes: ["Organization", "WebSite"],
27
+ pages: [
28
+ { path: "/en", language: "en", heading: "Technologies" },
29
+ { path: "/pt", language: "pt-PT", heading: "Tecnologias" },
30
+ ],
31
+ routes: ["/en/opengraph-image"],
32
+ });
33
+ ```
34
+
35
+ ## API
36
+
37
+ | Import | Export |
38
+ | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
39
+ | `…/visual-snapshot` | `prepareVisualSnapshot(page, url, { time?, step? })` |
40
+ | `…/search-engine-suite` | `describeSearchEngine({ origin, pages, structuredDataTypes, routes? })`, `STANDARD_ROUTES` |
41
+ | `…/installability-suite` | `describeInstallability(path)` |
42
+ | `…/preference-suite` | `describeLocaleMemory(options)`, `describeStyleMemory(options)`, `describeConsent(options)`; options in `…/preference-suite/type` |
43
+
44
+ The suites that need a clean browser open their own context with empty storage, whatever the project's starting state.
45
+
46
+ ## Develop
47
+
48
+ `pnpm verify` runs formatting, lint, type-check, tests with 100% coverage and the build. Branches follow `<feature>.development` → `development` → `index`, and releases are `v<version>` tags on `index`.
49
+
50
+ ## Licence
51
+
52
+ Licença Sharadox de Código Aberto, versão 0.1.0. See [português](LICENCA.md) (the binding text) and the [English translation](LICENSE.md).
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Registers a test that Chromium considers the page installable (a valid manifest, icons and HTTPS-equivalent
3
+ * localhost), using the DevTools protocol. Chromium projects only.
4
+ *
5
+ * @example
6
+ * describeInstallability("/en");
7
+ */
8
+ export declare function describeInstallability(path: string): void;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/installability-suite/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAUzD"}
@@ -0,0 +1,18 @@
1
+ import { expect, test } from "@playwright/test";
2
+ /**
3
+ * Registers a test that Chromium considers the page installable (a valid manifest, icons and HTTPS-equivalent
4
+ * localhost), using the DevTools protocol. Chromium projects only.
5
+ *
6
+ * @example
7
+ * describeInstallability("/en");
8
+ */
9
+ export function describeInstallability(path) {
10
+ test("the site can be installed", async ({ page, browserName }) => {
11
+ test.skip(browserName !== "chromium", "installability is reported by Chromium");
12
+ await page.goto(path);
13
+ const session = await page.context().newCDPSession(page);
14
+ const { installabilityErrors } = (await session.send("Page.getInstallabilityErrors"));
15
+ expect(installabilityErrors.map((error) => error.errorId)).toEqual([]);
16
+ });
17
+ }
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/installability-suite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,IAAI,CAAC,2BAA2B,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;QAChE,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,UAAU,EAAE,wCAAwC,CAAC,CAAC;QAChF,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,EAAE,oBAAoB,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAEnF,CAAC;QACF,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { ConsentSuiteOptions, LocaleMemoryOptions, StyleMemoryOptions } from "@sharadox/test-web-library/preference-suite/type";
2
+ /**
3
+ * Registers a test that `/` follows the browser's language until the visitor picks one, and then remembers it.
4
+ *
5
+ * @example
6
+ * describeLocaleMemory({ browserLocale: "pt-PT", automaticPath: "/pt", switchName: "Idioma", pick: { link: "EN", path: "/en" } });
7
+ */
8
+ export declare function describeLocaleMemory({ browserLocale, automaticPath, switchName, pick }: LocaleMemoryOptions): void;
9
+ /**
10
+ * Registers a test that a style group starts on its default and remembers a manual choice across visits.
11
+ *
12
+ * @example
13
+ * describeStyleMemory({ path: "/en", attribute: "data-style-color", switchName: "Style", colorScheme: "light",
14
+ * initial: "black", pick: { radio: "White", style: "white" } });
15
+ */
16
+ export declare function describeStyleMemory({ path, attribute, switchName, colorScheme, initial, pick, }: StyleMemoryOptions): void;
17
+ /**
18
+ * Registers a test of the cookie panel: Deny lasts only for the visit, a manual selection is kept for good, and
19
+ * the preferences link reopens it.
20
+ *
21
+ * @example
22
+ * describeConsent({ path: "/en", dialogName: "Cookies", deny: "Deny", customize: "Customize", save: "Save Choices",
23
+ * preferences: "Cookie Preferences", category: "Analytics", storageKey: "consent",
24
+ * expectedGranted: { required: true, analytics: true, marketing: false } });
25
+ */
26
+ export declare function describeConsent(options: ConsentSuiteOptions): void;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/preference-suite/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,kDAAkD,CAAC;AAK1D;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,mBAAmB,GAAG,IAAI,CAYlH;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,SAAS,EACT,UAAU,EACV,WAAW,EACX,OAAO,EACP,IAAI,GACL,EAAE,kBAAkB,GAAG,IAAI,CAa3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CA4BlE"}
@@ -0,0 +1,80 @@
1
+ import { expect, test } from "@playwright/test";
2
+ /** A browser context with no stored cookies or storage, whatever the project's starting state. */
3
+ const FRESH = { storageState: { cookies: [], origins: [] } };
4
+ /**
5
+ * Registers a test that `/` follows the browser's language until the visitor picks one, and then remembers it.
6
+ *
7
+ * @example
8
+ * describeLocaleMemory({ browserLocale: "pt-PT", automaticPath: "/pt", switchName: "Idioma", pick: { link: "EN", path: "/en" } });
9
+ */
10
+ export function describeLocaleMemory({ browserLocale, automaticPath, switchName, pick }) {
11
+ test("the language follows the browser until the visitor picks one, then is remembered", async ({ browser }) => {
12
+ const context = await browser.newContext({ ...FRESH, locale: browserLocale });
13
+ const page = await context.newPage();
14
+ await page.goto("/");
15
+ await expect(page).toHaveURL(new RegExp(`${automaticPath}$`));
16
+ await page.getByRole("group", { name: switchName }).getByRole("link", { name: pick.link }).first().click();
17
+ await expect(page).toHaveURL(new RegExp(`${pick.path}$`));
18
+ await page.goto("/");
19
+ await expect(page).toHaveURL(new RegExp(`${pick.path}$`));
20
+ await context.close();
21
+ });
22
+ }
23
+ /**
24
+ * Registers a test that a style group starts on its default and remembers a manual choice across visits.
25
+ *
26
+ * @example
27
+ * describeStyleMemory({ path: "/en", attribute: "data-style-color", switchName: "Style", colorScheme: "light",
28
+ * initial: "black", pick: { radio: "White", style: "white" } });
29
+ */
30
+ export function describeStyleMemory({ path, attribute, switchName, colorScheme, initial, pick, }) {
31
+ test("the style starts on its default and remembers the visitor's choice", async ({ browser }) => {
32
+ const context = await browser.newContext({ ...FRESH, colorScheme });
33
+ const page = await context.newPage();
34
+ const html = page.locator("html");
35
+ await page.goto(path);
36
+ await expect(html).toHaveAttribute(attribute, initial);
37
+ await page.getByRole("radiogroup", { name: switchName }).first().getByRole("radio", { name: pick.radio }).click();
38
+ await expect(html).toHaveAttribute(attribute, pick.style);
39
+ await page.reload();
40
+ await expect(html).toHaveAttribute(attribute, pick.style);
41
+ await context.close();
42
+ });
43
+ }
44
+ /**
45
+ * Registers a test of the cookie panel: Deny lasts only for the visit, a manual selection is kept for good, and
46
+ * the preferences link reopens it.
47
+ *
48
+ * @example
49
+ * describeConsent({ path: "/en", dialogName: "Cookies", deny: "Deny", customize: "Customize", save: "Save Choices",
50
+ * preferences: "Cookie Preferences", category: "Analytics", storageKey: "consent",
51
+ * expectedGranted: { required: true, analytics: true, marketing: false } });
52
+ */
53
+ export function describeConsent(options) {
54
+ const { path, dialogName, deny, customize, save, preferences, category, storageKey, expectedGranted } = options;
55
+ test("the cookie panel keeps answers, but asks again after a refusal on the next visit", async ({ browser }) => {
56
+ const context = await browser.newContext(FRESH);
57
+ const page = await context.newPage();
58
+ const panel = page.getByRole("dialog", { name: dialogName });
59
+ await page.goto(path);
60
+ await panel.getByRole("button", { name: deny }).click();
61
+ await expect(panel).toBeHidden();
62
+ await page.reload();
63
+ await expect(panel).toBeHidden();
64
+ const nextVisit = await context.newPage();
65
+ await nextVisit.goto(path);
66
+ const again = nextVisit.getByRole("dialog", { name: dialogName });
67
+ await again.getByRole("button", { name: customize }).click();
68
+ await again.getByRole("switch", { name: new RegExp(category) }).check();
69
+ await again.getByRole("button", { name: save }).click();
70
+ await expect(again).toBeHidden();
71
+ const stored = JSON.parse((await nextVisit.evaluate((key) => localStorage.getItem(key), storageKey)) ?? "{}");
72
+ expect(stored.granted).toEqual(expectedGranted);
73
+ await nextVisit.reload();
74
+ await expect(again).toBeHidden();
75
+ await nextVisit.getByRole("button", { name: preferences }).click();
76
+ await expect(again).toBeVisible();
77
+ await context.close();
78
+ });
79
+ }
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/preference-suite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAOhD,kGAAkG;AAClG,MAAM,KAAK,GAAG,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAuB;IAC1G,IAAI,CAAC,kFAAkF,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7G,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,KAAK,EAA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,CAAC,MAAM,EAAE,CAAC;QACzB,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACnE,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAClC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,43 @@
1
+ export interface LocaleMemoryOptions {
2
+ /** The browser's language, for example "pt-PT". */
3
+ browserLocale: string;
4
+ /** Where `/` must first go for that browser, for example "/pt". */
5
+ automaticPath: string;
6
+ /** Accessible name of the language switch group in that language, for example "Idioma". */
7
+ switchName: string;
8
+ /** The link to pick by hand, for example "EN", and where it leads, for example "/en". */
9
+ pick: {
10
+ link: string;
11
+ path: string;
12
+ };
13
+ }
14
+ export interface StyleMemoryOptions {
15
+ /** Path of a page with the style switch. */
16
+ path: string;
17
+ /** The `<html>` attribute of the style group, for example "data-style-color". */
18
+ attribute: string;
19
+ /** Accessible name of the switch's radio group, for example "Style". */
20
+ switchName: string;
21
+ /** The device's scheme during the test. */
22
+ colorScheme: "light" | "dark";
23
+ /** The style before any choice (the default), and a style to pick by hand. */
24
+ initial: string;
25
+ pick: {
26
+ radio: string;
27
+ style: string;
28
+ };
29
+ }
30
+ export interface ConsentSuiteOptions {
31
+ path: string;
32
+ /** Accessible name of the cookie dialog, and of its buttons. */
33
+ dialogName: string;
34
+ deny: string;
35
+ customize: string;
36
+ save: string;
37
+ preferences: string;
38
+ /** A category switch to turn on in the manual selection, and the storage key and expected answer. */
39
+ category: string;
40
+ storageKey: string;
41
+ expectedGranted: Record<string, boolean>;
42
+ }
43
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/preference-suite/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,aAAa,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/preference-suite/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { SearchEngineSuiteOptions } from "@sharadox/test-web-library/search-engine-suite/type";
2
+ /** The routes every Sharadox site serves for search engines, share cards and installation. */
3
+ export declare const STANDARD_ROUTES: readonly ["/sitemap.xml", "/robots.txt", "/manifest.webmanifest"];
4
+ /**
5
+ * Registers end-to-end tests that every page has its language, heading, canonical address, hreflang default, share
6
+ * image, large Twitter card and JSON-LD graph, and that the search-engine routes answer.
7
+ *
8
+ * @example
9
+ * // src/app/[locale]/search-engine-end-to-end-test.ts
10
+ * describeSearchEngine({ origin: "https://sharadox.com", structuredDataTypes: ["Organization", "WebSite"],
11
+ * pages: [{ path: "/en", language: "en", heading: "Technologies" }], routes: ["/en/opengraph-image"] });
12
+ */
13
+ export declare function describeSearchEngine({ origin, pages, structuredDataTypes, routes, }: SearchEngineSuiteOptions): void;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/search-engine-suite/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qDAAqD,CAAC;AAEpG,8FAA8F;AAC9F,eAAO,MAAM,eAAe,mEAAoE,CAAC;AAEjG;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,KAAK,EACL,mBAAmB,EACnB,MAAW,GACZ,EAAE,wBAAwB,GAAG,IAAI,CAwBjC"}
@@ -0,0 +1,33 @@
1
+ import { expect, test } from "@playwright/test";
2
+ /** The routes every Sharadox site serves for search engines, share cards and installation. */
3
+ export const STANDARD_ROUTES = ["/sitemap.xml", "/robots.txt", "/manifest.webmanifest"];
4
+ /**
5
+ * Registers end-to-end tests that every page has its language, heading, canonical address, hreflang default, share
6
+ * image, large Twitter card and JSON-LD graph, and that the search-engine routes answer.
7
+ *
8
+ * @example
9
+ * // src/app/[locale]/search-engine-end-to-end-test.ts
10
+ * describeSearchEngine({ origin: "https://sharadox.com", structuredDataTypes: ["Organization", "WebSite"],
11
+ * pages: [{ path: "/en", language: "en", heading: "Technologies" }], routes: ["/en/opengraph-image"] });
12
+ */
13
+ export function describeSearchEngine({ origin, pages, structuredDataTypes, routes = [], }) {
14
+ test("every page has complete search engine metadata", async ({ page }) => {
15
+ for (const { path, language, heading } of pages) {
16
+ await page.goto(path);
17
+ await expect(page.locator("html")).toHaveAttribute("lang", language);
18
+ await expect(page.getByRole("heading", { level: 1 })).toContainText(heading);
19
+ await expect(page.locator('link[rel="canonical"]')).toHaveAttribute("href", `${origin}${path}`);
20
+ await expect(page.locator('link[rel="alternate"][hreflang="x-default"]')).toHaveCount(1);
21
+ await expect(page.locator('meta[property="og:image"]')).toHaveCount(1);
22
+ await expect(page.locator('meta[name="twitter:card"]')).toHaveAttribute("content", "summary_large_image");
23
+ const data = JSON.parse((await page.locator('script[type="application/ld+json"]').first().textContent()) ?? "{}");
24
+ expect((data["@graph"] ?? []).map((node) => node["@type"])).toEqual(structuredDataTypes);
25
+ }
26
+ });
27
+ test("search engine, share and install routes are served", async ({ request }) => {
28
+ for (const path of [...STANDARD_ROUTES, ...routes]) {
29
+ expect((await request.get(path)).status(), path).toBe(200);
30
+ }
31
+ });
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/search-engine-suite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGhD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,uBAAuB,CAAU,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,EACnC,MAAM,EACN,KAAK,EACL,mBAAmB,EACnB,MAAM,GAAG,EAAE,GACc;IACzB,IAAI,CAAC,gDAAgD,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACxE,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,KAA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AE,OAAO,EAAE,EAAE,EAAE;QAC/E,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;YACnD,MAAM,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface SearchEnginePage {
2
+ /** Path of the page, for example "/en". */
3
+ path: string;
4
+ /** Expected `<html lang>`, for example "pt-PT". */
5
+ language: string;
6
+ /** Text the page's `<h1>` contains. */
7
+ heading: string;
8
+ }
9
+ export interface SearchEngineSuiteOptions {
10
+ /** The public origin canonical links use, for example "https://sharadox.com". */
11
+ origin: string;
12
+ pages: readonly SearchEnginePage[];
13
+ /** The `@type` of each node in the JSON-LD `@graph`, in order. */
14
+ structuredDataTypes: readonly string[];
15
+ /** Routes that must answer 200 (share images, sitemap, robots, manifest…). */
16
+ routes?: readonly string[];
17
+ }
18
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/search-engine-suite/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACnC,kEAAkE;IAClE,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/search-engine-suite/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { Page } from "@playwright/test";
2
+ import type { VisualSnapshotOptions } from "@sharadox/test-web-library/visual-snapshot/type";
3
+ /**
4
+ * Prepares a page for a deterministic full-page screenshot: freezes the clock, opens the url, waits for fonts,
5
+ * scrolls through so every reveal-on-scroll fires, then returns to the top and lets animations finish.
6
+ */
7
+ export declare function prepareVisualSnapshot(page: Page, url: string, { time, step }?: VisualSnapshotOptions): Promise<void>;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/visual-snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAE7F;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,EAAE,IAAuC,EAAE,IAAU,EAAE,GAAE,qBAA0B,GAClF,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Prepares a page for a deterministic full-page screenshot: freezes the clock, opens the url, waits for fonts,
3
+ * scrolls through so every reveal-on-scroll fires, then returns to the top and lets animations finish.
4
+ */
5
+ export async function prepareVisualSnapshot(page, url, { time = new Date("2026-11-08T12:00:00Z"), step = 400 } = {}) {
6
+ await page.clock.install({ time });
7
+ await page.clock.pauseAt(new Date(time.getTime() + 1000));
8
+ await page.goto(url);
9
+ await page.evaluate(() => document.fonts.ready);
10
+ const height = await page.evaluate(() => document.documentElement.scrollHeight);
11
+ for (let y = 0; y <= height; y += step) {
12
+ await page.evaluate((top) => window.scrollTo(0, top), y);
13
+ await page.waitForTimeout(60);
14
+ await page.clock.runFor(400);
15
+ }
16
+ await page.evaluate(() => window.scrollTo(0, 0));
17
+ await page.waitForTimeout(60);
18
+ await page.clock.runFor(4000);
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/visual-snapshot/index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAU,EACV,GAAW,EACX,EAAE,IAAI,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,EAAE,IAAI,GAAG,GAAG,KAA4B,EAAE;IAEnF,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACnC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAChF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QACvC,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface VisualSnapshotOptions {
2
+ /** The moment the page believes it is; animations and timers only move when the test advances the clock. */
3
+ time?: Date;
4
+ /** Pixels per scroll step while settling. Defaults to 400. */
5
+ step?: number;
6
+ }
7
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/visual-snapshot/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,4GAA4G;IAC5G,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/visual-snapshot/type.ts"],"names":[],"mappings":""}
package/llms.txt ADDED
@@ -0,0 +1,9 @@
1
+ # @sharadox/test-web-library
2
+
3
+ > Playwright helpers + shared e2e suites for Next.js sites.
4
+
5
+ - /visual-snapshot prepareVisualSnapshot(page, url, { time, step=400 })
6
+ - /search-engine-suite describeSearchEngine({ origin, pages: [{ path, language, heading }], structuredDataTypes, routes? }); STANDARD_ROUTES = sitemap.xml, robots.txt, manifest.webmanifest
7
+ - /installability-suite describeInstallability(path) (Chromium CDP Page.getInstallabilityErrors)
8
+ - /preference-suite describeLocaleMemory({ browserLocale, automaticPath, switchName, pick: { link, path } }), describeStyleMemory({ path, attribute, switchName, colorScheme, initial, pick: { radio, style } }), describeConsent({ path, dialogName, deny, customize, save, preferences, category, storageKey, expectedGranted })
9
+ - Peer: @playwright/test. Licence: Sharadox Open Source Licence 0.1.0
package/package.json CHANGED
@@ -1,6 +1,84 @@
1
1
  {
2
2
  "name": "@sharadox/test-web-library",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Playwright helpers for websites: deterministic visual snapshots and shared end-to-end suites for search engines, installability, remembered language and style, and cookie consent.",
5
+ "private": false,
6
+ "license": "SEE LICENSE IN LICENCA.md",
7
+ "author": "Sharadox <contact@sharadox.com>",
8
+ "type": "module",
9
+ "exports": {
10
+ "./*/type": {
11
+ "sharadox-source": "./source/*/type.ts",
12
+ "types": "./distribution/*/type.d.ts"
13
+ },
14
+ "./*": {
15
+ "sharadox-source": [
16
+ "./source/*/index.ts",
17
+ "./source/*/index.tsx"
18
+ ],
19
+ "types": "./distribution/*/index.d.ts",
20
+ "default": "./distribution/*/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "distribution",
25
+ "LICENCA.md",
26
+ "LICENSE.md",
27
+ "NOTICE.md",
28
+ "llms.txt"
29
+ ],
30
+ "sideEffects": false,
31
+ "engines": {
32
+ "node": ">=24"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "lint-staged": {
38
+ "*.{ts,tsx,js,mjs,cjs}": [
39
+ "prettier --write",
40
+ "eslint --fix --max-warnings=0"
41
+ ],
42
+ "*.{json,md,yml,yaml,scss}": "prettier --write"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/Sharadox/test-web-library.git"
47
+ },
48
+ "homepage": "https://github.com/Sharadox/test-web-library#readme",
49
+ "devDependencies": {
50
+ "@playwright/test": "1.65.0",
51
+ "@sharadox/es-lint-configuration-web-library": "^0.1.1",
52
+ "@sharadox/prettier-configuration-web-library": "^0.1.0",
53
+ "@sharadox/turborepo-configuration-web-library": "^0.1.0",
54
+ "@sharadox/type-script-configuration-web-library": "^0.2.0",
55
+ "@sharadox/vitest-configuration-web-library": "^0.1.2",
56
+ "@types/node": "^24.19.2",
57
+ "@vitest/coverage-v8": "^5.1.0",
58
+ "eslint": "9.39.5",
59
+ "husky": "^9.1.7",
60
+ "lint-staged": "^17.6.0",
61
+ "prettier": "^3.10.0",
62
+ "turbo": "^2.11.10",
63
+ "typedoc": "^0.28.20",
64
+ "typescript": "6.0.3",
65
+ "vitest": "^5.1.0"
66
+ },
67
+ "dependencies": {
68
+ "@sharadox/web-library": "^0.5.0"
69
+ },
70
+ "peerDependencies": {
71
+ "@playwright/test": ">=1.50"
72
+ },
73
+ "scripts": {
74
+ "build": "rm -rf distribution && tsc -p tsconfig.build.json",
75
+ "lint": "eslint --max-warnings=0 .",
76
+ "format": "prettier --write .",
77
+ "format:check": "prettier --check .",
78
+ "type-check": "tsc --noEmit",
79
+ "test:unit": "vitest run --coverage",
80
+ "documentation": "typedoc",
81
+ "verify": "turbo run format:check lint type-check test:unit build",
82
+ "test:benchmark": "vitest bench --run --passWithNoTests"
83
+ }
6
84
  }