Skip to content

Commit 006c794

Browse files
authored
Merge pull request #429 from duncdrum/e2e-rewrte-4
2 parents 18432a4 + 0616399 commit 006c794

20 files changed

+363
-975
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
command: |
6767
pwd
6868
sleep 15
69-
npx cypress run --config defaultCommandTimeout=55000
69+
npx cypress run --config defaultCommandTimeout=58000
7070
no_output_timeout: 2m
7171
workflows:
7272
browser_build:

cypress.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"baseUrl": "http://localhost:3000",
33
"ignoreTestFiles": "**/integration/examples/*.*",
44
"projectId": "ftw148",
5-
"experimentalFetchPolyfill": true,
65
"env": {
76
"API_HOST": "http://localhost:8080"
87
}

cypress/integration/00_temp_spec.js

Lines changed: 0 additions & 26 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

cypress/integration/04_document_spec.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ context('Document Operations', () => {
44
describe('working with tree view', () => {
55
before(() => {
66
cy.connect()
7+
cy.visit('/')
8+
cy.get(`[node-id=${CSS.escape('admin@' + Cypress.env('API_HOST'))}]`)
79
// TODO(DP): might have to improve by adding more before / after hooks to prevent dangling documents
810
// see #400
911
})
1012

1113
describe('db context menu', () => {
1214
it('should display creation options', () => {
13-
cy.visit('/')
1415
cy.get('.ReactVirtualized__Grid', { timeout: 55000 })
1516
.should('be.visible')
1617
cy.get('.fusion-item')
@@ -43,14 +44,19 @@ context('Document Operations', () => {
4344
// - two file create routes one with follow-up dialog (xquery lib) one without (txt, xml)
4445
})
4546

46-
// TODO(DP): make this work on all OS by either adjusting the key sequence ctrl+s cmd+s …
47-
// or by using the file menu UI instead
47+
// see https://github.com/cypress-io/cypress/pull/15388/files#
4848
// see #414
49+
4950
it('should let users edit new document', () => {
5051
cy.get('[node-id$=untitled-1]')
5152
.dblclick()
52-
cy.get('.view-line')
53+
if( Cypress.platform === 'darwin') {
54+
cy.get('.view-line')
5355
.type('asdf{meta+s}')
56+
} else {
57+
cy.get('.view-line')
58+
.type('asdf{ctrl+s}')
59+
}
5460
})
5561
// see #414 workaround is to run this after editing and saving the document,
5662
// we should be able to rename before entering content
@@ -111,7 +117,6 @@ context('Document Operations', () => {
111117
})
112118
})
113119

114-
115120
it('should let users delete documents', () => {
116121
cy.get('[node-id$=test\\.xml]')
117122
.rightclick()
Lines changed: 152 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,164 @@
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, including those produced by failed create commands
149+
cy.get('[node-id$=untitled-1]')
150+
.should('not.exist')
151+
cy.get('[node-id$=untitled-2]')
152+
.should('not.exist')
153+
cy.get('[node-id$=test_col]')
154+
.should('not.exist')
155+
cy.get('[node-id$=test_col1]')
156+
.should('not.exist')
157+
cy.get('[node-id$=test_col2]')
158+
.should('not.exist')
159+
cy.get('[node-id$=test_colA]')
160+
.should('not.exist')
161+
})
140162
})
163+
})
141164
})

0 commit comments

Comments
 (0)