-
Notifications
You must be signed in to change notification settings - Fork 9
/
traditional.spec.js
78 lines (63 loc) · 2.53 KB
/
traditional.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/// <reference types="cypress" />
// --------------------------------------------------------------------------------
// Test Cases
// --------------------------------------------------------------------------------
describe('A traditional test', () => {
beforeEach(() => {
cy.viewport(1600, 1200)
})
it('should log into the demo app', () => {
loadLoginPage()
verifyLoginPage()
performLogin()
verifyMainPage()
})
})
// --------------------------------------------------------------------------------
// Test Step Functions
// --------------------------------------------------------------------------------
function loadLoginPage() {
let site = Cypress.env('DEMO_SITE') ?? 'original'
let extra = (site == 'original') ? '' : '/index_v2.html'
cy.visit('https://demo.applitools.com' + extra)
}
function verifyLoginPage() {
cy.get('div.logo-w').should('be.visible')
cy.get('#username').should('be.visible')
cy.get('#password').should('be.visible')
cy.get('#log-in').should('be.visible')
cy.get('input.form-check-input').should('be.visible')
}
function performLogin() {
cy.get('#username').type('andy')
cy.get('#password').type('i<3pandas')
cy.get('#log-in').click()
}
function verifyMainPage() {
// Check various page elements
cy.get('div.logo-w').should('be.visible')
cy.get('div.element-search.autosuggest-search-activator > input').should('be.visible')
cy.get('div.avatar-w img').should('be.visible')
cy.get('ul.main-menu').should('be.visible')
cy.contains('Add Account').should('be.visible')
cy.contains('Make Payment').should('be.visible')
cy.contains('View Statement').should('be.visible')
cy.contains('Request Increase').should('be.visible')
cy.contains('Pay Now').should('be.visible')
// Check time message
cy.get('#time').invoke('text').should('match', /Your nearest branch closes in:( \d+[hms])+/)
// Check menu element names
cy.get('ul.main-menu li span').should(items => {
expect(items[0]).to.contain.text('Card types')
expect(items[1]).to.contain.text('Credit cards')
expect(items[2]).to.contain.text('Debit cards')
expect(items[3]).to.contain.text('Lending')
expect(items[4]).to.contain.text('Loans')
expect(items[5]).to.contain.text('Mortgages')
})
// Check transaction statuses
const statuses = ['Complete', 'Pending', 'Declined']
cy.get('span.status-pill + span').each(($span, index) => {
expect(statuses).to.include($span.text())
})
}