mirror of https://github.com/sgoudham/carbon.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
7 years ago
|
/* global cy */
|
||
7 years ago
|
import { editorVisible } from '../support'
|
||
7 years ago
|
|
||
|
// usually we can visit the page before each test
|
||
|
// but these tests use the url, which means wasted page load
|
||
|
// so instead visit the desired url in each test
|
||
|
|
||
|
describe('background color', () => {
|
||
7 years ago
|
const bgColor = '.bg-color-container .bg-color'
|
||
6 years ago
|
const picker = '#bg-select-pickers'
|
||
7 years ago
|
|
||
|
const openPicker = () => {
|
||
7 years ago
|
cy.get(bgColor).click()
|
||
|
return cy.get(picker).should('be.visible')
|
||
7 years ago
|
}
|
||
|
|
||
|
// clicking anywhere else closes it
|
||
7 years ago
|
const closePicker = () => cy.get('body').click()
|
||
7 years ago
|
|
||
|
it('opens BG color pick', () => {
|
||
|
cy.visit('/')
|
||
|
openPicker()
|
||
|
closePicker()
|
||
7 years ago
|
cy.get(picker).should('not.be.visible')
|
||
7 years ago
|
})
|
||
|
|
||
|
it('changes background color to dark red', () => {
|
||
|
cy.visit('/')
|
||
|
const darkRed = '#D0021B'
|
||
|
const darkRedTile = `[title="${darkRed}"]`
|
||
|
openPicker()
|
||
6 years ago
|
cy.get(picker)
|
||
7 years ago
|
.find(darkRedTile)
|
||
|
.click()
|
||
7 years ago
|
closePicker()
|
||
|
|
||
|
// changing background color triggers url change
|
||
|
cy.url().should('contain', '?bg=')
|
||
|
|
||
|
// confirm color change
|
||
6 years ago
|
cy.get('.container-bg .bg').should('have.css', 'background-color', 'rgb(208, 2, 27)')
|
||
7 years ago
|
})
|
||
|
|
||
|
it('specifies color in url', () => {
|
||
6 years ago
|
cy.visit('?bg=rgb(255,0,0)')
|
||
7 years ago
|
editorVisible()
|
||
6 years ago
|
cy.get('.container-bg .bg').should('have.css', 'background-color', 'rgb(255, 0, 0)')
|
||
7 years ago
|
})
|
||
|
|
||
|
it('enters neon pink', () => {
|
||
6 years ago
|
cy.visit('?bg=rgb(255,0,0)')
|
||
7 years ago
|
editorVisible()
|
||
|
|
||
|
const pink = 'ff00ff'
|
||
7 years ago
|
openPicker()
|
||
7 years ago
|
.find(`input[value="FF0000"]`)
|
||
7 years ago
|
.clear()
|
||
|
.type(`${pink}{enter}`)
|
||
7 years ago
|
closePicker()
|
||
|
|
||
6 years ago
|
cy.url().should('contain', `?bg=rgba(${encodeURIComponent('255,0,255,1')}`)
|
||
6 years ago
|
cy.get('.container-bg .bg').should('have.css', 'background-color', 'rgb(255, 0, 255)')
|
||
7 years ago
|
})
|
||
|
})
|