Skip to content

Commit

Permalink
fix(cypress): apply changes on splitted tests after rebase onto next
Browse files Browse the repository at this point in the history
  • Loading branch information
p-fernandez committed Nov 9, 2022
1 parent 4d2e1df commit 530536a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 879 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addAndEditChannel, dragAndDrop, goBack, waitLoadTemplatePage } from '.';
import { addAndEditChannel, clickWorkflow, dragAndDrop, goBack, waitLoadTemplatePage } from '.';

describe('Creation functionality', function () {
beforeEach(function () {
Expand Down Expand Up @@ -45,6 +45,7 @@ describe('Creation functionality', function () {
cy.visit('/templates/create');
});
cy.waitForNetworkIdle(1000);

cy.getByTestId('title').type('Test Notification Title');
cy.getByTestId('description').type('This is a test description for a test title');
cy.get('body').click();
Expand Down Expand Up @@ -171,7 +172,7 @@ describe('Creation functionality', function () {

dragAndDrop('digest');

cy.clickWorkflowNode(`node-digestSelector`);
cy.getByTestId('node-digestSelector').click({ force: true });

cy.getByTestId('time-unit').click();
cy.get('.mantine-Select-dropdown .mantine-Select-item').contains('Minutes').click();
Expand All @@ -187,26 +188,28 @@ describe('Creation functionality', function () {
cy.get('.mantine-Select-dropdown .mantine-Select-item').contains('Minutes').click();

cy.getByTestId('submit-btn').click();

cy.getByTestId('success-trigger-modal').should('be.visible');
cy.getByTestId('trigger-snippet-btn').click();

cy.intercept('GET', '/v1/notification-templates?page=0&limit=10').as('notification-templates');
cy.visit('/templates');
cy.wait('@notification-templates');

awaitGetContains('tbody', 'Test Notification Title').click({ force: true });

cy.clickNodeButton('workflowButton');
waitLoadTemplatePage(() => {
clickWorkflow();

cy.clickNodeButton(`node-digestSelector`);
cy.getByTestId('node-digestSelector').click({ force: true });

cy.getByTestId('time-amount').should('have.value', '20');
cy.getByTestId('batch-key').should('have.value', 'id');
cy.getByTestId('backoff-amount').should('have.value', '20');
cy.getByTestId('time-unit').should('have.value', 'Minutes');
cy.getByTestId('digest-type').should('have.value', 'Backoff');
cy.getByTestId('backoff-unit').should('have.value', 'Minutes');
// cy.getByTestId('updateMode').should('be.checked');
cy.getByTestId('time-amount').should('have.value', '20');
cy.getByTestId('batch-key').should('have.value', 'id');
cy.getByTestId('backoff-amount').should('have.value', '20');
cy.getByTestId('time-unit').should('have.value', 'Minutes');
cy.getByTestId('digest-type').should('have.value', 'Backoff');
cy.getByTestId('backoff-unit').should('have.value', 'Minutes');
// cy.getByTestId('updateMode').should('be.checked');
});
});

it('should create and edit group id', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ describe('Debugging - test trigger', function () {

cy.getByTestId('test-workflow-btn').click();

cy.waitForNetworkIdle(500);
cy.getByTestId('test-trigger-modal').should('be.visible');

cy.getByTestId('test-trigger-modal').getByTestId('test-trigger-to-param').contains(`"subscriberId": "${userId}"`);
});

it('should create template before opening test trigger modal', function () {
cy.intercept('POST', '*/notification-templates').as('createTemplate');
const userId = this.session.user.id;
Expand Down Expand Up @@ -59,6 +58,7 @@ describe('Debugging - test trigger', function () {
cy.location('pathname').should('equal', `/templates/edit/${createdTemplateId}`);
});
});

it('should not test trigger on error ', function () {
const template = this.session.templates[0];
waitLoadTemplatePage(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/cypress/tests/notification-editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function waitLoadTemplatePage(beforeWait = (): string[] | void => []) {
}

export function clickWorkflow() {
cy.getByTestId('workflowButton').click();
cy.getByTestId('workflowButton').click({ force: true });
cy.wait(1000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe('Workflow Editor - Main Functionality', function () {
it('should edit notification', function () {
const template = this.session.templates[0];
cy.visit('/templates/edit/' + template._id);
cy.waitForNetworkIdle(500);

cy.getByTestId('title').should('have.value', template.name);

Expand Down Expand Up @@ -85,7 +84,6 @@ describe('Workflow Editor - Main Functionality', function () {
cy.getByTestId('feed-button-1-checked');
cy.getByTestId('create-feed-input').type('test4');
cy.getByTestId('add-feed-button').click();
cy.wait(1000);
cy.getByTestId('feed-button-2-checked');
});

Expand Down Expand Up @@ -285,7 +283,7 @@ describe('Workflow Editor - Main Functionality', function () {
cy.get('#codeEditor').contains('Hello world code {{name}} <div>Test</div>');
});

it('should redirect to dev env for edit template', async function () {
it('should redirect to dev env for edit template', function () {
cy.intercept('POST', '*/notification-templates').as('createTemplate');
waitLoadTemplatePage(() => {
cy.visit('/templates/create');
Expand All @@ -298,18 +296,18 @@ describe('Workflow Editor - Main Functionality', function () {
cy.getByTestId('trigger-snippet-btn').click();
cy.intercept('GET', '/v1/changes?promoted=false').as('unpromoted-changes');
cy.visit('/changes');
cy.wait('@unpromoted-changes');
cy.getByTestId('promote-btn').eq(0).click();

cy.getByTestId('environment-switch').find(`input[value="Production"]`).click();

cy.getByTestId('notifications-template').find('tbody tr').first().click();
waitLoadTemplatePage(() => {
cy.getByTestId('promote-btn').eq(0).click({ force: true });
cy.getByTestId('environment-switch').find(`input[value="Production"]`).click({ force: true });
cy.getByTestId('notifications-template').find('tbody tr').first().click();

cy.location('pathname').should('not.equal', `/templates/edit/${res.response?.body.data._id}`);
cy.location('pathname').should('not.equal', `/templates/edit/${res.response?.body.data._id}`);

cy.getByTestId('environment-switch').find(`input[value="Development"]`).click();
cy.getByTestId('environment-switch').find(`input[value="Development"]`).click({ force: true });

cy.location('pathname').should('equal', `/templates/edit/${res.response?.body.data._id}`);
cy.location('pathname').should('equal', `/templates/edit/${res.response?.body.data._id}`);
});
});
});

Expand Down Expand Up @@ -337,11 +335,12 @@ describe('Workflow Editor - Main Functionality', function () {

it('should show add step in sidebar after delete', function () {
const template = this.session.templates[0];

waitLoadTemplatePage(() => {
cy.visit('/templates/edit/' + template._id);
clickWorkflow();
});

clickWorkflow();
cy.get('.react-flow__node').should('have.length', 4);
cy.getByTestId('step-actions-dropdown').first().click().getByTestId('delete-step-action').click();
cy.get('.mantine-Modal-modal button').contains('Yes').click();
Expand All @@ -352,19 +351,23 @@ describe('Workflow Editor - Main Functionality', function () {

it('should keep steps order on reload', function () {
const template = this.session.templates[0];

waitLoadTemplatePage(() => {
cy.visit('/templates/edit/' + template._id);
clickWorkflow();
});
clickWorkflow();

dragAndDrop('sms');

editChannel('sms');
cy.getByTestId('smsNotificationContent').type('new content for sms');
cy.getByTestId('submit-btn').click();

waitLoadTemplatePage(() => {
cy.visit('/templates/edit/' + template._id);
clickWorkflow();
});
clickWorkflow();

cy.get('.react-flow__node').should('have.length', 5);
cy.get('.react-flow__node')
.first()
Expand All @@ -381,16 +384,20 @@ describe('Workflow Editor - Main Functionality', function () {
const template = this.session.templates[0];
waitLoadTemplatePage(() => {
cy.visit('/templates/edit/' + template._id);
clickWorkflow();
});
clickWorkflow();

cy.clickWorkflowNode(`node-inAppSelector`);
cy.getByTestId(`step-properties-side-menu`).find('.mantine-Switch-input').get('label').contains('Step is active');
cy.getByTestId(`step-properties-side-menu`).find('.mantine-Switch-input').click();
cy.getByTestId('submit-btn').click();
cy.clickWorkflowNode(`node-inAppSelector`);
cy.getByTestId(`step-properties-side-menu`)
.find('.mantine-Switch-input')
.get('label')
.contains('Step is not active');

waitLoadEnv(() => {
cy.clickWorkflowNode(`node-inAppSelector`);
cy.getByTestId(`step-properties-side-menu`)
.find('.mantine-Switch-input')
.get('label')
.contains('Step is not active');
});
});
});
Loading

0 comments on commit 530536a

Please sign in to comment.