Skip to content

Commit c63c759

Browse files
committed
tests
1 parent 38cddce commit c63c759

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

.github/workflows/playwright.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ on:
33
push:
44
branches: [main]
55
paths:
6-
- 'static/nginxaas-azure/js/cost-calculator_v2.js'
6+
- 'static/nginxaas-azure/js/cost-calculator_v2.js'
77
- 'content/nginxaas-azure/billing/usage-and-cost-estimator.md'
8+
- 'static/nginxaas-google/js/cost-calculator_gc.js'
9+
- 'content/nginxaas-google/billing/usage-and-cost-estimator.md'
810
pull_request:
911
paths:
1012
- 'static/nginxaas-azure/js/cost-calculator_v2.js'
1113
- 'content/nginxaas-azure/billing/usage-and-cost-estimator.md'
14+
- 'static/nginxaas-google/js/cost-calculator_gc.js'
15+
- 'content/nginxaas-google/billing/usage-and-cost-estimator.md'
1216
permissions:
1317
contents: read
1418
jobs:

content/nginxaas-google/billing/usage-and-cost-estimator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ nd-product: NGOOGL
1111
{{< raw-html >}}
1212
<link rel="stylesheet" href="/nginxaas-google/css/cost-calculator_v2.css">
1313
<div id="calculator">
14-
<h3 id="calculator-section-heading">
14+
<h3 id="calculator-section-heading" data-testid="calculator-section-heading">
1515
Cost Estimation for Enterprise Plan
1616
<button id="printButton">Print Estimate</button>
1717
</h3>
1818

19-
<div class="section">
19+
<div class="section" data-testid="calculator-section-content">
2020
<div class="form-section">
2121
<div class="form-section-content">
2222
<h4 id="calculator-section-heading">Estimate Monthly Cost</h4>
@@ -51,7 +51,7 @@ nd-product: NGOOGL
5151
<div class="form-section-content">
5252
<div id="totals-section">
5353
<span class="total-text">Total Monthly Payment</span>
54-
<span id="total-value" class="total-text">--</span>
54+
<span id="total-value" class="total-text" data-testid="total-value">--</span>
5555

5656
<details id="total-cost-details">
5757
<summary>Show calculations</summary>

tests/src/n4g-calculator.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect, test } from "@playwright/test";
2+
import { handleConsentPopup, waitFor } from "../util";
3+
4+
test.describe("Testing for N4G calculator page", () => {
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto("/nginxaas/google/billing/usage-and-cost-estimator/");
7+
await page.waitForLoadState("load");
8+
await waitFor(async () => await handleConsentPopup(page));
9+
});
10+
11+
test("calculator renders", async ({ page }) => {
12+
const header = page.getByTestId("calculator-section-heading");
13+
const content = page.getByTestId("calculator-section-content");
14+
15+
await expect(header).toBeVisible();
16+
await expect(content).toBeVisible();
17+
});
18+
19+
test("calculator values render", async ({ page }) => {
20+
// Conjunction - If outputs are rendered, it is safe to say the inputs are rendered.
21+
// NOT testing changing numbers will impact the total values as that should be the job of unit tests. This is just a smoke tests.
22+
const ncuEstimateValue = page.getByTestId("ncuEstimateValue");
23+
const totalValue = page.getByTestId("total-value");
24+
25+
expect(await ncuEstimateValue.textContent()).toBeTruthy();
26+
expect(await totalValue.textContent()).toBeTruthy();
27+
});
28+
});

0 commit comments

Comments
 (0)