Skip to content

Commit 3c1b47f

Browse files
committed
feat: Added backward compatibility test and run contract test after fixing typo in spec.
1 parent fbacd3d commit 3c1b47f

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

page-objects/service-spec-config-page.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,18 @@ export class ServiceSpecConfigPage extends BasePage {
496496
await test.step("Click Save button after editing spec", async () => {
497497
await this.saveSpecBtn.waitFor({ state: "visible", timeout: 5000 });
498498
await this.saveSpecBtn.click();
499-
await takeAndAttachScreenshot(this.page, "save-button-clicked");
499+
const saveAlert = this.page.locator(
500+
"#alert-container .alert-msg.success",
501+
);
502+
await expect(saveAlert).toContainText(/Contents saved/i, {
503+
timeout: 10000,
504+
});
505+
506+
await takeAndAttachScreenshot(this.page, "spec-saved-successfully");
507+
508+
await saveAlert.locator("button").click();
509+
510+
await expect(saveAlert).toBeHidden({ timeout: 5000 });
500511
});
501512
}
502513
}

specs/openapi/update-service-spec/fix-spec-typo.spec.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import { test } from "../../../utils/eyesFixture";
2-
import { PRODUCT_SEARCH_BFF_SPEC_FIX_TYPO } from "../../specNames";
1+
import { test, expect } from "../../../utils/eyesFixture";
2+
import {
3+
PRODUCT_SEARCH_BFF_SPEC_FIX_TYPO,
4+
ORDER_BFF_SERVICE_URL,
5+
} from "../../specNames";
36
import { ServiceSpecConfigPage } from "../../../page-objects/service-spec-config-page";
7+
import { ApiContractPage } from "../../../page-objects/api-contract-page";
8+
import { validateSummaryAndTableCounts } from "../helpers/execute-contract-tests-helper";
49

510
test.describe("Fix Spec Typo - Conditional Update", () => {
611
test(
@@ -14,12 +19,41 @@ test.describe("Fix Spec Typo - Conditional Update", () => {
1419
PRODUCT_SEARCH_BFF_SPEC_FIX_TYPO,
1520
);
1621

22+
const contractPage = new ApiContractPage(
23+
page,
24+
testInfo,
25+
eyes,
26+
PRODUCT_SEARCH_BFF_SPEC_FIX_TYPO,
27+
);
28+
1729
await configPage.navigateToSpec(PRODUCT_SEARCH_BFF_SPEC_FIX_TYPO);
1830

1931
await test.step("Typo detected: Fixing /ordres to /orders", async () => {
2032
await configPage.editSpecInEditor(" /ordres:", " /orders:");
2133
await configPage.clickSaveAfterEdit();
34+
});
35+
36+
//TODO: Add Backward Compatibility
37+
await test.step("Check Backward Compataibility", async () => {
38+
await configPage.runBackwardCompatibilityTest();
39+
const toastText = await configPage.getAlertMessageText();
40+
expect(toastText).toBe("Changes are backward compatible");
41+
await configPage.dismissAlert();
42+
await expect(page.locator("#alert-container")).toBeEmpty();
43+
});
44+
//TODO: RUn Contract Test and Assert Count
45+
await test.step("Run contract test for spec with fixed typo and assert count", async () => {
2246
await configPage.verifyEndpointInContractTable("/orders");
47+
await contractPage.enterServiceUrl(ORDER_BFF_SERVICE_URL);
48+
await contractPage.clickRunContractTests();
49+
await validateSummaryAndTableCounts(contractPage, {
50+
success: 12,
51+
failed: 20,
52+
total: 33,
53+
error: 0,
54+
notcovered: 1,
55+
excluded: 0,
56+
});
2357
});
2458
},
2559
);

0 commit comments

Comments
 (0)