@live-change/db-admin 0.6.23 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/front/vite.config.js +2 -2
- package/package.json +21 -20
- package/server/init.js +2 -1
- package/server/services.config.js +1 -1
- package/e2e/codecept.conf.js +0 -60
- package/e2e/connectEmailCode.test.js +0 -61
- package/e2e/connectEmailLink.test.js +0 -60
- package/e2e/delete.test.js +0 -44
- package/e2e/disconnectEmail.test.js +0 -42
- package/e2e/resetPasswordWithEmailCode.test.js +0 -62
- package/e2e/resetPasswordWithEmailLink.test.js +0 -62
- package/e2e/setPassword.test.js +0 -70
- package/e2e/signInEmailCode.test.js +0 -52
- package/e2e/signInEmailLink.test.js +0 -52
- package/e2e/signInEmailPassword.test.js +0 -47
- package/e2e/signOut.test.js +0 -41
- package/e2e/signUpEmailCode.test.js +0 -41
- package/e2e/signUpEmailLink.test.js +0 -41
- package/e2e/steps.d.ts +0 -12
- package/e2e/steps_file.js +0 -85
package/front/vite.config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import vuePlugin from '@vitejs/plugin-vue'
|
|
3
3
|
import { defineConfig, searchForWorkspaceRoot } from 'vite'
|
|
4
4
|
import findFreePorts from "find-free-ports"
|
|
5
5
|
import { visualizer } from 'rollup-plugin-visualizer'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/db-admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"memDev": "lcli memDev --initScript ./init.js --dbAccess",
|
|
6
6
|
"localDevInit": "rm tmp.db; lcli localDev --initScript ./init.js --dbAccess",
|
|
@@ -16,16 +16,17 @@
|
|
|
16
16
|
"generate": "vite build --ssrManifest --outDir dist/static && yarn build:server && node prerender",
|
|
17
17
|
"debug": "node --inspect-brk server"
|
|
18
18
|
},
|
|
19
|
+
"type": "module",
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@live-change/cli": "0.7.
|
|
21
|
+
"@live-change/cli": "0.7.39",
|
|
21
22
|
"@live-change/dao": "0.5.22",
|
|
22
23
|
"@live-change/dao-vue3": "0.5.22",
|
|
23
24
|
"@live-change/dao-websocket": "0.5.22",
|
|
24
|
-
"@live-change/framework": "0.7.
|
|
25
|
-
"@live-change/vue3-components": "0.2.
|
|
26
|
-
"@live-change/vue3-ssr": "0.2.
|
|
27
|
-
"@vitejs/plugin-vue": "^
|
|
28
|
-
"@vueuse/core": "^10.
|
|
25
|
+
"@live-change/framework": "0.7.39",
|
|
26
|
+
"@live-change/vue3-components": "0.2.34",
|
|
27
|
+
"@live-change/vue3-ssr": "0.2.34",
|
|
28
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
29
|
+
"@vueuse/core": "^10.7.2",
|
|
29
30
|
"@vueuse/head": "^2.0.0",
|
|
30
31
|
"codeceptjs-assert": "^0.0.5",
|
|
31
32
|
"compression": "^1.7.4",
|
|
@@ -34,33 +35,33 @@
|
|
|
34
35
|
"javascript-stringify": "^2.1.0",
|
|
35
36
|
"primeflex": "^3.3.1",
|
|
36
37
|
"primeicons": "^6.0.1",
|
|
37
|
-
"primevue": "^3.
|
|
38
|
+
"primevue": "^3.48.1",
|
|
38
39
|
"prism-es6": "^1.2.0",
|
|
39
|
-
"prismjs": "^1.
|
|
40
|
+
"prismjs": "^1.29.0",
|
|
40
41
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
41
|
-
"rollup-plugin-visualizer": "5.
|
|
42
|
-
"serialize-javascript": "^6.0.
|
|
42
|
+
"rollup-plugin-visualizer": "5.12.0",
|
|
43
|
+
"serialize-javascript": "^6.0.2",
|
|
43
44
|
"serve-static": "^1.15.0",
|
|
44
45
|
"v-shared-element": "3.1.1",
|
|
45
46
|
"vite-plugin-compression": "^0.5.1",
|
|
46
47
|
"vite-plugin-vue-images": "^0.6.1",
|
|
47
|
-
"vue": "^3.
|
|
48
|
+
"vue": "^3.4.19",
|
|
48
49
|
"vue-prism-editor": "2.0.0-alpha.2",
|
|
49
|
-
"vue-router": "^4.2.
|
|
50
|
-
"vue3-scroll-border": "0.1.
|
|
50
|
+
"vue-router": "^4.2.5",
|
|
51
|
+
"vue3-scroll-border": "0.1.6"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@live-change/codeceptjs-helper": "0.7.
|
|
54
|
+
"@live-change/codeceptjs-helper": "0.7.39",
|
|
54
55
|
"@wdio/selenium-standalone-service": "^8.15.0",
|
|
55
|
-
"codeceptjs": "^3.5.
|
|
56
|
-
"generate-password": "1.7.
|
|
57
|
-
"playwright": "^1.
|
|
56
|
+
"codeceptjs": "^3.5.12",
|
|
57
|
+
"generate-password": "1.7.1",
|
|
58
|
+
"playwright": "^1.41.2",
|
|
58
59
|
"random-profile-generator": "^2.3.0",
|
|
59
60
|
"txtgen": "^3.0.6",
|
|
60
|
-
"webdriverio": "^8.
|
|
61
|
+
"webdriverio": "^8.31.1"
|
|
61
62
|
},
|
|
62
63
|
"author": "",
|
|
63
64
|
"license": "ISC",
|
|
64
65
|
"description": "",
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "b372725d436e29f7cc66b811533009c9ea5330a1"
|
|
66
67
|
}
|
package/server/init.js
CHANGED
package/e2e/codecept.conf.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const { devices } = require('playwright');
|
|
2
|
-
|
|
3
|
-
const testServerPort = process.env.TEST_URL ? 0 : require('get-port-sync')()
|
|
4
|
-
const testServerUrl = process.env.TEST_URL || `http://localhost:${testServerPort}`
|
|
5
|
-
|
|
6
|
-
const device = devices['Pixel 2']
|
|
7
|
-
|
|
8
|
-
exports.config = {
|
|
9
|
-
tests: './*.test.js',
|
|
10
|
-
output: './output',
|
|
11
|
-
helpers: {
|
|
12
|
-
LiveChange: {
|
|
13
|
-
require: '@live-change/codeceptjs-helper',
|
|
14
|
-
startServer: !process.env.TEST_URL,
|
|
15
|
-
enableSessions: true,
|
|
16
|
-
initScript: "./init.js",
|
|
17
|
-
port: testServerPort,
|
|
18
|
-
dev: true
|
|
19
|
-
},
|
|
20
|
-
VideoHelper: {
|
|
21
|
-
require: 'codeceptjs-video-helper'
|
|
22
|
-
},
|
|
23
|
-
AssertWrapper : {
|
|
24
|
-
require: "codeceptjs-assert"
|
|
25
|
-
},
|
|
26
|
-
Playwright: {
|
|
27
|
-
browser: 'chromium',
|
|
28
|
-
url: testServerUrl,
|
|
29
|
-
show: true,
|
|
30
|
-
emulate: {
|
|
31
|
-
...device,
|
|
32
|
-
recordVideo: process.env.RECORD_TESTS ? {
|
|
33
|
-
dir: "./output",
|
|
34
|
-
//size: { width: 1080, height: 1920 }
|
|
35
|
-
} : undefined,
|
|
36
|
-
},
|
|
37
|
-
chromium: {
|
|
38
|
-
args: [`--force-device-scale-factor=${device.deviceScaleFactor}`]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
include: {
|
|
43
|
-
I: './steps_file.js'
|
|
44
|
-
},
|
|
45
|
-
bootstrap: null,
|
|
46
|
-
mocha: {},
|
|
47
|
-
name: 'e2e',
|
|
48
|
-
plugins: {
|
|
49
|
-
pauseOnFail: {},
|
|
50
|
-
retryFailedStep: {
|
|
51
|
-
enabled: true
|
|
52
|
-
},
|
|
53
|
-
tryTo: {
|
|
54
|
-
enabled: true
|
|
55
|
-
},
|
|
56
|
-
screenshotOnFail: {
|
|
57
|
-
enabled: true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
5
|
-
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
6
|
-
|
|
7
|
-
const happyPath = false
|
|
8
|
-
|
|
9
|
-
Feature('user')
|
|
10
|
-
|
|
11
|
-
Scenario('connect email with code', async ({ I }) => {
|
|
12
|
-
|
|
13
|
-
const user = app.generateUid()
|
|
14
|
-
|
|
15
|
-
const User = await I.haveModel('user', 'User')
|
|
16
|
-
const Email = await I.haveModel('email', 'Email')
|
|
17
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
I.amOnPage('/')
|
|
22
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
-
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
-
|
|
25
|
-
I.amOnPage('/connected')
|
|
26
|
-
I.see(email)
|
|
27
|
-
I.dontSee(email2)
|
|
28
|
-
|
|
29
|
-
I.click('button#connect')
|
|
30
|
-
|
|
31
|
-
I.seeInCurrentUrl('/connect')
|
|
32
|
-
|
|
33
|
-
if(!happyPath) {
|
|
34
|
-
I.fillField('input#email', email)
|
|
35
|
-
I.click('button[type=submit]')
|
|
36
|
-
I.seeInCurrentUrl('/connect')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
I.fillField('input#email', email2)
|
|
40
|
-
I.click('button[type=submit]')
|
|
41
|
-
|
|
42
|
-
I.seeInCurrentUrl('/sent/')
|
|
43
|
-
|
|
44
|
-
const url = await I.grabCurrentUrl()
|
|
45
|
-
const authentication = url.split('/').pop()
|
|
46
|
-
|
|
47
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
48
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
49
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
50
|
-
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
51
|
-
|
|
52
|
-
await I.useSecretCode(authentication, happyPath)
|
|
53
|
-
|
|
54
|
-
I.seeInCurrentUrl('/connect-finished')
|
|
55
|
-
|
|
56
|
-
if(!happyPath) {
|
|
57
|
-
I.amOnPage(url)
|
|
58
|
-
I.seeInCurrentUrl('/connect-finished')
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
})
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
5
|
-
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
6
|
-
|
|
7
|
-
const happyPath = false
|
|
8
|
-
|
|
9
|
-
Feature('user')
|
|
10
|
-
|
|
11
|
-
Scenario('sign in with email link', async ({ I }) => {
|
|
12
|
-
|
|
13
|
-
const user = app.generateUid()
|
|
14
|
-
|
|
15
|
-
const User = await I.haveModel('user', 'User')
|
|
16
|
-
const Email = await I.haveModel('email', 'Email')
|
|
17
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
I.amOnPage('/')
|
|
22
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
-
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
-
|
|
25
|
-
I.amOnPage('/connected')
|
|
26
|
-
I.see(email)
|
|
27
|
-
I.dontSee(email2)
|
|
28
|
-
|
|
29
|
-
I.click('button#connect')
|
|
30
|
-
|
|
31
|
-
I.seeInCurrentUrl('/connect')
|
|
32
|
-
|
|
33
|
-
if(!happyPath) {
|
|
34
|
-
I.fillField('input#email', email)
|
|
35
|
-
I.click('button[type=submit]')
|
|
36
|
-
I.see('')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
I.fillField('input#email', email2)
|
|
40
|
-
I.click('button[type=submit]')
|
|
41
|
-
|
|
42
|
-
I.seeInCurrentUrl('/sent/')
|
|
43
|
-
const url = await I.grabCurrentUrl()
|
|
44
|
-
const authentication = url.split('/').pop()
|
|
45
|
-
|
|
46
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
47
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
48
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
49
|
-
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
50
|
-
|
|
51
|
-
const linkData = await I.useSecretLink(authentication, happyPath)
|
|
52
|
-
|
|
53
|
-
I.seeInCurrentUrl('/connect-finished')
|
|
54
|
-
|
|
55
|
-
if(!happyPath) {
|
|
56
|
-
I.amOnPage('/link/' + linkData.secretCode)
|
|
57
|
-
I.see('Link used')
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
})
|
package/e2e/delete.test.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const name = randomProfile.profile().firstName.toLowerCase()
|
|
5
|
-
const email = name + '@test.com' // test domain - emails not sent
|
|
6
|
-
|
|
7
|
-
const happyPath = false
|
|
8
|
-
|
|
9
|
-
Feature('user')
|
|
10
|
-
|
|
11
|
-
Scenario('delete account', async ({ I }) => {
|
|
12
|
-
|
|
13
|
-
const user = app.generateUid()
|
|
14
|
-
|
|
15
|
-
const User = await I.haveModel('user', 'User')
|
|
16
|
-
const Email = await I.haveModel('email', 'Email')
|
|
17
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
I.amOnPage('/')
|
|
22
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
-
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
-
|
|
25
|
-
await I.wait(0.2)
|
|
26
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
27
|
-
I.assert(user, clientUser, 'client logged in')
|
|
28
|
-
|
|
29
|
-
I.amOnPage('/delete')
|
|
30
|
-
I.click('.p-checkbox-box')
|
|
31
|
-
I.click('button#delete')
|
|
32
|
-
|
|
33
|
-
I.seeInCurrentUrl('/delete-finished')
|
|
34
|
-
|
|
35
|
-
await I.wait(0.3)
|
|
36
|
-
const clientUserAfterDelete = await I.executeScript(() => api.client.value.user)
|
|
37
|
-
I.assert(!!clientUserAfterDelete, false, 'user logged out')
|
|
38
|
-
|
|
39
|
-
const deletedUser = await User.get(user)
|
|
40
|
-
I.assert(!!deletedUser, false, 'user deleted')
|
|
41
|
-
|
|
42
|
-
const deletedEmail = await Email.get(email)
|
|
43
|
-
I.assert(!!deletedEmail, false, 'email deleted')
|
|
44
|
-
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const name = randomProfile.profile().firstName.toLowerCase()
|
|
5
|
-
const email = name + '@test.com' // test domain - emails not sent
|
|
6
|
-
const email2 = name + '2@test.com' // test domain - emails not sent
|
|
7
|
-
|
|
8
|
-
const happyPath = false
|
|
9
|
-
|
|
10
|
-
Feature('user')
|
|
11
|
-
|
|
12
|
-
Scenario('disconnect email', async ({ I }) => {
|
|
13
|
-
|
|
14
|
-
const user = app.generateUid()
|
|
15
|
-
|
|
16
|
-
const User = await I.haveModel('user', 'User')
|
|
17
|
-
const Email = await I.haveModel('email', 'Email')
|
|
18
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
19
|
-
|
|
20
|
-
await User.create({ id: user, roles: [] })
|
|
21
|
-
await Email.create({ id: email, email, user })
|
|
22
|
-
await Email.create({ id: email2, email: email2, user })
|
|
23
|
-
I.amOnPage('/')
|
|
24
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
25
|
-
await AuthenticatedUser.create({ id: session, user, session })
|
|
26
|
-
|
|
27
|
-
I.amOnPage('/connected')
|
|
28
|
-
I.see(email)
|
|
29
|
-
I.see(email2)
|
|
30
|
-
|
|
31
|
-
I.click('span.pi-times') // delete button
|
|
32
|
-
I.click('Yes')
|
|
33
|
-
|
|
34
|
-
I.dontSee(email2)
|
|
35
|
-
|
|
36
|
-
if(!happyPath) {
|
|
37
|
-
I.dontSeeElement('span.pi-times') // delete button
|
|
38
|
-
//I.click('Yes')
|
|
39
|
-
//I.see(email)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
})
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
const passwordGenerator = require('generate-password')
|
|
4
|
-
|
|
5
|
-
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
-
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
7
|
-
|
|
8
|
-
const happyPath = false
|
|
9
|
-
|
|
10
|
-
Feature('user')
|
|
11
|
-
|
|
12
|
-
Scenario('reset password with email code', async ({ I }) => {
|
|
13
|
-
|
|
14
|
-
const user = app.generateUid()
|
|
15
|
-
|
|
16
|
-
const User = await I.haveModel('user', 'User')
|
|
17
|
-
const Email = await I.haveModel('email', 'Email')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
I.amOnPage('/')
|
|
22
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
-
|
|
24
|
-
I.amOnPage('/reset-password')
|
|
25
|
-
I.fillField('input#email', email)
|
|
26
|
-
|
|
27
|
-
I.click('button[type=submit]')
|
|
28
|
-
|
|
29
|
-
I.seeInCurrentUrl('/sent')
|
|
30
|
-
let url = await I.grabCurrentUrl()
|
|
31
|
-
const authentication = url.split('/').pop()
|
|
32
|
-
|
|
33
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
34
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
35
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
36
|
-
I.assert(authenticationData?.messageData?.user, user, 'authentication message data contains user')
|
|
37
|
-
I.assert(authenticationData?.actionProperties?.user, user, 'authentication action properties contains user')
|
|
38
|
-
|
|
39
|
-
await I.useSecretCode(authentication, happyPath)
|
|
40
|
-
|
|
41
|
-
I.seeInCurrentUrl('/set-new-password/')
|
|
42
|
-
url = await I.grabCurrentUrl()
|
|
43
|
-
const resetPasswordAuthentication = url.split('/').pop()
|
|
44
|
-
await I.wait(0.1)
|
|
45
|
-
const ResetPasswordAuthentication = await I.haveModel('passwordAuthentication', 'ResetPasswordAuthentication')
|
|
46
|
-
const resetPasswordAuthenticationData =
|
|
47
|
-
await ResetPasswordAuthentication.indexObjectGet('byKey', resetPasswordAuthentication)
|
|
48
|
-
I.assert(!!resetPasswordAuthenticationData, true, 'reset password authentication created')
|
|
49
|
-
|
|
50
|
-
I.see('Reset password')
|
|
51
|
-
|
|
52
|
-
const password = passwordGenerator.generate({
|
|
53
|
-
length: 10,
|
|
54
|
-
numbers: true
|
|
55
|
-
})+(Math.random()*10).toFixed()
|
|
56
|
-
I.fillField('input#newPassword', password)
|
|
57
|
-
I.fillField('input#reenterPassword', password)
|
|
58
|
-
|
|
59
|
-
I.click('button[type=submit]')
|
|
60
|
-
I.seeInCurrentUrl('/reset-password-finished')
|
|
61
|
-
|
|
62
|
-
})
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
const passwordGenerator = require('generate-password')
|
|
4
|
-
|
|
5
|
-
const email = randomProfile.profile().firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
-
const email2 = randomProfile.profile().firstName.toLowerCase() + '2@test.com' // test domain - emails not sent
|
|
7
|
-
|
|
8
|
-
const happyPath = false
|
|
9
|
-
|
|
10
|
-
Feature('user')
|
|
11
|
-
|
|
12
|
-
Scenario('reset password with email code', async ({ I }) => {
|
|
13
|
-
|
|
14
|
-
const user = app.generateUid()
|
|
15
|
-
|
|
16
|
-
const User = await I.haveModel('user', 'User')
|
|
17
|
-
const Email = await I.haveModel('email', 'Email')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
I.amOnPage('/')
|
|
22
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
-
|
|
24
|
-
I.amOnPage('/reset-password')
|
|
25
|
-
I.fillField('input#email', email)
|
|
26
|
-
|
|
27
|
-
I.click('button[type=submit]')
|
|
28
|
-
|
|
29
|
-
I.seeInCurrentUrl('/sent')
|
|
30
|
-
let url = await I.grabCurrentUrl()
|
|
31
|
-
const authentication = url.split('/').pop()
|
|
32
|
-
|
|
33
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
34
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
35
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
36
|
-
I.assert(authenticationData?.messageData?.user, user, 'authentication message data contains user')
|
|
37
|
-
I.assert(authenticationData?.actionProperties?.user, user, 'authentication action properties contains user')
|
|
38
|
-
|
|
39
|
-
await I.useSecretLink(authentication, happyPath)
|
|
40
|
-
|
|
41
|
-
I.seeInCurrentUrl('/set-new-password/')
|
|
42
|
-
url = await I.grabCurrentUrl()
|
|
43
|
-
const resetPasswordAuthentication = url.split('/').pop()
|
|
44
|
-
await I.wait(0.1)
|
|
45
|
-
const ResetPasswordAuthentication = await I.haveModel('passwordAuthentication', 'ResetPasswordAuthentication')
|
|
46
|
-
const resetPasswordAuthenticationData =
|
|
47
|
-
await ResetPasswordAuthentication.indexObjectGet('byKey', resetPasswordAuthentication)
|
|
48
|
-
I.assert(!!resetPasswordAuthenticationData, true, 'reset password authentication created')
|
|
49
|
-
|
|
50
|
-
I.see('Reset password')
|
|
51
|
-
|
|
52
|
-
const password = passwordGenerator.generate({
|
|
53
|
-
length: 10,
|
|
54
|
-
numbers: true
|
|
55
|
-
})+(Math.random()*10).toFixed()
|
|
56
|
-
I.fillField('input#newPassword', password)
|
|
57
|
-
I.fillField('input#reenterPassword', password)
|
|
58
|
-
I.click('button[type=submit]')
|
|
59
|
-
|
|
60
|
-
I.seeInCurrentUrl('/reset-password-finished')
|
|
61
|
-
|
|
62
|
-
})
|
package/e2e/setPassword.test.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
const passwordGenerator = require('generate-password')
|
|
4
|
-
|
|
5
|
-
const name = randomProfile.profile().firstName.toLowerCase()
|
|
6
|
-
const email = name + '@test.com' // test domain - emails not sent
|
|
7
|
-
|
|
8
|
-
const happyPath = false
|
|
9
|
-
|
|
10
|
-
Feature('user')
|
|
11
|
-
|
|
12
|
-
Scenario('setPassword', async ({ I }) => {
|
|
13
|
-
|
|
14
|
-
const user = app.generateUid()
|
|
15
|
-
|
|
16
|
-
const User = await I.haveModel('user', 'User')
|
|
17
|
-
const Email = await I.haveModel('email', 'Email')
|
|
18
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
19
|
-
const PasswordAuthentication = await I.haveModel('passwordAuthentication', 'PasswordAuthentication')
|
|
20
|
-
|
|
21
|
-
await User.create({ id: user, roles: [] })
|
|
22
|
-
await Email.create({ id: email, email, user })
|
|
23
|
-
I.amOnPage('/')
|
|
24
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
25
|
-
await AuthenticatedUser.create({ id: session, user, session })
|
|
26
|
-
|
|
27
|
-
await I.wait(0.2)
|
|
28
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
29
|
-
I.assert(user, clientUser, 'client logged in')
|
|
30
|
-
|
|
31
|
-
const emptyPasswordAuthenticationData = await PasswordAuthentication.get(user)
|
|
32
|
-
I.assert(emptyPasswordAuthenticationData, null, 'password not set')
|
|
33
|
-
|
|
34
|
-
I.amOnPage('/change-password')
|
|
35
|
-
I.see('Set password')
|
|
36
|
-
|
|
37
|
-
const firstPassword = passwordGenerator.generate({
|
|
38
|
-
length: 10,
|
|
39
|
-
numbers: true
|
|
40
|
-
})+(Math.random()*10).toFixed()
|
|
41
|
-
I.fillField('input#newPassword', firstPassword)
|
|
42
|
-
I.fillField('input#reenterPassword', firstPassword)
|
|
43
|
-
I.click('button[type=submit]')
|
|
44
|
-
|
|
45
|
-
I.seeInCurrentUrl('/change-password-finished')
|
|
46
|
-
|
|
47
|
-
await I.wait(0.2)
|
|
48
|
-
const firstPasswordAuthenticationData = await PasswordAuthentication.get(user)
|
|
49
|
-
I.assert(!!firstPasswordAuthenticationData, true, 'password set')
|
|
50
|
-
|
|
51
|
-
I.amOnPage('/change-password')
|
|
52
|
-
I.see('Change password')
|
|
53
|
-
|
|
54
|
-
const secondPassword = passwordGenerator.generate({
|
|
55
|
-
length: 10,
|
|
56
|
-
numbers: true
|
|
57
|
-
})+(Math.random()*10).toFixed()
|
|
58
|
-
|
|
59
|
-
I.fillField('input#currentPassword', firstPassword)
|
|
60
|
-
I.fillField('input#newPassword', secondPassword)
|
|
61
|
-
I.fillField('input#reenterPassword', secondPassword)
|
|
62
|
-
I.click('button[type=submit]')
|
|
63
|
-
|
|
64
|
-
await I.wait(0.2)
|
|
65
|
-
const secondPasswordAuthenticationData = await PasswordAuthentication.get(user)
|
|
66
|
-
I.assert(!!secondPasswordAuthenticationData, true, 'password set')
|
|
67
|
-
I.assertNotEqual(secondPasswordAuthenticationData.passwordHash, firstPasswordAuthenticationData.passwordHash,
|
|
68
|
-
'password changed')
|
|
69
|
-
|
|
70
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const randomUserData = randomProfile.profile()
|
|
5
|
-
randomUserData.email = randomUserData.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
-
|
|
7
|
-
const happyPath = false
|
|
8
|
-
|
|
9
|
-
Feature('user')
|
|
10
|
-
|
|
11
|
-
Scenario('sign in with email code', async ({ I }) => {
|
|
12
|
-
|
|
13
|
-
const user = app.generateUid()
|
|
14
|
-
const email = randomUserData.email
|
|
15
|
-
|
|
16
|
-
const User = await I.haveModel('user', 'User')
|
|
17
|
-
const Email = await I.haveModel('email', 'Email')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
|
|
22
|
-
I.amOnPage('/sign-in')
|
|
23
|
-
I.fillField('input#email', email)
|
|
24
|
-
I.click('button[type=submit]')
|
|
25
|
-
|
|
26
|
-
I.seeInCurrentUrl('/sent/')
|
|
27
|
-
const url = await I.grabCurrentUrl()
|
|
28
|
-
const authentication = url.split('/').pop()
|
|
29
|
-
|
|
30
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
31
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
32
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
33
|
-
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
34
|
-
|
|
35
|
-
await I.useSecretCode(authentication, happyPath)
|
|
36
|
-
|
|
37
|
-
I.seeInCurrentUrl('/sign-in-finished')
|
|
38
|
-
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
39
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
40
|
-
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
41
|
-
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
42
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
43
|
-
console.log("CLIENT USER", clientUser)
|
|
44
|
-
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
45
|
-
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
46
|
-
|
|
47
|
-
if(!happyPath) {
|
|
48
|
-
I.amOnPage(url)
|
|
49
|
-
I.seeInCurrentUrl('/sign-in-finished')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const randomUserData = randomProfile.profile()
|
|
5
|
-
randomUserData.email = randomUserData.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
6
|
-
|
|
7
|
-
const happyPath = false
|
|
8
|
-
|
|
9
|
-
Feature('user')
|
|
10
|
-
|
|
11
|
-
Scenario('sign in with email link', async ({ I }) => {
|
|
12
|
-
|
|
13
|
-
const user = app.generateUid()
|
|
14
|
-
const email = randomUserData.email
|
|
15
|
-
|
|
16
|
-
const User = await I.haveModel('user', 'User')
|
|
17
|
-
const Email = await I.haveModel('email', 'Email')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
|
|
22
|
-
I.amOnPage('/sign-in')
|
|
23
|
-
I.fillField('input#email', email)
|
|
24
|
-
I.click('button[type=submit]')
|
|
25
|
-
|
|
26
|
-
I.seeInCurrentUrl('/sent/')
|
|
27
|
-
const url = await I.grabCurrentUrl()
|
|
28
|
-
const authentication = url.split('/').pop()
|
|
29
|
-
|
|
30
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
31
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
32
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
33
|
-
I.assert(authenticationData?.messageData?.user, user, 'authentication contains user')
|
|
34
|
-
|
|
35
|
-
const linkData = await I.useSecretLink(authentication, happyPath)
|
|
36
|
-
|
|
37
|
-
I.seeInCurrentUrl('/sign-in-finished')
|
|
38
|
-
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
39
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
40
|
-
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
41
|
-
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
42
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
43
|
-
console.log("CLIENT USER", clientUser)
|
|
44
|
-
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
45
|
-
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
46
|
-
|
|
47
|
-
if(!happyPath) {
|
|
48
|
-
I.amOnPage('/link/' + linkData.secretCode)
|
|
49
|
-
I.see('Link used')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
})
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
const crypto = require('crypto')
|
|
4
|
-
const passwordGenerator = require('generate-password')
|
|
5
|
-
|
|
6
|
-
const randomUserData = randomProfile.profile()
|
|
7
|
-
randomUserData.email = randomUserData.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
8
|
-
|
|
9
|
-
const happyPath = false
|
|
10
|
-
|
|
11
|
-
Feature('user')
|
|
12
|
-
|
|
13
|
-
Scenario('sign in with email and password', async ({ I }) => {
|
|
14
|
-
|
|
15
|
-
const user = app.generateUid()
|
|
16
|
-
const email = randomUserData.email
|
|
17
|
-
const password = passwordGenerator.generate({
|
|
18
|
-
length: 10,
|
|
19
|
-
numbers: true
|
|
20
|
-
})+(Math.random()*10).toFixed()
|
|
21
|
-
const passwordHash = crypto.createHash('sha256').update(password).digest('hex')
|
|
22
|
-
|
|
23
|
-
const User = await I.haveModel('user', 'User')
|
|
24
|
-
const Email = await I.haveModel('email', 'Email')
|
|
25
|
-
const PasswordAuthentication = await I.haveModel('passwordAuthentication', 'PasswordAuthentication')
|
|
26
|
-
|
|
27
|
-
await User.create({ id: user, roles: [] })
|
|
28
|
-
await Email.create({ id: email, email, user })
|
|
29
|
-
await PasswordAuthentication.create({ id: user, user, passwordHash })
|
|
30
|
-
|
|
31
|
-
I.amOnPage('/sign-in')
|
|
32
|
-
I.fillField('input#email', email)
|
|
33
|
-
I.fillField('input#password', password)
|
|
34
|
-
I.click('button[type=submit]')
|
|
35
|
-
|
|
36
|
-
I.seeInCurrentUrl('/sign-in-finished')
|
|
37
|
-
await I.wait(0.2)
|
|
38
|
-
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
39
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
40
|
-
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
41
|
-
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
42
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
43
|
-
console.log("CLIENT USER", clientUser)
|
|
44
|
-
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
45
|
-
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
46
|
-
|
|
47
|
-
})
|
package/e2e/signOut.test.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const app = require('@live-change/framework').app()
|
|
2
|
-
const randomProfile = require('random-profile-generator')
|
|
3
|
-
|
|
4
|
-
const name = randomProfile.profile().firstName.toLowerCase()
|
|
5
|
-
const email = name + '@test.com' // test domain - emails not sent
|
|
6
|
-
|
|
7
|
-
const happyPath = false
|
|
8
|
-
|
|
9
|
-
Feature('user')
|
|
10
|
-
|
|
11
|
-
Scenario('sign out', async ({ I }) => {
|
|
12
|
-
|
|
13
|
-
const user = app.generateUid()
|
|
14
|
-
|
|
15
|
-
const User = await I.haveModel('user', 'User')
|
|
16
|
-
const Email = await I.haveModel('email', 'Email')
|
|
17
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
18
|
-
|
|
19
|
-
await User.create({ id: user, roles: [] })
|
|
20
|
-
await Email.create({ id: email, email, user })
|
|
21
|
-
I.amOnPage('/')
|
|
22
|
-
const session = await I.executeScript(() => api.client.value.session)
|
|
23
|
-
await AuthenticatedUser.create({ id: session, user, session })
|
|
24
|
-
|
|
25
|
-
await I.wait(0.2)
|
|
26
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
27
|
-
I.assert(user, clientUser, 'client logged in')
|
|
28
|
-
|
|
29
|
-
I.amOnPage('/sign-out')
|
|
30
|
-
I.seeInCurrentUrl('/sign-out-finished')
|
|
31
|
-
|
|
32
|
-
await I.wait(1.0)
|
|
33
|
-
const clientUser2 = await I.executeScript(() => api.client.value.user)
|
|
34
|
-
console.log("CLIENT USER2", clientUser2)
|
|
35
|
-
const authenticatedUserData = await AuthenticatedUser.get(session)
|
|
36
|
-
console.log("AUTHENTICATED USER", authenticatedUserData)
|
|
37
|
-
|
|
38
|
-
I.assert(!!authenticatedUserData, false, 'no server user')
|
|
39
|
-
I.assert(!!clientUser2, false, 'no client user')
|
|
40
|
-
|
|
41
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const randomProfile = require('random-profile-generator')
|
|
2
|
-
|
|
3
|
-
const user = randomProfile.profile()
|
|
4
|
-
user.email = user.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
5
|
-
|
|
6
|
-
const happyPath = false
|
|
7
|
-
|
|
8
|
-
Feature('user')
|
|
9
|
-
|
|
10
|
-
Scenario('sign up with email code', async ({ I }) => {
|
|
11
|
-
|
|
12
|
-
I.amOnPage('/sign-up')
|
|
13
|
-
I.fillField('input#email', user.email)
|
|
14
|
-
I.click('button[type=submit]')
|
|
15
|
-
|
|
16
|
-
I.seeInCurrentUrl('/sent/')
|
|
17
|
-
const url = await I.grabCurrentUrl()
|
|
18
|
-
const authentication = url.split('/').pop()
|
|
19
|
-
|
|
20
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
21
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
22
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
23
|
-
|
|
24
|
-
await I.useSecretCode(authentication, happyPath)
|
|
25
|
-
|
|
26
|
-
I.seeInCurrentUrl('/sign-up-finished')
|
|
27
|
-
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
28
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
29
|
-
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
30
|
-
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
31
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
32
|
-
console.log("CLIENT USER", clientUser)
|
|
33
|
-
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
34
|
-
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
35
|
-
|
|
36
|
-
if(!happyPath) {
|
|
37
|
-
I.amOnPage(url)
|
|
38
|
-
I.seeInCurrentUrl('/sign-up-finished')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const randomProfile = require('random-profile-generator')
|
|
2
|
-
|
|
3
|
-
const user = randomProfile.profile()
|
|
4
|
-
user.email = user.firstName.toLowerCase() + '@test.com' // test domain - emails not sent
|
|
5
|
-
|
|
6
|
-
const happyPath = false
|
|
7
|
-
|
|
8
|
-
Feature('user')
|
|
9
|
-
|
|
10
|
-
Scenario('sign up with email link', async ({ I }) => {
|
|
11
|
-
|
|
12
|
-
I.amOnPage('/sign-up')
|
|
13
|
-
I.fillField('input#email', user.email)
|
|
14
|
-
I.click('button[type=submit]')
|
|
15
|
-
|
|
16
|
-
I.seeInCurrentUrl('/sent/')
|
|
17
|
-
const url = await I.grabCurrentUrl()
|
|
18
|
-
const authentication = url.split('/').pop()
|
|
19
|
-
|
|
20
|
-
const authenticationData = await I.grabObject('messageAuthentication', 'Authentication', authentication)
|
|
21
|
-
console.log("AUTHENTICATION DATA", authenticationData)
|
|
22
|
-
I.assert(!!authenticationData, true, 'authentication created')
|
|
23
|
-
|
|
24
|
-
const linkData = await I.useSecretLink(authentication, happyPath)
|
|
25
|
-
|
|
26
|
-
I.seeInCurrentUrl('/sign-up-finished')
|
|
27
|
-
const clientSession = await I.executeScript(() => api.client.value.session)
|
|
28
|
-
const AuthenticatedUser = await I.haveModel('user', 'AuthenticatedUser')
|
|
29
|
-
const authenticatedUserData = await AuthenticatedUser.get(clientSession)
|
|
30
|
-
I.assert(!!authenticatedUserData, true, 'user authenticated server-side')
|
|
31
|
-
const clientUser = await I.executeScript(() => api.client.value.user)
|
|
32
|
-
console.log("CLIENT USER", clientUser)
|
|
33
|
-
console.log("SERVER AUTHENTICATION", authenticatedUserData)
|
|
34
|
-
I.assert(clientUser, authenticatedUserData.user, 'user authenticated')
|
|
35
|
-
|
|
36
|
-
if(!happyPath) {
|
|
37
|
-
I.amOnPage('/link/' + linkData.secretCode)
|
|
38
|
-
I.see('Link used')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
})
|
package/e2e/steps.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types='codeceptjs' />
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
type steps_file = typeof import('./steps_file.js');
|
|
4
|
-
|
|
5
|
-
declare namespace CodeceptJS {
|
|
6
|
-
interface SupportObject { I: I, current: any }
|
|
7
|
-
interface Methods extends Playwright {}
|
|
8
|
-
interface I extends ReturnType<steps_file> {}
|
|
9
|
-
namespace Translation {
|
|
10
|
-
interface Actions {}
|
|
11
|
-
}
|
|
12
|
-
}
|
package/e2e/steps_file.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// in this file you can append custom step methods to 'I' object
|
|
2
|
-
|
|
3
|
-
module.exports = function() {
|
|
4
|
-
return actor({
|
|
5
|
-
|
|
6
|
-
async useSecretCode(authentication, happyPath) {
|
|
7
|
-
const I = this
|
|
8
|
-
const Code = await I.haveModel('secretCode', 'Code')
|
|
9
|
-
let codeData = await Code.indexObjectGet('byAuthentication', authentication)
|
|
10
|
-
console.log("CODE DATA", codeData)
|
|
11
|
-
I.assert(!!codeData, true, 'code created')
|
|
12
|
-
|
|
13
|
-
if(!happyPath) {
|
|
14
|
-
const wrongCode = codeData.secretCode == '123456' ? '654321' : '123456'
|
|
15
|
-
I.fillField('input#code', wrongCode)
|
|
16
|
-
I.fillField('input#code', wrongCode) /// twice because it can fail once with this type of field
|
|
17
|
-
I.click('button[type=submit]')
|
|
18
|
-
I.seeElement('#code-help.p-error')
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if(!happyPath) {
|
|
22
|
-
await I.wait(0.2)
|
|
23
|
-
await Code.update(codeData.id, { expire: new Date() }) // expire now
|
|
24
|
-
I.fillField('input#code', codeData.secretCode)
|
|
25
|
-
I.fillField('input#code', codeData.secretCode) /// twice because it can fail once with this type of field
|
|
26
|
-
I.click('button[type=submit]')
|
|
27
|
-
I.seeElement('#code-help.p-error')
|
|
28
|
-
|
|
29
|
-
I.click('Resend')
|
|
30
|
-
I.seeInCurrentUrl('/sent/')
|
|
31
|
-
|
|
32
|
-
await I.wait(0.2)
|
|
33
|
-
const newCodeData = await Code.indexRangeGet('byAuthentication', authentication)
|
|
34
|
-
newCodeData.sort((a,b) => new Date(b.expire).getTime() - new Date(a.expire).getTime())
|
|
35
|
-
const oldCodeData = codeData
|
|
36
|
-
codeData = newCodeData[0]
|
|
37
|
-
I.assert(!!codeData, true, 'code exists')
|
|
38
|
-
I.assert(oldCodeData.id != codeData.id, true, 'code is different from previous code')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
I.fillField('input#code', codeData.secretCode)
|
|
42
|
-
I.fillField('input#code', codeData.secretCode) /// twice because it can fail once with this type of field
|
|
43
|
-
I.click('button[type=submit]')
|
|
44
|
-
await I.wait(0.1)
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
async useSecretLink(authentication, happyPath) {
|
|
48
|
-
const I = this
|
|
49
|
-
const Link = await I.haveModel('secretLink', 'Link')
|
|
50
|
-
let linkData = await Link.indexObjectGet('byAuthentication', authentication)
|
|
51
|
-
console.log("LINK DATA", linkData)
|
|
52
|
-
I.assert(!!linkData, true, 'link created')
|
|
53
|
-
|
|
54
|
-
if(!happyPath) {
|
|
55
|
-
I.amOnPage('/link/[badSecret]')
|
|
56
|
-
I.see('Unknown link')
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if(!happyPath) {
|
|
60
|
-
await I.wait(0.2)
|
|
61
|
-
await Link.update(linkData.id, { expire: new Date() }) // expire now
|
|
62
|
-
I.amOnPage('/link/' + linkData.secretCode)
|
|
63
|
-
I.see('Link expired')
|
|
64
|
-
|
|
65
|
-
I.click('Resend')
|
|
66
|
-
I.seeInCurrentUrl('/sent/')
|
|
67
|
-
|
|
68
|
-
await I.wait(0.2)
|
|
69
|
-
const newLinksData = await Link.indexRangeGet('byAuthentication', authentication)
|
|
70
|
-
newLinksData.sort((a,b) => new Date(b.expire).getTime() - new Date(a.expire).getTime())
|
|
71
|
-
const oldLinkData = linkData
|
|
72
|
-
linkData = newLinksData[0]
|
|
73
|
-
I.assert(!!linkData, true, 'link exists')
|
|
74
|
-
I.assert(oldLinkData.id != linkData.id, true, 'link is different from previous link')
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
console.log("LINK RIGHT", '/link/' + linkData.secretCode)
|
|
78
|
-
I.amOnPage('/link/'+linkData.secretCode)
|
|
79
|
-
await I.wait(0.1)
|
|
80
|
-
|
|
81
|
-
return linkData
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
})
|
|
85
|
-
}
|