Updated acceptance tests

This commit is contained in:
Bjarke Berg
2020-05-13 20:12:02 +02:00
parent 45224a35d0
commit 985fcce4f0
26 changed files with 974 additions and 201 deletions

View File

@@ -1,8 +1,10 @@
{
"baseUrl": "https://localhost:44331",
"viewportHeight": 1024,
"viewportWidth": 1200,
"env": {
"username": "<insert username/email>",
"password": "<insert password>"
}
},
"supportFile": "cypress/support/index.ts"
}

View File

@@ -0,0 +1,62 @@
/// <reference types="Cypress" />
context('Login', () => {
beforeEach(() => {
cy.visit('/umbraco');
});
it('Login with correct username and password', () => {
const username = Cypress.env('username');
const password = Cypress.env('password');
//Precondition
cy.get('.text-error').should('not.exist');
//Action
cy.get('#umb-username').type(username);
cy.get('#umb-passwordTwo').type(password);
cy.get('[label-key="general_login"]').click();
//Assert
cy.url().should('include', '/umbraco#/content')
cy.get('#umb-username').should('not.exist');
cy.get('#umb-passwordTwo').should('not.exist');
});
it('Login with correct username but wrong password', () => {
const username = Cypress.env('username');
const password = 'wrong';
//Precondition
cy.get('.text-error').should('not.exist');
//Action
cy.get('#umb-username').type(username);
cy.get('#umb-passwordTwo').type(password);
cy.get('[label-key="general_login"]').click();
//Assert
cy.get('.text-error').should('exist');
cy.get('#umb-username').should('exist');
cy.get('#umb-passwordTwo').should('exist');
});
it('Login with wrong username and wrong password', () => {
const username = 'wrong-username';
const password = 'wrong';
//Precondition
cy.get('.text-error').should('not.exist');
//Action
cy.get('#umb-username').type(username);
cy.get('#umb-passwordTwo').type(password);
cy.get('[label-key="general_login"]').click();
//Assert
cy.get('.text-error').should('exist');
cy.get('#umb-username').should('exist');
cy.get('#umb-passwordTwo').should('exist');
});
});

View File

@@ -0,0 +1,66 @@
/// <reference types="Cypress" />
import {LabelDataTypeBuilder} from 'umbraco-cypress-testhelpers';
context('Data Types', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create data type', () => {
const name = "Test data type";
cy.umbracoEnsureDataTypeNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Data Types"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.umbracoContextMenuAction("action-data-type").click();
//Type name
cy.umbracoEditorHeaderName(name);
cy.get('select[name="selectedEditor"]').select('Label');
cy.get('.umb-property-editor select').select('Time');
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureDataTypeNameNotExists(name);
});
it('Delete data type', () => {
const name = "Test data type";
cy.umbracoEnsureDataTypeNameNotExists(name);
const dataType = new LabelDataTypeBuilder()
.withSaveNewAction()
.withName(name)
.build();
cy.saveDataType(dataType);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Data Types", name]).rightclick();
cy.umbracoContextMenuAction("action-delete").click();
cy.umbracoButtonByLabelKey("general_delete").click();
cy.contains(name).should('not.exist');
cy.umbracoEnsureDataTypeNameNotExists(name);
});
});

View File

@@ -0,0 +1,79 @@
/// <reference types="Cypress" />
import { DocumentTypeBuilder } from 'umbraco-cypress-testhelpers';
context('Document Types', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create document type', () => {
const name = "Test document type";
cy.umbracoEnsureDocumentTypeNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Document Types"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.umbracoContextMenuAction("action-documentType").click();
//Type name
cy.umbracoEditorHeaderName(name);
cy.get('[data-element="group-add"]').click();
cy.get('.umb-group-builder__group-title-input').type('Group name');
cy.get('[data-element="property-add"]').click();
cy.get('.editor-label').type('property name');
cy.get('[data-element="editor-add"]').click();
//Search for textstring
cy.get('.umb-search-field').type('Textstring');
// Choose first item
cy.get('ul.umb-card-grid li a[title="Textstring"]').closest("li").click();
// Save property
cy.get('.btn-success').last().click();
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureDocumentTypeNameNotExists(name);
});
it('Delete document type', () => {
const name = "Test document type";
cy.umbracoEnsureDocumentTypeNameNotExists(name);
const dataType = new DocumentTypeBuilder()
.withName(name)
.build();
cy.saveDocumentType(dataType);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Document Types", name]).rightclick();
cy.umbracoContextMenuAction("action-delete").click();
cy.get('label.checkbox').click();
cy.umbracoButtonByLabelKey("general_ok").click();
cy.contains(name).should('not.exist');
cy.umbracoEnsureDocumentTypeNameNotExists(name);
});
});

View File

@@ -0,0 +1,32 @@
/// <reference types="Cypress" />
context('Languages', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Add language', () => {
const name = "Neddersasssch (Nedderlannen)"; // Must be an option in the select box
cy.umbracoEnsureLanguageNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Languages"]).click();
cy.umbracoButtonByLabelKey("languages_addLanguage").click();
cy.get('select[name="newLang"]').select(name);
// //Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureLanguageNameNotExists(name);
});
});

View File

@@ -0,0 +1,33 @@
/// <reference types="Cypress" />
context('Macros', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create macro', () => {
const name = "Test macro";
cy.umbracoEnsureMacroNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Macros"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('form[name="createMacroForm"]').within(($form) => {
cy.get('input[name="itemKey"]').type(name);
cy.get(".btn-primary").click();
});
cy.location().should((loc) => {
expect(loc.hash).to.include('#/settings/macros/edit/')
});
//Clean up
cy.umbracoEnsureMacroNameNotExists(name);
});
});

View File

@@ -0,0 +1,52 @@
/// <reference types="Cypress" />
context('Media Types', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create media type', () => {
const name = "Test media type";
cy.umbracoEnsureMediaTypeNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Media Types"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click();
//Type name
cy.umbracoEditorHeaderName(name);
cy.get('[data-element="group-add"]').click();
cy.get('.umb-group-builder__group-title-input').type('Group name');
cy.get('[data-element="property-add"]').click();
cy.get('.editor-label').type('property name');
cy.get('[data-element="editor-add"]').click();
//Search for textstring
cy.get('.umb-search-field').type('Textstring');
// Choose first item
cy.get('ul.umb-card-grid li a[title="Textstring"]').closest("li").click();
// Save property
cy.get('.btn-success').last().click();
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureMediaTypeNameNotExists(name);
});
});

View File

@@ -0,0 +1,50 @@
/// <reference types="Cypress" />
context('Member Types', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create member type', () => {
const name = "Test member type";
cy.umbracoEnsureMemberTypeNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Member Types"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
//Type name
cy.umbracoEditorHeaderName(name);
cy.get('[data-element="group-add"]').click();
cy.get('.umb-group-builder__group-title-input').type('Group name');
cy.get('[data-element="property-add"]').click();
cy.get('.editor-label').type('property name');
cy.get('[data-element="editor-add"]').click();
//Search for textstring
cy.get('.umb-search-field').type('Textstring');
// Choose first item
cy.get('ul.umb-card-grid li a[title="Textstring"]').closest("li").click();
// Save property
cy.get('.btn-success').last().click();
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureMemberTypeNameNotExists(name);
});
});

View File

@@ -0,0 +1,37 @@
/// <reference types="Cypress" />
context('Partial View Macro Files', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create new partial view macro', () => {
const name = "TestPartialViewMacro";
const fileName = name + ".cshtml";
cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName);
cy.umbracoEnsureMacroNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Partial View Macro Files"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-label").click();
//Type name
cy.umbracoEditorHeaderName(name);
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsurePartialViewMacroFileNameNotExists(fileName);
cy.umbracoEnsureMacroNameNotExists(name);
});
});

View File

@@ -0,0 +1,35 @@
/// <reference types="Cypress" />
context('Partial Views', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create new empty partial view', () => {
const name = "TestPartialView";
const fileName = name + ".cshtml";
cy.umbracoEnsurePartialViewNameNotExists(fileName);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Partial Views"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click();
//Type name
cy.umbracoEditorHeaderName(name);
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsurePartialViewNameNotExists(fileName);
});
});

View File

@@ -0,0 +1,40 @@
/// <reference types="Cypress" />
context('Relation Types', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create relation type', () => {
const name = "Test relation type";
cy.umbracoEnsureRelationTypeNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Relation Types"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('form[name="createRelationTypeForm"]').within(($form) => {
cy.get('input[name="relationTypeName"]').type(name);
cy.get('[name="relationType-direction"] input').first().click({force:true});
cy.get('select[name="relationType-parent"]').select('Document');
cy.get('select[name="relationType-child"]').select('Media');
cy.get(".btn-primary").click();
});
cy.location().should((loc) => {
expect(loc.hash).to.include('#/settings/relationTypes/edit/')
})
//Clean up
cy.umbracoEnsureRelationTypeNameNotExists(name);
});
});

View File

@@ -0,0 +1,35 @@
/// <reference types="Cypress" />
context('Scripts', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create new JavaScript file', () => {
const name = "TestScript";
const fileName = name + ".js";
cy.umbracoEnsureScriptNameNotExists(fileName);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Stylesheets"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click();
//Type name
cy.umbracoEditorHeaderName(name);
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureScriptNameNotExists(fileName);
});
});

View File

@@ -0,0 +1,35 @@
/// <reference types="Cypress" />
context('Stylesheets', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create new style sheet file', () => {
const name = "TestStylesheet";
const fileName = name + ".css";
cy.umbracoEnsureStylesheetNameNotExists(fileName);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Stylesheets"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click();
//Type name
cy.umbracoEditorHeaderName(name);
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureStylesheetNameNotExists(fileName);
});
});

View File

@@ -0,0 +1,33 @@
/// <reference types="Cypress" />
context('Templates', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create template', () => {
const name = "Test template";
cy.umbracoEnsureTemplateNameNotExists(name);
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
cy.umbracoTreeItem("settings", ["Templates"]).rightclick();
cy.umbracoContextMenuAction("action-create").click();
//Type name
cy.umbracoEditorHeaderName(name);
//Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureTemplateNameNotExists(name);
});
});

View File

@@ -0,0 +1,36 @@
context('User Groups', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create user group', () => {
const name = "Test Group";
cy.umbracoEnsureUserGroupNameNotExists(name);
cy.umbracoSection('users');
cy.get('[data-element="sub-view-userGroups"]').click();
cy.umbracoButtonByLabelKey("actions_createGroup").click();
//Type name
cy.umbracoEditorHeaderName(name);
// Assign sections
cy.get('.umb-box:nth-child(1) .umb-property:nth-child(1) localize').click();
cy.get('.umb-tree-item span').click({multiple:true});
cy.get('.btn-success').last().click();
// Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureUserGroupNameNotExists(name);
});
});

View File

@@ -0,0 +1,35 @@
/// <reference types="Cypress" />
context('Users', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create user', () => {
const name = "Alice Bobson";
const email = "alice-bobson@acceptancetest.umbraco";
cy.umbracoEnsureUserEmailNotExists(email);
cy.umbracoSection('users');
cy.umbracoButtonByLabelKey("user_createUser").click();
cy.get('input[name="name"]').type(name);
cy.get('input[name="email"]').type(email);
cy.get('.umb-node-preview-add').click();
cy.get('.umb-user-group-picker-list-item:nth-child(1) > .umb-user-group-picker__action').click();
cy.get('.umb-user-group-picker-list-item:nth-child(2) > .umb-user-group-picker__action').click();
cy.get('.btn-success').click();
cy.get('.umb-button > .btn > .umb-button__content').click();
cy.umbracoButtonByLabelKey("user_goToProfile").should('be.visible');
//Clean up
cy.umbracoEnsureUserEmailNotExists(email);
});
});

View File

@@ -0,0 +1,21 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@@ -0,0 +1,30 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
import {Command} from 'umbraco-cypress-testhelpers';
import {Chainable} from './chainable';
new Chainable();
new Command().registerCypressCommands();

View File

@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

View File

@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"include": [
"../node_modules/cypress",
"*/*.ts"
]
}

View File

@@ -0,0 +1,5 @@
// type definitions for Cypress object "cy"
/// <reference types="Cypress" />
// type definitions for custom commands like "createDefaultTodos"
// <reference types="support" />

View File

@@ -1,14 +0,0 @@
ECHO OFF
set cypressCommand=%1
for /f "tokens=*" %%a in ('Powershell.exe "((./../../../build/build.ps1 -g true).GetUmbracoVersion().Semver.ToString())"') do set Port=%%a
REM Remove .'s
set Port=%Port:.=%
REM pad with 0's so the length is 4
set "Port=%Port%0"
set "Port=%Port:~-4%"
set baseUrl=http://localhost:%Port%
ECHO ON
npx cypress %cypressCommand% --config baseUrl="%baseUrl%"

View File

@@ -1,12 +1,15 @@
{
"scripts": {
"test": "cypressWithBaseUrl.cmd run",
"ui": "cypressWithBaseUrl.cmd open"
"test": "npx cypress run",
"ui": "npx cypress open"
},
"devDependencies": {
"cross-env": "^7.0.2",
"ncp": "^2.0.0",
"cypress": "^4.5.0",
"umbraco-cypress-testhelpers": "1.0.0-beta-34"
"cypress": "^4.5.0",
"umbraco-cypress-testhelpers": "1.0.0-beta-36"
},
"dependencies": {
"typescript": "^3.9.2"
}
}

View File

@@ -0,0 +1,36 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./lib",
"sourceMap": false,
"declaration": true,
"module": "CommonJS",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"importHelpers": true,
"target": "es5",
"types": [
"cypress"
],
"lib": [
"es5",
"dom"
],
"plugins": [
{
"name": "typescript-tslint-plugin",
"alwaysShowRuleFailuresAsWarnings": false,
"ignoreDefinitionFiles": true,
"configFile": "tslint.json",
"suppressWhileTypeErrorsPresent": false
}
]
},
"include": [
"src/**/*.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": ["tslint:recommended", "tslint-config-prettier"]
}

File diff suppressed because it is too large Load Diff