@nextsparkjs/theme-blog 0.1.0-beta.19 → 0.1.0-beta.20
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/package.json +2 -2
- package/tests/cypress/e2e/README.md +170 -0
- package/tests/cypress/e2e/categories/categories-crud.cy.ts +322 -0
- package/tests/cypress/e2e/categories/categories-crud.md +73 -0
- package/tests/cypress/e2e/posts/posts-crud.cy.ts +460 -0
- package/tests/cypress/e2e/posts/posts-crud.md +115 -0
- package/tests/cypress/e2e/posts/posts-editor.cy.ts +290 -0
- package/tests/cypress/e2e/posts/posts-editor.md +139 -0
- package/tests/cypress/e2e/posts/posts-status-workflow.cy.ts +302 -0
- package/tests/cypress/e2e/posts/posts-status-workflow.md +83 -0
- package/tests/cypress/fixtures/blocks.json +9 -0
- package/tests/cypress/fixtures/entities.json +42 -0
- package/tests/cypress/src/FeaturedImageUpload.js +131 -0
- package/tests/cypress/src/PostEditor.js +386 -0
- package/tests/cypress/src/PostsList.js +350 -0
- package/tests/cypress/src/WysiwygEditor.js +373 -0
- package/tests/cypress/src/components/EntityForm.ts +357 -0
- package/tests/cypress/src/components/EntityList.ts +360 -0
- package/tests/cypress/src/components/PostEditorPOM.ts +447 -0
- package/tests/cypress/src/components/PostsPOM.ts +362 -0
- package/tests/cypress/src/components/index.ts +18 -0
- package/tests/cypress/src/index.js +33 -0
- package/tests/cypress/src/selectors.ts +49 -0
- package/tests/cypress/src/session-helpers.ts +89 -0
- package/tests/cypress/support/e2e.ts +89 -0
- package/tests/cypress.config.ts +165 -0
- package/tests/tsconfig.json +15 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cypress Configuration for blog Theme
|
|
3
|
+
*
|
|
4
|
+
* This config works in both monorepo and npm mode.
|
|
5
|
+
* Run with: NEXT_PUBLIC_ACTIVE_THEME=default pnpm cy:open
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { defineConfig } from 'cypress'
|
|
9
|
+
import path from 'path'
|
|
10
|
+
import fs from 'fs'
|
|
11
|
+
import { fileURLToPath } from 'url'
|
|
12
|
+
|
|
13
|
+
// ESM-compatible __dirname
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
15
|
+
const __dirname = path.dirname(__filename)
|
|
16
|
+
|
|
17
|
+
// Paths relative to this config file
|
|
18
|
+
const themeRoot = path.resolve(__dirname, '..')
|
|
19
|
+
const projectRoot = path.resolve(__dirname, '../../../..')
|
|
20
|
+
const narrationsOutputDir = path.join(__dirname, 'cypress/videos/narrations')
|
|
21
|
+
|
|
22
|
+
// Detect if running in npm mode (no packages/core folder) vs monorepo
|
|
23
|
+
const isNpmMode = !fs.existsSync(path.join(projectRoot, 'packages/core'))
|
|
24
|
+
|
|
25
|
+
// Load environment variables
|
|
26
|
+
import dotenv from 'dotenv'
|
|
27
|
+
dotenv.config({ path: path.join(projectRoot, '.env') })
|
|
28
|
+
|
|
29
|
+
// Server port (from .env or default 3000)
|
|
30
|
+
const port = process.env.PORT || 3000
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
e2e: {
|
|
34
|
+
// Base URL for the application
|
|
35
|
+
baseUrl: `http://localhost:${port}`,
|
|
36
|
+
|
|
37
|
+
// Spec patterns: theme tests (core tests only in monorepo)
|
|
38
|
+
specPattern: isNpmMode
|
|
39
|
+
? [
|
|
40
|
+
// npm mode: only theme tests
|
|
41
|
+
path.join(__dirname, 'cypress/e2e/**/*.cy.{js,ts}'),
|
|
42
|
+
]
|
|
43
|
+
: [
|
|
44
|
+
// Monorepo: core tests + theme tests
|
|
45
|
+
path.join(projectRoot, 'packages/core/tests/cypress/e2e/core/**/*.cy.{js,ts}'),
|
|
46
|
+
path.join(__dirname, 'cypress/e2e/**/*.cy.{js,ts}'),
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
// Support file (theme-local in npm mode, core in monorepo)
|
|
50
|
+
supportFile: isNpmMode
|
|
51
|
+
? path.join(__dirname, 'cypress/support/e2e.ts')
|
|
52
|
+
: path.join(projectRoot, 'packages/core/tests/cypress/support/e2e.ts'),
|
|
53
|
+
|
|
54
|
+
// Fixtures folder (theme-specific)
|
|
55
|
+
fixturesFolder: path.join(__dirname, 'cypress/fixtures'),
|
|
56
|
+
|
|
57
|
+
// Output folders (theme-specific)
|
|
58
|
+
downloadsFolder: path.join(__dirname, 'cypress/downloads'),
|
|
59
|
+
screenshotsFolder: path.join(__dirname, 'cypress/screenshots'),
|
|
60
|
+
videosFolder: path.join(__dirname, 'cypress/videos'),
|
|
61
|
+
|
|
62
|
+
// Viewport settings
|
|
63
|
+
viewportWidth: 1280,
|
|
64
|
+
viewportHeight: 720,
|
|
65
|
+
|
|
66
|
+
// Video and screenshot settings
|
|
67
|
+
video: true,
|
|
68
|
+
screenshotOnRunFailure: true,
|
|
69
|
+
|
|
70
|
+
// Timeouts
|
|
71
|
+
defaultCommandTimeout: 10000,
|
|
72
|
+
requestTimeout: 10000,
|
|
73
|
+
responseTimeout: 10000,
|
|
74
|
+
pageLoadTimeout: 30000,
|
|
75
|
+
|
|
76
|
+
// Browser settings
|
|
77
|
+
chromeWebSecurity: false,
|
|
78
|
+
|
|
79
|
+
// Test isolation
|
|
80
|
+
testIsolation: true,
|
|
81
|
+
|
|
82
|
+
// Retry settings
|
|
83
|
+
retries: {
|
|
84
|
+
runMode: 1,
|
|
85
|
+
openMode: 0,
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
// Environment variables
|
|
89
|
+
env: {
|
|
90
|
+
// Theme info
|
|
91
|
+
ACTIVE_THEME: 'blog',
|
|
92
|
+
THEME_PATH: themeRoot,
|
|
93
|
+
|
|
94
|
+
// Test user credentials
|
|
95
|
+
TEST_USER_EMAIL: 'user@example.com',
|
|
96
|
+
TEST_USER_PASSWORD: 'Testing1234',
|
|
97
|
+
|
|
98
|
+
// Feature flags
|
|
99
|
+
ENABLE_ALLURE: true,
|
|
100
|
+
|
|
101
|
+
// Allure reporting
|
|
102
|
+
allureResultsPath: path.join(__dirname, 'cypress/allure-results'),
|
|
103
|
+
|
|
104
|
+
// API settings
|
|
105
|
+
API_URL: `http://localhost:${port}/api`,
|
|
106
|
+
API_BASE_URL: `http://localhost:${port}`,
|
|
107
|
+
|
|
108
|
+
// @cypress/grep - filter specs by tags
|
|
109
|
+
grepFilterSpecs: true,
|
|
110
|
+
grepOmitFiltered: true,
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
async setupNodeEvents(on, config) {
|
|
114
|
+
// Allure plugin setup (allure-cypress)
|
|
115
|
+
const { allureCypress } = await import('allure-cypress/reporter')
|
|
116
|
+
allureCypress(on, config, {
|
|
117
|
+
resultsDir: path.join(__dirname, 'cypress/allure-results'),
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
// @cypress/grep plugin for test filtering by tags
|
|
121
|
+
const grepPlugin = await import('@cypress/grep/src/plugin.js')
|
|
122
|
+
;(grepPlugin.default || grepPlugin)(config)
|
|
123
|
+
|
|
124
|
+
// Documentation video tasks
|
|
125
|
+
on('task', {
|
|
126
|
+
/**
|
|
127
|
+
* Save narrations to JSON file for post-processing
|
|
128
|
+
*/
|
|
129
|
+
saveNarrations({ specName, narrations }: { specName: string; narrations: unknown[] }) {
|
|
130
|
+
// Ensure output directory exists
|
|
131
|
+
if (!fs.existsSync(narrationsOutputDir)) {
|
|
132
|
+
fs.mkdirSync(narrationsOutputDir, { recursive: true })
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const filename = `${specName}-narrations.json`
|
|
136
|
+
const filepath = path.join(narrationsOutputDir, filename)
|
|
137
|
+
|
|
138
|
+
fs.writeFileSync(filepath, JSON.stringify(narrations, null, 2))
|
|
139
|
+
console.log(`📝 Narrations saved to: ${filepath}`)
|
|
140
|
+
|
|
141
|
+
return null
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Add narration entry (called per narration)
|
|
146
|
+
*/
|
|
147
|
+
addNarration(narration: unknown) {
|
|
148
|
+
// This could be used for real-time streaming to a narration service
|
|
149
|
+
console.log('🎙️ Narration:', narration)
|
|
150
|
+
return null
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
return config
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// Component testing (future use)
|
|
159
|
+
component: {
|
|
160
|
+
devServer: {
|
|
161
|
+
framework: 'next',
|
|
162
|
+
bundler: 'webpack',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.cypress.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "../../../..",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": ["./*"],
|
|
7
|
+
"@/core/*": ["./core/*"],
|
|
8
|
+
"@/contents/*": ["./contents/*"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"../../../../cypress.d.ts",
|
|
13
|
+
"cypress/**/*.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|