From 7584d2d7a7110aef0331ebfa178b2295842c59fa Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:19:14 -0700 Subject: refactor: project maintenance - work in progress --- tests/bootstrap.ts | 29 ++- tests/config.ts | 2 +- tests/functional/api/static/announcements.spec.ts | 26 ++- tests/functional/api/static/features.spec.ts | 24 +-- tests/functional/api/static/news.spec.ts | 14 +- tests/functional/api/static/services.spec.ts | 14 +- tests/functional/dashboard/account.spec.ts | 129 ++++++------- tests/functional/dashboard/data.spec.ts | 38 ++-- tests/functional/dashboard/delete.spec.ts | 49 +++-- .../dashboard/disabled-dashboard.spec.ts | 82 ++++----- tests/functional/dashboard/export.spec.ts | 91 +++++----- tests/functional/dashboard/forgot-password.spec.ts | 66 ++++--- .../import-stubs/services-workspaces.json | 5 +- tests/functional/dashboard/login.spec.ts | 62 +++---- tests/functional/dashboard/logout.spec.ts | 26 ++- tests/functional/dashboard/reset-password.spec.ts | 84 ++++----- tests/functional/dashboard/transfer.spec.ts | 200 ++++++++------------- tests/functional/health.spec.ts | 12 +- tests/functional/static-pages/home.spec.ts | 12 +- tests/functional/static-pages/privacy.spec.ts | 12 +- tests/functional/static-pages/terms.spec.ts | 12 +- tests/utils.ts | 4 +- 22 files changed, 430 insertions(+), 563 deletions(-) (limited to 'tests') diff --git a/tests/bootstrap.ts b/tests/bootstrap.ts index efd1d1f..1c6bea1 100644 --- a/tests/bootstrap.ts +++ b/tests/bootstrap.ts @@ -5,15 +5,10 @@ * file. */ -import type { Config } from '@japa/runner'; -import TestUtils from '@ioc:Adonis/Core/TestUtils'; -import { - assert, - runFailedTests, - specReporter, - apiClient, -} from '@japa/preset-adonis'; -import { fakeCsrfField } from './utils'; +import type { Config } from '@japa/runner' +import TestUtils from '@ioc:Adonis/Core/TestUtils' +import { assert, runFailedTests, specReporter, apiClient } from '@japa/preset-adonis' +import { fakeCsrfField } from './utils.js' /* |-------------------------------------------------------------------------- @@ -26,11 +21,7 @@ import { fakeCsrfField } from './utils'; | Feel free to remove existing plugins or add more. | */ -export const plugins: Config['plugins'] = [ - assert(), - runFailedTests(), - apiClient(), -]; +export const plugins: Config['plugins'] = [assert(), runFailedTests(), apiClient()] /* |-------------------------------------------------------------------------- @@ -42,7 +33,7 @@ export const plugins: Config['plugins'] = [ | of tests on the terminal. | */ -export const reporters: Config['reporters'] = [specReporter()]; +export const reporters: Config['reporters'] = [specReporter()] /* |-------------------------------------------------------------------------- @@ -63,7 +54,7 @@ export const runnerHooks: Required> = { () => fakeCsrfField(), ], teardown: [], -}; +} /* |-------------------------------------------------------------------------- @@ -76,8 +67,8 @@ export const runnerHooks: Required> = { | You can use this method to configure suites. For example: Only start | the HTTP server when it is a functional suite. */ -export const configureSuite: Config['configureSuite'] = suite => { +export const configureSuite: Config['configureSuite'] = (suite) => { if (suite.name === 'functional') { - suite.setup(() => TestUtils.httpServer().start()); + suite.setup(() => TestUtils.httpServer().start()) } -}; +} diff --git a/tests/config.ts b/tests/config.ts index 8cd3511..f40284e 100644 --- a/tests/config.ts +++ b/tests/config.ts @@ -1 +1 @@ -export const apiVersion = 'v1'; +export const apiVersion = 'v1' diff --git a/tests/functional/api/static/announcements.spec.ts b/tests/functional/api/static/announcements.spec.ts index ac933fe..45881ec 100644 --- a/tests/functional/api/static/announcements.spec.ts +++ b/tests/functional/api/static/announcements.spec.ts @@ -1,22 +1,20 @@ -import { test } from '@japa/runner'; -import { apiVersion } from '../../../config'; +import { test } from '@japa/runner' +import { apiVersion } from '../../../config.js' test.group('API / Static / News', () => { - test('returns a 404 response when the requested versions does not exist', async ({ - client, - }) => { - const response = await client.get(`/${apiVersion}/announcements/illegal`); + test('returns a 404 response when the requested versions does not exist', async ({ client }) => { + const response = await client.get(`/${apiVersion}/announcements/illegal`) - response.assertStatus(404); - response.assertTextIncludes('No announcement found.'); - }); + response.assertStatus(404) + response.assertTextIncludes('No announcement found.') + }) test('returns a 200 response with default version file when specifying version as input', async ({ client, }) => { - const response = await client.get(`/${apiVersion}/announcements/version`); + const response = await client.get(`/${apiVersion}/announcements/version`) - response.assertStatus(200); + response.assertStatus(200) response.assertBody({ main: { headline: 'Example Announcement', @@ -50,6 +48,6 @@ test.group('API / Static / News', () => { }, }, }, - }); - }); -}); + }) + }) +}) diff --git a/tests/functional/api/static/features.spec.ts b/tests/functional/api/static/features.spec.ts index 1050fcf..c31e25f 100644 --- a/tests/functional/api/static/features.spec.ts +++ b/tests/functional/api/static/features.spec.ts @@ -1,5 +1,5 @@ -import { test } from '@japa/runner'; -import { apiVersion } from '../../../config'; +import { test } from '@japa/runner' +import { apiVersion } from '../../../config.js' const defaultResponse = { isServiceProxyEnabled: true, @@ -8,22 +8,22 @@ const defaultResponse = { isSettingsWSEnabled: false, isMagicBarEnabled: true, isTodosEnabled: true, -}; +} test.group('API / Static / Features', () => { test('returns a 200 response with empty array', async ({ client }) => { - const response = await client.get(`/${apiVersion}/features`); + const response = await client.get(`/${apiVersion}/features`) - response.assertStatus(200); - response.assertBody(defaultResponse); - }); + response.assertStatus(200) + response.assertBody(defaultResponse) + }) test('returns a 200 response with expected object when calling with :mode', async ({ client, }) => { - const response = await client.get(`/${apiVersion}/features/random`); + const response = await client.get(`/${apiVersion}/features/random`) - response.assertStatus(200); - response.assertBody(defaultResponse); - }); -}); + response.assertStatus(200) + response.assertBody(defaultResponse) + }) +}) diff --git a/tests/functional/api/static/news.spec.ts b/tests/functional/api/static/news.spec.ts index 8f3818f..71b5797 100644 --- a/tests/functional/api/static/news.spec.ts +++ b/tests/functional/api/static/news.spec.ts @@ -1,11 +1,11 @@ -import { test } from '@japa/runner'; -import { apiVersion } from '../../../config'; +import { test } from '@japa/runner' +import { apiVersion } from '../../../config.js' test.group('API / Static / News', () => { test('returns a 200 response with empty array', async ({ client }) => { - const response = await client.get(`/${apiVersion}/news`); + const response = await client.get(`/${apiVersion}/news`) - response.assertStatus(200); - response.assertBody([]); - }); -}); + response.assertStatus(200) + response.assertBody([]) + }) +}) diff --git a/tests/functional/api/static/services.spec.ts b/tests/functional/api/static/services.spec.ts index 55eef37..595b8dc 100644 --- a/tests/functional/api/static/services.spec.ts +++ b/tests/functional/api/static/services.spec.ts @@ -1,11 +1,11 @@ -import { test } from '@japa/runner'; -import { apiVersion } from '../../../config'; +import { test } from '@japa/runner' +import { apiVersion } from '../../../config.js' test.group('API / Static / Services', () => { test('returns a 200 response with empty array', async ({ client }) => { - const response = await client.get(`/${apiVersion}/services`); + const response = await client.get(`/${apiVersion}/services`) - response.assertStatus(200); - response.assertBody([]); - }); -}); + response.assertStatus(200) + response.assertBody([]) + }) +}) diff --git a/tests/functional/dashboard/account.spec.ts b/tests/functional/dashboard/account.spec.ts index bee9d6a..25de22c 100644 --- a/tests/functional/dashboard/account.spec.ts +++ b/tests/functional/dashboard/account.spec.ts @@ -1,124 +1,109 @@ -import { test } from '@japa/runner'; -import User from 'App/Models/User'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import User from '#app/Models/User' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Account page', () => { - test('redirects to /user/login when accessing /user/account as guest', async ({ - client, - }) => { - const response = await client.get('/user/account'); + test('redirects to /user/login when accessing /user/account as guest', async ({ client }) => { + const response = await client.get('/user/account') - response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL - }); + response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL + }) - test('returns a 200 opening the account route while logged in', async ({ - client, - }) => { - const user = await UserFactory.create(); - const response = await client.get('/user/account').loginAs(user); + test('returns a 200 opening the account route while logged in', async ({ client }) => { + const user = await UserFactory.create() + const response = await client.get('/user/account').loginAs(user) - response.assertStatus(200); - response.assertTextIncludes('Your Ferdium account'); + response.assertStatus(200) + response.assertTextIncludes('Your Ferdium account') - response.assertTextIncludes(user.email); - response.assertTextIncludes(user.username); - response.assertTextIncludes(user.lastname); - }); + response.assertTextIncludes(user.email) + response.assertTextIncludes(user.username) + response.assertTextIncludes(user.lastname) + }) - test('returns a validation error for all fields when missing', async ({ - client, - }) => { - const user = await UserFactory.create(); - const response = await client.post('/user/account').loginAs(user); + test('returns a validation error for all fields when missing', async ({ client }) => { + const user = await UserFactory.create() + const response = await client.post('/user/account').loginAs(user) response.assertTextIncludes( - 'value="required validation failed,required validation failed" placeholder="E-Mail"', - ); + 'value="required validation failed,required validation failed" placeholder="E-Mail"' + ) response.assertTextIncludes( - 'value="required validation failed,required validation failed" placeholder="Name"', - ); + 'value="required validation failed,required validation failed" placeholder="Name"' + ) response.assertTextIncludes( - 'value="required validation failed,required validation failed" placeholder="Last Name"', - ); - }); + 'value="required validation failed,required validation failed" placeholder="Last Name"' + ) + }) test('returns a validation error for username when there is another user with same username', async ({ client, }) => { - const user = await UserFactory.create(); - const existingUser = await UserFactory.create(); + const user = await UserFactory.create() + const existingUser = await UserFactory.create() const response = await client.post('/user/account').loginAs(user).form({ username: existingUser.username, email: user.email, lastname: user.lastname, - }); + }) - response.assertTextIncludes( - 'value="unique validation failure" placeholder="Name"', - ); - }); + response.assertTextIncludes('value="unique validation failure" placeholder="Name"') + }) test('returns a validation error for email when there is another user with same email', async ({ client, }) => { - const user = await UserFactory.create(); - const existingUser = await UserFactory.create(); + const user = await UserFactory.create() + const existingUser = await UserFactory.create() const response = await client.post('/user/account').loginAs(user).form({ username: user.username, email: existingUser.email, lastname: user.lastname, - }); + }) - response.assertTextIncludes( - 'value="unique validation failure" placeholder="E-Mail"', - ); - }); + response.assertTextIncludes('value="unique validation failure" placeholder="E-Mail"') + }) - test('updates user data and ensures the data is persisted', async ({ - client, - assert, - }) => { - const user = await UserFactory.create(); + test('updates user data and ensures the data is persisted', async ({ client, assert }) => { + const user = await UserFactory.create() const response = await client.post('/user/account').loginAs(user).form({ username: 'edited-username', email: 'edited-email', lastname: 'edited-lastname', - }); + }) - response.assertStatus(200); + response.assertStatus(200) // Ensure updated data is displayed on account page - response.assertTextIncludes('edited-username'); - response.assertTextIncludes('edited-email'); - response.assertTextIncludes('edited-lastname'); + response.assertTextIncludes('edited-username') + response.assertTextIncludes('edited-email') + response.assertTextIncludes('edited-lastname') // Ensure updated data is persisted in database - const updatedUser = await User.findBy('id', user.id); - assert.equal(updatedUser?.username, 'edited-username'); - assert.equal(updatedUser?.email, 'edited-email'); - assert.equal(updatedUser?.lastname, 'edited-lastname'); - }); - - test('updates user password and ensures the user can still login', async ({ - client, - }) => { - const user = await UserFactory.create(); + const updatedUser = await User.findBy('id', user.id) + assert.equal(updatedUser?.username, 'edited-username') + assert.equal(updatedUser?.email, 'edited-email') + assert.equal(updatedUser?.lastname, 'edited-lastname') + }) + + test('updates user password and ensures the user can still login', async ({ client }) => { + const user = await UserFactory.create() const response = await client.post('/user/account').loginAs(user).form({ username: user.username, email: user.email, lastname: user.lastname, password: 'modified-password-account-page', - }); + }) - response.assertStatus(200); + response.assertStatus(200) const loginResponse = await client.post('/user/login').fields({ mail: user.email, password: 'modified-password-account-page', - }); + }) - loginResponse.assertRedirectsTo('/user/account'); - }); -}); + loginResponse.assertRedirectsTo('/user/account') + }) +}) diff --git a/tests/functional/dashboard/data.spec.ts b/tests/functional/dashboard/data.spec.ts index 1a0e7ad..150229a 100644 --- a/tests/functional/dashboard/data.spec.ts +++ b/tests/functional/dashboard/data.spec.ts @@ -1,31 +1,25 @@ -import { test } from '@japa/runner'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Data page', () => { - test('redirects to /user/login when accessing /user/data as guest', async ({ - client, - }) => { - const response = await client.get('/user/data'); + test('redirects to /user/login when accessing /user/data as guest', async ({ client }) => { + const response = await client.get('/user/data') - response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL - }); + response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL + }) test('ensure the correct data is shown on the page', async ({ client }) => { - const user = await UserFactory.create(); - const response = await client.get('/user/data').loginAs(user); + const user = await UserFactory.create() + const response = await client.get('/user/data').loginAs(user) - response.assertStatus(200); - response.assertTextIncludes(user.email); - response.assertTextIncludes(user.username); - response.assertTextIncludes(user.lastname); - response.assertTextIncludes( - user.created_at.toFormat('yyyy-MM-dd HH:mm:ss'), - ); - response.assertTextIncludes( - user.updated_at.toFormat('yyyy-MM-dd HH:mm:ss'), - ); - }); + response.assertStatus(200) + response.assertTextIncludes(user.email) + response.assertTextIncludes(user.username) + response.assertTextIncludes(user.lastname) + response.assertTextIncludes(user.created_at.toFormat('yyyy-MM-dd HH:mm:ss')) + response.assertTextIncludes(user.updated_at.toFormat('yyyy-MM-dd HH:mm:ss')) + }) // TODO: Add test to include services. // TODO: Add test to include workspaces. -}); +}) diff --git a/tests/functional/dashboard/delete.spec.ts b/tests/functional/dashboard/delete.spec.ts index ae3f0e6..9bb9f6a 100644 --- a/tests/functional/dashboard/delete.spec.ts +++ b/tests/functional/dashboard/delete.spec.ts @@ -1,37 +1,30 @@ -import { test } from '@japa/runner'; -import User from 'App/Models/User'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import User from '#app/Models/User' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Delete account page', () => { - test('redirects to /user/login when accessing /user/delete as guest', async ({ - client, - }) => { - const response = await client.get('/user/delete'); + test('redirects to /user/login when accessing /user/delete as guest', async ({ client }) => { + const response = await client.get('/user/delete') - response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL - }); + response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL + }) - test('returns a 200 opening the delete route while logged in', async ({ - client, - }) => { - const user = await UserFactory.create(); - const response = await client.get('/user/delete').loginAs(user); + test('returns a 200 opening the delete route while logged in', async ({ client }) => { + const user = await UserFactory.create() + const response = await client.get('/user/delete').loginAs(user) - response.assertStatus(200); - response.assertTextIncludes('Delete your account'); - }); + response.assertStatus(200) + response.assertTextIncludes('Delete your account') + }) - test('returns a 200 opening the delete route while logged in', async ({ - client, - assert, - }) => { - const user = await UserFactory.create(); - const response = await client.post('/user/delete').loginAs(user); + test('returns a 200 opening the delete route while logged in', async ({ client, assert }) => { + const user = await UserFactory.create() + const response = await client.post('/user/delete').loginAs(user) - response.assertRedirectsTo('/user/login'); + response.assertRedirectsTo('/user/login') // This asserts the session is deleted as well - response.assertSessionMissing('auth_web'); + response.assertSessionMissing('auth_web') - assert.isNull(await User.find(user.id)); - }); -}); + assert.isNull(await User.find(user.id)) + }) +}) diff --git a/tests/functional/dashboard/disabled-dashboard.spec.ts b/tests/functional/dashboard/disabled-dashboard.spec.ts index cc9052c..fd9600f 100644 --- a/tests/functional/dashboard/disabled-dashboard.spec.ts +++ b/tests/functional/dashboard/disabled-dashboard.spec.ts @@ -1,71 +1,63 @@ -import { test } from '@japa/runner'; -import Config from '@ioc:Adonis/Core/Config'; +import { test } from '@japa/runner' +import Config from '@ioc:Adonis/Core/Config' const disabledDashboardMessage = - 'The user dashboard is disabled on this server\n\nIf you are the server owner, please set IS_DASHBOARD_ENABLED to true to enable the dashboard.'; + 'The user dashboard is disabled on this server\n\nIf you are the server owner, please set IS_DASHBOARD_ENABLED to true to enable the dashboard.' -test.group('Dashboard / Disabled dashboard', group => { +test.group('Dashboard / Disabled dashboard', (group) => { group.setup(() => { - Config.set('dashboard.enabled', false); - }); + Config.set('dashboard.enabled', false) + }) group.teardown(() => { - Config.set('dashboard.enabled', true); - }); + Config.set('dashboard.enabled', true) + }) test('Login page returns disabled dashboard message', async ({ client }) => { - const response = await client.get('/user/login'); + const response = await client.get('/user/login') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) - test('Forgot password page returns disabled dashboard message', async ({ - client, - }) => { - const response = await client.get('/user/forgot'); + test('Forgot password page returns disabled dashboard message', async ({ client }) => { + const response = await client.get('/user/forgot') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) - test('Reset password page returns disabled dashboard message', async ({ - client, - }) => { - const response = await client.get('/user/reset'); + test('Reset password page returns disabled dashboard message', async ({ client }) => { + const response = await client.get('/user/reset') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) - test('Account page returns disabled dashboard message', async ({ - client, - }) => { - const response = await client.get('/user/account'); + test('Account page returns disabled dashboard message', async ({ client }) => { + const response = await client.get('/user/account') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) test('Data page returns disabled dashboard message', async ({ client }) => { - const response = await client.get('/user/data'); + const response = await client.get('/user/data') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) test('Export page returns disabled dashboard message', async ({ client }) => { - const response = await client.get('/user/export'); + const response = await client.get('/user/export') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) - test('Transfer page returns disabled dashboard message', async ({ - client, - }) => { - const response = await client.get('/user/transfer'); + test('Transfer page returns disabled dashboard message', async ({ client }) => { + const response = await client.get('/user/transfer') - response.assertTextIncludes(disabledDashboardMessage); - }); + response.assertTextIncludes(disabledDashboardMessage) + }) test('Logout page returns disabled dashboard message', async ({ client }) => { - const response = await client.get('/user/logout'); + const response = await client.get('/user/logout') - response.assertTextIncludes(disabledDashboardMessage); - }); -}); + response.assertTextIncludes(disabledDashboardMessage) + }) +}) diff --git a/tests/functional/dashboard/export.spec.ts b/tests/functional/dashboard/export.spec.ts index 4250622..f85673e 100644 --- a/tests/functional/dashboard/export.spec.ts +++ b/tests/functional/dashboard/export.spec.ts @@ -1,61 +1,50 @@ -import { test } from '@japa/runner'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Export page', () => { - test('redirects to /user/login when accessing /user/transfer as guest', async ({ - client, - }) => { - const response = await client.get('/user/transfer'); + test('redirects to /user/login when accessing /user/transfer as guest', async ({ client }) => { + const response = await client.get('/user/transfer') - response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL - }); + response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL + }) - test('returns a correct export with user data', async ({ - assert, - client, - }) => { - const user = await UserFactory.create(); - const response = await client.get('/user/export').loginAs(user); + test('returns a correct export with user data', async ({ assert, client }) => { + const user = await UserFactory.create() + const response = await client.get('/user/export').loginAs(user) - response.assertStatus(200); - const exportData = JSON.parse(response.text()); + response.assertStatus(200) + const exportData = JSON.parse(response.text()) - assert.equal(exportData.username, user.username); - assert.equal(exportData.lastname, user.lastname); - assert.equal(exportData.mail, user.email); - }); + assert.equal(exportData.username, user.username) + assert.equal(exportData.lastname, user.lastname) + assert.equal(exportData.mail, user.email) + }) // TODO: We can improve this test by hard checking the export data - test('returns a correct export with service data', async ({ - assert, - client, - }) => { - const user = await UserFactory.with('services', 5).create(); - const response = await client.get('/user/export').loginAs(user); - - response.assertStatus(200); - const exportData = JSON.parse(response.text()); - - assert.equal(exportData.username, user.username); - assert.equal(exportData.lastname, user.lastname); - assert.equal(exportData.mail, user.email); - assert.equal(exportData.services.length, user.services.length); - }); + test('returns a correct export with service data', async ({ assert, client }) => { + const user = await UserFactory.with('services', 5).create() + const response = await client.get('/user/export').loginAs(user) + + response.assertStatus(200) + const exportData = JSON.parse(response.text()) + + assert.equal(exportData.username, user.username) + assert.equal(exportData.lastname, user.lastname) + assert.equal(exportData.mail, user.email) + assert.equal(exportData.services.length, user.services.length) + }) // TODO: We can improve this test by hard checking the export data - test('returns a correct export with workspace data', async ({ - assert, - client, - }) => { - const user = await UserFactory.with('workspaces', 5).create(); - const response = await client.get('/user/export').loginAs(user); - - response.assertStatus(200); - const exportData = JSON.parse(response.text()); - - assert.equal(exportData.username, user.username); - assert.equal(exportData.lastname, user.lastname); - assert.equal(exportData.mail, user.email); - assert.equal(exportData.workspaces.length, user.workspaces.length); - }); -}); + test('returns a correct export with workspace data', async ({ assert, client }) => { + const user = await UserFactory.with('workspaces', 5).create() + const response = await client.get('/user/export').loginAs(user) + + response.assertStatus(200) + const exportData = JSON.parse(response.text()) + + assert.equal(exportData.username, user.username) + assert.equal(exportData.lastname, user.lastname) + assert.equal(exportData.mail, user.email) + assert.equal(exportData.workspaces.length, user.workspaces.length) + }) +}) diff --git a/tests/functional/dashboard/forgot-password.spec.ts b/tests/functional/dashboard/forgot-password.spec.ts index 9dcec5a..7c356c8 100644 --- a/tests/functional/dashboard/forgot-password.spec.ts +++ b/tests/functional/dashboard/forgot-password.spec.ts @@ -1,70 +1,66 @@ -import { test } from '@japa/runner'; -import Event from '@ioc:Adonis/Core/Event'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import emitter from '@adonisjs/core/services/emitter' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Forgot password page', () => { - test('returns a 200 opening the forgot password route', async ({ - client, - }) => { - const response = await client.get('/user/forgot'); + test('returns a 200 opening the forgot password route', async ({ client }) => { + const response = await client.get('/user/forgot') - response.assertStatus(200); - response.assertTextIncludes('Forgot Password?'); - }); + response.assertStatus(200) + response.assertTextIncludes('Forgot Password?') + }) test('returns `Please enter a valid email address` when providing invalid email', async ({ client, }) => { const response = await client.post('/user/forgot').fields({ mail: 'invalid', - }); + }) - response.assertStatus(200); - response.assertTextIncludes('Please enter a valid email address'); - }); + response.assertStatus(200) + response.assertTextIncludes('Please enter a valid email address') + }) test('returns `email send when exists` without forgot:password event', async ({ client, assert, }) => { - const emitter = Event.fake(); + const emitterService = emitter.fake() const response = await client.post('/user/forgot').fields({ mail: 'test@ferdium.org', - }); + }) - response.assertStatus(200); + response.assertStatus(200) response.assertTextIncludes( - 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.', - ); + 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.' + ) - assert.isFalse(emitter.exists('forgot:password')); - }); + assert.isFalse(emitterService.exists('forgot:password')) + }) test('returns `email send when exists` and trigger forgot:password event', async ({ client, assert, }) => { - const emitter = Event.fake(); + const emitterService = emitter.fake() const user = await UserFactory.merge({ email: 'test+forgot_password@ferdium.org', - }).create(); + }).create() const response = await client.post('/user/forgot').fields({ mail: 'test+forgot_password@ferdium.org', - }); + }) - response.assertStatus(200); + response.assertStatus(200) response.assertTextIncludes( - 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.', - ); + 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.' + ) assert.isTrue( - emitter.exists( - event => - event.name === 'forgot:password' && - event.data.user.email === user.email, - ), - ); - }); -}); + emitterService.exists( + (event) => event.name === 'forgot:password' && event.data.user.email === user.email + ) + ) + }) +}) diff --git a/tests/functional/dashboard/import-stubs/services-workspaces.json b/tests/functional/dashboard/import-stubs/services-workspaces.json index 139b32c..d1ad0dd 100644 --- a/tests/functional/dashboard/import-stubs/services-workspaces.json +++ b/tests/functional/dashboard/import-stubs/services-workspaces.json @@ -44,10 +44,7 @@ { "name": "workspace2", "order": 0, - "services": [ - "d6901fff-ec44-4251-93de-d7103ed9c44b", - "79769de5-a998-4af1-b7d0-89956a15b0ed" - ], + "services": ["d6901fff-ec44-4251-93de-d7103ed9c44b", "79769de5-a998-4af1-b7d0-89956a15b0ed"], "data": "{\"name\":\"workspace2\"}" }, { diff --git a/tests/functional/dashboard/login.spec.ts b/tests/functional/dashboard/login.spec.ts index adae66a..cf482cd 100644 --- a/tests/functional/dashboard/login.spec.ts +++ b/tests/functional/dashboard/login.spec.ts @@ -1,65 +1,57 @@ -import { test } from '@japa/runner'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Login page', () => { test('returns a 200 opening the login route', async ({ client }) => { - const response = await client.get('/user/login'); + const response = await client.get('/user/login') - response.assertStatus(200); - }); + response.assertStatus(200) + }) - test('returns `invalid mail or password` when validation fails', async ({ - client, - }) => { + test('returns `invalid mail or password` when validation fails', async ({ client }) => { const response = await client.post('/user/login').fields({ mail: 'invalid', password: 'invalid', - }); + }) - response.assertRedirectsTo('/user/login'); - response.assertTextIncludes('Invalid mail or password'); - }); + response.assertRedirectsTo('/user/login') + response.assertTextIncludes('Invalid mail or password') + }) - test('returns `invalid mail or password` when account is not found', async ({ - client, - }) => { + test('returns `invalid mail or password` when account is not found', async ({ client }) => { const response = await client.post('/user/login').fields({ mail: 'test+notexistingpassword@ferdium.org', password: 'notexistingpassword', - }); + }) - response.assertRedirectsTo('/user/login'); - response.assertTextIncludes('Invalid mail or password'); - }); + response.assertRedirectsTo('/user/login') + response.assertTextIncludes('Invalid mail or password') + }) - test('returns `invalid mail or password` when password is not valid', async ({ - client, - }) => { + test('returns `invalid mail or password` when password is not valid', async ({ client }) => { await UserFactory.merge({ email: 'test@ferdium.org', - }).create(); + }).create() const response = await client.post('/user/login').fields({ mail: 'test+invalid_password@ferdium.org', password: 'invalid_password', - }); + }) - response.assertRedirectsTo('/user/login'); - response.assertTextIncludes('Invalid mail or password'); - }); + response.assertRedirectsTo('/user/login') + response.assertTextIncludes('Invalid mail or password') + }) - test('redirects to account page when user is able to login', async ({ - client, - }) => { + test('redirects to account page when user is able to login', async ({ client }) => { await UserFactory.merge({ email: 'test+password@ferdium.org', - }).create(); + }).create() const response = await client.post('/user/login').fields({ mail: 'test+password@ferdium.org', password: 'password', - }); + }) - response.assertRedirectsTo('/user/account'); - }); -}); + response.assertRedirectsTo('/user/account') + }) +}) diff --git a/tests/functional/dashboard/logout.spec.ts b/tests/functional/dashboard/logout.spec.ts index a45ee72..ad117da 100644 --- a/tests/functional/dashboard/logout.spec.ts +++ b/tests/functional/dashboard/logout.spec.ts @@ -1,21 +1,19 @@ -import { test } from '@japa/runner'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Log out page', () => { - test('redirects to /user/login when accessing /user/logout as guest', async ({ - client, - }) => { - const response = await client.get('/user/logout'); + test('redirects to /user/login when accessing /user/logout as guest', async ({ client }) => { + const response = await client.get('/user/logout') - response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL - }); + response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL + }) test('logs the user out when opening the page', async ({ client }) => { - const user = await UserFactory.create(); - const response = await client.get('/user/logout').loginAs(user); + const user = await UserFactory.create() + const response = await client.get('/user/logout').loginAs(user) - response.assertRedirectsTo('/user/login'); + response.assertRedirectsTo('/user/login') // This asserts the session is deleted as well - response.assertSessionMissing('auth_web'); - }); -}); + response.assertSessionMissing('auth_web') + }) +}) diff --git a/tests/functional/dashboard/reset-password.spec.ts b/tests/functional/dashboard/reset-password.spec.ts index e488482..8883665 100644 --- a/tests/functional/dashboard/reset-password.spec.ts +++ b/tests/functional/dashboard/reset-password.spec.ts @@ -1,26 +1,22 @@ -import { test } from '@japa/runner'; -import Token from 'App/Models/Token'; -import UserFactory from 'Database/factories/UserFactory'; -import TokenFactory from 'Database/factories/TokenFactory'; +import { test } from '@japa/runner' +import Token from '#app/Models/Token' +import UserFactory from '#database/factories/UserFactory' +import TokenFactory from '#database/factories/TokenFactory' test.group('Dashboard / Reset password page', () => { - test('returns a `Invalid token` message when opening without a token', async ({ - client, - }) => { - const response = await client.get('/user/reset'); + test('returns a `Invalid token` message when opening without a token', async ({ client }) => { + const response = await client.get('/user/reset') - response.assertStatus(200); - response.assertTextIncludes('Invalid token'); - }); + response.assertStatus(200) + response.assertTextIncludes('Invalid token') + }) test('displays the form when a token is provided', async ({ client }) => { - const response = await client.get( - '/user/reset?token=randomtokenbutitworks', - ); + const response = await client.get('/user/reset?token=randomtokenbutitworks') - response.assertStatus(200); - response.assertTextIncludes('Reset Your Password'); - }); + response.assertStatus(200) + response.assertTextIncludes('Reset Your Password') + }) test('returns `passwords do not match` message when passwords do not match', async ({ client, @@ -29,22 +25,20 @@ test.group('Dashboard / Reset password page', () => { token: 'randomnotworkingtoken', password: 'password', password_confirmation: 'not_matching', - }); + }) - response.assertTextIncludes('Passwords do not match'); - }); + response.assertTextIncludes('Passwords do not match') + }) - test('returns `Cannot reset your password` when token does not exist', async ({ - client, - }) => { + test('returns `Cannot reset your password` when token does not exist', async ({ client }) => { const response = await client.post('/user/reset').fields({ token: 'randomnotworkingtoken', password: 'password', password_confirmation: 'password', - }); + }) - response.assertTextIncludes('Cannot reset your password'); - }); + response.assertTextIncludes('Cannot reset your password') + }) test('returns `Cannot reset your password` when token is older than 24 hours', async ({ client, @@ -54,41 +48,39 @@ test.group('Dashboard / Reset password page', () => { user_id: (await UserFactory.create()).id, }) .apply('old_token') - .create(); + .create() const response = await client.post('/user/reset').fields({ token: token.token, password: 'password', password_confirmation: 'password', - }); + }) - response.assertTextIncludes('Cannot reset your password'); - }); + response.assertTextIncludes('Cannot reset your password') + }) - test('returns `Cannot reset your password` when token is revoked', async ({ - client, - }) => { + test('returns `Cannot reset your password` when token is revoked', async ({ client }) => { const token = await TokenFactory.merge({ // eslint-disable-next-line unicorn/no-await-expression-member user_id: (await UserFactory.create()).id, }) .apply('revoked') - .create(); + .create() const response = await client.post('/user/reset').fields({ token: token.token, password: 'password', password_confirmation: 'password', - }); + }) - response.assertTextIncludes('Cannot reset your password'); - }); + response.assertTextIncludes('Cannot reset your password') + }) test('correctly resets password and deletes token and able to login with new password', async ({ client, assert, }) => { - const userEmail = 'working-reset-password-login@ferdium.org'; + const userEmail = 'working-reset-password-login@ferdium.org' const token = await TokenFactory.merge({ user_id: ( @@ -98,25 +90,25 @@ test.group('Dashboard / Reset password page', () => { // prettier-ignore // eslint-disable-next-line unicorn/no-await-expression-member ).id, - }).create(); + }).create() const response = await client.post('/user/reset').fields({ token: token.token, password: 'new_password', password_confirmation: 'new_password', - }); + }) // Assert response is as expected - response.assertTextIncludes('Successfully reset your password'); + response.assertTextIncludes('Successfully reset your password') // Token should be deleted from database - assert.isNull(await Token.query().where('token', token.token).first()); + assert.isNull(await Token.query().where('token', token.token).first()) const loginResponse = await client.post('/user/login').fields({ mail: userEmail, password: 'new_password', - }); + }) - loginResponse.assertRedirectsTo('/user/account'); - }); -}); + loginResponse.assertRedirectsTo('/user/account') + }) +}) diff --git a/tests/functional/dashboard/transfer.spec.ts b/tests/functional/dashboard/transfer.spec.ts index e40fca2..41a6709 100644 --- a/tests/functional/dashboard/transfer.spec.ts +++ b/tests/functional/dashboard/transfer.spec.ts @@ -1,80 +1,59 @@ -import { test } from '@japa/runner'; -import { readFileSync } from 'node:fs'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import { readFileSync } from 'node:fs' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Transfer page', () => { - test('redirects to /user/login when accessing /user/transfer as guest', async ({ - client, - }) => { - const response = await client.get('/user/transfer'); + test('redirects to /user/login when accessing /user/transfer as guest', async ({ client }) => { + const response = await client.get('/user/transfer') - response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL - }); + response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL + }) - test('returns a 200 opening the transfer route while being logged in', async ({ - client, - }) => { - const user = await UserFactory.create(); - const response = await client.get('/user/transfer').loginAs(user); + test('returns a 200 opening the transfer route while being logged in', async ({ client }) => { + const user = await UserFactory.create() + const response = await client.get('/user/transfer').loginAs(user) - response.assertStatus(200); - }); + response.assertStatus(200) + }) - test('returns a validation error when not uploading a file', async ({ - client, - }) => { - const user = await UserFactory.create(); - const response = await client.post('/user/transfer').loginAs(user); + test('returns a validation error when not uploading a file', async ({ client }) => { + const user = await UserFactory.create() + const response = await client.post('/user/transfer').loginAs(user) - response.assertTextIncludes('Invalid Ferdium account file'); - }); + response.assertTextIncludes('Invalid Ferdium account file') + }) - test('returns a validation error when trying to use anything but json', async ({ - client, - }) => { - const user = await UserFactory.create(); + test('returns a validation error when trying to use anything but json', async ({ client }) => { + const user = await UserFactory.create() const response = await client .post('/user/transfer') .loginAs(user) - .field( - 'file', - readFileSync('tests/functional/dashboard/import-stubs/random-file.txt'), - ); + .field('file', readFileSync('tests/functional/dashboard/import-stubs/random-file.txt')) - response.assertTextIncludes('Invalid Ferdium account file'); - }); + response.assertTextIncludes('Invalid Ferdium account file') + }) - test('returns a validation error when trying to use anything valid json', async ({ - client, - }) => { - const user = await UserFactory.create(); + test('returns a validation error when trying to use anything valid json', async ({ client }) => { + const user = await UserFactory.create() const response = await client .post('/user/transfer') .loginAs(user) - .field( - 'file', - readFileSync('tests/functional/dashboard/import-stubs/invalid.json'), - ); + .field('file', readFileSync('tests/functional/dashboard/import-stubs/invalid.json')) - response.assertTextIncludes('Invalid Ferdium account file'); - }); + response.assertTextIncludes('Invalid Ferdium account file') + }) test('returns a validation error when trying to use a json file with no ferdium structure', async ({ client, }) => { - const user = await UserFactory.create(); + const user = await UserFactory.create() const response = await client .post('/user/transfer') .loginAs(user) - .field( - 'file', - readFileSync( - 'tests/functional/dashboard/import-stubs/valid-no-data.json', - ), - ); + .field('file', readFileSync('tests/functional/dashboard/import-stubs/valid-no-data.json')) - response.assertTextIncludes('Invalid Ferdium account file'); - }); + response.assertTextIncludes('Invalid Ferdium account file') + }) test('correctly transfers data from json/ferdi-data and ferdium-data file with only workspaces', async ({ client, @@ -85,76 +64,62 @@ test.group('Dashboard / Transfer page', () => { 'workspaces-only.json', 'workspaces-only.ferdi-data', 'workspaces-only.ferdium-data', - ]; + ] for (const file of files) { // eslint-disable-next-line no-await-in-loop - const user = await UserFactory.create(); + const user = await UserFactory.create() // eslint-disable-next-line no-await-in-loop const response = await client .post('/user/transfer') .loginAs(user) - .field( - 'file', - readFileSync(`tests/functional/dashboard/import-stubs/${file}`), - ); - - response.assertTextIncludes( - 'Your account has been imported, you can now login as usual!', - ); + .field('file', readFileSync(`tests/functional/dashboard/import-stubs/${file}`)) + + response.assertTextIncludes('Your account has been imported, you can now login as usual!') // eslint-disable-next-line no-await-in-loop - await user.refresh(); + await user.refresh() // eslint-disable-next-line no-await-in-loop - const workspacesForUser = await user.related('workspaces').query(); - assert.equal(workspacesForUser.length, 3, file); + const workspacesForUser = await user.related('workspaces').query() + assert.equal(workspacesForUser.length, 3, file) // ensure not JSON encoded twice for (const workspace of workspacesForUser) { - assert.isNull(workspace.data.match(/\\"/), file); + assert.isNull(workspace.data.match(/\\"/), file) } } - }); + }) test('correctly transfers data from json/ferdi-data and ferdium-data file with only services', async ({ client, assert, }) => { // Repeat for all 3 file extension - const files = [ - 'services-only.json', - 'services-only.ferdi-data', - 'services-only.ferdium-data', - ]; + const files = ['services-only.json', 'services-only.ferdi-data', 'services-only.ferdium-data'] for (const file of files) { // eslint-disable-next-line no-await-in-loop - const user = await UserFactory.create(); + const user = await UserFactory.create() // eslint-disable-next-line no-await-in-loop const response = await client .post('/user/transfer') .loginAs(user) - .field( - 'file', - readFileSync(`tests/functional/dashboard/import-stubs/${file}`), - ); - - response.assertTextIncludes( - 'Your account has been imported, you can now login as usual!', - ); + .field('file', readFileSync(`tests/functional/dashboard/import-stubs/${file}`)) + + response.assertTextIncludes('Your account has been imported, you can now login as usual!') // eslint-disable-next-line no-await-in-loop - await user.refresh(); + await user.refresh() // eslint-disable-next-line no-await-in-loop - const servicesForUser = await user.related('services').query(); - assert.equal(servicesForUser.length, 3, file); + const servicesForUser = await user.related('services').query() + assert.equal(servicesForUser.length, 3, file) // ensure not JSON encoded twice for (const service of servicesForUser) { - assert.isNull(service.settings.match(/\\"/), file); + assert.isNull(service.settings.match(/\\"/), file) } } - }); + }) test('correctly transfers data from json/ferdi-data and ferdium-data file with workspaces and services', async ({ client, @@ -165,72 +130,57 @@ test.group('Dashboard / Transfer page', () => { 'services-workspaces.json', 'services-workspaces.ferdi-data', 'services-workspaces.ferdium-data', - ]; + ] for (const file of files) { // eslint-disable-next-line no-await-in-loop - const user = await UserFactory.create(); + const user = await UserFactory.create() // eslint-disable-next-line no-await-in-loop const response = await client .post('/user/transfer') .loginAs(user) - .field( - 'file', - readFileSync(`tests/functional/dashboard/import-stubs/${file}`), - ); - - response.assertTextIncludes( - 'Your account has been imported, you can now login as usual!', - ); + .field('file', readFileSync(`tests/functional/dashboard/import-stubs/${file}`)) + + response.assertTextIncludes('Your account has been imported, you can now login as usual!') // eslint-disable-next-line no-await-in-loop - await user.refresh(); + await user.refresh() // eslint-disable-next-line no-await-in-loop - const servicesForUser = await user.related('services').query(); + const servicesForUser = await user.related('services').query() // eslint-disable-next-line no-await-in-loop - const workspacesForUser = await user.related('workspaces').query(); - assert.equal(servicesForUser.length, 3, file); - assert.equal(workspacesForUser.length, 3, file); + const workspacesForUser = await user.related('workspaces').query() + assert.equal(servicesForUser.length, 3, file) + assert.equal(workspacesForUser.length, 3, file) - const firstServiceUuid = servicesForUser.find( - s => s.name === 'random-service-1', - )?.serviceId; + const firstServiceUuid = servicesForUser.find((s) => s.name === 'random-service-1')?.serviceId const secondServiceUuid = servicesForUser.find( - s => s.name === 'random-service-2', - )?.serviceId; - const thirdServiceUUid = servicesForUser.find( - s => s.name === 'random-service-3', - )?.serviceId; + (s) => s.name === 'random-service-2' + )?.serviceId + const thirdServiceUUid = servicesForUser.find((s) => s.name === 'random-service-3')?.serviceId // Assert the first workspace to not have any services - const firstWorkspace = workspacesForUser.find( - w => w.name === 'workspace1', - ); + const firstWorkspace = workspacesForUser.find((w) => w.name === 'workspace1') if (firstWorkspace?.services) { - assert.empty(JSON.parse(firstWorkspace.services), file); + assert.empty(JSON.parse(firstWorkspace.services), file) } - const secondWorkspace = workspacesForUser.find( - w => w.name === 'workspace2', - ); + const secondWorkspace = workspacesForUser.find((w) => w.name === 'workspace2') if (secondWorkspace?.services) { assert.deepEqual( JSON.parse(secondWorkspace.services), [firstServiceUuid, secondServiceUuid], - file, - ); + file + ) } - const thirdWorkspace = workspacesForUser.find( - w => w.name === 'workspace3', - ); + const thirdWorkspace = workspacesForUser.find((w) => w.name === 'workspace3') if (thirdWorkspace?.services) { assert.deepEqual( JSON.parse(thirdWorkspace.services), [firstServiceUuid, secondServiceUuid, thirdServiceUUid], - file, - ); + file + ) } } - }); -}); + }) +}) diff --git a/tests/functional/health.spec.ts b/tests/functional/health.spec.ts index 2f7e074..50bf46c 100644 --- a/tests/functional/health.spec.ts +++ b/tests/functional/health.spec.ts @@ -1,13 +1,13 @@ -import { test } from '@japa/runner'; +import { test } from '@japa/runner' test.group('health page', () => { test('returns a 200 response', async ({ client }) => { - const response = await client.get('/health'); + const response = await client.get('/health') - response.assertStatus(200); + response.assertStatus(200) response.assertBodyContains({ api: 'success', db: 'success', - }); - }); -}); + }) + }) +}) diff --git a/tests/functional/static-pages/home.spec.ts b/tests/functional/static-pages/home.spec.ts index 5054e05..20d02db 100644 --- a/tests/functional/static-pages/home.spec.ts +++ b/tests/functional/static-pages/home.spec.ts @@ -1,10 +1,10 @@ -import { test } from '@japa/runner'; +import { test } from '@japa/runner' test.group('home page', () => { test('returns a 200 response', async ({ client }) => { - const response = await client.get('/'); + const response = await client.get('/') - response.assertStatus(200); - response.assertTextIncludes('Go to account dashboard'); - }); -}); + response.assertStatus(200) + response.assertTextIncludes('Go to account dashboard') + }) +}) diff --git a/tests/functional/static-pages/privacy.spec.ts b/tests/functional/static-pages/privacy.spec.ts index f1d5bec..b79f580 100644 --- a/tests/functional/static-pages/privacy.spec.ts +++ b/tests/functional/static-pages/privacy.spec.ts @@ -1,10 +1,10 @@ -import { test } from '@japa/runner'; +import { test } from '@japa/runner' test.group('privacy page', () => { test('returns a 200 response', async ({ client }) => { - const response = await client.get('/privacy'); + const response = await client.get('/privacy') - response.assertStatus(200); - response.assertTextIncludes('PRIVACY POLICY'); - }); -}); + response.assertStatus(200) + response.assertTextIncludes('PRIVACY POLICY') + }) +}) diff --git a/tests/functional/static-pages/terms.spec.ts b/tests/functional/static-pages/terms.spec.ts index de990e4..9c22257 100644 --- a/tests/functional/static-pages/terms.spec.ts +++ b/tests/functional/static-pages/terms.spec.ts @@ -1,10 +1,10 @@ -import { test } from '@japa/runner'; +import { test } from '@japa/runner' test.group('terms page', () => { test('returns a 200 response', async ({ client }) => { - const response = await client.get('/terms'); + const response = await client.get('/terms') - response.assertStatus(200); - response.assertTextIncludes('Terms of Service'); - }); -}); + response.assertStatus(200) + response.assertTextIncludes('Terms of Service') + }) +}) diff --git a/tests/utils.ts b/tests/utils.ts index 14460b9..b60b867 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -1,6 +1,6 @@ -import View from '@ioc:Adonis/Core/View'; +import edge from 'edge.js' export function fakeCsrfField(): void { // Create fake csrField function in the view - View.global('csrfField', () => ''); + edge.global('csrfField', () => '') } -- cgit v1.2.3-70-g09d2