Skip to content

Commit

Permalink
Cypress (#1382)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* wip

* fixing number test

* wip

* wip

* wip

* wip

* wip

* wip

* fix pgsql env

* actions github

* fix phpstan
  • Loading branch information
luanfreitasdev authored Feb 4, 2024
1 parent 059a82b commit 42eefab
Show file tree
Hide file tree
Showing 13 changed files with 333 additions and 427 deletions.
57 changes: 34 additions & 23 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
name: Cypress

on:
workflow_dispatch:
push:
branches:
- "**"
paths-ignore:
- "art/**"
- "README.md"
pull_request:
types: [ready_for_review, synchronize, opened]
paths-ignore:
- "art/**"
- "README.md"

jobs:
build:
Expand All @@ -17,6 +27,16 @@ jobs:
- 3307:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

postgres:
image: postgres:9.6
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: powergridtest
ports:
- 5433:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

strategy:
matrix:
php: [ 8.2 ]
Expand All @@ -43,32 +63,23 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: $(composer config cache-files-dir)
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Install Composer dependencies
- name: Build App
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer install
npm install
git clone https://github.com/Power-Components/powergrid-cypress-base.git tests/cypress/app
chmod +x ./tests/cypress/mysql.sh
chmod +x ./tests/cypress/pgsql.sh
- name: Install openspout/openspout 4.20
if: matrix.php == '8.2'
run: composer require openspout/openspout 4.20
- name: MySQL
run: |
./tests/cypress/mysql.sh
cd ./tests/cypress/app && php artisan serve & sleep 5 &
cd ./tests/cypress && npx cypress run
shell: bash

- name: Cypress
- name: PostGreSQL
run: |
npm install
git clone https://github.com/Power-Components/powergrid-demo-misc.git tests/cypress/app
cd tests/cypress &&
cp stubs/CypressTable.php app/app/Livewire/CypressTable.php &&
cp stubs/rules-controllers.blade.php app/resources/views/components/header/rules-controllers.blade.php
cp stubs/filters-controllers.blade.php app/resources/views/components/header/filters-controllers.blade.php
cd ./../../
chmod +x ./tests/cypress/run.sh
./tests/cypress/run.sh
./tests/cypress/pgsql.sh
cd ./tests/cypress/app && php artisan serve & sleep 5 &
cd ./tests/cypress && npx cypress run
shell: bash
194 changes: 100 additions & 94 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,100 +1,106 @@
{
"name": "power-components/livewire-powergrid",
"description": "PowerGrid generates Advanced Datatables using Laravel Livewire.",
"homepage": "https://github.com/power-components/livewire-powergrid",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Luan Freitas",
"email": "[email protected]",
"role": "Developer"
},
{
"name": "DanSysAnalyst",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": "^8.1",
"livewire/livewire": "^3.4.3",
"laravel/prompts": "^0.1.15"
},
"require-dev": {
"composer/composer": "^2.6.6",
"laravel/pint": "^1.13.10",
"laradumps/laradumps-core": "^1.1",
"larastan/larastan": "^2.8.1",
"pestphp/pest": "2.28.0",
"orchestra/testbench": "8.19|^9.0"
},
"suggest": {
"openspout/openspout": "Required to export XLS and CSV"
},
"conflict": {
"laravel/framework": "10.40.0"
"name": "power-components/livewire-powergrid",
"description": "PowerGrid generates Advanced Datatables using Laravel Livewire.",
"homepage": "https://github.com/power-components/livewire-powergrid",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Luan Freitas",
"email": "[email protected]",
"role": "Developer"
},
"autoload": {
"psr-4": {
"PowerComponents\\LivewirePowerGrid\\": "src"
},
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"PowerComponents\\LivewirePowerGrid\\Tests\\" : "tests"
},
"files": [
"tests/Plugins/Autoload.php"
]
},
"extra": {
"laravel": {
"providers": [
"PowerComponents\\LivewirePowerGrid\\Providers\\PowerGridServiceProvider"
]
}
{
"name": "DanSysAnalyst",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": "^8.1",
"livewire/livewire": "^3.4.3",
"laravel/prompts": "^0.1.15"
},
"require-dev": {
"composer/composer": "^2.6.6",
"laravel/pint": "^1.13.10",
"laradumps/laradumps-core": "^1.1",
"larastan/larastan": "^2.8.1",
"pestphp/pest": "2.28.0",
"orchestra/testbench": "8.19|^9.0"
},
"suggest": {
"openspout/openspout": "Required to export XLS and CSV"
},
"conflict": {
"laravel/framework": "10.40.0"
},
"autoload": {
"psr-4": {
"PowerComponents\\LivewirePowerGrid\\": "src"
},
"scripts": {
"pint:fix": "./vendor/bin/pint",
"test": "@test:sqlite",
"test:pint": "./vendor/bin/pint --test",
"test:sqlite": [
"./vendor/bin/pest --compact"
],
"test:mysql": [
"./vendor/bin/pest --compact --configuration phpunit.mysql.xml"
],
"test:pgsql": [
"./vendor/bin/pest --compact --configuration phpunit.pgsql.xml"
],
"test:sqlsrv": [
"./vendor/bin/pest --configuration phpunit.sqlsrv.xml"
],
"test:types": "./vendor/bin/phpstan analyse --ansi --memory-limit=-1",
"test:dbs": [
"@test:sqlite",
"@test:mysql",
"@test:pgsql"
],
"ds:check": [
"@php vendor/bin/laradumps check --dir=src,resources,tests --text=dump,dd --ignore=dumpTo,Dump stop-on-failure"
],
"verify": [
"@ds:check",
"@test:pint",
"@test:types",
"@test"
]
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"PowerComponents\\LivewirePowerGrid\\Tests\\": "tests"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"pestphp/pest-plugin": true
}
"files": [
"tests/Plugins/Autoload.php"
]
},
"extra": {
"laravel": {
"providers": [
"PowerComponents\\LivewirePowerGrid\\Providers\\PowerGridServiceProvider"
]
}
},
"scripts": {
"pint:fix": "./vendor/bin/pint",
"test": "@test:sqlite",
"test:pint": "./vendor/bin/pint --test",
"test:sqlite": [
"./vendor/bin/pest --compact"
],
"test:mysql": [
"./vendor/bin/pest --compact --configuration phpunit.mysql.xml"
],
"test:pgsql": [
"./vendor/bin/pest --compact --configuration phpunit.pgsql.xml"
],
"test:sqlsrv": [
"./vendor/bin/pest --configuration phpunit.sqlsrv.xml"
],
"test:types": "./vendor/bin/phpstan analyse --ansi --memory-limit=-1",
"test:dbs": [
"@test:sqlite",
"@test:mysql",
"@test:pgsql"
],
"ds:check": [
"@php vendor/bin/laradumps check --dir=src,resources,tests --text=dump,dd --ignore=dumpTo,Dump stop-on-failure"
],
"verify": [
"@ds:check",
"@test:pint",
"@test:types",
"@test"
]
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"pestphp/pest-plugin": true
}
},
"repositories": [
{
"type": "path",
"url": "../../../"
}
]
}
25 changes: 9 additions & 16 deletions src/PowerGridComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@ private function throwColumnAction(): void
}
}

private function getTheme(string $key = null): array
private function getTheme(): array
{
$store = store($this)->get('powerGridTheme');
$class = $this->template() ?? powerGridTheme();

if (!$key) {
return convertObjectsToArray((array) $store);
}
return Cache::rememberForever('powerGridTheme_' . $class, function () use ($class) {
/** @var ThemeBase $themeBase */
$themeBase = PowerGrid::theme($class);

return convertObjectsToArray((array) data_get($store, $key));
return convertObjectsToArray((array) $themeBase->apply());
});
}

/**
Expand All @@ -226,10 +227,9 @@ public function fillData(): BaseCollection|LengthAwarePaginator|\Illuminate\Cont

private function renderView(mixed $data): Application|Factory|View
{
/** @phpstan-var view-string $view */
$view = $this->getTheme('layout')['table'];
$theme = $this->getTheme();

return view($view, [
return view($theme['layout']['table'], [
'data' => $data,
'theme' => $this->getTheme(),
'table' => 'livewire-powergrid::components.table',
Expand All @@ -251,13 +251,6 @@ public function getPublicPropertiesDefinedInComponent(): array
*/
public function render(): Application|Factory|View
{
/** @var ThemeBase $themeBase */
$themeBase = PowerGrid::theme($this->template() ?? powerGridTheme());

if (!store($this)->has('powerGridTheme')) {
store($this)->set('powerGridTheme', $themeBase->apply());
}

$this->columns = collect($this->columns)->map(function ($column) {
return (object) $column;
})->toArray();
Expand Down
Loading

0 comments on commit 42eefab

Please sign in to comment.