Skip to content

Beautiful Open-Source Form Builder

Fix tests, added gh action nuxt step

Julien Nahum80962678c187
diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml
index 6d24a2bd4..4415debb7 100644
--- a/.github/workflows/laravel.yml
+++ b/.github/workflows/laravel.yml
@@ -128,6 +128,27 @@ jobs:
path: storage/logs/laravel.log
retention-days: 3
+ build-nuxt-app:
+ runs-on: ubuntu-latest
+ name: Build the Nuxt app
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Get into client folder
+ run: cd client
+
+ - uses: actions/cache@v2
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-node-
+
+ - name: Prepare the environment
+ run: cp .env.example .env
+
- name: Install npm dependencies
run: npm install --no-audit --no-progress --silent
diff --git a/client/.env.example b/client/.env.example
new file mode 100644
index 000000000..30a53c86a
--- /dev/null
+++ b/client/.env.example
@@ -0,0 +1,13 @@
+NUXT_LOG_LEVEL=
+NUXT_PUBLIC_APP_URL=
+NUXT_PUBLIC_API_BASE=
+NUXT_PUBLIC_AI_ENABLED=
+NUXT_PUBLIC_AMPLITUDE_CODE=
+NUXT_PUBLIC_CRISP_WEBSITE_ID=
+NUXT_PUBLIC_CUSTOM_DOMAINS_ENABLED=
+NUXT_PUBLIC_ENV=
+NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE=
+NUXT_PUBLIC_H_CAPTCHA_SITE_KEY=
+NUXT_PUBLIC_PAID_PLANS_ENABLED=
+NUXT_PUBLIC_S3_ENABLED=
+NUXT_API_SECRET=
diff --git a/client/nuxt.config.ts b/client/nuxt.config.ts
index 8e091f202..9658e6e8e 100644
--- a/client/nuxt.config.ts
+++ b/client/nuxt.config.ts
@@ -14,6 +14,7 @@ export default defineNuxtConfig({
'nuxt3-notifications',
'nuxt-simple-sitemap',
'@nuxt/image',
+ ... process.env.NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE ? ['nuxt-gtag'] : [],
... process.env.NUXT_PUBLIC_SENTRY_DSN ? ['@nuxtjs/sentry'] : [],
],
build: {
@@ -34,6 +35,9 @@ export default defineNuxtConfig({
dsn: process.env.NUXT_PUBLIC_SENTRY_DSN,
lazy: true,
},
+ gtag: {
+ id: process.env.NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE,
+ },
components: [
{
path: '~/components/forms',
diff --git a/client/package-lock.json b/client/package-lock.json
index 63f645aa1..59c43ae38 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -46,6 +46,7 @@
"@nuxt/devtools": "latest",
"autoprefixer": "^10.4.16",
"nuxt": "^3.8.2",
+ "nuxt-gtag": "^1.1.2",
"nuxt-simple-sitemap": "^4.2.3",
"postcss": "^8.4.32",
"sass": "^1.69.6",
@@ -8753,6 +8754,17 @@
}
}
},
+ "node_modules/nuxt-gtag": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/nuxt-gtag/-/nuxt-gtag-1.1.2.tgz",
+ "integrity": "sha512-+gStu6D7RuKnYtmaeYlV+AYmqpNEk8sfv6XRL4hVMK0DSe1GnpPi3rVyx/R5WF8xe2xJl8/CTtgrE25CIOQsHQ==",
+ "dev": true,
+ "dependencies": {
+ "@nuxt/kit": "^3.8.2",
+ "defu": "^6.1.3",
+ "pathe": "^1.1.1"
+ }
+ },
"node_modules/nuxt-simple-sitemap": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/nuxt-simple-sitemap/-/nuxt-simple-sitemap-4.2.3.tgz",
diff --git a/client/package.json b/client/package.json
index 492dd51a7..c1d9ff719 100644
--- a/client/package.json
+++ b/client/package.json
@@ -13,6 +13,7 @@
"@nuxt/devtools": "latest",
"autoprefixer": "^10.4.16",
"nuxt": "^3.8.2",
+ "nuxt-gtag": "^1.1.2",
"nuxt-simple-sitemap": "^4.2.3",
"postcss": "^8.4.32",
"sass": "^1.69.6",
diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php
index e98622b52..f7461e4cf 100644
--- a/tests/Feature/LoginTest.php
+++ b/tests/Feature/LoginTest.php
@@ -5,7 +5,7 @@ use App\Models\User;
it('can login to Forms', function () {
$user = User::factory()->create();
- $this->postJson('/api/login', [
+ $this->postJson('/login', [
'email' => $user->email,
'password' => 'password',
])
@@ -16,23 +16,23 @@ it('can login to Forms', function () {
it('can fetch current user', function () {
$this->actingAs(User::factory()->create())
- ->getJson('/api/user')
+ ->getJson('/user')
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
});
it('can log out', function () {
- $this->postJson('/api/login', [
+ $this->postJson('/login', [
'email' => User::factory()->create()->email,
'password' => 'password',
])->assertSuccessful();
$this->assertAuthenticated();
- $this->postJson("/api/logout")
+ $this->postJson("/logout")
->assertSuccessful();
$this->assertGuest();
- $this->getJson("/api/user")
+ $this->getJson("/user")
->assertStatus(401);
});
diff --git a/tests/Feature/RegisterTest.php b/tests/Feature/RegisterTest.php
index a59c638a0..049a40a6f 100644
--- a/tests/Feature/RegisterTest.php
+++ b/tests/Feature/RegisterTest.php
@@ -5,7 +5,7 @@ use Tests\TestCase;
use function Pest\Faker\faker;
it('can register', function () {
- $this->postJson('/api/register', [
+ $this->postJson('/register', [
'name' => 'Test User',
'email' => '[email protected]',
'hear_about_us' => 'google',
@@ -24,7 +24,7 @@ it('can register', function () {
it('cannot register with existing email', function () {
User::factory()->create(['email' => '[email protected]']);
- $this->postJson('/api/register', [
+ $this->postJson('/register', [
'name' => 'Test User',
'email' => '[email protected]',
'password' => 'secret',
@@ -37,13 +37,13 @@ it('cannot register with existing email', function () {
it('cannot register with disposable email', function () {
// Select random email
$email = faker()->randomElement([
]);
- $this->postJson('/api/register', [
+ $this->postJson('/register', [
'name' => 'Test disposable',
'email' => $email,
'hear_about_us' => 'google',
@@ -61,4 +61,4 @@ it('cannot register with disposable email', function () {
],
],
]);
-});
\ No newline at end of file
+});
diff --git a/tests/Feature/SettingsTest.php b/tests/Feature/SettingsTest.php
index c57258e47..66c57bf4e 100644
--- a/tests/Feature/SettingsTest.php
+++ b/tests/Feature/SettingsTest.php
@@ -6,7 +6,7 @@ use Tests\TestCase;
it('update profile info',function() {
$this->actingAs($user = User::factory()->create())
- ->patchJson('/api/settings/profile', [
+ ->patchJson('/settings/profile', [
'name' => 'Test User',
'email' => '[email protected]',
])
@@ -22,7 +22,7 @@ it('update profile info',function() {
it('update password',function() {
$this->actingAs($user = User::factory()->create())
- ->patchJson('/api/settings/password', [
+ ->patchJson('/settings/password', [
'password' => 'updated',
'password_confirmation' => 'updated',
])
diff --git a/tests/TestHelpers.php b/tests/TestHelpers.php
index a04702061..1156cf57e 100644
--- a/tests/TestHelpers.php
+++ b/tests/TestHelpers.php
@@ -161,7 +161,7 @@ trait TestHelpers
$user = $this->createUser();
}
- $this->postJson('/api/login', [
+ $this->postJson('/login', [
'email' => $user->email,
'password' => 'password',
])->assertSuccessful();
diff --git a/vapor.yml b/vapor.yml
index 32aba7a46..0a9563dc6 100644
--- a/vapor.yml
+++ b/vapor.yml
@@ -18,9 +18,6 @@ environments:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
- 'php artisan event:cache'
- 'php artisan disposable:update'
- - 'cd client'
- - 'npm ci && npm run build && rm -rf node_modules'
- - 'cd ..'
deploy:
- 'php artisan migrate --force'
firewall:
@@ -38,9 +35,6 @@ environments:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
- 'php artisan event:cache'
- 'php artisan disposable:update'
- - 'cd client'
- - 'npm ci && npm run build && rm -rf node_modules'
- - 'cd ..'
deploy:
- 'php artisan migrate --force'
firewall: