This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
block-slate-format-boldlists.js
87 lines (75 loc) · 2.74 KB
/
block-slate-format-boldlists.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
79
80
81
82
83
84
85
86
87
import { slateBeforeEach, slateAfterEach } from '../support';
describe('Block Tests: Bold Bulleted lists', () => {
beforeEach(slateBeforeEach);
afterEach(slateAfterEach);
it('log browser info', () => {
Cypress.log(Cypress.browser);
});
it('gives clipboard permission to browser ', () => {
// use the Chrome debugger protocol to grant the current browser window
// access to the clipboard from the current origin
cy.wrap(
Cypress.automation('remote:debugger:protocol', {
command: 'Browser.grantPermissions',
params: {
permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'],
// make the permission tighter by allowing the current origin only
// like "http://localhost:56978"
origin: window.location.origin,
},
}),
);
});
it('can be queried in all browsers', () => {
cy.window()
.its('navigator.permissions')
.invoke('query', { name: 'clipboard-read' })
.its('state')
.should('be.oneOf', ['prompt', 'granted', 'denied']);
cy.window()
.its('navigator.permissions')
.invoke('query', { name: 'clipboard-write' })
.its('state')
.should('be.oneOf', ['prompt', 'granted', 'denied']);
});
it('As editor I can add bold bulleted lists', function () {
// Complete chained commands
cy.getSlateEditorAndType('Colorless green ideas sleep furiously.');
// Bold List
cy.setSlateSelection('Colorless green');
cy.clickSlateButton('Bold');
cy.clickSlateButton('Bulleted list');
// Split list
cy.setSlateCursor('ideas').type('{enter}');
// Save
cy.toolbarSave();
// then the page view should contain a link
cy.get('[id="page-document"] ul li strong').should('have.length', 1);
cy.get('[id="page-document"] ul li strong:nth-child(1)').contains(
'Colorless green',
);
cy.get('[id="page-document"] ul li:nth-child(2)').contains(
'sleep furiously.',
);
});
it('As editor I can paste internal(slate formatted) bold formatted bulleted lists', function () {
// Complete chained commands
cy.getSlateEditorAndType('This is slate"s own bold content');
cy.setSlateSelection('This is slate"s own');
//create a bold bullted list
cy.clickSlateButton('Bulleted list');
cy.clickSlateButton('Bold');
cy.setSlateSelection('This is slate"s own').type('{cmd+c}');
//copy content "This is slate"s own"
cy.setSlateCursor('content').type('{enter}').type('{cmd+v}');
// Save
cy.toolbarSave();
cy.get('[id="page-document"] ul li:nth-child(1) strong').contains(
'This is slate"s own',
);
//pasted content
cy.get('[id="page-document"] ul li:nth-child(2) strong').contains(
'This is slate"s own',
);
});
});