glib-web 4.44.3 → 4.44.6

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.
@@ -2,12 +2,12 @@ import { testPageUrl } from "../../helper"
2
2
 
3
3
  const url = testPageUrl('fields_captcha')
4
4
 
5
- const visitWithCaptcha = (executeResult: () => Promise<string>) => {
5
+ const visitWithCaptcha = (executeResult) => {
6
6
  cy.visit(url, {
7
- onBeforeLoad(win: Cypress.AUTWindow) {
8
- (win as unknown as Record<string, unknown>).grecaptcha = {
7
+ onBeforeLoad(win) {
8
+ win.grecaptcha = {
9
9
  enterprise: {
10
- ready: function(cb: () => void) { cb(); },
10
+ ready: function(cb) { cb(); },
11
11
  execute: function() { return executeResult(); }
12
12
  }
13
13
  }
@@ -2,7 +2,11 @@ import { testPageUrl } from "../../helper"
2
2
 
3
3
  const url = testPageUrl('panels_bulkEdit2')
4
4
 
5
- const csvFixturePath = 'cypress/fixtures/bulk_edit.csv'
5
+ const csvFixtureContents = [
6
+ 'month,electricity_usage,gas_usage,sources,compliant',
7
+ 'January,120,10,Generators,yes',
8
+ 'February,150,12,Solar Panels,no'
9
+ ].join('\n')
6
10
 
7
11
  describe('panels_bulkEdit2', () => {
8
12
  it('loads csv rows and toggles column variants', () => {
@@ -10,7 +14,14 @@ describe('panels_bulkEdit2', () => {
10
14
 
11
15
  cy.contains('Drag your CSV file here').should('exist')
12
16
 
13
- cy.get('input[type="file"]').selectFile(csvFixturePath, { force: true })
17
+ cy.get('input[type="file"]').selectFile(
18
+ {
19
+ contents: Cypress.Buffer.from(csvFixtureContents),
20
+ fileName: 'bulk_edit.csv',
21
+ mimeType: 'text/csv'
22
+ },
23
+ { force: true }
24
+ )
14
25
 
15
26
  cy.get('tbody tr').should('have.length', 2)
16
27
  cy.contains('Submit (top)').should('be.visible')
package/cypress/helper.ts CHANGED
@@ -1,4 +1,4 @@
1
- function testPageUrl(testPage: string) {
1
+ function testPageUrl(testPage) {
2
2
  const port = Cypress.env('BACKEND_PORT') || '3000';
3
3
  const baseUrl = `http://localhost:${port}/glib/json_ui_garage?path=test_page%2F${testPage}`;
4
4
  return baseUrl;
@@ -17,5 +17,14 @@
17
17
  import './commands'
18
18
  import '@cypress/code-coverage/support'
19
19
 
20
+ // Ignore retry failures from backend error pages so specs can assert UI state.
21
+ Cypress.on('uncaught:exception', (err) => {
22
+ const message = `${err}`;
23
+ if (message.includes('Retry failed')) {
24
+ return false;
25
+ }
26
+ return true;
27
+ });
28
+
20
29
  // Alternatively you can use CommonJS syntax:
21
30
  // require('./commands')
package/cypress.config.ts CHANGED
@@ -51,6 +51,10 @@ export default defineConfig({
51
51
  },
52
52
  },
53
53
  e2e: {
54
+ defaultCommandTimeout: 10000,
55
+ pageLoadTimeout: 60000,
56
+ requestTimeout: 15000,
57
+ responseTimeout: 15000,
54
58
  setupNodeEvents(on, config) {
55
59
  codeCoverageTask(on, config);
56
60
  return config;
@@ -43,14 +43,13 @@ jobs:
43
43
  - run: cp config/database.yml.github-actions config/database.yml
44
44
  - run: bundle exec rake db:test:prepare
45
45
  - run: bundle exec rails server -d
46
- - name: Cypress run
47
- uses: cypress-io/github-action@v6
48
- with:
49
- browser: chrome
46
+ - name: Cypress run (e2e)
47
+ run: env -u ELECTRON_RUN_AS_NODE yarn cypress run --browser chrome
48
+ - name: Cypress run (component)
49
+ run: env -u ELECTRON_RUN_AS_NODE yarn cypress run --component
50
50
  - name: Upload screenshots
51
51
  uses: actions/upload-artifact@v4
52
52
  if: failure()
53
53
  with:
54
54
  name: cypress-screenshots
55
55
  path: cypress/screenshots
56
- - run: yarn run cypress run
package/index.js CHANGED
@@ -61,6 +61,7 @@ import CommonResponsive from "./components/responsive.vue";
61
61
  import CommonTemplateMenu from "./templates/_menu.vue";
62
62
  import BigProgressCircle from "./templates/bigProgressCircle.vue";
63
63
  import RichButton from "./components/button.vue";
64
+ import Dom from "./utils/dom";
64
65
  Vue.component("panels-vertical", VerticalPanel);
65
66
  Vue.component("panels-responsive", ResponsivePanel);
66
67
  Vue.component("common-avatar", CommonAvatar);
@@ -123,6 +124,7 @@ const vPhoneInput = createVPhoneInput({
123
124
 
124
125
  Vue.use(vPhoneInput);
125
126
 
127
+ Dom.ensureCsrfElement();
126
128
 
127
129
  document.addEventListener("DOMContentLoaded", () => {
128
130
  Vue.mount(`#${APP_ID}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "glib-web",
4
- "version": "4.44.3",
4
+ "version": "4.44.6",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -68,4 +68,4 @@
68
68
  "vite-plugin-istanbul": "^7.2.1",
69
69
  "vite-plugin-ruby": "^5.1.1"
70
70
  }
71
- }
71
+ }
package/utils/dom.js CHANGED
@@ -1,6 +1,24 @@
1
+ import * as TypeUtils from "./type";
2
+
1
3
  export default class {
4
+ static ensureCsrfElement() {
5
+ let element = document.querySelector('meta[name="csrf-token"]');
6
+ if (!TypeUtils.isObject(element)) {
7
+ const meta = document.createElement("meta");
8
+ meta.setAttribute("name", "csrf-token");
9
+ meta.setAttribute("content", "");
10
+ if (TypeUtils.isObject(document.head)) {
11
+ document.head.appendChild(meta);
12
+ } else {
13
+ document.documentElement.appendChild(meta);
14
+ }
15
+ element = meta;
16
+ }
17
+ return element;
18
+ }
19
+
2
20
  static get csrfElement() {
3
- return document.querySelector(`meta[name="csrf-token"]`);
21
+ return this.ensureCsrfElement();
4
22
  }
5
23
 
6
24
  static getCsrf() {
@@ -1,34 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Read(//home/hgani/workspace/glib-web/app/views/json_ui/garage/**)",
5
- "Read(//home/hgani/workspace/glib-web-npm/doc/garage/**)",
6
- "Read(//home/hgani/workspace/glib-web-npm/doc/common/**)",
7
- "Bash(find:*)",
8
- "Bash(npx cypress run:*)",
9
- "Read(//home/hgani/workspace/glib-web/**)",
10
- "Bash(curl:*)",
11
- "Bash(pkill:*)",
12
- "Bash(gh pr list:*)",
13
- "WebSearch",
14
- "WebFetch(domain:vuetifyjs.com)",
15
- "Bash(lsof:*)",
16
- "Bash(readlink:*)",
17
- "WebFetch(domain:github.com)",
18
- "Bash(npm run dev)",
19
- "Bash(npm run)",
20
- "Bash(npx eslint:*)",
21
- "Bash(npm install:*)",
22
- "Bash(yarn lint:*)",
23
- "Bash(bin/rails db:migrate:*)",
24
- "Bash(bin/rails server:*)",
25
- "Bash(dpkg -S:*)",
26
- "Bash(source:*)",
27
- "Bash(node --version:*)",
28
- "Bash(nvm ls:*)",
29
- "Bash(nvm use:*)"
30
- ],
31
- "deny": [],
32
- "ask": []
33
- }
34
- }