diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 7142070b..64991b28 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,7 +31,7 @@ jobs: "cypress/e2e/jobs/verified/success-path-single.cy.js", "cypress/e2e/jobs/instant/success-path-single.cy.js", ] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - name: Set the value diff --git a/Makefile b/Makefile index 18efd2ae..aee2cede 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ unit: codecept-build test: functional integration unit prepare-container: - PHP_VERSION=8.0 docker compose up -d + docker compose up -d docker compose exec -T -u root cli-app sh -c "chown -R www-data:www-data /craft-lilt-plugin" docker compose exec -T -u root cli-app sh -c "apk --no-cache add bash make git" docker compose exec -T -u www-data cli-app sh -c "cp tests/.env.test tests/.env" diff --git a/e2e/Makefile b/e2e/Makefile index 8ad18eb2..8d69de2e 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -16,8 +16,8 @@ composer-install: composer require --ignore-platform-reqs "lilt/craft-lilt-plugin":"^999.9.9" reset: cp composer-install - docker-compose exec -T app sh -c 'php craft db/restore happylager.sql' - docker-compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin' + docker compose exec -T app sh -c 'php craft db/restore happylager.sql' + docker compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin' install: clone @@ -28,23 +28,23 @@ install: clone composer require craftcms/cms:3.7.68 -W backup-db: - docker-compose exec -T app sh -c 'php craft db/backup' + docker compose exec -T app sh -c 'php craft db/backup' refresh: - docker-compose exec -T app sh -c 'rm -rf /app/vendor/lilt/craft-lilt-plugin' - docker-compose exec -T app sh -c 'composer require --ignore-platform-reqs "lilt/craft-lilt-plugin":"^999.9.9"' + docker compose exec -T app sh -c 'rm -rf /app/vendor/lilt/craft-lilt-plugin' + docker compose exec -T app sh -c 'composer require --ignore-platform-reqs "lilt/craft-lilt-plugin":"^999.9.9"' build: docker build -f happy-lager-main/Dockerfile happy-lager-main -t happy-lager down: - docker-compose down --remove-orphans -v + docker compose down --remove-orphans -v mup: #migrate app up - docker-compose exec -T app sh -c 'php craft migrate/up' + docker compose exec -T app sh -c 'php craft migrate/up' mdown: #migrate app down - docker-compose exec -T app sh -c 'php craft migrate/down' + docker compose exec -T app sh -c 'php craft migrate/down' cp: rm -rf happy-lager-main/plugin-src @@ -84,32 +84,32 @@ wait-service: @echo "Service is up and running or max retries reached!" up: clone down composer-install - docker-compose up --build -d - docker-compose ps - docker-compose exec -T app sh -c 'chmod -R 777 /app' - docker-compose exec -T app sh -c 'chown -R www-data:www-data /app' - docker-compose exec -T mysql sh -c 'while ! mysqladmin ping -h"mysql" --silent; do sleep 1; done' - docker-compose exec -T app sh -c 'php craft setup/security-key' - docker-compose exec -T app sh -c 'echo DB_DRIVER=mysql >> .env' - docker-compose exec -T app sh -c 'echo DB_SERVER=mysql >> .env' - docker-compose exec -T app sh -c 'echo DB_DATABASE=${DB_DATABASE} >> .env' - docker-compose exec -T app sh -c 'echo DB_USER=craft-lilt >> .env' - docker-compose exec -T app sh -c 'echo DB_PASSWORD=craft-lilt >> .env' - docker-compose exec -T app sh -c 'echo DB_SCHEMA=public >> .env' - docker-compose exec -T app sh -c 'echo DB_TABLE_PREFIX= >> .env' - docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=1 >> .env' - docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_MANAGER_WAIT_TIME_IN_SECONDS=86400 >> .env' - docker-compose exec -T app sh -c 'php craft db/restore happylager.sql' - docker-compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin' - docker-compose exec -T app sh -c 'php craft plugin/install neo' - docker-compose exec -T app sh -c 'php craft plugin/install super-table' - docker-compose exec -T app sh -c 'php craft project-config/rebuild' - docker-compose exec -T app sh -c 'php craft up' - docker-compose exec -T app sh -c 'php craft migrate/up' - docker-compose exec -T app sh -c 'nohup ./queue_listen.sh > queue.log 2>&1 &' - docker-compose exec -T app sh -c 'cat .env' + docker compose up --build -d + docker compose ps + docker compose exec -T app sh -c 'chmod -R 777 /app' + docker compose exec -T app sh -c 'chown -R www-data:www-data /app' + docker compose exec -T mysql sh -c 'while ! mysqladmin ping -h"mysql" --silent; do sleep 1; done' + docker compose exec -T app sh -c 'php craft setup/security-key' + docker compose exec -T app sh -c 'echo DB_DRIVER=mysql >> .env' + docker compose exec -T app sh -c 'echo DB_SERVER=mysql >> .env' + docker compose exec -T app sh -c 'echo DB_DATABASE=${DB_DATABASE} >> .env' + docker compose exec -T app sh -c 'echo DB_USER=craft-lilt >> .env' + docker compose exec -T app sh -c 'echo DB_PASSWORD=craft-lilt >> .env' + docker compose exec -T app sh -c 'echo DB_SCHEMA=public >> .env' + docker compose exec -T app sh -c 'echo DB_TABLE_PREFIX= >> .env' + docker compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=1 >> .env' + docker compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_MANAGER_WAIT_TIME_IN_SECONDS=86400 >> .env' + docker compose exec -T app sh -c 'php craft db/restore happylager.sql' + docker compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin' + docker compose exec -T app sh -c 'php craft plugin/install neo' + docker compose exec -T app sh -c 'php craft plugin/install super-table' + docker compose exec -T app sh -c 'php craft project-config/rebuild' + docker compose exec -T app sh -c 'php craft up' + docker compose exec -T app sh -c 'php craft migrate/up' + docker compose exec -T app sh -c 'nohup ./queue_listen.sh > queue.log 2>&1 &' + docker compose exec -T app sh -c 'cat .env' cli: - docker-compose exec app sh + docker compose exec app sh test: docker run -u root -t -v ${PWD}:/e2e -w /e2e --env CYPRESS_CACHE_FOLDER=${CYPRESS_CACHE_FOLDER} node:18.12.1 npm install diff --git a/src/elements/Translation.php b/src/elements/Translation.php index 89f2205e..6ede1a9a 100644 --- a/src/elements/Translation.php +++ b/src/elements/Translation.php @@ -19,6 +19,7 @@ use lilthq\craftliltplugin\elements\actions\JobEdit; use lilthq\craftliltplugin\elements\db\TranslationQuery; use lilthq\craftliltplugin\models\TranslationModelTrait; +use craft\elements\User; use lilthq\craftliltplugin\records\TranslationNotificationsRecord; use lilthq\craftliltplugin\records\TranslationRecord; @@ -128,6 +129,16 @@ public function getIsReviewed(): bool return $this->getIsPublished() || $this->status === TranslationRecord::STATUS_READY_TO_PUBLISH; } + public function getUrl(): ?string + { + return $this->getCpEditUrl(); + } + + public function canView(User $user): bool + { + return true; + } + public function getStatusHtml(): string { $label = self::statuses()[$this->status]['label'] ?? self::statuses()[$this->status]; diff --git a/tests/_craft/migrations/m220617_164156_add_sites.php b/tests/_craft/migrations/m220617_164156_add_sites.php index 0a7ee79f..0db1e052 100644 --- a/tests/_craft/migrations/m220617_164156_add_sites.php +++ b/tests/_craft/migrations/m220617_164156_add_sites.php @@ -42,8 +42,7 @@ public function safeUp() } $siteEnUS->name = 'Craft test'; - $siteEnUS->setBaseUrl('$PRIMARY_SITE_URL'); - + $siteEnUS->setBaseUrl('http://test.craftcms.test:80'); Craft::$app->sites->saveSite($siteEnUS); $siteSetting = new Section_SiteSettings(); @@ -61,6 +60,7 @@ public function safeUp() $site->setName( sprintf('Craft test %s', explode('-', $language)[0]) ); + $site->groupId = $groups[0]->id; $site->setBaseUrl('@web/' . explode('-', $language)[0]); @@ -72,7 +72,6 @@ public function safeUp() $siteSetting->siteId = $site->id; $siteSetting->enabledByDefault = true; - #$siteSetting->uriFormat = sprintf('/blog/%s', explode('-',$language)[0]); $siteSetting->uriFormat = sprintf('/blog/%s/{slug}', explode('-', $language)[0]); $siteSetting->hasUrls = true; diff --git a/tests/integration/controllers/job/GetJobCreateFormControllerCest.php b/tests/integration/controllers/job/GetJobCreateFormControllerCest.php index 0f0596b8..c6cafc7d 100644 --- a/tests/integration/controllers/job/GetJobCreateFormControllerCest.php +++ b/tests/integration/controllers/job/GetJobCreateFormControllerCest.php @@ -266,11 +266,11 @@ private function getExpected(): array 'crumbs' => [ 0 => [ 'label' => 'Lilt Plugin', - 'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin&site=default', + 'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin&site=default', ], 1 => [ 'label' => 'Jobs', - 'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default', + 'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default', ], ], ], diff --git a/tests/integration/controllers/job/GetJobEditFormControllerCest.php b/tests/integration/controllers/job/GetJobEditFormControllerCest.php index 17f5db74..f1dd8385 100644 --- a/tests/integration/controllers/job/GetJobEditFormControllerCest.php +++ b/tests/integration/controllers/job/GetJobEditFormControllerCest.php @@ -331,11 +331,11 @@ private function getExpected(Job $job): array 'crumbs' => [ 0 => [ 'label' => 'Lilt Plugin', - 'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin&site=default', + 'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin&site=default', ], 1 => [ 'label' => 'Jobs', - 'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default', + 'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default', ], ], ], diff --git a/tests/integration/controllers/job/GetTranslationReviewControllerCest.php b/tests/integration/controllers/job/GetTranslationReviewControllerCest.php index 15fcec87..7a681849 100644 --- a/tests/integration/controllers/job/GetTranslationReviewControllerCest.php +++ b/tests/integration/controllers/job/GetTranslationReviewControllerCest.php @@ -119,7 +119,7 @@ public function testSuccess(IntegrationTester $I): void if (method_exists(Assert::class, 'assertMatchesRegularExpression')) { Assert::assertMatchesRegularExpression( - "/^http:\/\/\\\$PRIMARY_SITE_URL\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/", + "/^http:\/\/test\.craftcms\.test:80\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/", $actual['variables']['originalUrl'] ); Assert::assertMatchesRegularExpression( @@ -128,7 +128,7 @@ public function testSuccess(IntegrationTester $I): void ); } else { Assert::assertRegExp( - "/^http:\/\/\\\$PRIMARY_SITE_URL\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/", + "/^http:\/\/test\.craftcms\.test:80\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/", $actual['variables']['originalUrl'] ); Assert::assertRegExp(