diff --git a/src/Umbraco.Tests.AcceptanceTest/README.md b/src/Umbraco.Tests.AcceptanceTest/README.md index e8699b0733..541efd40f8 100644 --- a/src/Umbraco.Tests.AcceptanceTest/README.md +++ b/src/Umbraco.Tests.AcceptanceTest/README.md @@ -1,18 +1,18 @@ # Umbraco Acceptance Tests -### Prerequisite +### Prerequisites - NodeJS 12+ - A running installed Umbraco on url: [https://localhost:44331](https://localhost:44331) (Default development port) - Install using a `SqlServer`/`LocalDb` as the tests execute too fast for `SqlCE` to handle. - User information in `cypress.env.json` (See [Getting started](#getting-started)) ### Getting started -The tests is located in the project/folder named `Umbraco.Tests.AcceptanceTests`. Ensur to run `npm install` in that folder, or let your IDE do that. +The tests are located in the project/folder as `Umbraco.Tests.AcceptanceTests`. Make sure you run `npm install` in that folder, or let your IDE do that. -Next, it is important you create a new file in the root of the project called `cypress.env.json`. -This file is already added to `.gitignore` and can contain values that is different for each developer machine. +Next, it is important that you create a new file in the root of the project called `cypress.env.json`. +This file is already added to `.gitignore` and can contain values that are different for each developer machine. -The file need the following content: +The file needs the following content: ``` { "username": "", @@ -24,8 +24,7 @@ Replace the `` and `` placeholder ### Executing tests - -There exists two npm scripts, that can be used to execute the test. +There are two npm scripts that can be used to execute the test: 1. `npm run test` - Executes the tests headless. diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts index ed891a2eea..307da2518c 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts @@ -1,49 +1,103 @@ /// + context('Backoffice Tour', () => { + var timeout = 60000; + beforeEach(() => { + //arrange + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + resetTourData(); + }); - beforeEach(() => { - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); - }); + it('Backoffice introduction tour should run', () => { + //act + cy.umbracoGlobalHelp().should("be.visible"); + cy.umbracoGlobalHelp().click(); + runBackOfficeIntroTour(0, 'Start'); - it('Backoffice introduction tour should run', () => { - //arrange - cy.umbracoGlobalHelp().should("be.visible"); - - //act - cy.umbracoGlobalHelp().click() - //assert + //assert + cy.get('[data-element="help-tours"]').should("be.visible"); + cy.get('[data-element="help-tours"]').click(); + getPercentage(17, timeout); + }); + + it('Backoffice introduction tour should run then rerun', () => { + //act + cy.umbracoGlobalHelp().should("be.visible"); + cy.umbracoGlobalHelp().click(); + runBackOfficeIntroTour(0, 'Start', timeout); + runBackOfficeIntroTour(17, 'Rerun', timeout); + + //assert + cy.get('[data-element="help-tours"]').should("be.visible"); + cy.get('[data-element="help-tours"]').click(); + cy.umbracoGlobalHelp().should("be.visible"); + getPercentage(17, timeout); + }); + + afterEach(() => { + //cleanup + resetTourData(); + }); +}); + +function getPercentage(percentage, timeout) { + cy.get('[data-element="help-tours"] .umb-progress-circle', { timeout: timeout }).get('[percentage]').contains(percentage + '%'); +} + +function resetTourData() { + var tourStatus = + { + "alias": "umbIntroIntroduction", + "completed": false, + "disabled": false + }; + + cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => { + cy.request({ + method: 'POST', + url: '/umbraco/backoffice/UmbracoApi/CurrentUser/PostSetUserTour', + followRedirect: false, + headers: { + ContentType: 'application/json', + 'X-UMB-XSRF-TOKEN': token.value, + }, + body: tourStatus, + }).then((resp) => { + return; + }); + }) +} + +function runBackOfficeIntroTour(percentageComplete, buttonText, timeout) { cy.get('[data-element="help-tours"]').should("be.visible"); - //act cy.get('[data-element="help-tours"]').click(); - //assert + cy.get('[data-element="help-tours"] .umb-progress-circle', { timeout: timeout }).get('[percentage]').contains(percentageComplete + '%'); + cy.get('[data-element="help-tours"]').click(); cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').should("be.visible"); - //act + cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').contains(buttonText); cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').click(); - //assert - cy.get('.umb-tour-step', { timeout: 60000 }).should('be.visible'); - cy.get('.umb-tour-step__footer').should('be.visible'); + //act + cy.get('.umb-tour-step', { timeout: timeout }).should('be.visible'); + cy.get('.umb-tour-step__footer').should('be.visible'); cy.get('.umb-tour-step__counter').should('be.visible'); - for(let i=1;i<7;i++){ - cy.get('.umb-tour-step__counter').contains(i + '/12'); - cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); + for (let i = 1; i < 7; i++) { + cy.get('.umb-tour-step__counter').contains(i + '/12'); + cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); } cy.umbracoGlobalUser().click() - cy.get('.umb-tour-step__counter').contains('8/12'); + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('8/12'); cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); - cy.get('.umb-tour-step__counter').contains('9/12'); + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('9/12'); cy.get('.umb-overlay-drawer__align-right .umb-button').should('be.visible').click(); - cy.get('.umb-tour-step__counter').contains('10/12'); + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('10/12'); cy.umbracoGlobalHelp().click() - for(let i=11;i<13;i++){ - cy.get('.umb-tour-step__counter').contains(i + '/12'); - cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); + for (let i = 11; i < 13; i++) { + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains(i + '/12'); + cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); } cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); - //assert cy.umbracoGlobalHelp().should("be.visible"); - cy.get('[data-element="help-tours"] .umb-progress-circle').contains('17%'); - }); -}); +}