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

feat: migrate E2E test with bot creation v2 #7040

Merged
merged 10 commits into from
Apr 20, 2021
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
61 changes: 0 additions & 61 deletions Composer/cypress/integration/Breadcrumb.spec.ts

This file was deleted.

25 changes: 0 additions & 25 deletions Composer/cypress/integration/CreateNewBot.spec.ts

This file was deleted.

136 changes: 136 additions & 0 deletions Composer/cypress/integration/DesignPage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Tests for dialog & trigger CRUD

context('breadcrumb', () => {
beforeEach(() => {
cy.createTestBot('TestSample', ({ id }) => {
cy.visit(`/bot/${id}`);
});
});

function hasBreadcrumbItems(cy: Cypress.cy, items: (string | RegExp)[]) {
cy.get('[data-testid="Breadcrumb"]')
.last()
.within(() => {
cy.get('li').should(($li) => {
items.forEach((item, idx) => {
expect($li.eq(idx)).to.contain(item);
});
});
});
}

it('can show dialog, trigger, action in breadcrumb', () => {
// Should path = main dialog at first render
hasBreadcrumbItems(cy, ['TestBot_TestSample']);

// Click on an trigger
cy.findByTestId('ProjectTree').within(() => {
cy.findAllByText('Greeting').last().click();
});

hasBreadcrumbItems(cy, ['TestBot_TestSample', 'Greeting']);

// Click on an action
cy.withinEditor('VisualEditor', () => {
cy.findByTestId('RuleEditor').within(() => {
cy.findByText('Send a response').click();
});
});

hasBreadcrumbItems(cy, ['TestBot_TestSample', 'Greeting', 'Send a response']);
});

it('can create / remove dialog from project tree', () => {
// create
cy.findByTestId('BotHeader-TestBot_TestSample').within(() => {
cy.findByTestId('dialogMoreButton').click({ force: true });
});
cy.findAllByText('Add a dialog').click({ force: true });
cy.findByTestId('NewDialogName').type('{selectall}TestNewDialog2{enter}');
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('TestNewDialog2').should('exist');
});

// remove
cy.findByTestId('ProjectTree').within(() => {
cy.findByTestId('$Root_TestNewDialog2').within(() => {
cy.findByTestId('dialogMoreButton').first().invoke('attr', 'style', 'visibility: visible').click();
});
});

cy.findByText('Remove this dialog').click();

cy.findByText('Yes').click();

cy.findByTestId('ProjectTree').within(() => {
cy.get('[title="TestNewDialog2"]').should('not.exist');
});
});

it('can create different kinds of triggers ', () => {
cy.visitPage('Design');
cy.findByTestId('DialogHeader-TestBot_TestSample').click();
cy.findByTestId('recognizerTypeDropdown').click();
cy.findByText('Regular expression recognizer').click();

//onintent trigger
cy.findByTestId('DialogHeader-TestBot_TestSample').within(() => {
cy.findByTestId('dialogMoreButton').click({ force: true });
});
cy.findAllByText('Add a trigger').click({ force: true });
cy.findByTestId('triggerTypeDropDown').click();
cy.get('[title="Intent recognized"]').click();
cy.findByTestId('TriggerName').type('myTrigger1');
cy.findByTestId('RegExField').type('test');
cy.findByTestId('triggerFormSubmit').click();
cy.findAllByText('myTrigger1').should('exist');

//on Dialog Event trigger
cy.findByTestId('DialogHeader-TestBot_TestSample').within(() => {
cy.findByTestId('dialogMoreButton').click({ force: true });
});
cy.findAllByText('Add a trigger').click({ force: true });
cy.findByTestId('triggerTypeDropDown').click();
cy.get('[title="Dialog events"]').click();
cy.findByText('Select an event type').click();
cy.findByText('Dialog started (Begin dialog event)').click();
cy.findByTestId('triggerFormSubmit').click();
cy.findAllByText('Begin dialog event').should('exist');

// custom event
cy.findByTestId('DialogHeader-TestBot_TestSample').within(() => {
cy.findByTestId('dialogMoreButton').click({ force: true });
});
cy.findAllByText('Add a trigger').click({ force: true });
cy.findByTestId('triggerTypeDropDown').click();
cy.get('[title="Custom events"]').click();
cy.findByTestId('CustomEventName').type('myCustomEvent');
cy.findByTestId('triggerFormSubmit').click();
cy.findAllByText('myCustomEvent').should('exist');

//on activity trigger
cy.findByTestId('DialogHeader-TestBot_TestSample').within(() => {
cy.findByTestId('dialogMoreButton').click({ force: true });
});
cy.findAllByText('Add a trigger').click({ force: true });
cy.findByTestId('triggerTypeDropDown').click();
cy.get('[title="Activities"]').click();
cy.findByText('Select an activity type').click();
cy.findByText('Activities (Activity received)').click();
cy.findByTestId('triggerFormSubmit').click();
cy.findAllByText('Activities').should('exist');
});

it('can find Visual Designer default trigger in container', () => {
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('Greeting').click();
});

cy.withinEditor('VisualEditor', () => {
cy.findByText('ConversationUpdate activity').should('exist');
});
});
});
63 changes: 63 additions & 0 deletions Composer/cypress/integration/HomePage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Tests for bot create, save, page navigation, creation flow modal.

context('Home Page ', () => {
beforeEach(() => {
cy.visit('/home');
Expand All @@ -17,4 +19,65 @@ context('Home Page ', () => {
cy.findByText('Cancel').click();
cy.findByTestId('homePage-Toolbar-New').click();
});

// page navigation
it('can expand left Nav Bar', () => {
cy.createTestBot('EmptySample', ({ id }) => {
cy.visit(`/bot/${id}`);
cy.findByTestId('LeftNavButton').click();
cy.findByTestId('LeftNav-CommandBarButtonDesign').should('exist');
cy.findByTestId('LeftNav-CommandBarButtonBot responses').click();
cy.url().should('include', 'language-generation');
cy.findByTestId('LeftNav-CommandBarButtonUser input').click();
cy.url().should('include', 'language-understanding');
cy.findByTestId('LeftNav-CommandBarButtonComposer settings').click();
cy.url().should('include', 'setting');
});
});

// creation flow
it('should open Select Template window from a url', () => {
cy.visit('/projects/create');
cy.findAllByTestId('dotnetFeed').should('exist');
});

it('should open Define Conversations window from a url', () => {
cy.visit('/projects/create/dotnet/conversationalCore');
cy.get('[data-testid="NewDialogName"]').should('be.visible');
});

it('should create the Open a Bot window from a location through the specified url', () => {
cy.visit('/projects/open');
cy.get('[data-testid="SelectLocation"]').should('be.visible');
});

it('can create a new bot', () => {
cy.visit('/home');
cy.findByTestId('LeftNav-CommandBarButtonHome').click();
cy.findByTestId('homePage-Toolbar-New').within(() => {
cy.findByText('New').click();
});
cy.wait(3000);
cy.findByTestId('@microsoft/generator-bot-empty').click();
cy.findByTestId('NextStepButton').click();
cy.enterTextAndSubmit('NewDialogName', 'TestNewProject3', 'SubmitNewBotBtn');
cy.wait(100000);
cy.findByTestId('ProjectTree').within(() => {
cy.findAllByText('TestNewProject3').should('exist');
});
});

it('can save as a new bot from an existing bot', () => {
cy.createTestBot('EmptySample', ({ id }) => {
cy.visit(`/bot/${id}`);
cy.findByTestId('LeftNav-CommandBarButtonHome').click();
cy.url().should('contain', 'home');
cy.findByText('Save as').click();
cy.enterTextAndSubmit('NewDialogName', 'TestSaveAs', 'SubmitNewBotBtn');
cy.wait(5000);
cy.findByTestId('ProjectTree').within(() => {
cy.findAllByText('TestSaveAs').should('exist');
});
});
});
});
9 changes: 5 additions & 4 deletions Composer/cypress/integration/LGPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

context('LG Page', () => {
beforeEach(() => {
cy.visit('/home');
cy.createBot('TodoSample');
cy.createTestBot('TestSample', ({ id }) => {
cy.visit(`/bot/${id}`);
});
});

it('can open language generation page', () => {
cy.findByTestId('LeftNav-CommandBarButtonBot responses').click();
// left nav tree
cy.contains('TodoSample');
cy.contains('TestBot_TestSample');

cy.findByTestId('showcode').as('switchButton');

Expand All @@ -28,7 +29,7 @@ context('LG Page', () => {

// nav to Main dialog
cy.findByTestId('ProjectTree').within(() => {
cy.findAllByText('__TestTodoSample').last().click();
cy.findAllByText('TestBot_TestSample').last().click();
});
});
});
11 changes: 5 additions & 6 deletions Composer/cypress/integration/LUPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@

context('LU Page', () => {
beforeEach(() => {
cy.visit('/home');
cy.createBot('ToDoBotWithLuisSample');
cy.createTestBot('TestSample', ({ id }) => {
cy.visit(`/bot/${id}`);
});
});

it('can open language understanding page', () => {
cy.findByTestId('LeftNav-CommandBarButtonUser input').click();
// left nav tree
cy.contains('__TestToDoBotWithLuisSample');

cy.findByTestId('showcode').should('not.exist');
cy.contains('TestBot_TestSample');

// by default it goes to table view
cy.findByTestId('LUPage').findByTestId('table-view').should('exist');
Expand All @@ -22,7 +21,7 @@ context('LU Page', () => {

// nav to ToDoBotWithLuisSample.main dialog
cy.findByTestId('ProjectTree').within(() => {
cy.findAllByText('__TestToDoBotWithLuisSample').last().click('left');
cy.findAllByText('TestBot_TestSample').last().click();
});
cy.findByTestId('showcode').as('switchButton');
// goto edit-mode
Expand Down
20 changes: 0 additions & 20 deletions Composer/cypress/integration/LeftNavBar.spec.ts

This file was deleted.

6 changes: 3 additions & 3 deletions Composer/cypress/integration/LuisDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ context('Luis Deploy', () => {
cy.route('POST', '/api/publish/*/publish/default', { endpointURL: 'anything', status: 202 });
cy.route('POST', '/api/projects/*/settings', 'OK');
cy.route('GET', '/api/publish/*/status/default', { endpointURL: 'anything', status: 404 });
cy.visit('/home');
cy.createBot('ToDoBotWithLuisSample');
cy.visitPage('Design');
cy.createTestBot('TestSample', ({ id }) => {
cy.visit(`/bot/${id}`);
});
});

it('can deploy luis success', () => {
Expand Down
Loading