tonder-web-sdk 1.4.0
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.
- package/.env-example +1 -0
- package/.htaccess +1 -0
- package/README.md +204 -0
- package/cypress/e2e/1-getting-started/todo.cy.js +143 -0
- package/cypress/e2e/2-advanced-examples/actions.cy.js +299 -0
- package/cypress/e2e/2-advanced-examples/aliasing.cy.js +39 -0
- package/cypress/e2e/2-advanced-examples/assertions.cy.js +176 -0
- package/cypress/e2e/2-advanced-examples/connectors.cy.js +98 -0
- package/cypress/e2e/2-advanced-examples/cookies.cy.js +118 -0
- package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +185 -0
- package/cypress/e2e/2-advanced-examples/files.cy.js +85 -0
- package/cypress/e2e/2-advanced-examples/location.cy.js +32 -0
- package/cypress/e2e/2-advanced-examples/misc.cy.js +104 -0
- package/cypress/e2e/2-advanced-examples/navigation.cy.js +56 -0
- package/cypress/e2e/2-advanced-examples/network_requests.cy.js +163 -0
- package/cypress/e2e/2-advanced-examples/querying.cy.js +114 -0
- package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +201 -0
- package/cypress/e2e/2-advanced-examples/storage.cy.js +110 -0
- package/cypress/e2e/2-advanced-examples/traversal.cy.js +121 -0
- package/cypress/e2e/2-advanced-examples/utilities.cy.js +108 -0
- package/cypress/e2e/2-advanced-examples/viewport.cy.js +58 -0
- package/cypress/e2e/2-advanced-examples/waiting.cy.js +30 -0
- package/cypress/e2e/2-advanced-examples/window.cy.js +22 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/e2e.js +20 -0
- package/cypress.config.js +9 -0
- package/index.html +178 -0
- package/index.js.example +50 -0
- package/package.json +29 -0
- package/samples/react/README.md +70 -0
- package/samples/react/build/asset-manifest.json +16 -0
- package/samples/react/build/favicon.ico +0 -0
- package/samples/react/build/index.html +1 -0
- package/samples/react/build/logo192.png +0 -0
- package/samples/react/build/logo512.png +0 -0
- package/samples/react/build/manifest.json +25 -0
- package/samples/react/build/robots.txt +3 -0
- package/samples/react/build/static/css/main.073c9b0a.css +2 -0
- package/samples/react/build/static/css/main.073c9b0a.css.map +1 -0
- package/samples/react/build/static/js/787.b83ed06f.chunk.js +2 -0
- package/samples/react/build/static/js/787.b83ed06f.chunk.js.map +1 -0
- package/samples/react/build/static/js/main.0a848807.js +3 -0
- package/samples/react/build/static/js/main.0a848807.js.LICENSE.txt +39 -0
- package/samples/react/build/static/js/main.0a848807.js.map +1 -0
- package/samples/react/build/static/media/sdk-icons.b491623214b2af4cccdb.png +0 -0
- package/samples/react/package-lock.json +28973 -0
- package/samples/react/package.json +44 -0
- package/samples/react/public/favicon.ico +0 -0
- package/samples/react/public/index.html +43 -0
- package/samples/react/public/logo192.png +0 -0
- package/samples/react/public/logo512.png +0 -0
- package/samples/react/public/manifest.json +25 -0
- package/samples/react/public/robots.txt +3 -0
- package/samples/react/src/App.css +38 -0
- package/samples/react/src/App.js +22 -0
- package/samples/react/src/App.test.js +8 -0
- package/samples/react/src/assets/img/sdk-icons.png +0 -0
- package/samples/react/src/components/Cart.js +29 -0
- package/samples/react/src/components/ProductCard.js +27 -0
- package/samples/react/src/context/CartContext.js +116 -0
- package/samples/react/src/index.css +13 -0
- package/samples/react/src/index.js +17 -0
- package/samples/react/src/logo.svg +1 -0
- package/samples/react/src/reportWebVitals.js +13 -0
- package/samples/react/src/screens/Checkout.js +82 -0
- package/samples/react/src/screens/Store.js +21 -0
- package/samples/react/src/setupTests.js +5 -0
- package/samples/react/src/storeProducts.js +30 -0
- package/src/classes/3dsHandler.js +203 -0
- package/src/classes/checkout.js +125 -0
- package/src/classes/inlineCheckout.js +349 -0
- package/src/data/api.js +109 -0
- package/src/helpers/skyflow.js +139 -0
- package/src/helpers/styles.js +61 -0
- package/src/helpers/template.js +112 -0
- package/src/helpers/utils.js +68 -0
- package/src/index-dev.js +129 -0
- package/src/index.html +58 -0
- package/src/index.js +7 -0
- package/success.html +22 -0
- package/v1/bundle.min.js +18 -0
- package/webpack.config.js +66 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Local Storage / Session Storage', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/storage')
|
|
6
|
+
})
|
|
7
|
+
// Although localStorage is automatically cleared
|
|
8
|
+
// in between tests to maintain a clean state
|
|
9
|
+
// sometimes we need to clear localStorage manually
|
|
10
|
+
|
|
11
|
+
it('cy.clearLocalStorage() - clear all data in localStorage for the current origin', () => {
|
|
12
|
+
// https://on.cypress.io/clearlocalstorage
|
|
13
|
+
cy.get('.ls-btn').click().should(() => {
|
|
14
|
+
expect(localStorage.getItem('prop1')).to.eq('red')
|
|
15
|
+
expect(localStorage.getItem('prop2')).to.eq('blue')
|
|
16
|
+
expect(localStorage.getItem('prop3')).to.eq('magenta')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// clearLocalStorage() yields the localStorage object
|
|
20
|
+
cy.clearLocalStorage().should((ls) => {
|
|
21
|
+
expect(ls.getItem('prop1')).to.be.null
|
|
22
|
+
expect(ls.getItem('prop2')).to.be.null
|
|
23
|
+
expect(ls.getItem('prop3')).to.be.null
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
cy.get('.ls-btn').click().should(() => {
|
|
27
|
+
expect(localStorage.getItem('prop1')).to.eq('red')
|
|
28
|
+
expect(localStorage.getItem('prop2')).to.eq('blue')
|
|
29
|
+
expect(localStorage.getItem('prop3')).to.eq('magenta')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Clear key matching string in localStorage
|
|
33
|
+
cy.clearLocalStorage('prop1').should((ls) => {
|
|
34
|
+
expect(ls.getItem('prop1')).to.be.null
|
|
35
|
+
expect(ls.getItem('prop2')).to.eq('blue')
|
|
36
|
+
expect(ls.getItem('prop3')).to.eq('magenta')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
cy.get('.ls-btn').click().should(() => {
|
|
40
|
+
expect(localStorage.getItem('prop1')).to.eq('red')
|
|
41
|
+
expect(localStorage.getItem('prop2')).to.eq('blue')
|
|
42
|
+
expect(localStorage.getItem('prop3')).to.eq('magenta')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// Clear keys matching regex in localStorage
|
|
46
|
+
cy.clearLocalStorage(/prop1|2/).should((ls) => {
|
|
47
|
+
expect(ls.getItem('prop1')).to.be.null
|
|
48
|
+
expect(ls.getItem('prop2')).to.be.null
|
|
49
|
+
expect(ls.getItem('prop3')).to.eq('magenta')
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('cy.getAllLocalStorage() - get all data in localStorage for all origins', () => {
|
|
54
|
+
// https://on.cypress.io/getalllocalstorage
|
|
55
|
+
cy.get('.ls-btn').click()
|
|
56
|
+
|
|
57
|
+
// getAllLocalStorage() yields a map of origins to localStorage values
|
|
58
|
+
cy.getAllLocalStorage().should((storageMap) => {
|
|
59
|
+
expect(storageMap).to.deep.equal({
|
|
60
|
+
// other origins will also be present if localStorage is set on them
|
|
61
|
+
'https://example.cypress.io': {
|
|
62
|
+
'prop1': 'red',
|
|
63
|
+
'prop2': 'blue',
|
|
64
|
+
'prop3': 'magenta',
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('cy.clearAllLocalStorage() - clear all data in localStorage for all origins', () => {
|
|
71
|
+
// https://on.cypress.io/clearalllocalstorage
|
|
72
|
+
cy.get('.ls-btn').click()
|
|
73
|
+
|
|
74
|
+
// clearAllLocalStorage() yields null
|
|
75
|
+
cy.clearAllLocalStorage().should(() => {
|
|
76
|
+
expect(sessionStorage.getItem('prop1')).to.be.null
|
|
77
|
+
expect(sessionStorage.getItem('prop2')).to.be.null
|
|
78
|
+
expect(sessionStorage.getItem('prop3')).to.be.null
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('cy.getAllSessionStorage() - get all data in sessionStorage for all origins', () => {
|
|
83
|
+
// https://on.cypress.io/getallsessionstorage
|
|
84
|
+
cy.get('.ls-btn').click()
|
|
85
|
+
|
|
86
|
+
// getAllSessionStorage() yields a map of origins to sessionStorage values
|
|
87
|
+
cy.getAllSessionStorage().should((storageMap) => {
|
|
88
|
+
expect(storageMap).to.deep.equal({
|
|
89
|
+
// other origins will also be present if sessionStorage is set on them
|
|
90
|
+
'https://example.cypress.io': {
|
|
91
|
+
'prop4': 'cyan',
|
|
92
|
+
'prop5': 'yellow',
|
|
93
|
+
'prop6': 'black',
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('cy.clearAllSessionStorage() - clear all data in sessionStorage for all origins', () => {
|
|
100
|
+
// https://on.cypress.io/clearallsessionstorage
|
|
101
|
+
cy.get('.ls-btn').click()
|
|
102
|
+
|
|
103
|
+
// clearAllSessionStorage() yields null
|
|
104
|
+
cy.clearAllSessionStorage().should(() => {
|
|
105
|
+
expect(sessionStorage.getItem('prop4')).to.be.null
|
|
106
|
+
expect(sessionStorage.getItem('prop5')).to.be.null
|
|
107
|
+
expect(sessionStorage.getItem('prop6')).to.be.null
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Traversal', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/traversal')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('.children() - get child DOM elements', () => {
|
|
9
|
+
// https://on.cypress.io/children
|
|
10
|
+
cy.get('.traversal-breadcrumb')
|
|
11
|
+
.children('.active')
|
|
12
|
+
.should('contain', 'Data')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('.closest() - get closest ancestor DOM element', () => {
|
|
16
|
+
// https://on.cypress.io/closest
|
|
17
|
+
cy.get('.traversal-badge')
|
|
18
|
+
.closest('ul')
|
|
19
|
+
.should('have.class', 'list-group')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('.eq() - get a DOM element at a specific index', () => {
|
|
23
|
+
// https://on.cypress.io/eq
|
|
24
|
+
cy.get('.traversal-list>li')
|
|
25
|
+
.eq(1).should('contain', 'siamese')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('.filter() - get DOM elements that match the selector', () => {
|
|
29
|
+
// https://on.cypress.io/filter
|
|
30
|
+
cy.get('.traversal-nav>li')
|
|
31
|
+
.filter('.active').should('contain', 'About')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('.find() - get descendant DOM elements of the selector', () => {
|
|
35
|
+
// https://on.cypress.io/find
|
|
36
|
+
cy.get('.traversal-pagination')
|
|
37
|
+
.find('li').find('a')
|
|
38
|
+
.should('have.length', 7)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('.first() - get first DOM element', () => {
|
|
42
|
+
// https://on.cypress.io/first
|
|
43
|
+
cy.get('.traversal-table td')
|
|
44
|
+
.first().should('contain', '1')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('.last() - get last DOM element', () => {
|
|
48
|
+
// https://on.cypress.io/last
|
|
49
|
+
cy.get('.traversal-buttons .btn')
|
|
50
|
+
.last().should('contain', 'Submit')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('.next() - get next sibling DOM element', () => {
|
|
54
|
+
// https://on.cypress.io/next
|
|
55
|
+
cy.get('.traversal-ul')
|
|
56
|
+
.contains('apples').next().should('contain', 'oranges')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('.nextAll() - get all next sibling DOM elements', () => {
|
|
60
|
+
// https://on.cypress.io/nextall
|
|
61
|
+
cy.get('.traversal-next-all')
|
|
62
|
+
.contains('oranges')
|
|
63
|
+
.nextAll().should('have.length', 3)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('.nextUntil() - get next sibling DOM elements until next el', () => {
|
|
67
|
+
// https://on.cypress.io/nextuntil
|
|
68
|
+
cy.get('#veggies')
|
|
69
|
+
.nextUntil('#nuts').should('have.length', 3)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('.not() - remove DOM elements from set of DOM elements', () => {
|
|
73
|
+
// https://on.cypress.io/not
|
|
74
|
+
cy.get('.traversal-disabled .btn')
|
|
75
|
+
.not('[disabled]').should('not.contain', 'Disabled')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('.parent() - get parent DOM element from DOM elements', () => {
|
|
79
|
+
// https://on.cypress.io/parent
|
|
80
|
+
cy.get('.traversal-mark')
|
|
81
|
+
.parent().should('contain', 'Morbi leo risus')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('.parents() - get parent DOM elements from DOM elements', () => {
|
|
85
|
+
// https://on.cypress.io/parents
|
|
86
|
+
cy.get('.traversal-cite')
|
|
87
|
+
.parents().should('match', 'blockquote')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('.parentsUntil() - get parent DOM elements from DOM elements until el', () => {
|
|
91
|
+
// https://on.cypress.io/parentsuntil
|
|
92
|
+
cy.get('.clothes-nav')
|
|
93
|
+
.find('.active')
|
|
94
|
+
.parentsUntil('.clothes-nav')
|
|
95
|
+
.should('have.length', 2)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('.prev() - get previous sibling DOM element', () => {
|
|
99
|
+
// https://on.cypress.io/prev
|
|
100
|
+
cy.get('.birds').find('.active')
|
|
101
|
+
.prev().should('contain', 'Lorikeets')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('.prevAll() - get all previous sibling DOM elements', () => {
|
|
105
|
+
// https://on.cypress.io/prevall
|
|
106
|
+
cy.get('.fruits-list').find('.third')
|
|
107
|
+
.prevAll().should('have.length', 2)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('.prevUntil() - get all previous sibling DOM elements until el', () => {
|
|
111
|
+
// https://on.cypress.io/prevuntil
|
|
112
|
+
cy.get('.foods-list').find('#nuts')
|
|
113
|
+
.prevUntil('#veggies').should('have.length', 3)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('.siblings() - get all sibling DOM elements', () => {
|
|
117
|
+
// https://on.cypress.io/siblings
|
|
118
|
+
cy.get('.traversal-pills .active')
|
|
119
|
+
.siblings().should('have.length', 2)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Utilities', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/utilities')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('Cypress._ - call a lodash method', () => {
|
|
9
|
+
// https://on.cypress.io/_
|
|
10
|
+
cy.request('https://jsonplaceholder.cypress.io/users')
|
|
11
|
+
.then((response) => {
|
|
12
|
+
let ids = Cypress._.chain(response.body).map('id').take(3).value()
|
|
13
|
+
|
|
14
|
+
expect(ids).to.deep.eq([1, 2, 3])
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('Cypress.$ - call a jQuery method', () => {
|
|
19
|
+
// https://on.cypress.io/$
|
|
20
|
+
let $li = Cypress.$('.utility-jquery li:first')
|
|
21
|
+
|
|
22
|
+
cy.wrap($li)
|
|
23
|
+
.should('not.have.class', 'active')
|
|
24
|
+
.click()
|
|
25
|
+
.should('have.class', 'active')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Cypress.Blob - blob utilities and base64 string conversion', () => {
|
|
29
|
+
// https://on.cypress.io/blob
|
|
30
|
+
cy.get('.utility-blob').then(($div) => {
|
|
31
|
+
// https://github.com/nolanlawson/blob-util#imgSrcToDataURL
|
|
32
|
+
// get the dataUrl string for the javascript-logo
|
|
33
|
+
return Cypress.Blob.imgSrcToDataURL('https://example.cypress.io/assets/img/javascript-logo.png', undefined, 'anonymous')
|
|
34
|
+
.then((dataUrl) => {
|
|
35
|
+
// create an <img> element and set its src to the dataUrl
|
|
36
|
+
let img = Cypress.$('<img />', { src: dataUrl })
|
|
37
|
+
|
|
38
|
+
// need to explicitly return cy here since we are initially returning
|
|
39
|
+
// the Cypress.Blob.imgSrcToDataURL promise to our test
|
|
40
|
+
// append the image
|
|
41
|
+
$div.append(img)
|
|
42
|
+
|
|
43
|
+
cy.get('.utility-blob img').click()
|
|
44
|
+
.should('have.attr', 'src', dataUrl)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('Cypress.minimatch - test out glob patterns against strings', () => {
|
|
50
|
+
// https://on.cypress.io/minimatch
|
|
51
|
+
let matching = Cypress.minimatch('/users/1/comments', '/users/*/comments', {
|
|
52
|
+
matchBase: true,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
expect(matching, 'matching wildcard').to.be.true
|
|
56
|
+
|
|
57
|
+
matching = Cypress.minimatch('/users/1/comments/2', '/users/*/comments', {
|
|
58
|
+
matchBase: true,
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
expect(matching, 'comments').to.be.false
|
|
62
|
+
|
|
63
|
+
// ** matches against all downstream path segments
|
|
64
|
+
matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/**', {
|
|
65
|
+
matchBase: true,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
expect(matching, 'comments').to.be.true
|
|
69
|
+
|
|
70
|
+
// whereas * matches only the next path segment
|
|
71
|
+
|
|
72
|
+
matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/*', {
|
|
73
|
+
matchBase: false,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
expect(matching, 'comments').to.be.false
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('Cypress.Promise - instantiate a bluebird promise', () => {
|
|
80
|
+
// https://on.cypress.io/promise
|
|
81
|
+
let waited = false
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @return Bluebird<string>
|
|
85
|
+
*/
|
|
86
|
+
function waitOneSecond () {
|
|
87
|
+
// return a promise that resolves after 1 second
|
|
88
|
+
return new Cypress.Promise((resolve, reject) => {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
// set waited to true
|
|
91
|
+
waited = true
|
|
92
|
+
|
|
93
|
+
// resolve with 'foo' string
|
|
94
|
+
resolve('foo')
|
|
95
|
+
}, 1000)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
cy.then(() => {
|
|
100
|
+
// return a promise to cy.then() that
|
|
101
|
+
// is awaited until it resolves
|
|
102
|
+
return waitOneSecond().then((str) => {
|
|
103
|
+
expect(str).to.eq('foo')
|
|
104
|
+
expect(waited).to.be.true
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
context('Viewport', () => {
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
cy.visit('https://example.cypress.io/commands/viewport')
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
it('cy.viewport() - set the viewport size and dimension', () => {
|
|
8
|
+
// https://on.cypress.io/viewport
|
|
9
|
+
|
|
10
|
+
cy.get('#navbar').should('be.visible')
|
|
11
|
+
cy.viewport(320, 480)
|
|
12
|
+
|
|
13
|
+
// the navbar should have collapse since our screen is smaller
|
|
14
|
+
cy.get('#navbar').should('not.be.visible')
|
|
15
|
+
cy.get('.navbar-toggle').should('be.visible').click()
|
|
16
|
+
cy.get('.nav').find('a').should('be.visible')
|
|
17
|
+
|
|
18
|
+
// lets see what our app looks like on a super large screen
|
|
19
|
+
cy.viewport(2999, 2999)
|
|
20
|
+
|
|
21
|
+
// cy.viewport() accepts a set of preset sizes
|
|
22
|
+
// to easily set the screen to a device's width and height
|
|
23
|
+
|
|
24
|
+
// We added a cy.wait() between each viewport change so you can see
|
|
25
|
+
// the change otherwise it is a little too fast to see :)
|
|
26
|
+
|
|
27
|
+
cy.viewport('macbook-15')
|
|
28
|
+
cy.wait(200)
|
|
29
|
+
cy.viewport('macbook-13')
|
|
30
|
+
cy.wait(200)
|
|
31
|
+
cy.viewport('macbook-11')
|
|
32
|
+
cy.wait(200)
|
|
33
|
+
cy.viewport('ipad-2')
|
|
34
|
+
cy.wait(200)
|
|
35
|
+
cy.viewport('ipad-mini')
|
|
36
|
+
cy.wait(200)
|
|
37
|
+
cy.viewport('iphone-6+')
|
|
38
|
+
cy.wait(200)
|
|
39
|
+
cy.viewport('iphone-6')
|
|
40
|
+
cy.wait(200)
|
|
41
|
+
cy.viewport('iphone-5')
|
|
42
|
+
cy.wait(200)
|
|
43
|
+
cy.viewport('iphone-4')
|
|
44
|
+
cy.wait(200)
|
|
45
|
+
cy.viewport('iphone-3')
|
|
46
|
+
cy.wait(200)
|
|
47
|
+
|
|
48
|
+
// cy.viewport() accepts an orientation for all presets
|
|
49
|
+
// the default orientation is 'portrait'
|
|
50
|
+
cy.viewport('ipad-2', 'portrait')
|
|
51
|
+
cy.wait(200)
|
|
52
|
+
cy.viewport('iphone-4', 'landscape')
|
|
53
|
+
cy.wait(200)
|
|
54
|
+
|
|
55
|
+
// The viewport will be reset back to the default dimensions
|
|
56
|
+
// in between tests (the default can be set in cypress.config.{js|ts})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
context('Waiting', () => {
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
cy.visit('https://example.cypress.io/commands/waiting')
|
|
5
|
+
})
|
|
6
|
+
// BE CAREFUL of adding unnecessary wait times.
|
|
7
|
+
// https://on.cypress.io/best-practices#Unnecessary-Waiting
|
|
8
|
+
|
|
9
|
+
// https://on.cypress.io/wait
|
|
10
|
+
it('cy.wait() - wait for a specific amount of time', () => {
|
|
11
|
+
cy.get('.wait-input1').type('Wait 1000ms after typing')
|
|
12
|
+
cy.wait(1000)
|
|
13
|
+
cy.get('.wait-input2').type('Wait 1000ms after typing')
|
|
14
|
+
cy.wait(1000)
|
|
15
|
+
cy.get('.wait-input3').type('Wait 1000ms after typing')
|
|
16
|
+
cy.wait(1000)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('cy.wait() - wait for a specific route', () => {
|
|
20
|
+
// Listen to GET to comments/1
|
|
21
|
+
cy.intercept('GET', '**/comments/*').as('getComment')
|
|
22
|
+
|
|
23
|
+
// we have code that gets a comment when
|
|
24
|
+
// the button is clicked in scripts.js
|
|
25
|
+
cy.get('.network-btn').click()
|
|
26
|
+
|
|
27
|
+
// wait for GET comments/1
|
|
28
|
+
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304])
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Window', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/window')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('cy.window() - get the global window object', () => {
|
|
9
|
+
// https://on.cypress.io/window
|
|
10
|
+
cy.window().should('have.property', 'top')
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('cy.document() - get the document object', () => {
|
|
14
|
+
// https://on.cypress.io/document
|
|
15
|
+
cy.document().should('have.property', 'charset').and('eq', 'UTF-8')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('cy.title() - get the title', () => {
|
|
19
|
+
// https://on.cypress.io/title
|
|
20
|
+
cy.title().should('include', 'Kitchen Sink')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ***********************************************
|
|
2
|
+
// This example commands.js shows you how to
|
|
3
|
+
// create various custom commands and overwrite
|
|
4
|
+
// existing commands.
|
|
5
|
+
//
|
|
6
|
+
// For more comprehensive examples of custom
|
|
7
|
+
// commands please read more here:
|
|
8
|
+
// https://on.cypress.io/custom-commands
|
|
9
|
+
// ***********************************************
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
// -- This is a parent command --
|
|
13
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
// -- This is a child command --
|
|
17
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// -- This is a dual command --
|
|
21
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
// -- This will overwrite an existing command --
|
|
25
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/e2e.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|