diff --git a/preact/0.56.1/maintenance.preact.0.56.1.yml b/preact/0.56.1/maintenance.preact.0.56.1.yml new file mode 100644 index 0000000..e6a2372 --- /dev/null +++ b/preact/0.56.1/maintenance.preact.0.56.1.yml @@ -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 diff --git a/preact/0.56.1/tests/cypress/support/commands.js b/preact/0.56.1/tests/cypress/support/commands.js new file mode 100644 index 0000000..9def0bf --- /dev/null +++ b/preact/0.56.1/tests/cypress/support/commands.js @@ -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); + }); +}); \ No newline at end of file