Browse Source

Add cypress options test

zhixin 5 years ago
parent
commit
2717979eec

+ 1 - 1
.travis.yml

@@ -29,7 +29,7 @@ jobs:
         directories:
           - ~/.cache
       script:
-        - git clone --depth=1 -b feature/cypress-test https://github.com/wenzhixin/bootstrap-table-examples cypress/html
+        - git clone --depth=1 https://github.com/wenzhixin/bootstrap-table-examples cypress/html
         - npm run css:build:src
         - npm run test
       if: branch != master AND type = pull_request

+ 27 - 0
cypress/common/options.js

@@ -0,0 +1,27 @@
+module.exports = (theme = '') => {
+  const baseUrl = require('./utils')(theme, 'options')
+
+  describe('Welcome Test', () => {
+    it('Test Custom AJAX', () => {
+      cy.visit(`${baseUrl}table-ajax.html`)
+        .get('.fixed-table-pagination >.pagination-detail').should('have.length', 1)
+        .get('.fixed-table-pagination > .pagination').should('have.length', 1)
+        .get('span.pagination-info').should('contain', '800')
+    })
+
+    it('Test AJAX Options', () => {
+      cy.visit(`${baseUrl}ajax-options.html`)
+        .intercept('GET', '**/json/data1.json').as('ajax')
+        .wait('@ajax')
+        .should(({ request }) => {
+          expect(request.headers).to.have.property('custom-auth-token')
+            .and.eq('custom-auth-token')
+        })
+    })
+
+    it('Test Basic Columns', () => {
+      cy.visit(`${baseUrl}basic-columns.html`)
+        .get('.fixed-table-toolbar .columns').should('exist')
+    })
+  })
+}

+ 1 - 1
cypress/common/welcome.js

@@ -29,7 +29,7 @@ module.exports = (theme = '') => {
       const html = theme ? `modal-table-${theme}.html` : 'modal-table.html'
 
       cy.visit(`${baseUrl}${html}`)
-        .get('#button').wait(100).click()
+        .get('#button').wait(200).click()
         .get('.bootstrap-table').should('be.visible')
         .get('.fixed-table-container').should('have.css', 'height', '345px')
         .invoke('css', 'padding-bottom').then(str => parseInt(str)).should('be.greaterThan', 0)

+ 1 - 0
cypress/integration/options/bootstrap3.js

@@ -0,0 +1 @@
+require('../../common/options')('bootstrap3')

+ 1 - 0
cypress/integration/options/bootstrap5.js

@@ -0,0 +1 @@
+require('../../common/options')('bootstrap5')

+ 1 - 0
cypress/integration/options/bulma.js

@@ -0,0 +1 @@
+require('../../common/options')('bulma')

+ 1 - 0
cypress/integration/options/foundation.js

@@ -0,0 +1 @@
+require('../../common/options')('foundation')

+ 1 - 0
cypress/integration/options/index.js

@@ -0,0 +1 @@
+require('../../common/options')()

+ 1 - 0
cypress/integration/options/materialize.js

@@ -0,0 +1 @@
+require('../../common/options')('materialize')

+ 1 - 0
cypress/integration/options/semantic.js

@@ -0,0 +1 @@
+require('../../common/options')('semantic')

+ 1 - 1
package.json

@@ -15,7 +15,7 @@
     "clean-css-cli": "^5.0.1",
     "core-js": "^3.1.4",
     "cross-env": "^7.0.2",
-    "cypress": "^6.1.0",
+    "cypress": "^8.6.0",
     "eslint": "^8.0.1",
     "esm": "^3.2.25",
     "foreach-cli": "^1.8.1",