Skip to content

Commit

Permalink
patch maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
korgon committed May 23, 2024
1 parent 38c6f4b commit face069
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
16 changes: 16 additions & 0 deletions preact/0.56.1/maintenance.preact.0.56.1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 0.56.1
description: 'adjust github action add concurency check'

steps:
# normalize set of cypress files
- run: |
cp ./patch/tests/cypress/support/commands.js ./tests/cypress/support/commands.js
- files:
.github/workflows/deploy.yml:
action: edit-yaml
changes:
- update:
path: ['concurrency']
value:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
98 changes: 98 additions & 0 deletions preact/0.56.1/tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// DO NOT EDIT - THIS FILE CAN/WILL BE REPLACED!!!
// ***********************************************
// Custom Snap Cypress Commands
//
// For more comprehensive examples:
// https://on.cypress.io/custom-commands
// ***********************************************

import packageJSON from '../../../package.json';

Cypress.Commands.add('addScript', (script) => {
cy.document().then((doc) => {
const scriptElem = document.createElement('script');
scriptElem.type = 'text/javascript';
scriptElem.src = script;
doc.head.appendChild(scriptElem);
});
});

Cypress.Commands.add('addScripts', (scripts = []) => {
scripts = typeof scripts === 'string' ? [scripts] : scripts;

if (!scripts.length) return;

scripts.forEach((script) => {
cy.addScript(script);
});
});

Cypress.Commands.add('addLocalSnap', () => {
cy.window().then((window) => {
if (!window?.searchspring) {
cy.addScript('https://localhost:3333/bundle.js');
}
});
});

Cypress.Commands.add('addCloudSnap', (branch = 'production') => {
cy.intercept(/.*snapui.searchspring.io\/.*\/bundle.js$/).as('script');
cy.addScript(`https://snapui.searchspring.io/${packageJSON.searchspring.siteId}/${branch}/bundle.js`);
});

Cypress.Commands.add('snapController', (controllerId = 'search') => {
return cy.window().then((window) => {
return new Cypress.Promise((resolve) => {
const checkTimeout = 100;
const interval = setInterval(() => {
if (window.searchspring?.controller && window.searchspring.controller[controllerId]) {
if (!window.searchspring.controller[controllerId].store.loading) {
clearInterval(interval);
resolve(window.searchspring.controller[controllerId]);
}
}
}, checkTimeout);
});
});
});

Cypress.Commands.add('waitForBundle', () => {
cy.window().then((window) => {
return new Cypress.Promise((resolve) => {
const checkTimeout = 100;
let interval = setInterval(() => {
if (window.searchspring) {
clearInterval(interval);
resolve();
}
}, checkTimeout);
});
});
});

Cypress.Commands.add('waitForIdle', (options) => {
options = { timeout: 200, ...options };

return cy.window().then((window) => {
return new Cypress.Promise((resolve) => {
let timeout = setTimeout(resolve, options.timeout);

const observer = new window.PerformanceObserver(() => {
clearTimeout(timeout);
timeout = setTimeout(resolve, options.timeout);
});

observer.observe({ entryTypes: ['resource'] });
});
});
});

Cypress.Commands.overwrite('clear', (orig, element, text, options) => {
return new Cypress.Promise(async(resolve) => {
const cleared = await orig(element, text, options);

setTimeout(() => {
resolve(cleared);
}, 500);
});
});

0 comments on commit face069

Please sign in to comment.