Skip to content

Commit 9b2acd0

Browse files
committed
Merge remote-tracking branch 'origin/v8/feature/implement-tabs-cypress-test' into v9/dev
2 parents b21b93d + 2e14abc commit 9b2acd0

File tree

6 files changed

+732
-17
lines changed

6 files changed

+732
-17
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/// <reference types="Cypress" />
2+
import {
3+
DocumentTypeBuilder,
4+
ContentBuilder,
5+
AliasHelper
6+
} from 'umbraco-cypress-testhelpers';
7+
8+
context('Url Picker', () => {
9+
10+
beforeEach(() => {
11+
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false);
12+
});
13+
14+
it('Test Url Picker', () => {
15+
16+
const urlPickerDocTypeName = 'Url Picker Test';
17+
const pickerDocTypeAlias = AliasHelper.toAlias(urlPickerDocTypeName);
18+
cy.umbracoEnsureDocumentTypeNameNotExists(urlPickerDocTypeName);
19+
cy.deleteAllContent();
20+
const pickerDocType = new DocumentTypeBuilder()
21+
.withName(urlPickerDocTypeName)
22+
.withAlias(pickerDocTypeAlias)
23+
.withAllowAsRoot(true)
24+
.withDefaultTemplate(pickerDocTypeAlias)
25+
.addGroup()
26+
.withName('ContentPickerGroup')
27+
.addUrlPickerProperty()
28+
.withAlias('picker')
29+
.done()
30+
.done()
31+
.build();
32+
33+
cy.saveDocumentType(pickerDocType);
34+
cy.editTemplate(urlPickerDocTypeName, '@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.UrlPickerTest>' +
35+
'\n@using ContentModels = Umbraco.Web.PublishedModels;' +
36+
'\n@{' +
37+
'\n Layout = null;' +
38+
'\n}' +
39+
'\n@foreach(var link in @Model.Picker)' +
40+
'\n{' +
41+
'\n <a href="@link.Url">@link.Name</a>' +
42+
'\n}');
43+
// Create content with url picker
44+
cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick();
45+
cy.get('[data-element="action-create"]').click();
46+
cy.get('[data-element="action-create-' + pickerDocTypeAlias + '"] > .umb-action-link').click();
47+
// Fill out content
48+
cy.umbracoEditorHeaderName('UrlPickerContent');
49+
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
50+
cy.umbracoSuccessNotification().should('be.visible');
51+
cy.get('.umb-node-preview-add').click();
52+
// Should really try and find a better way to do this, but umbracoTreeItem tries to click the content pane in the background
53+
cy.get('#treePicker li:first', {timeout: 6000}).click();
54+
cy.get('.umb-editor-footer-content__right-side > [button-style="success"] > .umb-button > .btn > .umb-button__content').click();
55+
cy.get('.umb-node-preview__name').should('be.visible');
56+
//Save and publish
57+
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
58+
cy.umbracoSuccessNotification().should('be.visible');
59+
//Waiting to ensure we have saved properly before leaving
60+
cy.reload();
61+
//Assert
62+
cy.get('.umb-notifications__notifications > .alert-error').should('not.exist');
63+
//Editing template with some content
64+
65+
//Testing if the edits match the expected results
66+
const expected = '<a href="/">UrlPickerContent</a>';
67+
cy.umbracoVerifyRenderedViewContent('/', expected, true).should('be.true');
68+
//clean
69+
cy.umbracoEnsureDocumentTypeNameNotExists(urlPickerDocTypeName);
70+
cy.umbracoEnsureTemplateNameNotExists(urlPickerDocTypeName);
71+
72+
});
73+
});
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/// <reference types="Cypress" />
2+
import {
3+
AliasHelper,
4+
ApprovedColorPickerDataTypeBuilder,
5+
} from 'umbraco-cypress-testhelpers';
6+
7+
context('DataTypes', () => {
8+
9+
beforeEach(() => {
10+
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false);
11+
});
12+
13+
it('Tests Approved Colors', () => {
14+
cy.deleteAllContent();
15+
const name = 'Approved Colour Test';
16+
const alias = AliasHelper.toAlias(name);
17+
18+
cy.umbracoEnsureDocumentTypeNameNotExists(name);
19+
cy.umbracoEnsureDataTypeNameNotExists(name);
20+
21+
const pickerDataType = new ApprovedColorPickerDataTypeBuilder()
22+
.withName(name)
23+
.withPrevalues(['000000', 'FF0000'])
24+
.build()
25+
26+
//umbracoMakeDocTypeWithDataTypeAndContent(name, alias, pickerDataType);
27+
cy.umbracoCreateDocTypeWithContent(name, alias, pickerDataType);
28+
29+
// Act
30+
// Enter content
31+
cy.umbracoRefreshContentTree();
32+
cy.umbracoTreeItem("content", [name]).click();
33+
//Pick a colour
34+
cy.get('.btn-000000').click();
35+
//Save
36+
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
37+
cy.umbracoSuccessNotification().should('be.visible');
38+
//Editing template with some content
39+
cy.editTemplate(name, '@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.ApprovedColourTest>' +
40+
'\n@using ContentModels = Umbraco.Web.PublishedModels;' +
41+
'\n@{' +
42+
'\n Layout = null;' +
43+
'\n}' +
44+
'\n<p style="color:@Model.UmbracoTest">Lorem ipsum dolor sit amet</p>');
45+
46+
//Assert
47+
const expected = `<p style="color:000000" > Lorem ipsum dolor sit amet </p>`;
48+
cy.umbracoVerifyRenderedViewContent('/', expected, true).should('be.true');
49+
50+
//Pick another colour to verify both work
51+
cy.get('.btn-FF0000').click();
52+
//Save
53+
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
54+
cy.umbracoSuccessNotification().should('be.visible');
55+
//Assert
56+
const expected2 = '<p style="color:FF0000">Lorem ipsum dolor sit amet</p>';
57+
cy.umbracoVerifyRenderedViewContent('/', expected2, true).should('be.true');
58+
59+
//Clean
60+
cy.umbracoEnsureDataTypeNameNotExists(name);
61+
cy.umbracoEnsureDocumentTypeNameNotExists(name);
62+
cy.umbracoEnsureTemplateNameNotExists(name);
63+
});
64+
65+
// it('Tests Checkbox List', () => {
66+
// const name = 'CheckBox List';
67+
// const alias = AliasHelper.toAlias(name);
68+
69+
// cy.umbracoEnsureDocumentTypeNameNotExists(name);
70+
// cy.umbracoEnsureDataTypeNameNotExists(name);
71+
72+
// const pickerDataType = new CheckBoxListDataTypeBuilder()
73+
// .withName(name)
74+
// .withPrevalues(['Choice 1', 'Choice 2'])
75+
// .build()
76+
77+
// cy.umbracoCreateDocTypeWithContent(name, alias, pickerDataType);
78+
// // Act
79+
// // Enter content
80+
// cy.umbracoRefreshContentTree();
81+
// cy.umbracoTreeItem("content", [name]).click();
82+
// //Check box 1
83+
// cy.get(':nth-child(1) > umb-checkbox.ng-isolate-scope > .checkbox > .umb-form-check__symbol > .umb-form-check__state > .umb-form-check__check')
84+
// .click();
85+
// //Save
86+
// cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
87+
// cy.umbracoSuccessNotification().should('be.visible');
88+
89+
// //Edit template with content
90+
// cy.editTemplate(name, '@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.CheckboxList>' +
91+
// '\n@using ContentModels = Umbraco.Web.PublishedModels;' +
92+
// '\n@{' +
93+
// '\n Layout = null;' +
94+
// '\n}' +
95+
// '\n<p>@Model.UmbracoTest</p>');
96+
// });
97+
});

0 commit comments

Comments
 (0)