Skip to content

Commit ff4ffe0

Browse files
committed
feature: covered all playground features with functional tests
1 parent 6e61647 commit ff4ffe0

File tree

16 files changed

+624
-13
lines changed

16 files changed

+624
-13
lines changed

web/landing/assets/bootstrap.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { startStimulusApp } from '@symfony/stimulus-bundle';
22

3-
addEventListener("DOMContentLoaded", (event) => {
3+
function initializeStimulus() {
44
const app = startStimulusApp()
55

6+
window.Stimulus = app;
7+
68
let env = window.document.body.dataset.environment;
79

810
if (window.location.search.includes('__env=')) {
@@ -12,4 +14,10 @@ addEventListener("DOMContentLoaded", (event) => {
1214
if (env === 'prod') {
1315
app.debug = false;
1416
}
15-
})
17+
}
18+
19+
if (document.readyState === 'loading') {
20+
document.addEventListener("DOMContentLoaded", initializeStimulus);
21+
} else {
22+
initializeStimulus();
23+
}

web/landing/assets/codemirror/completions/dataframe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,10 @@ const dataframeMethods = [
571571
const div = document.createElement("div")
572572
div.innerHTML = `
573573
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
574-
<span class=\"fn-name\">mode</span><span class=\"fn-operator\">(</span><span class=\"fn-type\">SaveMode</span> <span class=\"fn-param\">$mode</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">self</span>
574+
<span class=\"fn-name\">mode</span><span class=\"fn-operator\">(</span><span class=\"fn-type\">SaveMode|ExecutionMode</span> <span class=\"fn-param\">$mode</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">self</span>
575575
</div>
576576
<div style="color: #8b949e; font-size: 13px;">
577-
SaveMode defines how Flow should behave when writing to a file/files that already exists.<br>For more details please see SaveMode enum.<br>@param SaveMode $mode<br>@lazy<br>@return $this
577+
This method is used to set the behavior of the DataFrame.<br>Available modes:<br>- SaveMode defines how Flow should behave when writing to a file/files that already exists.<br>- ExecutionMode - defines how functions should behave when they encounter unexpected data (e.g., type mismatches, missing values).<br>@lazy<br>@return $this
578578
</div>
579579
`
580580
return div

web/landing/assets/codemirror/completions/dsl.js

Lines changed: 164 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* CodeMirror Completer for Flow PHP DSL Functions
33
*
4-
* Total functions: 341
4+
* Total functions: 350
55
*
66
* This completer provides autocompletion for all Flow PHP DSL functions:
77
* - Extractors (flow-extractors)
@@ -86,6 +86,9 @@ const dslFunctions = [
8686
div.innerHTML = `
8787
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
8888
<span class=\"fn-name\">append</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
89+
</div>
90+
<div style="color: #8b949e; font-size: 13px;">
91+
Alias for save_mode_append().
8992
</div>
9093
`
9194
return div
@@ -1610,6 +1613,9 @@ const dslFunctions = [
16101613
div.innerHTML = `
16111614
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
16121615
<span class=\"fn-name\">exception_if_exists</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
1616+
</div>
1617+
<div style="color: #8b949e; font-size: 13px;">
1618+
Alias for save_mode_exception_if_exists().
16131619
</div>
16141620
`
16151621
return div
@@ -1631,6 +1637,42 @@ const dslFunctions = [
16311637
},
16321638
apply: snippet("\\Flow\\ETL\\DSL\\execution_context(" + "$" + "{" + "1:config" + "}" + ")"),
16331639
boost: 10
1640+
}, {
1641+
label: "execution_lenient",
1642+
type: "function",
1643+
detail: "flow\u002Ddsl\u002Ddata\u002Dframe",
1644+
info: () => {
1645+
const div = document.createElement("div")
1646+
div.innerHTML = `
1647+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
1648+
<span class=\"fn-name\">execution_lenient</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">ExecutionMode</span>
1649+
</div>
1650+
<div style="color: #8b949e; font-size: 13px;">
1651+
In this mode, functions returns nulls instead of throwing exceptions.
1652+
</div>
1653+
`
1654+
return div
1655+
},
1656+
apply: snippet("\\Flow\\ETL\\DSL\\execution_lenient()"),
1657+
boost: 10
1658+
}, {
1659+
label: "execution_strict",
1660+
type: "function",
1661+
detail: "flow\u002Ddsl\u002Ddata\u002Dframe",
1662+
info: () => {
1663+
const div = document.createElement("div")
1664+
div.innerHTML = `
1665+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
1666+
<span class=\"fn-name\">execution_strict</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">ExecutionMode</span>
1667+
</div>
1668+
<div style="color: #8b949e; font-size: 13px;">
1669+
In this mode, functions throws exceptions if the given entry is not found<br>or passed parameters are invalid.
1670+
</div>
1671+
`
1672+
return div
1673+
},
1674+
apply: snippet("\\Flow\\ETL\\DSL\\execution_strict()"),
1675+
boost: 10
16341676
}, {
16351677
label: "exists",
16361678
type: "function",
@@ -2372,6 +2414,42 @@ const dslFunctions = [
23722414
},
23732415
apply: snippet("\\Flow\\ETL\\Adapter\\Elasticsearch\\hash_id_factory(" + "$" + "{" + "1:entry_names" + "}" + ")"),
23742416
boost: 10
2417+
}, {
2418+
label: "html_element_entry",
2419+
type: "function",
2420+
detail: "flow\u002Ddsl\u002Dentries",
2421+
info: () => {
2422+
const div = document.createElement("div")
2423+
div.innerHTML = `
2424+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
2425+
<span class=\"fn-name\">html_element_entry</span><span class=\"fn-operator\">(</span><span class=\"fn-type\">string</span> <span class=\"fn-param\">$name</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">Dom\\HTMLElement|string|null</span> <span class=\"fn-param\">$value</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">Metadata</span> <span class=\"fn-param\">$metadata</span> <span class=\"fn-operator\">=</span> <span class=\"fn-default\">null</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">Entry</span>
2426+
</div>
2427+
<div style="color: #8b949e; font-size: 13px;">
2428+
@return Entry<?HTMLElement>
2429+
</div>
2430+
`
2431+
return div
2432+
},
2433+
apply: snippet("\\Flow\\ETL\\DSL\\html_element_entry(" + "$" + "{" + "1:name" + "}" + ", " + "$" + "{" + "2:value" + "}" + ", " + "$" + "{" + "3:metadata" + "}" + ")"),
2434+
boost: 10
2435+
}, {
2436+
label: "html_element_schema",
2437+
type: "function",
2438+
detail: "flow\u002Ddsl\u002Dschema",
2439+
info: () => {
2440+
const div = document.createElement("div")
2441+
div.innerHTML = `
2442+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
2443+
<span class=\"fn-name\">html_element_schema</span><span class=\"fn-operator\">(</span><span class=\"fn-type\">string</span> <span class=\"fn-param\">$name</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">bool</span> <span class=\"fn-param\">$nullable</span> <span class=\"fn-operator\">=</span> <span class=\"fn-default\">false</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">Metadata</span> <span class=\"fn-param\">$metadata</span> <span class=\"fn-operator\">=</span> <span class=\"fn-default\">null</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">Definition</span>
2444+
</div>
2445+
<div style="color: #8b949e; font-size: 13px;">
2446+
@return Definition<HTMLElement>
2447+
</div>
2448+
`
2449+
return div
2450+
},
2451+
apply: snippet("\\Flow\\ETL\\DSL\\html_element_schema(" + "$" + "{" + "1:name" + "}" + ", " + "$" + "{" + "2:nullable" + "}" + ", " + "$" + "{" + "3:metadata" + "}" + ")"),
2452+
boost: 10
23752453
}, {
23762454
label: "html_entry",
23772455
type: "function",
@@ -2380,7 +2458,7 @@ const dslFunctions = [
23802458
const div = document.createElement("div")
23812459
div.innerHTML = `
23822460
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
2383-
<span class=\"fn-name\">html_entry</span><span class=\"fn-operator\">(</span><span class=\"fn-type\">string</span> <span class=\"fn-param\">$name</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">HTMLDocument|string|null</span> <span class=\"fn-param\">$value</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">Metadata</span> <span class=\"fn-param\">$metadata</span> <span class=\"fn-operator\">=</span> <span class=\"fn-default\">null</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">Entry</span>
2461+
<span class=\"fn-name\">html_entry</span><span class=\"fn-operator\">(</span><span class=\"fn-type\">string</span> <span class=\"fn-param\">$name</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">Dom\\HTMLDocument|string|null</span> <span class=\"fn-param\">$value</span><span class=\"fn-operator\">,</span> <span class=\"fn-type\">Metadata</span> <span class=\"fn-param\">$metadata</span> <span class=\"fn-operator\">=</span> <span class=\"fn-default\">null</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">Entry</span>
23842462
</div>
23852463
<div style="color: #8b949e; font-size: 13px;">
23862464
@return Entry<?HTMLDocument>
@@ -2432,6 +2510,9 @@ const dslFunctions = [
24322510
div.innerHTML = `
24332511
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
24342512
<span class=\"fn-name\">ignore</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
2513+
</div>
2514+
<div style="color: #8b949e; font-size: 13px;">
2515+
Alias for save_mode_ignore().
24352516
</div>
24362517
`
24372518
return div
@@ -3062,6 +3143,9 @@ const dslFunctions = [
30623143
div.innerHTML = `
30633144
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
30643145
<span class=\"fn-name\">overwrite</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
3146+
</div>
3147+
<div style="color: #8b949e; font-size: 13px;">
3148+
Alias for save_mode_overwrite().
30653149
</div>
30663150
`
30673151
return div
@@ -3611,6 +3695,66 @@ const dslFunctions = [
36113695
},
36123696
apply: snippet("\\Flow\\ETL\\DSL\\sanitize(" + "$" + "{" + "1:value" + "}" + ", " + "$" + "{" + "2:placeholder" + "}" + ", " + "$" + "{" + "3:skipCharacters" + "}" + ")"),
36133697
boost: 10
3698+
}, {
3699+
label: "save_mode_append",
3700+
type: "function",
3701+
detail: "flow\u002Ddsl\u002Ddata\u002Dframe",
3702+
info: () => {
3703+
const div = document.createElement("div")
3704+
div.innerHTML = `
3705+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
3706+
<span class=\"fn-name\">save_mode_append</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
3707+
</div>
3708+
`
3709+
return div
3710+
},
3711+
apply: snippet("\\Flow\\ETL\\DSL\\save_mode_append()"),
3712+
boost: 10
3713+
}, {
3714+
label: "save_mode_exception_if_exists",
3715+
type: "function",
3716+
detail: "flow\u002Ddsl\u002Ddata\u002Dframe",
3717+
info: () => {
3718+
const div = document.createElement("div")
3719+
div.innerHTML = `
3720+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
3721+
<span class=\"fn-name\">save_mode_exception_if_exists</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
3722+
</div>
3723+
`
3724+
return div
3725+
},
3726+
apply: snippet("\\Flow\\ETL\\DSL\\save_mode_exception_if_exists()"),
3727+
boost: 10
3728+
}, {
3729+
label: "save_mode_ignore",
3730+
type: "function",
3731+
detail: "flow\u002Ddsl\u002Ddata\u002Dframe",
3732+
info: () => {
3733+
const div = document.createElement("div")
3734+
div.innerHTML = `
3735+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
3736+
<span class=\"fn-name\">save_mode_ignore</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
3737+
</div>
3738+
`
3739+
return div
3740+
},
3741+
apply: snippet("\\Flow\\ETL\\DSL\\save_mode_ignore()"),
3742+
boost: 10
3743+
}, {
3744+
label: "save_mode_overwrite",
3745+
type: "function",
3746+
detail: "flow\u002Ddsl\u002Ddata\u002Dframe",
3747+
info: () => {
3748+
const div = document.createElement("div")
3749+
div.innerHTML = `
3750+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
3751+
<span class=\"fn-name\">save_mode_overwrite</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">SaveMode</span>
3752+
</div>
3753+
`
3754+
return div
3755+
},
3756+
apply: snippet("\\Flow\\ETL\\DSL\\save_mode_overwrite()"),
3757+
boost: 10
36143758
}, {
36153759
label: "schema",
36163760
type: "function",
@@ -4952,6 +5096,24 @@ const dslFunctions = [
49525096
},
49535097
apply: snippet("\\Flow\\Types\\DSL\\type_html()"),
49545098
boost: 10
5099+
}, {
5100+
label: "type_html_element",
5101+
type: "function",
5102+
detail: "flow\u002Ddsl\u002Dtype",
5103+
info: () => {
5104+
const div = document.createElement("div")
5105+
div.innerHTML = `
5106+
<div style="font-family: 'Fira Code', 'JetBrains Mono', monospace; margin-bottom: 8px;">
5107+
<span class=\"fn-name\">type_html_element</span><span class=\"fn-operator\">(</span><span class=\"fn-operator\">)</span> <span class=\"fn-operator\">:</span> <span class=\"fn-return\">Type</span>
5108+
</div>
5109+
<div style="color: #8b949e; font-size: 13px;">
5110+
@return Type<HTMLElement>
5111+
</div>
5112+
`
5113+
return div
5114+
},
5115+
apply: snippet("\\Flow\\Types\\DSL\\type_html_element()"),
5116+
boost: 10
49555117
}, {
49565118
label: "type_instance_of",
49575119
type: "function",

web/landing/composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@
7777
"test": [
7878
"tools/phpunit/vendor/bin/phpunit"
7979
],
80-
"test:e2e": [
81-
"tools/phpunit/vendor/bin/phpunit --testsuite=e2e"
82-
],
8380
"assets:clear": "rm -rf public/assets",
8481
"importmap:install": "bin/console importmap:install",
8582
"build:assets": [

web/landing/phpunit.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
xsi:noNamespaceSchemaLocation="tools/phpunit/vendor/phpunit/phpunit/phpunit.xsd"
55
bootstrap="tests/autoload.php"
66
colors="true"
7+
cacheDirectory="./var/phpunit/"
78
cacheResultFile="./var/phpunit/phpunit.cache"
89
displayDetailsOnTestsThatTriggerWarnings="true"
910
displayDetailsOnTestsThatTriggerErrors="true"
1011
executionOrder="random"
1112
>
1213
<php>
1314
<env name="APP_ENV" value="test"/>
15+
<server name="PANTHER_WEB_SERVER_ROUTER" value="../tests/router.php"/>
1416
</php>
1517
<testsuites>
1618
<testsuite name="integration">
@@ -19,9 +21,6 @@
1921
<testsuite name="functional">
2022
<directory>tests/Flow/Website/Tests/Functional</directory>
2123
</testsuite>
22-
<testsuite name="e2e">
23-
<directory>tests/Flow/Website/Tests/E2E</directory>
24-
</testsuite>
2524
</testsuites>
2625
<source>
2726
<include>

web/landing/tests/Flow/Website/Tests/E2E/.gitkeep

Whitespace-only changes.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Flow\Website\Tests\Functional;
6+
7+
use Flow\Website\Kernel;
8+
use Symfony\Component\Panther\{Client, PantherTestCase};
9+
10+
abstract class EndToEndTestCase extends PantherTestCase
11+
{
12+
private array $tempFiles = [];
13+
14+
protected function tearDown() : void
15+
{
16+
foreach ($this->tempFiles as $file) {
17+
@\unlink($file);
18+
}
19+
20+
parent::tearDown();
21+
}
22+
23+
protected function clearLocalStorage(Client $client) : void
24+
{
25+
$client->executeScript('window.Stimulus.getControllerForElementAndIdentifier(document.getElementById("playground"), "playground-storage").clearStorage();');
26+
}
27+
28+
protected function createTempFile(string $filename, string $content) : string
29+
{
30+
$path = \sys_get_temp_dir() . '/' . $filename;
31+
\file_put_contents($path, $content);
32+
$this->tempFiles[] = $path;
33+
34+
return $path;
35+
}
36+
37+
protected function dismissAlert(Client $client) : void
38+
{
39+
try {
40+
$client->switchTo()->alert()->accept();
41+
} catch (\Exception) {
42+
}
43+
}
44+
45+
protected function getFromLocalStorage(Client $client, string $key) : ?string
46+
{
47+
return $client->executeScript(\sprintf('return localStorage.getItem(%s);', \json_encode($key)));
48+
}
49+
50+
protected function getPlaygroundCode(Client $client) : string
51+
{
52+
return $client->executeScript(
53+
'const textarea = document.getElementById("code-editor");
54+
const controller = window.Stimulus.getControllerForElementAndIdentifier(textarea, "code-mirror-editor");
55+
return controller.getCode();'
56+
);
57+
}
58+
59+
protected function saveToLocalStorage(Client $client) : void
60+
{
61+
$client->executeScript('window.Stimulus.getControllerForElementAndIdentifier(document.getElementById("playground"), "playground-storage").saveCode();');
62+
}
63+
64+
protected function setPlaygroundCode(Client $client, string $code) : void
65+
{
66+
$client->executeScript(\sprintf(
67+
'const textarea = document.getElementById("code-editor");
68+
const controller = window.Stimulus.getControllerForElementAndIdentifier(textarea, "code-mirror-editor");
69+
controller.setValue(%s);',
70+
\json_encode($code)
71+
));
72+
}
73+
74+
protected static function createE2EClient(array $options = []) : Client
75+
{
76+
return static::createPantherClient(\array_merge([
77+
'env' => ['APP_ENV' => 'test'],
78+
], $options));
79+
}
80+
81+
protected static function getKernelClass() : string
82+
{
83+
return Kernel::class;
84+
}
85+
}

0 commit comments

Comments
 (0)