(user)
| 9 | } = require('./constants'); |
| 10 | |
| 11 | function login(user) { |
| 12 | console.log( |
| 13 | '[login] START user=', |
| 14 | user ? 'yes' : 'no', |
| 15 | 'netlifySiteURL=', |
| 16 | user?.netlifySiteURL || 'none', |
| 17 | ); |
| 18 | cy.viewport(1200, 1200); |
| 19 | if (user) { |
| 20 | console.log('[login] About to cy.visit("/")'); |
| 21 | cy.visit('/', { |
| 22 | onBeforeLoad: () => { |
| 23 | // https://github.com/cypress-io/cypress/issues/1208 |
| 24 | window.indexedDB.deleteDatabase('localforage'); |
| 25 | window.localStorage.setItem('decap-cms-user', JSON.stringify(user)); |
| 26 | if (user.netlifySiteURL) { |
| 27 | window.localStorage.setItem('netlifySiteURL', user.netlifySiteURL); |
| 28 | } |
| 29 | console.log('[login] onBeforeLoad complete'); |
| 30 | }, |
| 31 | }).then(() => { |
| 32 | console.log('[login] cy.visit completed'); |
| 33 | }); |
| 34 | if (user.netlifySiteURL && user.email && user.password) { |
| 35 | console.log('[login] Filling login form'); |
| 36 | cy.get('input[name="email"]', { timeout: 10000 }).clear(); |
| 37 | cy.get('input[name="email"]').type(user.email); |
| 38 | cy.get('input[name="password"]').clear(); |
| 39 | cy.get('input[name="password"]').type(user.password); |
| 40 | cy.contains('button', 'Login').click(); |
| 41 | console.log('[login] Login button clicked'); |
| 42 | } |
| 43 | } else { |
| 44 | cy.visit('/'); |
| 45 | cy.contains('button', 'Login').click(); |
| 46 | } |
| 47 | console.log('[login] Waiting for New Post link'); |
| 48 | cy.contains('a', '+ Post', { timeout: 60000 }).then(() => { |
| 49 | console.log('[login] New Post link found - COMPLETE'); |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | function withExistingClock(callback) { |
| 54 | return cy.then(() => { |
no test coverage detected