Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier plugin added to Cypress tests #240

Merged
merged 5 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions functional/cypress-tests/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
Comment on lines +1 to +3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier setup

4 changes: 3 additions & 1 deletion functional/cypress-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ All cypress related commits should be done on branches starting with `automation

### Coding conventions

All tests should be written according to [Cypress.io Best Practices guide](https://docs.cypress.io/guides/references/best-practices.html "Best Practices | Cypress Documentation"). Read it before starting to contribute.
All tests should be written according to [Cypress.io Best Practices guide](https://docs.cypress.io/guides/references/best-practices.html 'Best Practices | Cypress Documentation'). Read it before starting to contribute.

Additional project specific conventions:

Expand Down Expand Up @@ -82,6 +82,8 @@ Use helpers below to minimize specfiles size. Keep in mind that some of those he

### Widget

`createWidget(name)` - use any name from `functional/cypress-tests/cypress/fixtures/Widgets.js` for example: `Widgets.whiteSpace.name` - this will add configured widget to current board. Widget type will be deducted from name prop.

Comment on lines +85 to +86
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation update

`cy.clickAddWidgetButton()` - Click the Add Widget button visible after login.

`cy.fillNewWidgetGeneral(widgetType, title, newLine, disabled, columnsCount, rowsCount)` - Fill out the General Tab of the Widget Creation dialog. `widgetType` specifies Widget to be added, `title` is it's name, `newLine` will set the widget to be added on a next row, following the last existing widget on a Dashboard when set to `true`, `disabled` will make the widget disabled when set to `true`. `columnsCount` and `rowsCount` will determine number of, respectively, columns and rows.
Expand Down
3 changes: 1 addition & 2 deletions functional/cypress-tests/cypress/fixtures/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export function dashboardNameGen(name = 'Dashboard') {
return name + Date.now()
.toString();
return name + Date.now().toString();
}

export const columnEdgeValues = ['3', '4', '20', '21'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export const testCredential = timestamp => {
return {
password: "TestPassword1",
user: "TestUser1",
password: 'TestPassword1',
user: 'TestUser1',
label: `TC-${timestamp}`
};
};

export const testEndpoint = timestamp => {
return {
label: `TE-${timestamp}`,
url: "http://cognifide.com",
publicUrl: "http://cognifide.com",
url: 'http://cognifide.com',
publicUrl: 'http://cognifide.com',
credentials: `TC-${timestamp}`,
id: `TE-${timestamp}`
};
};

export const testLbl = "test";
export const testLbl = 'test';

export const editedLbl = "EditedLabel";
export const editedLbl = 'EditedLabel';
134 changes: 67 additions & 67 deletions functional/cypress-tests/cypress/integration/credentialsEndpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
testEndpoint,
testLbl,
editedLbl
} from "../fixtures/credentialsEndpoints";
} from '../fixtures/credentialsEndpoints';

describe("Credentials and endpoints", () => {
describe('Credentials and endpoints', () => {
const timestamp = Date.now().toString();

before(() => {
Expand All @@ -18,77 +18,77 @@ describe("Credentials and endpoints", () => {
});
});

context("Anonymous user", () => {
it("Anonymous user: settings menu button is not available", () => {
cy.visit("/");
cy.get('[data-cy="settings-menu-open-button"]').should("not.be.visible");
context('Anonymous user', () => {
it('Anonymous user: settings menu button is not available', () => {
cy.visit('/');
cy.get('[data-cy="settings-menu-open-button"]').should('not.be.visible');
});
});

context("Logged in user - general check", () => {
context('Logged in user - general check', () => {
beforeEach(() => {
cy.visit("/");
cy.visit('/');
cy.loginWithToken();
cy.get('[data-cy="settings-menu-open-button"]').click();
});

it("Logged-in user: settings panel is available with its elements", () => {
it('Logged-in user: settings panel is available with its elements', () => {
cy.get('[data-cy="app-dialog-title"]')
.find("h2")
.should("have.text", "Settings");
cy.get('button[aria-selected="true"]').should("have.text", "Endpoints");
cy.get('[data-cy="add-endpoint-add-button"]').should("exist");
.find('h2')
.should('have.text', 'Settings');
cy.get('button[aria-selected="true"]').should('have.text', 'Endpoints');
cy.get('[data-cy="add-endpoint-add-button"]').should('exist');

cy.get('[data-cy="settings-menu-credentials-tab"]').click();

cy.get('[data-cy="app-dialog-title"]')
.find("h2")
.should("have.text", "Settings");
cy.get('button[aria-selected="true"]').should("have.text", "Credentials");
cy.get('[data-cy="add-credential-add-button"]').should("exist");
.find('h2')
.should('have.text', 'Settings');
cy.get('button[aria-selected="true"]').should('have.text', 'Credentials');
cy.get('[data-cy="add-credential-add-button"]').should('exist');

cy.get('[data-cy="settings-menu-endpoints-tab"]').click();

cy.get('[data-cy="app-dialog-title"]')
.find("h2")
.should("have.text", "Settings");
cy.get('button[aria-selected="true"]').should("have.text", "Endpoints");
cy.get('[data-cy="add-endpoint-add-button"]').should("exist");
.find('h2')
.should('have.text', 'Settings');
cy.get('button[aria-selected="true"]').should('have.text', 'Endpoints');
cy.get('[data-cy="add-endpoint-add-button"]').should('exist');
});

it("User can switch to add new credential form directly from add new endpoint form", () => {
it('User can switch to add new credential form directly from add new endpoint form', () => {
cy.get('[data-cy="add-endpoint-add-button"]').click();
cy.get('[data-cy="add-credential-add-button-small"]').click();
cy.contains('[data-cy="app-dialog-title"]', "Add new credential").should(
"exist"
cy.contains('[data-cy="app-dialog-title"]', 'Add new credential').should(
'exist'
);
});
});

context("Logged in user - endpoints", () => {
context('Logged in user - endpoints', () => {
beforeEach(() => {
cy.visit("/");
cy.visit('/');
cy.loginWithToken();
cy.get('[data-cy="settings-menu-open-button"]').click();
});

it("Error messages are displayed when user submits empty / non valid form at endpoints tab", () => {
it('Error messages are displayed when user submits empty / non valid form at endpoints tab', () => {
cy.get('[data-cy="add-endpoint-add-button"]').click();
cy.get('[data-cy="endpoint-form-url-input"]').type(" ");
cy.get('[data-cy="endpoint-form-public-url-input"]').type(" ");
cy.get('[data-cy="endpoint-form-url-input"]').type(' ');
cy.get('[data-cy="endpoint-form-public-url-input"]').type(' ');
cy.get('[data-cy="endpoint-form-submit-button"]').click();
cy.get('[data-cy="endpoint-form-label-input-error"]').should(
"be.visible"
'be.visible'
);
cy.get('[data-cy="endpoint-form-url-input-error"]').should("be.visible");
cy.get('[data-cy="endpoint-form-url-input-error"]').should('be.visible');
cy.get('[data-cy="endpoint-form-public-url-input-error"]').should(
"be.visible"
'be.visible'
);
cy.get("p.MuiFormHelperText-root.Mui-error") // <= needs data-cy
.should("be.visible");
cy.get('p.MuiFormHelperText-root.Mui-error') // <= needs data-cy
.should('be.visible');
});

it("User can add new endpoint. New endpoints label is visible", () => {
it('User can add new endpoint. New endpoints label is visible', () => {
cy.get('[data-cy="add-endpoint-add-button"]').click();
cy.get('[data-cy="endpoint-form-label-input"]')
.type(testEndpoint(testLbl).label)
Expand All @@ -104,27 +104,27 @@ describe("Credentials and endpoints", () => {

cy.get('[data-cy="endpoint-form-credentials-input"]').click();
cy.get('[role="listbox"]').within(() => {
cy.contains("li", `${testCredential(timestamp).label}`).click();
cy.contains('li', `${testCredential(timestamp).label}`).click();
});
cy.get('[data-cy="endpoint-form-submit-button"]').click();
cy.get('[data-cy="app-dialog-content"]').should(
"contain",
'contain',
testEndpoint(testLbl).label
);
});

it("User cannot add endpoints with existing label", () => {
it('User cannot add endpoints with existing label', () => {
cy.get('[data-cy="add-endpoint-add-button"]').click();
cy.get('[data-cy="endpoint-form-label-input"]')
.type(testEndpoint(timestamp).label)
.blur();
cy.get('[data-cy="endpoint-form-label-input-error"]')
.should("be.visible")
.and("contain.text", "This field must be unique.");
.should('be.visible')
.and('contain.text', 'This field must be unique.');
});

it("User can edit existing endpoint", () => {
cy.contains("li.MuiListItem-container", testEndpoint(testLbl).label) // <= no data-cy for this one
it('User can edit existing endpoint', () => {
cy.contains('li.MuiListItem-container', testEndpoint(testLbl).label) // <= no data-cy for this one
.find('[data-cy="edit-endpoint-edit-button"]')
.click();
cy.get('[data-cy="endpoint-form-label-input"]')
Expand All @@ -133,52 +133,52 @@ describe("Credentials and endpoints", () => {
.blur();
cy.get('[data-cy="endpoint-form-submit-button"]').click();
cy.get('[data-cy="app-dialog-content"]').should(
"contain",
'contain',
testEndpoint(editedLbl).label
);
});

it("User can delete existing endpoint", () => {
cy.contains("li.MuiListItem-container", testEndpoint(timestamp).label)
it('User can delete existing endpoint', () => {
cy.contains('li.MuiListItem-container', testEndpoint(timestamp).label)
.find('[data-cy="delete-endpoint-delete-button"]')
.click();
cy.get('[data-cy="confirmation-dialog-ok"]').click();
cy.get('[data-cy="app-dialog-content"]').should(
"not.contain",
'not.contain',
testEndpoint(timestamp).label
);
});
});

context("Logged in user - credentials", () => {
context('Logged in user - credentials', () => {
beforeEach(() => {
cy.visit("/");
cy.visit('/');
cy.loginWithToken();
cy.get('[data-cy="settings-menu-open-button"]').click();
cy.get('[data-cy="settings-menu-credentials-tab"]').click();
});

it("Error messages are displayed when user submits empty / non valid form at credentials tab", () => {
it('Error messages are displayed when user submits empty / non valid form at credentials tab', () => {
cy.get('[data-cy="add-credential-add-button"]').click();
cy.get('[data-cy="credential-form-password-confirmation-input"]').type(
" "
' '
);
cy.get('[data-cy="credential-form-submit-button"]').click();
cy.get('[data-cy="credential-form-label-input-error"]').should(
"be.visible"
'be.visible'
);
cy.get('[data-cy="credential-form-user-input-error"]').should(
"be.visible"
'be.visible'
);
cy.get('[data-cy="credential-form-password-input-error"]').should(
"be.visible"
'be.visible'
);
cy.get(
'[data-cy="credential-form-password-confirmation-input-error"]'
).should("be.visible");
).should('be.visible');
});

it("User can add new credentials. New credentials label is visible", () => {
it('User can add new credentials. New credentials label is visible', () => {
cy.get('[data-cy="add-credential-add-button"]').click();
cy.get('[data-cy="credential-form-label-input"]')
.type(testCredential(testLbl).label)
Expand All @@ -197,28 +197,28 @@ describe("Credentials and endpoints", () => {
.blur();
cy.get('[data-cy="credential-form-submit-button"]').click();
cy.get('[data-cy="app-dialog-content"]').should(
"contain",
'contain',
testCredential(testLbl).label
);
});

it("User cannot add credentials with existing label", () => {
it('User cannot add credentials with existing label', () => {
cy.get('[data-cy="add-credential-add-button"]').click();
cy.get('[data-cy="credential-form-label-input"]')
.type(testCredential(timestamp).label)
.blur();
cy.get('[data-cy="credential-form-label-input-error"]')
.should("be.visible")
.and("contain.text", "This field must be unique.");
.should('be.visible')
.and('contain.text', 'This field must be unique.');
});

it("User can edit existing credentials", () => {
cy.contains("li.MuiListItem-container", testCredential(testLbl).label) // <= no data-cy for this one
it('User can edit existing credentials', () => {
cy.contains('li.MuiListItem-container', testCredential(testLbl).label) // <= no data-cy for this one
.find('[data-cy="edit-credential-edit-button"]')
.click();
cy.get('[data-cy="credential-form-label-input"]')
.clear()
.type("TC-EditedLabel")
.type('TC-EditedLabel')
.blur();
cy.get('[data-cy="credential-form-password-input"]')
.type(testCredential(timestamp).password)
Expand All @@ -228,18 +228,18 @@ describe("Credentials and endpoints", () => {
.blur();
cy.get('[data-cy="credential-form-submit-button"]').click();
cy.get('[data-cy="app-dialog-content"]').should(
"contain",
"TC-EditedLabel"
'contain',
'TC-EditedLabel'
);
});

it("User can delete existing credentials", () => {
cy.contains("li.MuiListItem-container", testCredential(timestamp).label)
it('User can delete existing credentials', () => {
cy.contains('li.MuiListItem-container', testCredential(timestamp).label)
.find('[data-cy="delete-credential-delete-button"]')
.click();
cy.get('[data-cy="confirmation-dialog-ok"]').click();
cy.get('[data-cy="app-dialog-content"]').should(
"not.contain",
'not.contain',
testCredential(timestamp).label
);
});
Expand Down
Loading