Skip to content

Commit a119cec

Browse files
ccheraaduncdrum
authored andcommitted
updated collection tests
and added spies
1 parent e3ed17f commit a119cec

File tree

1 file changed

+144
-129
lines changed

1 file changed

+144
-129
lines changed
Lines changed: 144 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,156 @@
11
/// <reference types="Cypress" />
22

33
context('Collection Operations', () => {
4-
describe('working with tree view', () => {
5-
before(() => {
6-
cy.connect()
7-
})
4+
let fetchSpy;
5+
describe('working with tree view', () => {
6+
before(() => {
7+
cy.connect()
8+
cy.visit('/');
9+
})
10+
beforeEach(() => {
11+
cy.window().then(win => fetchSpy = cy.spy(win, 'fetch').as('fetch'));
12+
})
813

9-
describe('db context menu', () => {
10-
it('should display creation options', () => {
11-
cy.visit('/')
12-
cy.get('.ReactVirtualized__Grid')
13-
.should('be.visible')
14-
cy.get('.fusion-item')
15-
.click()
16-
// all we need is the final part of the node-id attribute
17-
cy.get('[node-id$=db]')
18-
.rightclick()
19-
.then(() => {
20-
cy.get('.p-Menu')
21-
.should('be.visible')
22-
.contains('New collection')
23-
.trigger('mousemove')
24-
cy.get('[data-command="fusion.new-collection"] > .p-Menu-itemLabel')
25-
.should('be.visible')
26-
.click()
27-
})
28-
// (DP): start workaround for #413
29-
cy.get('[node-id$=db]')
30-
.trigger('mousemove')
31-
.type('{enter}')
32-
// end workaround for #413
33-
cy.get('.ReactVirtualized__Grid')
34-
.contains('untitled-1')
35-
})
14+
describe('db context menu', () => {
15+
it('should display creation options', () => {
16+
cy.get('.fusion-view')
17+
.should('be.visible')
18+
cy.get('.fusion-item')
19+
.click()
20+
// all we need is the final part of the node-id attribute
21+
// (DP): start workaround for #413
22+
cy.get('[node-id$=db]')
23+
.click()
24+
cy.get('.fa-spinner')
25+
.should('not.exist')
26+
// (DP): end workaround for #413
27+
cy.get('@fetch').should('be.calledWith', Cypress.env('API_HOST') + '/exist/restxq/fusiondb/explorer?uri=/db');
28+
cy.get('[node-id$=db]')
29+
.rightclick();
30+
cy.get('.p-Menu')
31+
.should('be.visible')
32+
.find('[data-command="fusion.new-collection"]')
33+
.should('be.visible')
34+
.contains('New collection')
35+
.click()
36+
cy.focused()
37+
.type('{enter}')
38+
cy.get('.fusion-view')
39+
.contains('untitled-1')
40+
cy.get('@fetch').should('be.calledWithMatch', Cypress.env('API_HOST') + '/exist/restxq/fusiondb/collection?uri=/db/untitled-1', { method: 'PUT' });
41+
})
3642

37-
it('should let users rename collection', () => {
38-
cy.get('[node-id$=untitled-1]')
39-
.rightclick()
40-
cy.get('[data-command="fusion.rename"] > .p-Menu-itemLabel')
41-
.should('be.visible')
42-
.click()
43-
.focused()
44-
.type('test_col{enter}')
45-
})
43+
it('should let users rename collection', () => {
44+
cy.get('[node-id$=untitled-1]')
45+
.rightclick()
46+
cy.get('[data-command="fusion.rename"]')
47+
.should('be.visible')
48+
.contains('Rename')
49+
.click()
50+
cy.focused()
51+
.type('test_col{enter}')
52+
cy.get('@fetch').should('be.calledWithMatch', Cypress.env('API_HOST') + '/exist/restxq/fusiondb/collection?uri=/db/test_col', {
53+
method: 'PUT',
54+
headers: { 'x-fs-move-source': '/db/untitled-1' },
55+
});
56+
cy.get('.fusion-view')
57+
.contains('test_col')
58+
cy.get('[node-id$=untitled-1]')
59+
.should('not.exist')
60+
})
4661

47-
it('should display collection properties', () => {
48-
cy.get('[node-id$=test_col]')
49-
.rightclick()
50-
.type('{alt+enter}', { force: true })
51-
cy.get('.dialogTitle')
52-
.should('contain.text', 'Properties')
53-
// rename file -> text.xml
54-
cy.get('.value > .theia-input')
55-
.clear()
56-
.type('test_col2')
57-
// check properties table
58-
cy.get('.dialogContent')
59-
.find('.keys > tr')
60-
.should('have.length', 7)
61-
.contains('Created')
62-
cy.get('.dialogContent')
63-
.find('.keys > tr')
64-
.contains('Owner')
65-
// check permissions table
66-
cy.get('.dialogContent')
67-
.find('.permissions-editor > tr')
68-
.should('have.length', 3)
69-
.contains('user')
70-
cy.get('.main')
71-
.click()
72-
})
62+
it('should display collection properties', () => {
63+
cy.get('[node-id$=test_col]')
64+
.click()
65+
.type('{alt+enter}', { force: true })
66+
cy.get('.dialogTitle')
67+
.should('contain.text', 'Properties')
68+
// rename file -> text.xml
69+
cy.get('.value > .theia-input')
70+
.should('have.value', 'test_col')
71+
.clear()
72+
.type('test_col2')
73+
// check properties table
74+
cy.get('.dialogContent')
75+
.find('.keys > tr')
76+
.should('have.length', 7)
77+
.should('contain', 'Created')
78+
.should('contain', 'Owner')
79+
.should('contain', 'Group')
80+
// check permissions table
81+
cy.get('.dialogContent')
82+
.find('.permissions-editor > tr')
83+
.should('have.length', 3)
84+
.should('contain', 'user')
85+
.should('contain', 'group')
86+
.should('contain', 'other')
87+
cy.get('.main')
88+
.click()
89+
cy.get('.dialogBlock')
90+
.should('not.exist');
91+
cy.get('[node-id$=test_col2]')
92+
.should('exist')
93+
cy.get('[node-id$=test_col]')
94+
.should('not.exist')
95+
})
7396

74-
it('should not create duplicate collection', () => {
75-
cy.get('[node-id$=db]')
76-
.rightclick()
77-
.then(() => {
78-
cy.get('.p-Menu')
79-
.should('be.visible')
80-
.contains('New collection')
81-
.trigger('mousemove')
82-
cy.get('[data-command="fusion.new-collection"] > .p-Menu-itemLabel')
83-
.should('be.visible')
84-
.click()
85-
cy.get('.fs-inline-input > .theia-input')
86-
.clear()
87-
.type('test_col2{enter}')
88-
cy.get('.error')
89-
.should('exist')
90-
.should('contain.text', 'Item already exists')
91-
})
92-
})
97+
it('should not create duplicate collection', () => {
98+
cy.get('[node-id$=db]')
99+
.rightclick()
100+
.then(() => {
101+
cy.get('.p-Menu')
102+
.should('be.visible')
103+
.contains('New collection')
104+
.trigger('mousemove')
105+
cy.get('[data-command="fusion.new-collection"]')
106+
.should('be.visible')
107+
.click()
108+
cy.focused()
109+
.clear()
110+
.type('test_col2{enter}')
111+
cy.get('.error')
112+
.should('exist')
113+
.should('contain.text', 'Item already exists')
114+
})
115+
})
93116

94-
it('should create nested collection', () => {
95-
cy.get('[node-id$=test_col2]')
96-
.rightclick()
97-
.then(() => {
98-
cy.get('.p-Menu')
99-
.should('be.visible')
100-
.contains('New collection')
101-
.trigger('mousemove')
102-
cy.get('[data-command="fusion.new-collection"] > .p-Menu-itemLabel')
103-
.should('be.visible')
104-
.click()
105-
cy.get('.fs-inline-input > .theia-input')
106-
.clear()
107-
.type('test_colA{enter}')
108-
// TODO(DP): we migh want to check the proper nesting more explicitely,
109-
// but that is already covered by checking for this collection after deleting
110-
// its parent collection
111-
cy.get('.ReactVirtualized__Grid')
112-
.contains('test_colA')
113-
})
114-
})
117+
it('should create nested collection', () => {
118+
cy.get('[node-id$=test_col2]')
119+
.click()
120+
.rightclick()
121+
cy.get('.p-Menu')
122+
.should('be.visible')
123+
.contains('New collection')
124+
cy.get('[data-command="fusion.new-collection"]')
125+
.should('be.visible')
126+
.click()
127+
cy.focused()
128+
.clear()
129+
.type('test_colA{enter}')
130+
// TODO(DP): we migh want to check the proper nesting more explicitely,
131+
// but that is already covered by checking for this collection after deleting
132+
// its parent collection
133+
cy.get('.fusion-view')
134+
.contains('test_colA')
135+
})
115136

116137

117-
it('should let users delete collection', () => {
118-
cy.get('[node-id$=test_col2]')
119-
.rightclick()
120-
cy.get('[data-command="fusion.delete"] > .p-Menu-itemLabel')
121-
.should('be.visible')
122-
.click()
123-
cy.get('.main')
124-
.click()
125-
// make sure all test files are gone see #400
126-
cy.get('[node-id$=untitled-1]')
127-
.should('not.exist')
128-
cy.get('[node-id$=untitled-2]')
129-
.should('not.exist')
130-
cy.get('[node-id$=test_col]')
131-
.should('not.exist')
132-
cy.get('[node-id$=test_col1]')
133-
.should('not.exist')
134-
cy.get('[node-id$=test_col2]')
135-
.should('not.exist')
136-
cy.get('[node-id$=test_colA]')
137-
.should('not.exist')
138-
})
139-
})
138+
it('should let users delete collection', () => {
139+
cy.get('[node-id$=test_col2]')
140+
.rightclick()
141+
cy.get('[data-command="fusion.delete"]')
142+
.should('be.visible')
143+
.contains('Delete')
144+
.click()
145+
cy.get('.main')
146+
.click()
147+
cy.get('@fetch').should('be.calledWithMatch', Cypress.env('API_HOST') + '/exist/restxq/fusiondb/collection?uri=/db/test_col2', { method: 'DELETE' });
148+
// make sure all test files are gone see #400
149+
cy.get('[node-id$=test_col2]')
150+
.should('not.exist')
151+
cy.get('[node-id$=test_colA]')
152+
.should('not.exist')
153+
})
140154
})
155+
})
141156
})

0 commit comments

Comments
 (0)