-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdrupal-auth.cy.js
42 lines (32 loc) · 1.23 KB
/
drupal-auth.cy.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
/// <reference types="cypress" />
describe('Authentication tests', () => {
beforeEach(() => {
Cypress.config('baseUrl', 'http://drupal.ddev.site')
})
it('logs in without custom command', function () {
cy.visit('/user/login')
cy.get('#edit-name').type('admin')
cy.get('#edit-pass').type('admin')
cy.get('input[value="Log in"]').scrollIntoView().click()
cy.visit('/admin/content')
cy.get('h1.page-title').contains('Content')
})
it('Logs in and out as an administrator', () => {
// Log in as an administrator.
cy.login('admin', 'admin')
// Go visit a page that requires authentication.
cy.visit('/admin/content')
// Confirm the page loads instead of 404.
cy.get('h1.page-title').contains('Content')
// Go visit a page that requires more authentication.
cy.visit('/admin/config/system/site-information')
// Confirm the page loads instead of 404.
cy.get('h1.page-title').contains('Basic site settings')
// Log out from being an administrator.
cy.logout()
// Go visit a page that requires authentication.
cy.visit('/admin/content', { failOnStatusCode: false })
// Confirm the page loads 403.
cy.get('h1.page-title').contains('Access denied')
})
})