Fix tests, added gh action nuxt step

This commit is contained in:
Julien Nahum 2024-01-14 20:52:14 +01:00
parent 675b88f75a
commit 80962678c1
10 changed files with 66 additions and 21 deletions

View File

@ -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

13
client/.env.example Normal file
View File

@ -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=

View File

@ -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',

View File

@ -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",

View File

@ -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",

View File

@ -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);
});

View File

@ -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' => 'test@test.app',
'hear_about_us' => 'google',
@ -24,7 +24,7 @@ it('can register', function () {
it('cannot register with existing email', function () {
User::factory()->create(['email' => 'test@test.app']);
$this->postJson('/api/register', [
$this->postJson('/register', [
'name' => 'Test User',
'email' => 'test@test.app',
'password' => 'secret',
@ -43,7 +43,7 @@ it('cannot register with disposable email', function () {
'qvj86ypqfm@email.edu.pl'
]);
$this->postJson('/api/register', [
$this->postJson('/register', [
'name' => 'Test disposable',
'email' => $email,
'hear_about_us' => 'google',

View File

@ -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' => 'test@test.app',
])
@ -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',
])

View File

@ -161,7 +161,7 @@ trait TestHelpers
$user = $this->createUser();
}
$this->postJson('/api/login', [
$this->postJson('/login', [
'email' => $user->email,
'password' => 'password',
])->assertSuccessful();

View File

@ -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: