glib-web 5.0.7 → 6.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/.claude/commands/gen-cypress-test.md +101 -0
- package/.github/dependabot.yml +24 -12
- package/.nycrc.json +4 -0
- package/AGENTS.md +1 -0
- package/README.md +4 -0
- package/actions/logics/set.js +5 -0
- package/actions/panels/scrollTo.js +2 -2
- package/actions/timeouts/set.js +1 -1
- package/app.vue +1 -1
- package/components/charts/series.js +2 -2
- package/components/composable/gmap.js +1 -1
- package/components/composable/upload.js +1 -4
- package/components/composable/upload_nothing.js +1 -1
- package/components/fields/_buttonDate.vue +2 -2
- package/components/fields/_patternText.vue +2 -8
- package/components/fields/_select.vue +10 -8
- package/components/fields/_selectItemDefault.vue +1 -3
- package/components/fields/_selectItemWithIcon.vue +1 -3
- package/components/fields/_selectItemWithImage.vue +1 -3
- package/components/fields/clipboardUpload.vue +115 -0
- package/components/fields/dynamicGroup2.vue +1 -1
- package/components/fields/multiUpload.vue +12 -19
- package/components/fields/placeholderUpload.vue +8 -4
- package/components/fields/radioGroup.vue +0 -7
- package/components/fields/sign.vue +1 -1
- package/components/fields/text.vue +1 -9
- package/components/fields/upload.vue +4 -0
- package/components/mixins/longClick.js +1 -1
- package/components/panels/bulkEdit2.vue +1 -1
- package/components/panels/list.vue +1 -1
- package/components/popover.vue +1 -1
- package/components/responsive.vue +1 -1
- package/cypress/e2e/glib-web/dialog.cy.js +0 -1
- package/cypress/e2e/glib-web/dirtyState.cy.js +37 -37
- package/cypress/e2e/glib-web/fieldsDateTime.cy.js +46 -3
- package/cypress/e2e/glib-web/fieldsRadio.cy.js +65 -0
- package/cypress/e2e/glib-web/fieldsSelect.cy.js +116 -76
- package/cypress/e2e/glib-web/fieldsText.cy.js +83 -0
- package/cypress/e2e/glib-web/fieldsUpload.cy.js +230 -120
- package/cypress/e2e/glib-web/image.cy.js +62 -33
- package/cypress/e2e/glib-web/switch.cy.js +13 -0
- package/cypress/e2e/glib-web/tabBar.cy.js +23 -0
- package/cypress/fixtures/document.pdf +12 -0
- package/cypress/fixtures/large.png +0 -0
- package/cypress/fixtures/upload.png +0 -0
- package/cypress/helper.js +13 -1
- package/cypress/support/component.js +1 -1
- package/cypress/support/e2e.js +20 -13
- package/doc/dependabot.md +22 -0
- package/eslint-rules/index.js +6 -6
- package/nav/dialog.vue +1 -1
- package/package.json +18 -16
- package/templates/_menu.vue +2 -2
- package/cypress/component/inputUpload.cy.js +0 -103
- package/cypress/component/multiUpload.cy.js +0 -107
- package/cypress/component/placeholderUpload.cy.js +0 -91
package/cypress/support/e2e.js
CHANGED
|
@@ -15,21 +15,28 @@
|
|
|
15
15
|
|
|
16
16
|
// Import commands.js using ES2015 syntax:
|
|
17
17
|
import "./commands.js";
|
|
18
|
-
import "@cypress/code-coverage/support
|
|
19
|
-
import { isFunction, isObject } from "../../utils/type.js";
|
|
18
|
+
import "@cypress/code-coverage/support";
|
|
19
|
+
// import { isFunction, isObject } from "../../utils/type.js";
|
|
20
20
|
|
|
21
|
-
Cypress.on("window:before:load", (win) => {
|
|
22
|
-
|
|
21
|
+
// Cypress.on("window:before:load", (win) => {
|
|
22
|
+
// if (!isObject(win) || !isObject(win.console)) return;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
// if (isFunction(win.console.log)) {
|
|
25
|
+
// win.console.log = () => {};
|
|
26
|
+
// }
|
|
27
|
+
// if (isFunction(win.console.warn)) {
|
|
28
|
+
// win.console.warn = () => {};
|
|
29
|
+
// }
|
|
30
|
+
// if (isFunction(win.console.info)) {
|
|
31
|
+
// win.console.info = () => {};
|
|
32
|
+
// }
|
|
33
|
+
// });
|
|
34
|
+
|
|
35
|
+
// Stripe and Google Maps telemetry requests block cy.visit() in Cypress 15+ due
|
|
36
|
+
// to stricter network idle detection. Stub them globally so they don't stall tests.
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
cy.intercept('https://m.stripe.com/**', { statusCode: 200, body: {}, log: false },);
|
|
39
|
+
cy.intercept('https://maps.googleapis.com/**', { statusCode: 200, body: {}, log: false });
|
|
33
40
|
});
|
|
34
41
|
|
|
35
42
|
// Ignore retry failures from backend error pages so specs can assert UI state.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Handling Dependabot Dependency Updates
|
|
2
|
+
|
|
3
|
+
### Review the changelog first
|
|
4
|
+
Before merging, check what changed between versions — especially for major bumps. Look for breaking changes, deprecated APIs, or behavior changes.
|
|
5
|
+
|
|
6
|
+
### Understand semver signals
|
|
7
|
+
- **Patch (1.0.x)** — bug/security fixes, generally safe to merge
|
|
8
|
+
- **Minor (1.x.0)** — new features, backward-compatible, low risk
|
|
9
|
+
- **Major (x.0.0)** — breaking changes likely, requires careful review and testing
|
|
10
|
+
|
|
11
|
+
The general rule: patch = merge quickly, minor = review and merge, major = treat like a migration task.
|
|
12
|
+
|
|
13
|
+
### Don't skip tests
|
|
14
|
+
Make sure CI runs the full test suite on each Dependabot PR before merging. If tests are absent, do a manual smoke test of critical paths.
|
|
15
|
+
|
|
16
|
+
For **minor version updates**, run the Cypress test suite locally before merging (`yarn test`). New features in a minor bump can introduce subtle behavior changes that unit tests won't catch.
|
|
17
|
+
|
|
18
|
+
### Check for dependency compatibility
|
|
19
|
+
Bumping one package can cause peer dependency conflicts with others. Review the `yarn.lock` diff — a surprisingly large change warrants a closer look. Also check that the updated package is compatible with other key dependencies (e.g. a Vite plugin bumped to support Vite 6 may break if you're still on Vite 5).
|
|
20
|
+
|
|
21
|
+
### Don't blindly auto-merge everything
|
|
22
|
+
Auto-merge is reasonable for patch-level updates in well-tested projects, but be cautious with minor/major bumps or packages central to the app (e.g. web framework, auth libraries).
|
package/eslint-rules/index.js
CHANGED
|
@@ -89,7 +89,7 @@ function containsSpecReference(node, visitorKeys, matcher) {
|
|
|
89
89
|
|
|
90
90
|
function findEnclosingOptionsFunctionName(node, context, names) {
|
|
91
91
|
if (!isArray(names)) return null;
|
|
92
|
-
const ancestors = context.getAncestors();
|
|
92
|
+
const ancestors = context.sourceCode.getAncestors(node);
|
|
93
93
|
for (let i = ancestors.length - 1; i >= 0; i -= 1) {
|
|
94
94
|
const ancestor = ancestors[i];
|
|
95
95
|
if (!isFunctionNode(ancestor)) continue;
|
|
@@ -110,7 +110,7 @@ function isSetupFunction(node) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function isInSetup(node, context) {
|
|
113
|
-
const ancestors = context.getAncestors();
|
|
113
|
+
const ancestors = context.sourceCode.getAncestors(node);
|
|
114
114
|
for (let i = ancestors.length - 1; i >= 0; i -= 1) {
|
|
115
115
|
const ancestor = ancestors[i];
|
|
116
116
|
if (isSetupFunction(ancestor)) return true;
|
|
@@ -119,7 +119,7 @@ function isInSetup(node, context) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
function isVueFile(context) {
|
|
122
|
-
const filename = context.
|
|
122
|
+
const filename = context.filename;
|
|
123
123
|
if (!isString(filename)) return false;
|
|
124
124
|
return filename.endsWith(".vue");
|
|
125
125
|
}
|
|
@@ -136,7 +136,7 @@ const rules = {
|
|
|
136
136
|
},
|
|
137
137
|
create(context) {
|
|
138
138
|
if (!isVueFile(context)) return {};
|
|
139
|
-
const sourceCode = context.
|
|
139
|
+
const sourceCode = context.sourceCode;
|
|
140
140
|
const visitorKeys = sourceCode.visitorKeys;
|
|
141
141
|
|
|
142
142
|
return {
|
|
@@ -170,7 +170,7 @@ const rules = {
|
|
|
170
170
|
},
|
|
171
171
|
create(context) {
|
|
172
172
|
if (!isVueFile(context)) return {};
|
|
173
|
-
const sourceCode = context.
|
|
173
|
+
const sourceCode = context.sourceCode;
|
|
174
174
|
const visitorKeys = sourceCode.visitorKeys;
|
|
175
175
|
|
|
176
176
|
return {
|
|
@@ -201,7 +201,7 @@ const rules = {
|
|
|
201
201
|
},
|
|
202
202
|
create(context) {
|
|
203
203
|
if (!isVueFile(context)) return {};
|
|
204
|
-
const sourceCode = context.
|
|
204
|
+
const sourceCode = context.sourceCode;
|
|
205
205
|
const visitorKeys = sourceCode.visitorKeys;
|
|
206
206
|
|
|
207
207
|
return {
|
package/nav/dialog.vue
CHANGED
|
@@ -56,10 +56,10 @@ export default {
|
|
|
56
56
|
"panels-form": FormPanel,
|
|
57
57
|
},
|
|
58
58
|
extends: GlibBase,
|
|
59
|
-
expose: ['model', 'close', 'isFormDirty'],
|
|
60
59
|
props: {
|
|
61
60
|
spec: { type: Object, required: true }, // Original spec. It might be different from the latest spec (after reloading).
|
|
62
61
|
},
|
|
62
|
+
expose: ['model', 'close', 'isFormDirty'],
|
|
63
63
|
setup() {
|
|
64
64
|
const filePaster = ref(undefined);
|
|
65
65
|
usePasteable(filePaster);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "glib-web",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -42,30 +42,32 @@
|
|
|
42
42
|
"turndown": "^7.1.1",
|
|
43
43
|
"turndown-plugin-gfm": "^1.0.2",
|
|
44
44
|
"v-phone-input": "^4.2.2",
|
|
45
|
-
"vue": "3.5.
|
|
45
|
+
"vue": "3.5.33",
|
|
46
46
|
"vue-chartkick": "^1.1.0",
|
|
47
47
|
"vue-social-sharing": "^4.0.0-alpha4",
|
|
48
48
|
"vuedraggable": "^4.1.0",
|
|
49
|
-
"vuetify": "
|
|
49
|
+
"vuetify": "^4.0.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"
|
|
52
|
+
"@cypress/code-coverage": "^4.0.3",
|
|
53
|
+
"@cypress/vite-dev-server": "^7.3.1",
|
|
54
|
+
"@eslint/js": "^10.0.1",
|
|
55
|
+
"@types/chart.js": "^4.0.1",
|
|
56
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
57
|
+
"cypress": "^15.14.2",
|
|
58
|
+
"eslint": "^10.3.0",
|
|
53
59
|
"eslint-config-prettier": "^10.1.8",
|
|
54
|
-
"@cypress/code-coverage": "^3.14.7",
|
|
55
|
-
"@cypress/vite-dev-server": "^5.0.0",
|
|
56
|
-
"@types/chart.js": "^2.9.34",
|
|
57
|
-
"@vitejs/plugin-vue": "^6.0.2",
|
|
58
|
-
"cypress": "^13.13.1",
|
|
59
|
-
"eslint": "^8.36.0",
|
|
60
60
|
"eslint-plugin-chai-friendly": "^1.0.1",
|
|
61
|
-
"eslint-plugin-vue": "^9.
|
|
62
|
-
"prettier": "^
|
|
61
|
+
"eslint-plugin-vue": "^10.9.0",
|
|
62
|
+
"prettier": "^3.8.3",
|
|
63
63
|
"sass-embedded": "^1.97.1",
|
|
64
|
-
"typescript": "^
|
|
65
|
-
"
|
|
64
|
+
"typescript": "^6.0.3",
|
|
65
|
+
"typescript-eslint": "^8.54.0",
|
|
66
|
+
"vite": "^8.0.10",
|
|
66
67
|
"vite-plugin-compression": "^0.5.1",
|
|
67
68
|
"vite-plugin-environment": "^1.1.3",
|
|
68
|
-
"vite-plugin-istanbul": "^
|
|
69
|
-
"vite-plugin-ruby": "^5.1.1"
|
|
69
|
+
"vite-plugin-istanbul": "^8.0.0",
|
|
70
|
+
"vite-plugin-ruby": "^5.1.1",
|
|
71
|
+
"vue-eslint-parser": "^10.4.0"
|
|
70
72
|
}
|
|
71
73
|
}
|
package/templates/_menu.vue
CHANGED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import inputUpload from "../../components/fields/inputUpload.vue";
|
|
2
|
-
import Uploader from "../../utils/glibDirectUpload";
|
|
3
|
-
import { mountWithGlib, restoreUploaderStartStub, setupGlibGlobals } from "./testUtils";
|
|
4
|
-
|
|
5
|
-
const buildSpec = (overrides = {}) => ({
|
|
6
|
-
name: "user[file]",
|
|
7
|
-
label: "Upload file",
|
|
8
|
-
accepts: { fileType: "txt" },
|
|
9
|
-
...overrides,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const mountComponent = (spec) => {
|
|
13
|
-
mountWithGlib(inputUpload, spec);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
describe("inputUpload", () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
setupGlibGlobals();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
restoreUploaderStartStub();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("uploads via direct upload and sets hidden signed ids", () => {
|
|
26
|
-
cy.stub(Uploader.prototype, "start")
|
|
27
|
-
.callsFake((callback) => {
|
|
28
|
-
callback(null, { signed_id: "signed-123" });
|
|
29
|
-
})
|
|
30
|
-
.as("directUploadStart");
|
|
31
|
-
|
|
32
|
-
mountComponent(
|
|
33
|
-
buildSpec({
|
|
34
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
35
|
-
})
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
39
|
-
|
|
40
|
-
cy.get("@directUploadStart").should("have.been.calledOnce");
|
|
41
|
-
cy.get('input[type="hidden"]')
|
|
42
|
-
.should("have.value", "signed-123")
|
|
43
|
-
.and("have.attr", "name", "user[file]");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("blocks uploads when file type validation fails", () => {
|
|
47
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
48
|
-
|
|
49
|
-
mountComponent(
|
|
50
|
-
buildSpec({
|
|
51
|
-
accepts: { fileType: "image" },
|
|
52
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
57
|
-
|
|
58
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
59
|
-
cy.get('input[type="hidden"]').should("not.exist");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("blocks uploads when file size validation fails", () => {
|
|
63
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
64
|
-
|
|
65
|
-
mountComponent(
|
|
66
|
-
buildSpec({
|
|
67
|
-
accepts: { fileType: "txt", maxFileSize: 0.000001 },
|
|
68
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
73
|
-
|
|
74
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
75
|
-
cy.get('input[type="hidden"]').should("not.exist");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("blocks uploads when file count validation fails", () => {
|
|
79
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
80
|
-
|
|
81
|
-
mountComponent(
|
|
82
|
-
buildSpec({
|
|
83
|
-
accepts: { fileType: "txt", maxFileLength: 1 },
|
|
84
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
85
|
-
files: [
|
|
86
|
-
{
|
|
87
|
-
url: "https://example.com/existing.txt",
|
|
88
|
-
name: "existing.txt",
|
|
89
|
-
signed_id: "signed-existing",
|
|
90
|
-
type: "text/plain",
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
multiple: true,
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
cy.get('input[type="hidden"]').should("have.length", 1);
|
|
98
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
99
|
-
|
|
100
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
101
|
-
cy.get('input[type="hidden"]').should("have.length", 1);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import multiUpload from "../../components/fields/multiUpload.vue";
|
|
2
|
-
import Uploader from "../../utils/glibDirectUpload";
|
|
3
|
-
import { mountWithGlib, restoreUploaderStartStub, setupGlibGlobals } from "./testUtils";
|
|
4
|
-
|
|
5
|
-
const buildSpec = (overrides = {}) => ({
|
|
6
|
-
name: "user[files][]",
|
|
7
|
-
accepts: { fileType: "txt" },
|
|
8
|
-
placeholder: "Drop files",
|
|
9
|
-
hint: "Attach files",
|
|
10
|
-
...overrides,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const mountComponent = (spec) => {
|
|
14
|
-
mountWithGlib(multiUpload, spec);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe("multiUpload", () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
setupGlibGlobals();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
restoreUploaderStartStub();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("uploads via direct upload and sets hidden signed ids", () => {
|
|
27
|
-
cy.stub(Uploader.prototype, "start")
|
|
28
|
-
.callsFake((callback) => {
|
|
29
|
-
callback(null, { signed_id: "signed-123" });
|
|
30
|
-
})
|
|
31
|
-
.as("directUploadStart");
|
|
32
|
-
|
|
33
|
-
mountComponent(
|
|
34
|
-
buildSpec({
|
|
35
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
cy.get(".gdrop-file").click({ force: true });
|
|
40
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
41
|
-
|
|
42
|
-
cy.get("@directUploadStart").should("have.been.calledOnce");
|
|
43
|
-
cy.get('input[type="hidden"]')
|
|
44
|
-
.should("have.value", "signed-123")
|
|
45
|
-
.and("have.attr", "name", "user[files][]");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("blocks uploads when file type validation fails", () => {
|
|
49
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
50
|
-
|
|
51
|
-
mountComponent(
|
|
52
|
-
buildSpec({
|
|
53
|
-
accepts: { fileType: "image" },
|
|
54
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
cy.get(".gdrop-file").click({ force: true });
|
|
59
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
60
|
-
|
|
61
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
62
|
-
cy.get('input[type="hidden"]').should("not.exist");
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("blocks uploads when file size validation fails", () => {
|
|
66
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
67
|
-
|
|
68
|
-
mountComponent(
|
|
69
|
-
buildSpec({
|
|
70
|
-
accepts: { fileType: "txt", maxFileSize: 0.000001 },
|
|
71
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
cy.get(".gdrop-file").click({ force: true });
|
|
76
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
77
|
-
|
|
78
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
79
|
-
cy.get('input[type="hidden"]').should("not.exist");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("blocks uploads when file count validation fails", () => {
|
|
83
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
84
|
-
|
|
85
|
-
mountComponent(
|
|
86
|
-
buildSpec({
|
|
87
|
-
accepts: { fileType: "txt", maxFileLength: 1 },
|
|
88
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
89
|
-
files: [
|
|
90
|
-
{
|
|
91
|
-
url: "https://example.com/existing.txt",
|
|
92
|
-
name: "existing.txt",
|
|
93
|
-
signed_id: "signed-existing",
|
|
94
|
-
type: "text/plain",
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
})
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
cy.get(".gdrop-file").click({ force: true });
|
|
101
|
-
cy.get('input[type="hidden"]').should("have.length", 1);
|
|
102
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
103
|
-
|
|
104
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
105
|
-
cy.get('input[type="hidden"]').should("have.length", 1);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import placeholderUpload from "../../components/fields/placeholderUpload.vue";
|
|
2
|
-
import Uploader from "../../utils/glibDirectUpload";
|
|
3
|
-
import { mountWithGlib, restoreUploaderStartStub, setupGlibGlobals } from "./testUtils";
|
|
4
|
-
|
|
5
|
-
const buildSpec = (overrides = {}) => ({
|
|
6
|
-
name: "user[file]",
|
|
7
|
-
type: "image",
|
|
8
|
-
width: 120,
|
|
9
|
-
height: 80,
|
|
10
|
-
url: "https://example.com/image.png",
|
|
11
|
-
accepts: { fileType: "txt" },
|
|
12
|
-
...overrides,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const mountComponent = (spec) => {
|
|
16
|
-
mountWithGlib(placeholderUpload, spec);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
describe("placeholderUpload", () => {
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
setupGlibGlobals();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
restoreUploaderStartStub();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("uploads via direct upload and sets hidden signed id", () => {
|
|
29
|
-
cy.stub(Uploader.prototype, "start")
|
|
30
|
-
.callsFake((callback) => {
|
|
31
|
-
callback(null, { signed_id: "signed-123" });
|
|
32
|
-
})
|
|
33
|
-
.as("directUploadStart");
|
|
34
|
-
|
|
35
|
-
mountComponent(
|
|
36
|
-
buildSpec({
|
|
37
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
42
|
-
|
|
43
|
-
cy.get("@directUploadStart").should("have.been.calledOnce");
|
|
44
|
-
cy.get('input[type="hidden"]')
|
|
45
|
-
.should("have.value", "signed-123")
|
|
46
|
-
.and("have.attr", "name", "user[file]");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("uses native file input when direct upload is not set", () => {
|
|
50
|
-
mountComponent(buildSpec());
|
|
51
|
-
|
|
52
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
53
|
-
|
|
54
|
-
cy.get('input[type="file"]').then((input) => {
|
|
55
|
-
expect(input[0].files).to.have.length(1);
|
|
56
|
-
});
|
|
57
|
-
cy.get('input[type="hidden"]').should("not.exist");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("blocks uploads when file type validation fails", () => {
|
|
61
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
62
|
-
|
|
63
|
-
mountComponent(
|
|
64
|
-
buildSpec({
|
|
65
|
-
accepts: { fileType: "image" },
|
|
66
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
71
|
-
|
|
72
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
73
|
-
cy.get('input[type="hidden"]').should("have.value", "");
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("blocks uploads when file size validation fails", () => {
|
|
77
|
-
cy.stub(Uploader.prototype, "start").as("directUploadStart");
|
|
78
|
-
|
|
79
|
-
mountComponent(
|
|
80
|
-
buildSpec({
|
|
81
|
-
accepts: { fileType: "txt", maxFileSize: 0.000001 },
|
|
82
|
-
directUploadUrl: "/rails/active_storage/direct_uploads",
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
cy.get('input[type="file"]').selectFile("cypress/fixtures/upload.txt", { force: true });
|
|
87
|
-
|
|
88
|
-
cy.get("@directUploadStart").should("not.have.been.called");
|
|
89
|
-
cy.get('input[type="hidden"]').should("have.value", "");
|
|
90
|
-
});
|
|
91
|
-
});
|