Skip to content

Commit e3ed17f

Browse files
committed
refactor(cy-support): inline all the old things
see #378
1 parent 2d797b6 commit e3ed17f

3 files changed

Lines changed: 77 additions & 77 deletions

File tree

cypress/support/config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// (DP) rewrite
22

3-
export const apiHost = 'http://localhost:';
4-
export const apiPort = '8080';
5-
export const apiUrl = apiHost + apiPort + "/exist/restxq/fusiondb";
3+
// export const apiHost = 'http://localhost:';
4+
// export const apiPort = '8080';
5+
// export const apiUrl = apiHost + apiPort + "/exist/restxq/fusiondb";
66

7-
export function mkApiUrl(apiService) {
8-
return apiHost + apiService;
9-
};
10-
export function mkApiPathUrl(username, dbPath = '') {
11-
return username + '@' + apiHost + apiPort + dbPath;
12-
};
7+
// export function mkApiUrl(apiService) {
8+
// return apiHost + apiService;
9+
// };
10+
// export function mkApiPathUrl(username, dbPath = '') {
11+
// return username + '@' + apiHost + apiPort + dbPath;
12+
// };
1313

1414

1515
// Connection details for the Fusion Studio API

cypress/support/index.d.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
/// <reference types="cypress" />
22

3-
declare namespace Cypress {
4-
interface Cypress {
5-
formatDate(date?: Date): string;
6-
}
7-
interface Chainable<Subject> {
8-
getMenuCommand(command: string, options: any): Chainable<Subject>;
9-
getSubMenu(text: string, options: any): Chainable<Subject>;
10-
getTreeNode(id: string, options: any): Chainable<Subject>;
11-
getTreeNode(id: string, options: any): Chainable<Subject>;
12-
addConnection(name?: string, server?: string, username?: string, password?: string): Chainable<Subject>;
13-
addCollection(id: string, name: string): Chainable<Subject>;
14-
getDialogOverlay(): Chainable<Subject>;
15-
getDialog(): Chainable<Subject>;
16-
getDialogTitle(): Chainable<Subject>;
17-
getDialogBody(): Chainable<Subject>;
18-
getDialogFooter(): Chainable<Subject>;
19-
getDialogButtons(): Chainable<Subject>;
20-
getDialogMainButton(): Chainable<Subject>;
21-
getCheckbox(label, options): Chainable<Subject>;
22-
findCheckbox(label, options): Chainable<Subject>;
23-
checked(): Chainable<Subject>;
24-
notChecked(): Chainable<Subject>;
25-
addDocument(collection: string, name: string, type?: string): Chainable<Subject>;
26-
}
27-
}
3+
// declare namespace Cypress {
4+
// interface Cypress {
5+
// formatDate(date?: Date): string;
6+
// }
7+
// interface Chainable<Subject> {
8+
// getMenuCommand(command: string, options: any): Chainable<Subject>;
9+
// getSubMenu(text: string, options: any): Chainable<Subject>;
10+
// getTreeNode(id: string, options: any): Chainable<Subject>;
11+
// getTreeNode(id: string, options: any): Chainable<Subject>;
12+
// addConnection(name?: string, server?: string, username?: string, password?: string): Chainable<Subject>;
13+
// addCollection(id: string, name: string): Chainable<Subject>;
14+
// getDialogOverlay(): Chainable<Subject>;
15+
// getDialog(): Chainable<Subject>;
16+
// getDialogTitle(): Chainable<Subject>;
17+
// getDialogBody(): Chainable<Subject>;
18+
// getDialogFooter(): Chainable<Subject>;
19+
// getDialogButtons(): Chainable<Subject>;
20+
// getDialogMainButton(): Chainable<Subject>;
21+
// getCheckbox(label, options): Chainable<Subject>;
22+
// findCheckbox(label, options): Chainable<Subject>;
23+
// checked(): Chainable<Subject>;
24+
// notChecked(): Chainable<Subject>;
25+
// addDocument(collection: string, name: string, type?: string): Chainable<Subject>;
26+
// }
27+
// }

cypress/support/utils.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import { apiHost, apiPort } from '../support/config.js';
1+
// import { apiHost, apiPort } from '../support/config.js';
22

33
// CSS does not require custom approach
44
// see https://docs.cypress.io/faq/questions/using-cypress-faq#How-do-I-use-special-characters-with-cy-get
5-
export function treenode(id) {
6-
return '[node-id=' + CSS.escape(id) + ']';
7-
}
8-
export function checkbox() {
9-
return 'span.checkbox';
10-
}
11-
Cypress.formatDate = (date) => {
12-
if (!date) {
13-
date = new Date();
14-
}
15-
var month = (date.getMonth() + 1).toString();
16-
var day = date.getDate().toString();
17-
if (month.length < 2) {
18-
month = '0' + month;
19-
}
20-
if (day.length < 2) {
21-
day = '0' + day;
22-
}
23-
return day + '-' + month + '-' + date.getUTCFullYear().toString()
24-
}
25-
Cypress.Commands.add('waitForLoading', (options) => cy.wait(50).get('.fs-icon.fa-spinner', { ...options, timeout: options?.timeout || 10000 }).should('not.exist').wait(50));
26-
Cypress.Commands.add('getMenuCommand', (command, options) => cy.get('.p-Widget.p-Menu .p-Menu-item[data-type=command][data-command=' + CSS.escape(command) + ']', options).should('exist').should('not.have.class', 'p-mod-disabled'));
27-
Cypress.Commands.add('getSubMenu', (text, options) => cy.get('.p-Widget.p-Menu .p-Menu-item[data-type=submenu]', options).should('contain.text', text).should('not.have.class', 'p-mod-disabled'));
28-
Cypress.Commands.add('getTreeNode', (id, options) => cy.get(treenode(id), options));
29-
Cypress.Commands.add('getCheckbox', (label, options) => {
30-
const result = cy.get(checkbox(label), options);
31-
return label ? result.contains(label) : result;
32-
});
33-
Cypress.Commands.add('findCheckbox', { prevSubject: true }, (subject, label, options) => {
34-
const result = cy.wrap(subject).find(checkbox(label), options);
35-
return label ? result.contains(label) : result;
36-
});
37-
Cypress.Commands.add('checked', { prevSubject: true }, subject => cy.wrap(subject).find('.checkbox-box').should('have.class', 'checked'));
38-
Cypress.Commands.add('notChecked', { prevSubject: true }, subject => cy.wrap(subject).find('.checkbox-box').should('not.have.class', 'checked'));
5+
// export function treenode(id) {
6+
// return '[node-id=' + CSS.escape(id) + ']';
7+
// }
8+
// export function checkbox() {
9+
// return 'span.checkbox';
10+
// }
11+
// Cypress.formatDate = (date) => {
12+
// if (!date) {
13+
// date = new Date();
14+
// }
15+
// var month = (date.getMonth() + 1).toString();
16+
// var day = date.getDate().toString();
17+
// if (month.length < 2) {
18+
// month = '0' + month;
19+
// }
20+
// if (day.length < 2) {
21+
// day = '0' + day;
22+
// }
23+
// return day + '-' + month + '-' + date.getUTCFullYear().toString()
24+
// }
25+
// Cypress.Commands.add('waitForLoading', (options) => cy.wait(50).get('.fs-icon.fa-spinner', { ...options, timeout: options?.timeout || 10000 }).should('not.exist').wait(50));
26+
// Cypress.Commands.add('getMenuCommand', (command, options) => cy.get('.p-Widget.p-Menu .p-Menu-item[data-type=command][data-command=' + CSS.escape(command) + ']', options).should('exist').should('not.have.class', 'p-mod-disabled'));
27+
// Cypress.Commands.add('getSubMenu', (text, options) => cy.get('.p-Widget.p-Menu .p-Menu-item[data-type=submenu]', options).should('contain.text', text).should('not.have.class', 'p-mod-disabled'));
28+
// Cypress.Commands.add('getTreeNode', (id, options) => cy.get(treenode(id), options));
29+
// Cypress.Commands.add('getCheckbox', (label, options) => {
30+
// const result = cy.get(checkbox(label), options);
31+
// return label ? result.contains(label) : result;
32+
// });
33+
// Cypress.Commands.add('findCheckbox', { prevSubject: true }, (subject, label, options) => {
34+
// const result = cy.wrap(subject).find(checkbox(label), options);
35+
// return label ? result.contains(label) : result;
36+
// });
37+
// Cypress.Commands.add('checked', { prevSubject: true }, subject => cy.wrap(subject).find('.checkbox-box').should('have.class', 'checked'));
38+
// Cypress.Commands.add('notChecked', { prevSubject: true }, subject => cy.wrap(subject).find('.checkbox-box').should('not.have.class', 'checked'));
3939
// Cypress.Commands.add('addConnection', (name = 'localhost', server = apiHost + apiPort, username = 'admin', password = '') => {
4040
// cy.get('#theia-top-panel .p-MenuBar-item').contains('File')
4141
// .click()
@@ -82,11 +82,11 @@ Cypress.Commands.add('notChecked', { prevSubject: true }, subject => cy.wrap(sub
8282
// });
8383

8484
// TODO: All of these need to replaced by meaningful selectors in the source-code
85-
export const dialogOverlay = '.p-Widget.dialogOverlay#theia-dialog-shell';
86-
export const dialog = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock';
87-
export const dialogTitle = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogTitle';
88-
export const dialogBody = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogContent';
89-
export const dialogFooter = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl';
90-
export const dialogButtons = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button';
91-
export const dialogMainButton = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button.main';
92-
export const dialogSecondaryButton = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button.secondary';
85+
// export const dialogOverlay = '.p-Widget.dialogOverlay#theia-dialog-shell';
86+
// export const dialog = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock';
87+
// export const dialogTitle = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogTitle';
88+
// export const dialogBody = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogContent';
89+
// export const dialogFooter = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl';
90+
// export const dialogButtons = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button';
91+
// export const dialogMainButton = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button.main';
92+
// export const dialogSecondaryButton = '.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button.secondary';

0 commit comments

Comments
 (0)