-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add configuration for Playwright tests (#161)
- Loading branch information
Showing
17 changed files
with
413 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# shellcheck shell=bash | ||
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then | ||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w=" | ||
fi | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
{ | ||
"$schema": "https://turbo.build/schema.json", | ||
"extends": ["//"], | ||
"extends": [ | ||
"//" | ||
], | ||
"tasks": { | ||
"build": { | ||
"inputs": ["*", "src/**", "public/**", "../packages/*/package.json"] | ||
"inputs": [ | ||
"*", | ||
"src/**", | ||
"public/**", | ||
"../packages/*/package.json" | ||
], | ||
"outputs": [ | ||
".vercel", | ||
".astro" | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
description = "A collection of oxygen-free tools for astronauts."; | ||
inputs = { | ||
nixpkgs.url = "github:Fryuni/nixpkgs/master"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { | ||
nixpkgs, | ||
flake-utils, | ||
... | ||
}: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: let | ||
throwSystem = throw "Unsupported system: ${system}"; | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
|
||
browsersInfo = builtins.fromJSON (builtins.readFile "${pkgs.playwright-driver}/browsers.json"); | ||
in { | ||
devShells.default = pkgs.mkShell { | ||
packages = [ | ||
pkgs.nodejs_20 | ||
pkgs.corepack_20 | ||
pkgs.playwright | ||
]; | ||
|
||
PLAYWRIGHT_NODEJS_PATH = "${pkgs.nodejs_20}/bin/node"; | ||
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true; | ||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1; | ||
PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}"; | ||
|
||
PLAYWRIGHT_CHROME_BIN = let | ||
chromeInfo = pkgs.lib.lists.findFirst (b: b.name == "chromium") (throw "value not found") browsersInfo.browsers; | ||
chromePath = | ||
{ | ||
x86_64-linux = "chrome-linux/chrome"; | ||
aarch64-linux = "chrome-linux/chrome"; | ||
x86_64-darwin = "chrome-mac/Chromium.app/Contents/MacOS/Chromium"; | ||
arm64-darwin = "chrome-mac/Chromium.app/Contents/MacOS/Chromium"; | ||
} | ||
.${system} | ||
or throwSystem; | ||
in "${pkgs.playwright-driver.browsers}/chromium-${chromeInfo.revision}/${chromePath}"; | ||
|
||
PLAYWRIGHT_FIREFOX_BIN = let | ||
firefoxInfo = pkgs.lib.lists.findFirst (b: b.name == "firefox") (throw "value not found") browsersInfo.browsers; | ||
firefoxPath = | ||
{ | ||
x86_64-linux = "firefox-linux/firefox"; | ||
aarch64-linux = "firefox-linux/firefox"; | ||
x86_64-darwin = "firefox/Nightly.app/Contents/MacOS/firefox"; | ||
arm64-darwin = "firefox/Nightly.app/Contents/MacOS/firefox"; | ||
} | ||
.${system} | ||
or throwSystem; | ||
in "${pkgs.playwright-driver.browsers}/firefox-${firefoxInfo.revision}/${firefoxPath}"; | ||
}; | ||
|
||
formatter = pkgs.alejandra; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { setTimeout } from 'node:timers/promises'; | ||
import { loadFixture, type PreviewServer } from '@inox-tools/astro-tests/astroFixture'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const fixture = await loadFixture({ | ||
root: './fixture/basic', | ||
}); | ||
|
||
let server: PreviewServer; | ||
|
||
test.beforeAll(async () => { | ||
await fixture.build({}); | ||
server = await fixture.preview({}); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await server?.stop(); | ||
await server?.closed(); | ||
}); | ||
|
||
test('share state ', async ({ page }) => { | ||
const pageUrl = fixture.resolveUrl('/?name=John+Doe'); | ||
|
||
await page.goto(pageUrl); | ||
|
||
await setTimeout(15000); | ||
|
||
await expect(page.locator('span#name')).toHaveText('John Doe'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import node from '@astrojs/node'; | ||
import requestState from '@inox-tools/request-state'; | ||
|
||
export default defineConfig({ | ||
output: 'server', | ||
adapter: node({ mode: 'standalone' }), | ||
integrations: [requestState()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@request-state/basic", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"@astrojs/node": "catalog:", | ||
"@inox-tools/request-state": "workspace:", | ||
"astro": "catalog:" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/request-state/e2e/fixture/basic/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
import { setState } from '@it-astro:state'; | ||
const name = Astro.url.searchParams.get('name'); | ||
setState('name', name ?? 'World'); | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>Basic example</title> | ||
</head> | ||
<body> | ||
<h1>Hello, <span id="name"></span>!</h1> | ||
</body> | ||
<script> | ||
import { getState } from '@it-astro:state'; | ||
|
||
document.getElementById('name')!.textContent = getState('name') as string; | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig", | ||
"extends": "../../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"lib": [ | ||
"dom" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.