Skip to content

Commit 32d8e0b

Browse files
ZeegaanNikolaj Geisle
authored andcommitted
v9: Fix tests on Linux (#11586)
* downgraded cypress, updated package * Fixed language test * Fix language test * Fixed routing tests to wait for popup * Publish test artifacts * Added better element to wait on * Fix routing tests for linux * Fix language tests on linux * Stablize tabs tests * Implement waiting for inner tree like in content tests * Assert that we are in settings section so we dont click an element that doesnt exist * Fixed rollback by not doing cy.reload() * Fix language test with correct wait * Stabilize dataTypes by moving API Call, and stabilize systemInformation.ts test by waiting for success notification * Fix dataTypes, tabs and template tests * Update node to newer version in package-lock.json and fix template test * Implemented cy.wait to test if it is because we are too fast * Added comments * Bigger wait * Try another wait instead of magic numbers Co-authored-by: Nikolaj Geisle <[email protected]>
1 parent 169fc7c commit 32d8e0b

File tree

9 files changed

+2378
-46
lines changed

9 files changed

+2378
-46
lines changed

build/azure-pipelines.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ stages:
259259
# customCommand: 'run test -- --config="viewportHeight=812,viewportWidth=375,screenshotsFolder=cypress/artifacts/mobile/screenshots,videosFolder=cypress/artifacts/mobile/videos,videoUploadOnPasses=false"'
260260
- task: PublishPipelineArtifact@1
261261
displayName: "Publish test artifacts"
262-
condition: failed()
263262
inputs:
264263
targetPath: '$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/cypress/artifacts'
265264
artifact: 'Test artifacts - Windows'
@@ -361,13 +360,11 @@ stages:
361360
# customCommand: 'run test -- --config="viewportHeight=812,viewportWidth=375,screenshotsFolder=cypress/artifacts/mobile/screenshots,videosFolder=cypress/artifacts/mobile/videos,videoUploadOnPasses=false"'
362361
- task: PublishPipelineArtifact@1
363362
displayName: "Publish test artifacts"
364-
condition: failed()
365363
inputs:
366364
targetPath: '$(Build.SourcesDirectory)/tests/Umbraco.Tests.AcceptanceTest/cypress/artifacts'
367365
artifact: 'Test artifacts - Linux'
368366
- task: PublishPipelineArtifact@1
369367
displayName: "Publish run log"
370-
condition: failed()
371368
inputs:
372369
targetPath: '$(Build.ArtifactStagingDirectory)/dotnet_run_log_linux.txt'
373370
artifact: Test Run logs - Linux

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ context('Content', () => {
353353

354354
cy.get('.umb-editor-footer-content__right-side > [button-style="success"] > .umb-button > .btn-success').click();
355355

356-
cy.reload();
356+
refreshContentTree();
357357

358358
// Assert
359359
cy.get('.history').find('.umb-badge').contains('Save').should('be.visible');

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Content/routing.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ context('Routing', () => {
5757

5858
beforeEach(() => {
5959
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
60+
// Ensure cleaned before tests run
61+
cy.deleteAllContent();
62+
cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName);
6063
cy.umbracoEnsureLanguageNotExists(danishCulture);
6164
cy.umbracoEnsureLanguageNotExists(swedishCulture);
6265
});
6366

6467
afterEach(() => {
68+
// Cleanup after tests
69+
cy.deleteAllContent();
6570
cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName);
6671
cy.umbracoEnsureLanguageNotExists(danishCulture);
6772
cy.umbracoEnsureLanguageNotExists(swedishCulture);
@@ -75,9 +80,6 @@ context('Routing', () => {
7580
.withAllowCultureVariation(true)
7681
.build();
7782

78-
cy.deleteAllContent();
79-
cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName);
80-
8183
saveNewLanguages();
8284

8385
cy.saveDocumentType(rootDocType).then((generatedRootDocType) => {
@@ -129,9 +131,6 @@ context('Routing', () => {
129131
.withAllowCultureVariation(true)
130132
.build();
131133

132-
cy.deleteAllContent();
133-
cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName);
134-
135134
saveNewLanguages();
136135

137136
cy.saveDocumentType(rootDocType).then((generatedRootDocType) => {
@@ -173,7 +172,8 @@ context('Routing', () => {
173172
cy.umbracoTreeItem("content", [nodeName, childNodeName]).click();
174173
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
175174
// Pop-up with what cultures you want to publish shows, click it
176-
cy.get('.umb-list').contains("Swedish").click();
175+
cy.get('.umb-list').should('be.visible');
176+
cy.get('.checkbox').last().click();
177177
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').last().click();
178178

179179
// Assert
@@ -189,9 +189,6 @@ context('Routing', () => {
189189
.withAllowCultureVariation(true)
190190
.build();
191191

192-
cy.deleteAllContent();
193-
cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName);
194-
195192
saveNewLanguages();
196193

197194
cy.saveDocumentType(rootDocType).then((generatedRootDocType) => {
@@ -256,14 +253,16 @@ context('Routing', () => {
256253
cy.umbracoTreeItem("content", [nodeName, childNodeName]).click();
257254
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
258255
//Pop-up with what cultures you want to publish shows, click it
259-
cy.get('.umb-list').contains("Swedish").click();
256+
cy.get('.umb-list').should('be.visible');
257+
cy.get('.checkbox').last().click();
260258
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').last().click();
261259

262260
// Publish Grandchild
263261
cy.umbracoTreeItem("content", [nodeName, childNodeName, grandChildNodeName]).click();
264262
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
265263
// Pop-up with what cultures you want to publish shows, click it
266-
cy.get('.umb-list').contains("Swedish").click();
264+
cy.get('.umb-list').should('be.visible');
265+
cy.get('.checkbox').last().click();
267266
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').last().click();
268267

269268
// Assert
@@ -279,9 +278,6 @@ context('Routing', () => {
279278
.withAllowCultureVariation(true)
280279
.build();
281280

282-
cy.deleteAllContent();
283-
cy.umbracoEnsureDocumentTypeNameNotExists(rootDocTypeName);
284-
285281
saveNewLanguages();
286282

287283
cy.saveDocumentType(rootDocType).then((generatedRootDocType) => {
@@ -351,15 +347,16 @@ context('Routing', () => {
351347
cy.umbracoTreeItem("content", [nodeName, childNodeName]).click();
352348
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
353349
// Pop-up with what cultures you want to publish shows, click it
354-
cy.get('.umb-list').contains("Swedish").click();
350+
cy.get('.umb-list').should('be.visible');
351+
cy.get('.checkbox').last().click();
355352
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').last().click();
356353

357354
// Publish Grandchild
358355
cy.umbracoTreeItem("content", [nodeName, childNodeName, grandChildNodeName]).click();
359356
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
360357
// Pop-up with what cultures you want to publish shows, click it
361-
cy.get('.umb-list').contains("Swedish").click();
362-
cy.get('.umb-list').contains("Danish").click();
358+
cy.get('.umb-list').should('be.visible');
359+
cy.get('.checkbox').click({multiple : true});
363360
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').last().click();
364361

365362
// Assert

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
context('DataTypes', () => {
99

1010
beforeEach(() => {
11-
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false);
12-
});
11+
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
12+
});
1313

1414
it('Tests Approved Colors', () => {
1515
cy.deleteAllContent();
@@ -26,6 +26,12 @@ context('DataTypes', () => {
2626

2727
//umbracoMakeDocTypeWithDataTypeAndContent(name, alias, pickerDataType);
2828
cy.umbracoCreateDocTypeWithContent(name, alias, pickerDataType);
29+
//Editing template with some content
30+
cy.editTemplate(name, '@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ApprovedColourTest>' +
31+
'\n@{' +
32+
'\n Layout = null;' +
33+
'\n}' +
34+
'\n<p style="color:@Model.UmbracoTest">Lorem ipsum dolor sit amet</p>');
2935

3036
// Act
3137
// Enter content
@@ -36,22 +42,19 @@ context('DataTypes', () => {
3642
//Save
3743
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
3844
cy.umbracoSuccessNotification().should('be.visible');
39-
//Editing template with some content
40-
cy.editTemplate(name, '@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ApprovedColourTest>' +
41-
'\n@{' +
42-
'\n Layout = null;' +
43-
'\n}' +
44-
'\n<p style="color:@Model.UmbracoTest">Lorem ipsum dolor sit amet</p>');
4545

4646
//Assert
4747
const expected = `<p style="color:000000" > Lorem ipsum dolor sit amet </p>`;
4848
cy.umbracoVerifyRenderedViewContent('/', expected, true).should('be.true');
49+
cy.get('.umb-button__overlay').should('not.be.visible');
4950

5051
//Pick another colour to verify both work
5152
cy.get('.btn-FF0000').click();
5253
//Save
5354
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click();
5455
cy.umbracoSuccessNotification().should('be.visible');
56+
cy.umbracoButtonByLabelKey('buttons_saveAndPublish').should('be.visible');
57+
cy.get('.umb-button__overlay').should('not.be.visible');
5558
//Assert
5659
const expected2 = '<p style="color:FF0000">Lorem ipsum dolor sit amet</p>';
5760
cy.umbracoVerifyRenderedViewContent('/', expected2, true).should('be.true');
@@ -100,6 +103,7 @@ context('DataTypes', () => {
100103
cy.get('.property-error').should('be.visible');
101104

102105
// Clean
106+
cy.umbracoEnsureTemplateNameNotExists(name);
103107
cy.umbracoEnsureDataTypeNameNotExists(name);
104108
cy.umbracoEnsureDocumentTypeNameNotExists(name);
105109
})

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ context('System Information', () => {
2424
cy.contains('Current Culture').parent().should('contain', 'en-US');
2525
cy.contains('Current UI Culture').parent().should('contain', 'en-US');
2626
});
27-
27+
2828
it('Checks language displays correctly after switching', () => {
2929

3030
//Navigate to edit user and change language
3131
cy.umbracoGlobalUser().click();
3232
cy.get('[alias="editUser"]').click();
3333
cy.get('[name="culture"]').select('string:da-DK', { force: true});
3434
cy.umbracoButtonByLabelKey('buttons_save').click({force: true});
35+
cy.umbracoSuccessNotification().should('be.visible');
3536

3637
openSystemInformation();
3738
//Assert

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Languages/languages.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ context('Languages', () => {
1313
cy.umbracoEnsureLanguageNotExists(language2);
1414
cy.umbracoCreateLanguage(language1, true, '1');
1515
cy.umbracoCreateLanguage(language2, true, '1');
16+
//Enter settings section and wait for everything to load
1617
cy.umbracoSection('settings');
18+
cy.get('.umb-box-content').should('be.visible');
19+
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
1720

1821
// Enter language tree and select the language we just created
1922
cy.umbracoTreeItem('settings', ['Languages']).click();
2023

2124
// Assert there are 3 languages
2225
cy.get('tbody > tr').should('have.length', 3);
2326

24-
// Delete the Danish language
25-
cy.get('tr').contains('Danish').parents('tr').within(() => {
26-
cy.get('umb-button[label-key="general_delete"]').click()
27-
});
27+
// Delete UK Language
28+
cy.get('umb-button[label-key="general_delete"]').last().click();
2829
cy.umbracoButtonByLabelKey('contentTypeEditor_yesDelete').click();
2930

30-
// Assert there is only 2 language
31-
cy.get('tbody > tr').should('have.length', 3);
31+
// Assert there is only 2 languages
32+
cy.get('tbody > tr').should('have.length', 2);
3233

3334
// Cleanup
3435
cy.umbracoEnsureLanguageNotExists(language1);
3536
cy.umbracoEnsureLanguageNotExists(language2);
3637
});
3738

38-
});
39+
});

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Settings/templates.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ context('Templates', () => {
6868
// Open partial view
6969
cy.umbracoTreeItem("settings", ["Templates", name]).click();
7070
// Edit
71-
cy.get('.ace_text-input').type(edit, {force:true} );
71+
cy.get('.ace_content').type(edit);
72+
cy.get('.ace_content').contains(edit).should('be.visible');
73+
cy.get('.btn-success').should('be.visible')
7274

7375
// Navigate away
7476
cy.umbracoSection('content');
@@ -101,7 +103,9 @@ context('Templates', () => {
101103
// Open partial view
102104
cy.umbracoTreeItem("settings", ["Templates", name]).click();
103105
// Edit
104-
cy.get('.ace_text-input').type(edit, {force:true} );
106+
cy.get('.ace_content').type(edit);
107+
cy.get('.ace_content').contains(edit).should('be.visible');
108+
cy.get('.btn-success').should('be.visible')
105109

106110
// Navigate away
107111
cy.umbracoSection('content');

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import {
1414
});
1515

1616
afterEach(() => {
17-
cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName)
17+
cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName);
18+
cy.umbracoEnsureTemplateNameNotExists(tabsDocTypeName);
1819
});
1920

2021
function OpenDocTypeFolder(){
2122
cy.umbracoSection('settings');
23+
// We have to wait in case the execution is slow, otherwise we'll try and click the item before it appears in the UI
2224
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
23-
cy.get('.umb-tree-item__inner > .umb-tree-item__arrow').eq(0).click();
24-
cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(tabsDocTypeName).click();
25+
cy.umbracoTreeItem('settings', ["Document Types", tabsDocTypeName]).click();
2526
}
2627

2728
function CreateDocWithTabAndNavigate(){
@@ -98,8 +99,6 @@ import {
9899
cy.umbracoButtonByLabelKey('buttons_save').click();
99100
//Assert
100101
cy.get('[title="aTab 1"]').should('not.exist');
101-
//Clean
102-
cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName);
103102
});
104103

105104
it('Delete property in tab', () => {

0 commit comments

Comments
 (0)