]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Create screenshots directory when needed
authorChocobozzz <me@florianbigard.com>
Wed, 15 Feb 2023 15:25:52 +0000 (16:25 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 15 Feb 2023 15:26:21 +0000 (16:26 +0100)
client/e2e/src/suites-local/signup.e2e-spec.ts
client/e2e/src/utils/files.ts [new file with mode: 0644]
client/e2e/src/utils/hooks.ts
client/e2e/src/utils/index.ts

index b6f7ad1a788bd272ca8ea5b77d783d1104f6832f..7c822a6e67e01b4de75e7981a8bf0e3dd5472ab6 100644 (file)
@@ -2,7 +2,16 @@ import { AdminConfigPage } from '../po/admin-config.po'
 import { AdminRegistrationPage } from '../po/admin-registration.po'
 import { LoginPage } from '../po/login.po'
 import { SignupPage } from '../po/signup.po'
-import { browserSleep, getVerificationLink, go, findEmailTo, isMobileDevice, MockSMTPServer, waitServerUp } from '../utils'
+import {
+  browserSleep,
+  findEmailTo,
+  getScreenshotPath,
+  getVerificationLink,
+  go,
+  isMobileDevice,
+  MockSMTPServer,
+  waitServerUp
+} from '../utils'
 
 function checkEndMessage (options: {
   message: string
@@ -155,7 +164,7 @@ describe('Signup', () => {
           afterEmailVerification: false
         })
 
-        await browser.saveScreenshot('./screenshots/direct-without-email.png')
+        await browser.saveScreenshot(getScreenshotPath('direct-without-email.png'))
 
         await loginPage.logout()
       })
@@ -203,7 +212,7 @@ describe('Signup', () => {
           afterEmailVerification: false
         })
 
-        await browser.saveScreenshot('./screenshots/request-without-email.png')
+        await browser.saveScreenshot(getScreenshotPath('request-without-email.png'))
       })
 
       it('Should display a message when trying to login with this account', async function () {
@@ -283,7 +292,7 @@ describe('Signup', () => {
           afterEmailVerification: false
         })
 
-        await browser.saveScreenshot('./screenshots/direct-with-email.png')
+        await browser.saveScreenshot(getScreenshotPath('direct-with-email.png'))
       })
 
       it('Should validate the email', async function () {
@@ -304,7 +313,7 @@ describe('Signup', () => {
           afterEmailVerification: true
         })
 
-        await browser.saveScreenshot('./screenshots/direct-after-email.png')
+        await browser.saveScreenshot(getScreenshotPath('direct-after-email.png'))
       })
     })
 
@@ -355,7 +364,7 @@ describe('Signup', () => {
           afterEmailVerification: false
         })
 
-        await browser.saveScreenshot('./screenshots/request-with-email.png')
+        await browser.saveScreenshot(getScreenshotPath('request-with-email.png'))
       })
 
       it('Should display a message when trying to login with this account', async function () {
@@ -391,7 +400,7 @@ describe('Signup', () => {
           afterEmailVerification: true
         })
 
-        await browser.saveScreenshot('./screenshots/request-after-email.png')
+        await browser.saveScreenshot(getScreenshotPath('request-after-email.png'))
       })
     })
 
diff --git a/client/e2e/src/utils/files.ts b/client/e2e/src/utils/files.ts
new file mode 100644 (file)
index 0000000..c532c98
--- /dev/null
@@ -0,0 +1,17 @@
+import { mkdirSync } from 'fs'
+import { join } from 'path'
+
+const SCREENSHOTS_DIRECTORY = 'screenshots'
+
+function createScreenshotsDirectory () {
+  mkdirSync(SCREENSHOTS_DIRECTORY, { recursive: true })
+}
+
+function getScreenshotPath (filename: string) {
+  return join(SCREENSHOTS_DIRECTORY, filename)
+}
+
+export {
+  createScreenshotsDirectory,
+  getScreenshotPath
+}
index 7fe2476810fdbf0b289311e9814ff08fdd91ebb3..8baf9fb4419e8c41a0a733d8c39fb9a3bd634984 100644 (file)
@@ -1,7 +1,8 @@
 import { ChildProcessWithoutNullStreams } from 'child_process'
 import { basename } from 'path'
-import { runCommand, runServer } from './server'
 import { setValue } from '@wdio/shared-store-service'
+import { createScreenshotsDirectory } from './files'
+import { runCommand, runServer } from './server'
 
 let appInstance: number
 let app: ChildProcessWithoutNullStreams
@@ -21,6 +22,8 @@ function afterLocalSuite () {
 }
 
 async function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) {
+  await createScreenshotsDirectory()
+
   appInstance = capabilities['browserName'] === 'chrome'
     ? 1
     : 2
index 420fd239eb2e6fefe015e64b10727aa4625c26a4..0770cb0f45fb0e1c494221f681e914ee2a39fa65 100644 (file)
@@ -1,6 +1,7 @@
 export * from './common'
 export * from './elements'
 export * from './email'
+export * from './files'
 export * from './hooks'
 export * from './mock-smtp'
 export * from './server'