@webship.co/workspace-adminlte 0.0.0-stage → 1.0.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/LICENSE +15 -0
- package/README.md +215 -2
- package/ai/agents/adminlte-tester.md +158 -0
- package/ai/agents/adminlte-ui-builder.md +99 -0
- package/ai/commands/adminlte-test.md +96 -0
- package/ai/prompts/adminlte-build-and-test.md +24 -0
- package/ai/prompts/adminlte-scenarios-for-a-site.md +28 -0
- package/ai/skills/adminlte-scenarios/SKILL.md +82 -0
- package/ai/skills/adminlte-scenarios/examples/cards-and-chat.feature +23 -0
- package/ai/skills/adminlte-scenarios/examples/inside-the-dashboard.feature +23 -0
- package/ai/skills/adminlte-scenarios/examples/sidebar-and-menu.feature +21 -0
- package/commands/cmd-adminlte-project.sh +38 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.js +56 -0
- package/dist/src/index.js.map +1 -0
- package/features/adminlte-runtimes.feature +39 -0
- package/features/adminlte.feature +36 -0
- package/package.json +99 -4
- package/scripts/adminlte-serve.js +52 -0
- package/scripts/args/arg-adminlte.sh +33 -0
- package/scripts/functions/fun-adminlte.sh +368 -0
- package/testing/site.feature +34 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# AdminLTE for the Webship Workspace: serve the components demo site of the AdminLTE step pack in a container, on DDEV,
|
|
4
|
+
# Docker Compose, Podman or Kubernetes, and wire the step pack into the testing setup of such a site.
|
|
5
|
+
#
|
|
6
|
+
# Placed by `plugins.sh --install adminlte` in core/scripts/plugins/adminlte/functions/, where bootstrap sources it after the
|
|
7
|
+
# core's own functions. Everything runs in the project's container, never on the host: the demo site is a folder of
|
|
8
|
+
# static pages (site/, taken from the demo-site/ folder of the step pack's repository, in the container), with AdminLTE's
|
|
9
|
+
# own style sheet and script, Bootstrap's and (for 3.2) jQuery. There is no database.
|
|
10
|
+
# on DDEV DDEV's own web server (nginx) serves site/ (site/3.2 for the 3.2 pages), the project's docroot;
|
|
11
|
+
# elsewhere the runtime layer's generic stack on Node.js's own image (rt_stack node, the Workspace's own Node.js
|
|
12
|
+
# line), and the plugin's small static server (adminlte-serve.js, Node.js's standard library only) as the
|
|
13
|
+
# web container's own server (rt_serve), serving the same folder.
|
|
14
|
+
#
|
|
15
|
+
# The demo site is static: it has no accounts. The components are not a platform and the container tools have no
|
|
16
|
+
# project type for them, so a project of this builder is recognised by its mark (.ddev/config.adminlte.yaml on DDEV,
|
|
17
|
+
# `platform: adminlte` in the x-webship block elsewhere), and four names are the ones the core's tools look for:
|
|
18
|
+
# set_adminlte_users an empty list: there are no accounts (cmd-tools-add-users.sh <project> adminlte)
|
|
19
|
+
# add_adminlte_users says so, and adds nothing (the same tool)
|
|
20
|
+
# cancel_adminlte_users says so, and removes nothing (cmd-tools-cancel-users.sh <project> adminlte)
|
|
21
|
+
# testing_configure_adminlte the step packs in the testing stack (cmd-tools-testing.sh <project>)
|
|
22
|
+
#
|
|
23
|
+
# Any other project whose dashboard uses AdminLTE gets the two step packs from the core:
|
|
24
|
+
# cmd-tools-testing.sh <project> --add-steps bootstrap ; cmd-tools-testing.sh <project> --add-steps adminlte
|
|
25
|
+
|
|
26
|
+
# The step pack a demo site is tested with, and the release line it is required at.
|
|
27
|
+
readonly ADMINLTE_STEPS_PACKAGE='@webship-js/adminlte-steps';
|
|
28
|
+
readonly ADMINLTE_STEPS_VERSION='^2.0.0';
|
|
29
|
+
# The Bootstrap pack, loaded beside it: the Bootstrap components inside a dashboard (dialogs, menus, tabs, alerts).
|
|
30
|
+
readonly ADMINLTE_BOOTSTRAP_STEPS_PACKAGE='@webship-js/bootstrap-steps';
|
|
31
|
+
readonly ADMINLTE_BOOTSTRAP_STEPS_VERSION='^2.0.1';
|
|
32
|
+
|
|
33
|
+
# The versions of AdminLTE the demo site serves: the latest line, and 3.2, the line most dashboards still run (the only
|
|
34
|
+
# stable line from 2022 until 4.0.0 in May 2026).
|
|
35
|
+
readonly ADMINLTE_VERSIONS='4 3.2';
|
|
36
|
+
readonly ADMINLTE_DEFAULT_VERSION='4';
|
|
37
|
+
|
|
38
|
+
# Where the demo site lives in the web container, and the plugin's own files in the project.
|
|
39
|
+
readonly ADMINLTE_IN_CONTAINER='/var/www/html';
|
|
40
|
+
readonly ADMINLTE_SITE='site';
|
|
41
|
+
readonly ADMINLTE_OWN='.webship-adminlte';
|
|
42
|
+
|
|
43
|
+
# Off DDEV: Node.js's own image at the Workspace's line, and the port of the static server.
|
|
44
|
+
readonly ADMINLTE_NODE_VERSION='24';
|
|
45
|
+
readonly ADMINLTE_PORT='8080';
|
|
46
|
+
readonly ADMINLTE_RUNTIMES='ddev docker podman kubernetes';
|
|
47
|
+
|
|
48
|
+
# The memory limits of the site's containers, through the core's runtime layer (rt_memory, core 1.0.60), from the peaks
|
|
49
|
+
# measured under the step pack's suite: DDEV's web container (nginx, the clone of the demo, and on DDEV the testing
|
|
50
|
+
# stack too: cmd-tools-testing.sh installs webship-js and runs its browser in the web container, 1050 MiB at its peak on
|
|
51
|
+
# the Bulma plugin's identical setup; 549 MiB with the pack's whole suite against the site),
|
|
52
|
+
# the stack's web container elsewhere (the static server and the clone; the suite runs in the core's tests container
|
|
53
|
+
# there), and the stack's mail catcher off DDEV (a static site sends no mail). A person's `memory:` in
|
|
54
|
+
# core/config/plugin.adminlte.settings.yml wins.
|
|
55
|
+
readonly ADMINLTE_DDEV_MEMORY='1280m';
|
|
56
|
+
readonly ADMINLTE_WEB_MEMORY='192m';
|
|
57
|
+
readonly ADMINLTE_MAIL_MEMORY='128m';
|
|
58
|
+
|
|
59
|
+
# A static site has no accounts: the list is empty.
|
|
60
|
+
function set_adminlte_users() {
|
|
61
|
+
users=();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# The runtime of the project in this folder, or of a new build (--runtime, else the workspace's setting, else DDEV).
|
|
65
|
+
function adminlte_runtime() {
|
|
66
|
+
if declare -f runtime_of > /dev/null ; then runtime_of ; else echo 'ddev' ; fi
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# The address of the site in this folder: https://<name>.ddev.site on DDEV, http://127.0.0.1:<port> on Docker Compose
|
|
70
|
+
# and Podman, the node's address and a port on Kubernetes. Asked after `ddev config`.
|
|
71
|
+
function adminlte_url() {
|
|
72
|
+
if declare -f rt_url > /dev/null ; then rt_url ; else echo "https://${PROJECT_NAME}.ddev.site" ; fi
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function adminlte_plugin_dir() {
|
|
76
|
+
echo "${WORKSPACE_SCRIPTS}/plugins/adminlte" ;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Is this folder a project of the AdminLTE builder?
|
|
80
|
+
function adminlte_is_project() {
|
|
81
|
+
local project_path="$1";
|
|
82
|
+
[ -f "${project_path}/.ddev/config.adminlte.yaml" ] && return 0 ;
|
|
83
|
+
declare -f rt_is_platform > /dev/null && rt_is_platform "${project_path}" adminlte ;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function adminlte_version_known() {
|
|
87
|
+
case " ${ADMINLTE_VERSIONS} " in *" $1 "*) return 0 ;; *) return 1 ;; esac
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# The version of AdminLTE a demo site serves (4 or 3.2), as the builder wrote it.
|
|
91
|
+
function adminlte_served_version() {
|
|
92
|
+
local project_path="$1";
|
|
93
|
+
cat "${project_path}/${ADMINLTE_OWN}/version" 2>/dev/null | head -n 1 ;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# The folder of the pages of a version, from the project's root: site/ for 4, site/3.2 for 3.2.
|
|
97
|
+
function adminlte_docroot() {
|
|
98
|
+
if [ "$1" = '3.2' ] ; then echo "${ADMINLTE_SITE}/3.2" ; else echo "${ADMINLTE_SITE}" ; fi
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# The builder's own files: the version served, where the site came from, and the static server (used off DDEV).
|
|
102
|
+
function adminlte_write_own() {
|
|
103
|
+
local project_path="$1" version="$2" source="$3" ref="$4" own ;
|
|
104
|
+
own="${project_path}/${ADMINLTE_OWN}" ;
|
|
105
|
+
mkdir -p "${own}" || return 1 ;
|
|
106
|
+
printf '%s\n' "${version}" > "${own}/version" || return 1 ;
|
|
107
|
+
printf '%s%s\n' "${source}" "${ref:+ (${ref})}" > "${own}/source" || return 1 ;
|
|
108
|
+
cp "$(adminlte_plugin_dir)/adminlte-serve.js" "${own}/adminlte-serve.js" ;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# What DDEV is told about the site: the web server serves the pages of the version asked for as they are. The file also
|
|
112
|
+
# marks the project as one of this builder.
|
|
113
|
+
function adminlte_write_ddev_config() {
|
|
114
|
+
local project_path="$1" version="$2" source="$3" ref="$4";
|
|
115
|
+
mkdir -p "${project_path}/.ddev" || return 1 ;
|
|
116
|
+
cat > "${project_path}/.ddev/config.adminlte.yaml" <<YAMLEOF
|
|
117
|
+
# The components demo site of the AdminLTE step pack. Written by the AdminLTE builder of the workspace; build again rather
|
|
118
|
+
# than editing by hand.
|
|
119
|
+
# version: ${version}
|
|
120
|
+
# source: ${source}${ref:+ (${ref})}
|
|
121
|
+
# The web server serves the static pages of $(adminlte_docroot "${version}")/: there is no database.
|
|
122
|
+
YAMLEOF
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# The command of the static server off DDEV, from the project's root in the web container.
|
|
126
|
+
function adminlte_serve_line() {
|
|
127
|
+
echo "exec node ./${ADMINLTE_OWN}/adminlte-serve.js ./$(adminlte_docroot "$1") ${ADMINLTE_PORT}" ;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# On another runtime than DDEV (webship/workspace#841): the plugin's claim, Node.js's own image as the stack, and the
|
|
131
|
+
# static server as the web container's own.
|
|
132
|
+
function adminlte_runtime_config() {
|
|
133
|
+
local version="$1" ;
|
|
134
|
+
rt_claim adminlte || return 1 ;
|
|
135
|
+
rt_stack node "${ADMINLTE_NODE_VERSION}" || return 1 ;
|
|
136
|
+
rt_serve "${ADMINLTE_PORT}" "$(adminlte_serve_line "${version}")" ;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# The memory limits of the site's containers (rt_memory, webship/workspace#1044).
|
|
140
|
+
function adminlte_memory() {
|
|
141
|
+
if [ "${1:-ddev}" = ddev ] ; then
|
|
142
|
+
rt_memory web "${ADMINLTE_DDEV_MEMORY}" ;
|
|
143
|
+
else
|
|
144
|
+
rt_memory web "${ADMINLTE_WEB_MEMORY}" && rt_memory mail "${ADMINLTE_MAIL_MEMORY}" ;
|
|
145
|
+
fi
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# The demo site's pages, from the step pack's repository, into site/: cloned in the web container (through the
|
|
149
|
+
# runtime's own exec: ddev exec, or the runtime layer's), its demo-site/ folder copied, the clone removed.
|
|
150
|
+
function adminlte_get_site() {
|
|
151
|
+
local project_path="$1" version="$2" source="$3" ref="$4" docroot ;
|
|
152
|
+
docroot="$(adminlte_docroot "${version}")" ;
|
|
153
|
+
echo "Getting the demo site: ${source}${ref:+ at ${ref}}" ;
|
|
154
|
+
# Five tries, ten seconds apart: a container that has just started may not resolve names yet (a Kubernetes node
|
|
155
|
+
# whose DNS is still coming up after it started).
|
|
156
|
+
local try ;
|
|
157
|
+
for try in 1 2 3 4 5 ; do
|
|
158
|
+
ddev exec "rm -rf /tmp/components-demo && git -c advice.detachedHead=false clone --quiet --depth 1 ${ref:+--branch '${ref}'} '${source}' /tmp/components-demo" < /dev/null && break ;
|
|
159
|
+
[ "${try}" = 5 ] && { echo "The demo site could not be cloned from ${source}${ref:+ at ${ref}}." ; return 1 ; } ;
|
|
160
|
+
echo "The clone failed (try ${try} of 5); trying again in ten seconds." ;
|
|
161
|
+
sleep 10 ;
|
|
162
|
+
done
|
|
163
|
+
ddev exec "test -f /tmp/components-demo/demo-site/index.html && mkdir -p ${ADMINLTE_IN_CONTAINER}/${ADMINLTE_SITE} && cp -a /tmp/components-demo/demo-site/. ${ADMINLTE_IN_CONTAINER}/${ADMINLTE_SITE}/ && rm -rf ${ADMINLTE_IN_CONTAINER}/${ADMINLTE_SITE}/.ddev /tmp/components-demo" < /dev/null \
|
|
164
|
+
|| { echo "${source} has no demo-site/ folder with an index.html." ; return 1 ; } ;
|
|
165
|
+
if [ ! -f "${project_path}/${docroot}/index.html" ] ; then
|
|
166
|
+
echo "The demo site has no pages for AdminLTE ${version} (${docroot}/index.html)." ;
|
|
167
|
+
return 1 ;
|
|
168
|
+
fi
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
# The site answers at its address with its home page, from this machine.
|
|
172
|
+
function adminlte_healthy() {
|
|
173
|
+
local url="$1" ;
|
|
174
|
+
[ "$(curl -ks -o /dev/null -w '%{http_code}' --max-time 10 "${url}/index.html")" = 200 ] ;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Wait until the site answers, up to 2 minutes.
|
|
178
|
+
function adminlte_wait() {
|
|
179
|
+
local url="$1" attempt ;
|
|
180
|
+
for attempt in $(seq 1 60) ; do
|
|
181
|
+
adminlte_healthy "${url}" && return 0 ;
|
|
182
|
+
sleep 2 ;
|
|
183
|
+
done
|
|
184
|
+
echo "The demo site does not answer at ${url}." ;
|
|
185
|
+
return 1 ;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
# Build a demo site from nothing: the container, the pages of the step pack, and with --install the site checked.
|
|
189
|
+
function adminlte_build() {
|
|
190
|
+
trim_project_name ;
|
|
191
|
+
local base_url runtime ;
|
|
192
|
+
runtime="$(adminlte_runtime)" ;
|
|
193
|
+
local version="${ADMINLTE:-${site_adminlte_version:-${ADMINLTE_DEFAULT_VERSION}}}" ;
|
|
194
|
+
local source="${SOURCE:-${site_source}}" ;
|
|
195
|
+
local ref="${REF:-${site_source_ref:-}}" ;
|
|
196
|
+
if ! adminlte_version_known "${version}" ; then
|
|
197
|
+
echo "AdminLTE ${version} is not a version this builder serves: ${ADMINLTE_VERSIONS}. Nothing was changed." ;
|
|
198
|
+
exit 1 ;
|
|
199
|
+
fi
|
|
200
|
+
if [ "${RUNTIME:-_none_}" != '_none_' ] && [ "${RUNTIME}" != "${runtime}" ] ; then
|
|
201
|
+
echo "--runtime ${RUNTIME} needs a Webship Workspace with the container runtimes (webship/workspace#694): update the workspace, or build on DDEV." ;
|
|
202
|
+
exit 1 ;
|
|
203
|
+
fi
|
|
204
|
+
case " ${ADMINLTE_RUNTIMES} " in
|
|
205
|
+
*" ${runtime} "*) ;;
|
|
206
|
+
*) echo "The AdminLTE demo site builds on DDEV, Docker Compose, Podman and Kubernetes for now (--runtime ddev, docker, podman or kubernetes), not on ${runtime}: that runtime is not proven for it yet. Nothing was changed." ; exit 1 ;;
|
|
207
|
+
esac
|
|
208
|
+
if ! declare -F rt_memory > /dev/null ; then
|
|
209
|
+
echo "The site's container is capped through the core's runtime layer (webship/workspace#1044): it needs Webship Workspace 1.0.60 or newer. Update the workspace. Nothing was changed." ;
|
|
210
|
+
exit 1 ;
|
|
211
|
+
fi
|
|
212
|
+
if [[ "${source}${ref}" == *"'"* ]] ; then
|
|
213
|
+
echo "--source and --ref take a repository and a branch or tag. Nothing was changed." ;
|
|
214
|
+
exit 1 ;
|
|
215
|
+
fi
|
|
216
|
+
if [ ${#PROJECT_NAME} -gt 40 ] || ! [[ "${PROJECT_NAME}" =~ ^[a-z0-9][a-z0-9-]*$ ]] ; then
|
|
217
|
+
echo "The project name ${PROJECT_NAME} must be small letters, digits and dashes (its address and its containers take it). Nothing was changed." ;
|
|
218
|
+
exit 1 ;
|
|
219
|
+
fi
|
|
220
|
+
local project_path="${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME}" ;
|
|
221
|
+
local docroot ; docroot="$(adminlte_docroot "${version}")" ;
|
|
222
|
+
|
|
223
|
+
cd ${WORKSPACE_ROOT}/${doc_name} || exit 1 ;
|
|
224
|
+
|
|
225
|
+
drop_database ;
|
|
226
|
+
rm -rf "${PROJECT_NAME:?}" ;
|
|
227
|
+
mkdir -p "${PROJECT_NAME}/${ADMINLTE_SITE}" ;
|
|
228
|
+
cd "${project_path}" || exit 1 ;
|
|
229
|
+
|
|
230
|
+
if [ "${runtime}" == 'ddev' ] ; then
|
|
231
|
+
# A web server and no database: the site is static pages, served as they are.
|
|
232
|
+
ddev config --project-type=php --docroot="${docroot}" --project-name=${PROJECT_NAME} \
|
|
233
|
+
--omit-containers=db --nodejs-version=$(ddev_nodejs_version) --auto < /dev/null || exit 1 ;
|
|
234
|
+
else
|
|
235
|
+
ddev config --project-type=generic --webserver-type=generic --docroot="" --project-name=${PROJECT_NAME} \
|
|
236
|
+
--omit-containers=db --auto < /dev/null || exit 1 ;
|
|
237
|
+
fi
|
|
238
|
+
adminlte_write_own "${project_path}" "${version}" "${source}" "${ref}" || { echo "The AdminLTE site's own files could not be written." ; exit 1 ; } ;
|
|
239
|
+
if [ "${runtime}" == 'ddev' ] ; then
|
|
240
|
+
adminlte_write_ddev_config "${project_path}" "${version}" "${source}" "${ref}" || exit 1 ;
|
|
241
|
+
else
|
|
242
|
+
adminlte_runtime_config "${version}" || { echo "The AdminLTE site's stack could not be written through the runtime layer." ; exit 1 ; } ;
|
|
243
|
+
fi
|
|
244
|
+
adminlte_memory "${runtime}" || { echo "The AdminLTE site's memory limits could not be written through the runtime layer." ; exit 1 ; } ;
|
|
245
|
+
base_url="$(adminlte_url)" ;
|
|
246
|
+
|
|
247
|
+
ddev_up start -y < /dev/null || exit 1 ;
|
|
248
|
+
adminlte_get_site "${project_path}" "${version}" "${source}" "${ref}" || exit 1 ;
|
|
249
|
+
|
|
250
|
+
[ "${ADD_USERS}" == 'yes' ] && echo "--add-users: the demo site is static and has no accounts; nothing is added." ;
|
|
251
|
+
|
|
252
|
+
if [ "${INSTALL}" == 'yes' ] ; then
|
|
253
|
+
adminlte_wait "${base_url}" || exit 1 ;
|
|
254
|
+
echo "${doc_name} ${PROJECT_NAME} is served: the components of AdminLTE ${version}${runtime:+ on ${runtime}}, $(find "${project_path}/${docroot}" -maxdepth 1 -name '*.html' | wc -l) pages.";
|
|
255
|
+
echo "Go to ${base_url}";
|
|
256
|
+
else
|
|
257
|
+
ddev stop < /dev/null ;
|
|
258
|
+
echo "${doc_name} ${PROJECT_NAME} is ready: the components of AdminLTE ${version}, at ${base_url} once started.";
|
|
259
|
+
if [ "${runtime}" = 'ddev' ] ; then echo "Serve it with: cd ${PROJECT_NAME} && ddev start (or build with --install)" ;
|
|
260
|
+
else echo "Serve it with Start in its row of the dashboard (or build with --install)" ; fi
|
|
261
|
+
fi
|
|
262
|
+
|
|
263
|
+
if [ "${LAUNCH}" == 'yes' ] ; then
|
|
264
|
+
ddev launch ;
|
|
265
|
+
fi
|
|
266
|
+
|
|
267
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
# A static site has no accounts: there is nothing to add, and nothing to remove.
|
|
271
|
+
function add_adminlte_users() {
|
|
272
|
+
echo "The components demo site is static: it has no accounts, so there are none to add." ;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function cancel_adminlte_users() {
|
|
276
|
+
echo "The components demo site is static: it has no accounts, so there are none to remove." ;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
# The step packs in the testing stack of a demo site. The core's testing_configure calls this in the project folder once
|
|
280
|
+
# webship-js is scaffolded and before the dependencies are installed; for a project that is not a demo site of this
|
|
281
|
+
# builder it changes nothing (any other project gets the packs with the core's --add-steps bootstrap and --add-steps
|
|
282
|
+
# adminlte).
|
|
283
|
+
#
|
|
284
|
+
# It adds the two packs to package.json (the Bootstrap pack for the Bootstrap components inside the dashboard, then
|
|
285
|
+
# this one), lists their step definitions in cucumber.js after webship-js's own, sets the tags of the version served
|
|
286
|
+
# (the 3.2 pages leave out what only AdminLTE 4 has: @lte4), sets the site's address where the scaffold has its
|
|
287
|
+
# placeholder, and writes a first feature when the project has none of its own. There is no users registry: the site
|
|
288
|
+
# has no accounts. Every part is skipped when it is already there, so a second run adds what the first missed and
|
|
289
|
+
# never resets a suite. The suite is the project's (its package.json, cucumber.js and tests/ are next to site/, not in
|
|
290
|
+
# it).
|
|
291
|
+
function testing_configure_adminlte() {
|
|
292
|
+
local project_path="$1" address version ;
|
|
293
|
+
adminlte_is_project "${project_path}" || return 0 ;
|
|
294
|
+
if [ ! -f "${project_path}/cucumber.js" ] || [ ! -f "${project_path}/package.json" ] ; then
|
|
295
|
+
echo " AdminLTE: cucumber.js is not here yet — run the testing setup again once webship-js is scaffolded." ;
|
|
296
|
+
return 1 ;
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
version="$(adminlte_served_version "${project_path}")" ;
|
|
300
|
+
address="$(cd "${project_path}" && PROJECT_NAME="${PROJECT_NAME:-$(basename "${project_path}")}" adminlte_url)" ;
|
|
301
|
+
echo "Adding the Bootstrap and AdminLTE step packs (${ADMINLTE_BOOTSTRAP_STEPS_PACKAGE} ${ADMINLTE_BOOTSTRAP_STEPS_VERSION}, ${ADMINLTE_STEPS_PACKAGE} ${ADMINLTE_STEPS_VERSION}) for the pages of AdminLTE ${version:-4}.";
|
|
302
|
+
|
|
303
|
+
python3 - "${project_path}" "${ADMINLTE_BOOTSTRAP_STEPS_PACKAGE}" "${ADMINLTE_BOOTSTRAP_STEPS_VERSION}" "${ADMINLTE_STEPS_PACKAGE}" "${ADMINLTE_STEPS_VERSION}" "${version:-4}" "${address}" <<'PYEOF' || return 1
|
|
304
|
+
import json, re, sys
|
|
305
|
+
|
|
306
|
+
project, bs_pack, bs_version, pack, version, served, address = sys.argv[1:8]
|
|
307
|
+
packs = [(bs_pack, bs_version), (pack, version)]
|
|
308
|
+
|
|
309
|
+
# package.json: the packs as dev dependencies, at the release lines this plugin was proven on.
|
|
310
|
+
pkg_file = project + '/package.json'
|
|
311
|
+
pkg = json.load(open(pkg_file))
|
|
312
|
+
changed = False
|
|
313
|
+
for name, line in packs:
|
|
314
|
+
if name not in pkg.get('dependencies', {}) and name not in pkg.get('devDependencies', {}):
|
|
315
|
+
pkg.setdefault('devDependencies', {})[name] = line
|
|
316
|
+
changed = True
|
|
317
|
+
print(' package.json: %s %s' % (name, line))
|
|
318
|
+
if changed:
|
|
319
|
+
open(pkg_file, 'w').write(json.dumps(pkg, indent=2) + '\n')
|
|
320
|
+
|
|
321
|
+
# cucumber.js: the packs' step definitions after webship-js's own, the Bootstrap pack first.
|
|
322
|
+
cucumber_file = project + '/cucumber.js'
|
|
323
|
+
src = open(cucumber_file).read()
|
|
324
|
+
before = src
|
|
325
|
+
|
|
326
|
+
for name, _ in packs:
|
|
327
|
+
if ('node_modules/%s/' % name) in src:
|
|
328
|
+
continue
|
|
329
|
+
entry = "'node_modules/%s/tests/step-definitions/*.js'," % name
|
|
330
|
+
last = None
|
|
331
|
+
for m in re.finditer(r"^([ \t]*)'node_modules/(webship-js|@webship-js/[a-z0-9-]+)/tests/step-definitions/[^']*',.*$", src, re.M):
|
|
332
|
+
last = m
|
|
333
|
+
opening = re.search(r"^([ \t]*)require:[ \t]*\[[ \t]*$", src, re.M)
|
|
334
|
+
if last:
|
|
335
|
+
src = src[:last.end()] + '\n' + last.group(1) + entry + src[last.end():]
|
|
336
|
+
elif opening:
|
|
337
|
+
src = src[:opening.end()] + '\n' + opening.group(1) + ' ' + entry + src[opening.end():]
|
|
338
|
+
else:
|
|
339
|
+
sys.exit(" cucumber.js has no require list this can add to. Add this line to it:\n " + entry)
|
|
340
|
+
print(' cucumber.js: the step definitions of %s' % name)
|
|
341
|
+
|
|
342
|
+
# The tags of the version served: the scenarios the pack tags for one version stay out of a run against the other
|
|
343
|
+
# (@lte4: what only AdminLTE 4 has; @lte3: the 3.2 pages only).
|
|
344
|
+
skip = '@lte4' if served == '3.2' else '@lte3'
|
|
345
|
+
if 'tags:' not in src:
|
|
346
|
+
opening = re.search(r"^([ \t]*)paths:.*$", src, re.M)
|
|
347
|
+
if opening:
|
|
348
|
+
src = src[:opening.end()] + '\n' + opening.group(1) + "tags: process.env.CUCUMBER_TAGS || 'not @wip and not %s'," % skip + src[opening.end():]
|
|
349
|
+
print(' cucumber.js: the tags of the pages of AdminLTE %s (not %s)' % (served, skip))
|
|
350
|
+
|
|
351
|
+
# The site's address, where the scaffold has its placeholder.
|
|
352
|
+
placeholder = "process.env.LAUNCH_URL || 'http://localhost:8080'"
|
|
353
|
+
if address and placeholder in src:
|
|
354
|
+
src = src.replace(placeholder, "process.env.LAUNCH_URL || '%s'" % address)
|
|
355
|
+
print(' cucumber.js: the address of the site (%s)' % address)
|
|
356
|
+
|
|
357
|
+
if src != before:
|
|
358
|
+
open(cucumber_file, 'w').write(src)
|
|
359
|
+
PYEOF
|
|
360
|
+
|
|
361
|
+
# A first feature, when the project has none for the site yet: the theme's style sheet, the sidebar and its menu, a
|
|
362
|
+
# card's tools and a dialog of the Bootstrap pack, on the pages of either version.
|
|
363
|
+
local feature="$(adminlte_plugin_dir)/site.feature" ;
|
|
364
|
+
if [ -f "${feature}" ] && [ ! -f "${project_path}/tests/features/site.feature" ] ; then
|
|
365
|
+
mkdir -p "${project_path}/tests/features" && cp "${feature}" "${project_path}/tests/features/site.feature" \
|
|
366
|
+
&& echo " tests/features/site.feature: a first feature for the site" ;
|
|
367
|
+
fi
|
|
368
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Feature: The dashboard answers and its components work
|
|
2
|
+
As the owner of the demo dashboard
|
|
3
|
+
I want its pages to load AdminLTE's style sheet and its components to move
|
|
4
|
+
So that a build that came out broken is caught before anything else is tested
|
|
5
|
+
|
|
6
|
+
# Placed by the workspace's testing setup as a starting point: it is yours to change. It holds on
|
|
7
|
+
# the pages of AdminLTE 4 and on those of 3.2 (cmd-adminlte-project.sh --adminlte 3.2).
|
|
8
|
+
|
|
9
|
+
@critical
|
|
10
|
+
Scenario: The home page is served with AdminLTE's style sheet
|
|
11
|
+
Given I am on the homepage
|
|
12
|
+
Then the response status code should be 200
|
|
13
|
+
And the page should use the dashboard theme
|
|
14
|
+
And I should see "Field Office"
|
|
15
|
+
|
|
16
|
+
@critical
|
|
17
|
+
Scenario: The sidebar's menu opens a submenu
|
|
18
|
+
Given I am on "/index.html"
|
|
19
|
+
When I expand the "Reports" sidebar menu item
|
|
20
|
+
Then the "Reports" sidebar menu item should be expanded
|
|
21
|
+
|
|
22
|
+
Scenario: A card collapses and expands
|
|
23
|
+
Given I am on "/index.html"
|
|
24
|
+
When I collapse the "Sales" card
|
|
25
|
+
Then the "Sales" card should be collapsed
|
|
26
|
+
When I expand the "Sales" card
|
|
27
|
+
Then the "Sales" card should be expanded
|
|
28
|
+
|
|
29
|
+
Scenario: A dialog inside the dashboard opens and closes
|
|
30
|
+
Given I am on "/components.html"
|
|
31
|
+
When I open the "Export report" dialog
|
|
32
|
+
Then the "Export report" dialog should show "exported as a spreadsheet"
|
|
33
|
+
When I press Escape in the "Export report" dialog
|
|
34
|
+
Then no dialog should be shown
|