blob: 22eb88ca7fa1ff1d73db46f34e4270d05728ce94 [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2/// <reference types="Cypress" />
3import { JsonBuilder } from '../../support/jsonBuilders/jsonBuilder';
4import { ServiceModel } from '../../support/jsonBuilders/models/service.model';
5
6describe('A la carte', function () {
7 describe('check service name', () => {
8 var jsonBuilderAAIService : JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
9
10
11 beforeEach(() => {
12 cy.window().then((win) => {
13 win.sessionStorage.clear();
14 cy.setReduxState();
15 cy.preventErrorsOnLoading();
16 cy.initAAIMock();
17 cy.initVidMock();
18 cy.initAlaCarteService();
19 cy.initZones();
20 cy.login();
21 });
22 });
23
24 const SERVICE_ID: string = '4d71990b-d8ad-4510-ac61-496288d9078e';
25 const INSTANCE_NAME_MANDATORY_MESSAGE: string = 'Missing data ("Instance Name" and 3 other fields';
26 const INSTANCE_NAME_NOT_MANDATORY_MESSAGE: string = 'Missing data ("Subscriber Name" and 2 other fields)';
27 const CONFIRM_BUTTON : string = 'confirmButton';
28
29
30 // function changeServiceName(obj : AAIServiceModel){
31 // obj.service.version = "NEW VALUE";
32 // return obj;
33 // }
34 it(`service name should be mandatory : serviceEcompNaming = false`, function () {
35 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
36 jsonBuilderAAIService.basicJson(res,
37 Cypress.config('baseUrl') + '/rest/models/services/4d71990b-d8ad-4510-ac61-496288d9078e',
38 200,
39 0,
40 SERVICE_ID + ' - service',
41 changeServiceEcompNamingToFalse);
42
43 checkServiceNameInputIdMandatory();
44 });
45 });
46
47 it(`service name should be mandatory : serviceEcompNaming = true`, function () {
48 cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/basicService.json').then((res) => {
49 jsonBuilderAAIService.basicJson(res,
50 Cypress.config('baseUrl') + '/rest/models/services/4d71990b-d8ad-4510-ac61-496288d9078e',
51 200,
52 0,
53 SERVICE_ID + ' - service',
54 changeServiceEcompNamingToTrue);
55 checkServiceNameInputIdMandatory();
56 });
57 });
58
59 function changeServiceEcompNamingToTrue(obj : ServiceModel){
60 obj.service.serviceEcompNaming = "true";
61 return obj;
62 }
63
64 function changeServiceEcompNamingToFalse(obj : ServiceModel){
65 obj.service.serviceEcompNaming = "false";
66 return obj;
67 }
68
69 function checkServiceNameInputIdMandatory(){
70 cy.get('span').contains('Browse ASDC Service Models').click({force: true})
71 .getElementByDataTestsId('deploy-' + SERVICE_ID).click({force: true})
72 .wait(1000).getElementByDataTestsId(CONFIRM_BUTTON).click({force: true})
73 .get('.error').contains(INSTANCE_NAME_MANDATORY_MESSAGE)
74 .typeToInput('instanceName', 'testService');
75
76 cy.getElementByDataTestsId(CONFIRM_BUTTON).click({force: true})
77 .get('.error').contains(INSTANCE_NAME_NOT_MANDATORY_MESSAGE);
78 }
79 });
80});