diff --git a/.github/workflows/size-check.yml b/.github/workflows/size-check.yml index c970b0ea0e0decca7611e3f3566459d7946c46dd..9988fd838e1bfd2983db7d878abe500c1d3bdfd6 100644 --- a/.github/workflows/size-check.yml +++ b/.github/workflows/size-check.yml @@ -20,9 +20,3 @@ jobs: build_script: build files: packages/size-check/dist/size-check.es.js packages/size-check/dist/style.css packages/uni-app/dist/uni-app.es.js packages/uni-h5-vue/dist/vue.runtime.esm.js packages/uni-mp-vue/dist/vue.runtime.esm.js packages/uni-mp-alipay/dist/uni.api.esm.js packages/uni-mp-alipay/dist/uni.mp.esm.js packages/uni-mp-baidu/dist/uni.api.esm.js packages/uni-mp-baidu/dist/uni.mp.esm.js packages/uni-mp-qq/dist/uni.api.esm.js packages/uni-mp-qq/dist/uni.mp.esm.js packages/uni-mp-toutiao/dist/uni.api.esm.js packages/uni-mp-toutiao/dist/uni.mp.esm.js packages/uni-mp-weixin/dist/uni.api.esm.js packages/uni-mp-weixin/dist/uni.mp.esm.js packages/uni-quickapp-webview/dist/uni.api.esm.js packages/uni-quickapp-webview/dist/uni.mp.esm.js - run: npm run test - - uses: bahmutov/npm-install@v1 - with: - working-directory: packages/playground/ssr - - name: build ssr - run: npm run build:ssr - working-directory: packages/playground/ssr diff --git a/.github/workflows/ssr.yml b/.github/workflows/ssr.yml new file mode 100644 index 0000000000000000000000000000000000000000..a72697634e2a825c9080beb8aa05adecf9417241 --- /dev/null +++ b/.github/workflows/ssr.yml @@ -0,0 +1,29 @@ +name: 'ssr' +on: + push: + branches: + - next + pull_request: + branches: + - next +jobs: + cypress-run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: build + run: npm run build + - uses: bahmutov/npm-install@v1 + working-directory: packages/playground/ssr + - name: Cypress run + uses: cypress-io/github-action@v2 + working-directory: packages/playground/ssr + with: + install: false + start: npm run dev:ssr + wait-on: 'http://localhost:3000' + wait-on-timeout: 120 + browser: chrome + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index e94373c20f378e268b099705d773aa28971d83e8..bbff3918a89abc7c9ee9d4dc115d867b7911625c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"", "ls-lint": "ls-lint", "test": "jest", - "preinstall": "node ./scripts/checkYarn.js" + "preinstall": "node ./scripts/checkYarn.js", + "e2e:ssr": "cypress open --project packages/playground/ssr" }, "types": "test-dts/index.d.ts", "tsd": { diff --git a/packages/playground/ssr/cypress.json b/packages/playground/ssr/cypress.json new file mode 100644 index 0000000000000000000000000000000000000000..17ef242e711f0f7671c727133fe03419968bac3b --- /dev/null +++ b/packages/playground/ssr/cypress.json @@ -0,0 +1,3 @@ +{ + "baseUrl": "http://localhost:3000" +} diff --git a/packages/playground/ssr/cypress/examples/actions.spec.js b/packages/playground/ssr/cypress/examples/actions.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..2f11a34565518a013aee31615cda8d296208cc60 --- /dev/null +++ b/packages/playground/ssr/cypress/examples/actions.spec.js @@ -0,0 +1,313 @@ +/// + +context('Actions', () => { + beforeEach(() => { + cy.visit('https://example.cypress.io/commands/actions') + }) + + // https://on.cypress.io/interacting-with-elements + + it('.type() - type into a DOM element', () => { + // https://on.cypress.io/type + cy.get('.action-email') + .type('fake@email.com') + .should('have.value', 'fake@email.com') + + // .type() with special character sequences + .type('{leftarrow}{rightarrow}{uparrow}{downarrow}') + .type('{del}{selectall}{backspace}') + + // .type() with key modifiers + .type('{alt}{option}') //these are equivalent + .type('{ctrl}{control}') //these are equivalent + .type('{meta}{command}{cmd}') //these are equivalent + .type('{shift}') + + // Delay each keypress by 0.1 sec + .type('slow.typing@email.com', { delay: 100 }) + .should('have.value', 'slow.typing@email.com') + + cy.get('.action-disabled') + // Ignore error checking prior to type + // like whether the input is visible or disabled + .type('disabled error checking', { force: true }) + .should('have.value', 'disabled error checking') + }) + + it('.focus() - focus on a DOM element', () => { + // https://on.cypress.io/focus + cy.get('.action-focus') + .focus() + .should('have.class', 'focus') + .prev() + .should('have.attr', 'style', 'color: orange;') + }) + + it('.blur() - blur off a DOM element', () => { + // https://on.cypress.io/blur + cy.get('.action-blur') + .type('About to blur') + .blur() + .should('have.class', 'error') + .prev() + .should('have.attr', 'style', 'color: red;') + }) + + it('.clear() - clears an input or textarea element', () => { + // https://on.cypress.io/clear + cy.get('.action-clear') + .type('Clear this text') + .should('have.value', 'Clear this text') + .clear() + .should('have.value', '') + }) + + it('.submit() - submit a form', () => { + // https://on.cypress.io/submit + cy.get('.action-form').find('[type="text"]').type('HALFOFF') + + cy.get('.action-form') + .submit() + .next() + .should('contain', 'Your form has been submitted!') + }) + + it('.click() - click on a DOM element', () => { + // https://on.cypress.io/click + cy.get('.action-btn').click() + + // You can click on 9 specific positions of an element: + // ----------------------------------- + // | topLeft top topRight | + // | | + // | | + // | | + // | left center right | + // | | + // | | + // | | + // | bottomLeft bottom bottomRight | + // ----------------------------------- + + // clicking in the center of the element is the default + cy.get('#action-canvas').click() + + cy.get('#action-canvas').click('topLeft') + cy.get('#action-canvas').click('top') + cy.get('#action-canvas').click('topRight') + cy.get('#action-canvas').click('left') + cy.get('#action-canvas').click('right') + cy.get('#action-canvas').click('bottomLeft') + cy.get('#action-canvas').click('bottom') + cy.get('#action-canvas').click('bottomRight') + + // .click() accepts an x and y coordinate + // that controls where the click occurs :) + + cy.get('#action-canvas') + .click(80, 75) // click 80px on x coord and 75px on y coord + .click(170, 75) + .click(80, 165) + .click(100, 185) + .click(125, 190) + .click(150, 185) + .click(170, 165) + + // click multiple elements by passing multiple: true + cy.get('.action-labels>.label').click({ multiple: true }) + + // Ignore error checking prior to clicking + cy.get('.action-opacity>.btn').click({ force: true }) + }) + + it('.dblclick() - double click on a DOM element', () => { + // https://on.cypress.io/dblclick + + // Our app has a listener on 'dblclick' event in our 'scripts.js' + // that hides the div and shows an input on double click + cy.get('.action-div').dblclick().should('not.be.visible') + cy.get('.action-input-hidden').should('be.visible') + }) + + it('.rightclick() - right click on a DOM element', () => { + // https://on.cypress.io/rightclick + + // Our app has a listener on 'contextmenu' event in our 'scripts.js' + // that hides the div and shows an input on right click + cy.get('.rightclick-action-div').rightclick().should('not.be.visible') + cy.get('.rightclick-action-input-hidden').should('be.visible') + }) + + it('.check() - check a checkbox or radio element', () => { + // https://on.cypress.io/check + + // By default, .check() will check all + // matching checkbox or radio elements in succession, one after another + cy.get('.action-checkboxes [type="checkbox"]') + .not('[disabled]') + .check() + .should('be.checked') + + cy.get('.action-radios [type="radio"]') + .not('[disabled]') + .check() + .should('be.checked') + + // .check() accepts a value argument + cy.get('.action-radios [type="radio"]').check('radio1').should('be.checked') + + // .check() accepts an array of values + cy.get('.action-multiple-checkboxes [type="checkbox"]') + .check(['checkbox1', 'checkbox2']) + .should('be.checked') + + // Ignore error checking prior to checking + cy.get('.action-checkboxes [disabled]') + .check({ force: true }) + .should('be.checked') + + cy.get('.action-radios [type="radio"]') + .check('radio3', { force: true }) + .should('be.checked') + }) + + it('.uncheck() - uncheck a checkbox element', () => { + // https://on.cypress.io/uncheck + + // By default, .uncheck() will uncheck all matching + // checkbox elements in succession, one after another + cy.get('.action-check [type="checkbox"]') + .not('[disabled]') + .uncheck() + .should('not.be.checked') + + // .uncheck() accepts a value argument + cy.get('.action-check [type="checkbox"]') + .check('checkbox1') + .uncheck('checkbox1') + .should('not.be.checked') + + // .uncheck() accepts an array of values + cy.get('.action-check [type="checkbox"]') + .check(['checkbox1', 'checkbox3']) + .uncheck(['checkbox1', 'checkbox3']) + .should('not.be.checked') + + // Ignore error checking prior to unchecking + cy.get('.action-check [disabled]') + .uncheck({ force: true }) + .should('not.be.checked') + }) + + it('.select() - select an option in a