1- import { expect , test } from ' @playwright/test' ;
2- // import { handleConsentPopup, waitFor } from ' ./util' ;
1+ import { expect , test } from " @playwright/test" ;
2+ import { handleConsentPopup , waitFor } from " ./util" ;
33
44// Unit test for the accuracy of the calculations
5- test . describe ( 'Numerical test for N4A calculator page' , ( ) => {
6- test . beforeEach ( async ( { page } ) => {
7- await page . goto ( '/test-product' ) ;
8- await page . waitForLoadState ( 'load' ) ;
9- } ) ;
10-
11- test ( 'estimageNCUUsage calculations are accurate' , async ( { page} ) => {
12- await page . getByTestId ( "button-ncu-usage-details" ) . click ( ) ;
13- await page . getByTestId ( "button-total-cost-details" ) . click ( ) ;
14- } ) ;
15- } ) ;
5+ // test.describe('Numerical test for N4A calculator page', () => {
6+ // test.beforeEach(async ({ page }) => {
7+ // await page.goto('/nginxaas/azure/billing/usage-and-cost-estimator/');
8+ // await page.waitForLoadState('load');
9+ // await waitFor(async () => await handleConsentPopup(page));
10+ // });
11+
12+ // test('estimageNCUUsage calculations are accurate', async ({page}) => {
13+ // // change input-avgNewConnsPerSec to 1000 (label-ncuEstimateValue should be 30 NCUs)
14+
15+ // // change input-avgConnDuration 100 (label-ncuEstimateValue should be 30 NCUs)
16+
17+ // // change input-totalBandwidth to 1000 (label-ncuEstimateValue should be 20 NCUs)
18+
19+ // });
20+ // });
1621
1722// UI test to click buttons to test functionality
18- test . describe ( 'Button functionality test for N4A calculator page' , ( ) => {
19- test . beforeEach ( async ( { page } ) => {
20- await page . goto ( '/test-product' ) ;
21- await page . waitForLoadState ( 'load' ) ;
22- } ) ;
23-
24- test ( 'estimateNCUUsage buttons are functional' , async ( { page} ) => {
25- await page . getByTestId ( "button-ncu-usage-details" ) . click ( ) ;
26- await page . getByTestId ( "button-total-cost-details" ) . click ( ) ;
27- } ) ;
28- } ) ;
23+ test . describe ( "Button and input functionality test for N4A calculator page" , ( ) => {
24+ test . beforeEach ( async ( { page } ) => {
25+ await page . goto ( "/nginxaas/azure/billing/usage-and-cost-estimator/" ) ;
26+ await page . waitForLoadState ( "load" ) ;
27+ await waitFor ( async ( ) => await handleConsentPopup ( page ) ) ;
28+ } ) ;
29+
30+ test ( "estimateNCUUsage buttons and input are functional" , async ( {
31+ page,
32+ } ) => {
33+ await page . getByTestId ( "button-ncu-usage-details" ) . click ( ) ;
34+ await page . getByTestId ( "button-total-cost-details" ) . click ( ) ;
35+ } ) ;
36+ // go through each input and change it to 10000. label-total-value != $219
37+ test ( "input-avgNewConnsPerSec" , async ( { page } ) => {
38+ const input = page . getByTestId ( "input-avgNewConnsPerSec" ) ;
39+ const label = page . getByTestId ( "label-total-value" ) ;
40+
41+ const before = await label . textContent ( ) ;
42+
43+ await input . fill ( "1000" ) ;
44+ await input . blur ( ) ;
45+
46+ await expect ( input ) . toHaveValue ( "1000" ) ;
47+ await expect ( label ) . not . toHaveText ( before || "" ) ;
48+ console . log ( 'before:' , before , 'after:' , await label . textContent ( ) ) ;
49+ } ) ;
50+
51+ test ( "input-avgConnDuration" , async ( { page } ) => {
52+ const input = page . getByTestId ( "input-avgConnDuration" ) ;
53+ const label = page . getByTestId ( "label-total-value" ) ;
54+
55+ const before = await label . textContent ( ) ;
56+
57+ await input . fill ( "1000" ) ;
58+ await input . blur ( ) ;
59+
60+ await expect ( input ) . toHaveValue ( "1000" ) ;
61+ await expect ( label ) . not . toHaveText ( before || "" ) ;
62+ } ) ;
63+
64+ test ( "input-totalBandwidth" , async ( { page } ) => {
65+ const input = page . getByTestId ( "input-totalBandwidth" ) ;
66+ const label = page . getByTestId ( "label-total-value" ) ;
67+
68+ const before = await label . textContent ( ) ;
2969
30- // UI test to make sure the page renders correctly. IE. Calculator with #s on it, regions, etc are populated
31- test . describe ( 'Smoke test for calculation page' , ( ) => {
32- test . beforeEach ( async ( { page } ) => {
33- await page . goto ( '/test-product' ) ;
34- await page . waitForLoadState ( 'load' ) ;
35- // await waitFor(async () => await handleConsentPopup(page));
36- } ) ;
37-
38- test ( 'estimateNCUUSage renders' , async ( { page} ) => {
39- await expect (
40- await page . getByTestId ( "form-section-content-estimateNCUUsage" ) . count ( )
41- ) . toBeTruthy ( ) ;
42- await expect (
43- await page . getByTestId ( "input-avgNewConnsPerSec" ) . count ( )
44- ) . toBeTruthy ( ) ;
45- await expect (
46- await page . getByTestId ( "input-avgConnDuration" ) . count ( )
47- ) . toBeTruthy ( ) ;
48- await expect (
49- await page . getByTestId ( "input-totalBandwidth" ) . count ( )
50- ) . toBeTruthy ( ) ;
51- await expect (
52- await page . getByTestId ( "form-section-content-capacityUnitsNeeded" ) . count ( )
53- ) . toBeTruthy ( ) ;
54- await expect (
55- await page . getByTestId ( "label-ncuEstimateValue" ) . count ( )
56- ) . toBeTruthy ( ) ;
57- await expect (
58- await page . getByTestId ( "button-ncu-usage-details" ) . count ( )
59- ) . toBeTruthy ( ) ;
60- await expect (
61- await page . getByTestId ( "label-ncuEstMin1" ) . count ( )
62- ) . toBeTruthy ( ) ;
63- await expect (
64- await page . getByTestId ( "form-section-content-estimateMonthlyCost" ) . count ( )
65- ) . toBeTruthy ( ) ;
66- await expect (
67- await page . getByTestId ( "dropdown-region" ) . count ( )
68- ) . toBeTruthy ( ) ;
69- await expect (
70- await page . getByTestId ( "input-numNcus" ) . count ( )
71- ) . toBeTruthy ( ) ;
72- await expect (
73- await page . getByTestId ( "input-numHours" ) . count ( )
74- ) . toBeTruthy ( ) ;
75- await expect (
76- await page . getByTestId ( "input-numListenPorts" ) . count ( )
77- ) . toBeTruthy ( ) ;
78- await expect (
79- await page . getByTestId ( "label-total-value" ) . count ( )
80- ) . toBeTruthy ( ) ;
81- await expect (
82- await page . getByTestId ( "button-total-cost-details" ) . count ( )
83- ) . toBeTruthy ( ) ;
84-
85- } )
70+ await input . fill ( "1000" ) ;
71+ await input . blur ( ) ;
72+
73+ await expect ( input ) . toHaveValue ( "1000" ) ;
74+ await expect ( label ) . not . toHaveText ( before || "" ) ;
75+ } ) ;
76+
77+ test ( "input-numNcus" , async ( { page } ) => {
78+ const input = page . getByTestId ( "input-numNcus" ) ;
79+ const label = page . getByTestId ( "label-total-value" ) ;
80+
81+ const before = await label . textContent ( ) ;
82+
83+ await input . fill ( "1000" ) ;
84+ await input . blur ( ) ;
85+
86+ await expect ( input ) . toHaveValue ( "1000" ) ;
87+ await expect ( label ) . not . toHaveText ( before || "" ) ;
88+ } ) ;
89+
90+ test ( "input-numHours" , async ( { page } ) => {
91+ const input = page . getByTestId ( "input-numHours" ) ;
92+ const label = page . getByTestId ( "label-total-value" ) ;
93+
94+ const before = await label . textContent ( ) ;
95+
96+ await input . fill ( "1000" ) ;
97+ await input . blur ( ) ;
98+
99+ await expect ( input ) . toHaveValue ( "1000" ) ;
100+ await expect ( label ) . not . toHaveText ( before || "" ) ;
101+ } ) ;
102+
103+ test ( "input-numListenPorts" , async ( { page } ) => {
104+ const input = page . getByTestId ( "input-numListenPorts" ) ;
105+ const label = page . getByTestId ( "label-total-value" ) ;
106+
107+ const before = await label . textContent ( ) ;
108+
109+ await input . fill ( "1000" ) ;
110+ await input . blur ( ) ;
111+
112+ await expect ( input ) . toHaveValue ( "1000" ) ;
113+ await expect ( label ) . not . toHaveText ( before || "" ) ;
114+ } ) ;
86115} ) ;
87116
88- // Behavioural test
117+ // // UI test to make sure the page renders correctly. IE. Calculator with #s on it, regions, etc are populated
118+ // test.describe('Smoke test for calculation page', () => {
119+ // test.beforeEach(async ({ page }) => {
120+ // await page.goto('/nginxaas/azure/billing/usage-and-cost-estimator/');
121+ // await page.waitForLoadState('load');
122+ // await waitFor(async () => await handleConsentPopup(page));
123+ // // await waitFor(async () => await handleConsentPopup(page));
124+ // });
125+
126+ // test('estimateNCUUSage renders', async ({page}) => {
127+ // await expect(
128+ // await page.getByTestId("form-section-content-estimateNCUUsage").count()
129+ // ).toBeTruthy();
130+ // await expect(
131+ // await page.getByTestId("input-avgNewConnsPerSec").count()
132+ // ).toBeTruthy();
133+ // await expect(
134+ // await page.getByTestId("input-avgConnDuration").count()
135+ // ).toBeTruthy();
136+ // await expect(
137+ // await page.getByTestId("input-totalBandwidth").count()
138+ // ).toBeTruthy();
139+ // await expect(
140+ // await page.getByTestId("form-section-content-capacityUnitsNeeded").count()
141+ // ).toBeTruthy();
142+ // await expect(
143+ // await page.getByTestId("label-ncuEstimateValue").count()
144+ // ).toBeTruthy();
145+ // await expect(
146+ // await page.getByTestId("button-ncu-usage-details").count()
147+ // ).toBeTruthy();
148+ // await expect(
149+ // await page.getByTestId("label-ncuEstMin1").count()
150+ // ).toBeTruthy();
151+ // await expect(
152+ // await page.getByTestId("form-section-content-estimateMonthlyCost").count()
153+ // ).toBeTruthy();
154+ // await expect(
155+ // await page.getByTestId("dropdown-region").count()
156+ // ).toBeTruthy();
157+ // await expect(
158+ // await page.getByTestId("input-numNcus").count()
159+ // ).toBeTruthy();
160+ // await expect(
161+ // await page.getByTestId("input-numHours").count()
162+ // ).toBeTruthy();
163+ // await expect(
164+ // await page.getByTestId("input-numListenPorts").count()
165+ // ).toBeTruthy();
166+ // await expect(
167+ // await page.getByTestId("label-total-value").count()
168+ // ).toBeTruthy();
169+ // await expect(
170+ // await page.getByTestId("button-total-cost-details").count()
171+ // ).toBeTruthy();
172+
173+ // })
174+ // });
175+
176+ // Behavioural test
0 commit comments