Skip to content

Commit

Permalink
add search by qr and ID
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Sep 11, 2023
1 parent 7cda789 commit 16b0bd8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import { AssetQRScanPage } from "../../pageobject/Asset/AssetQRScan";
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import { AssetFilters } from "../../pageobject/Asset/AssetFilters";
import LoginPage from "../../pageobject/Login/LoginPage";

describe("Asset Tab", () => {
const assetSearchPage = new AssetSearchPage();
const assetQRScanPage = new AssetQRScanPage();
const assetPagination = new AssetPagination();
const assetFilters = new AssetFilters();
const loginPage = new LoginPage();

before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

Expand All @@ -24,11 +26,27 @@ describe("Asset Tab", () => {

// search for a element

it("Search Asset Name", () => {
const initialUrl = cy.url();
assetSearchPage.typeSearchKeyword("dummy camera 30");
it("Search Asset Name/QR_ID/Serial_number", () => {
assetSearchPage.typeSearchKeyword("dummy camera 10");
assetSearchPage.pressEnter();
assetSearchPage.verifyUrlChanged(initialUrl);
assetSearchPage.verifyBadgeContent(
"Name/Serial No./QR ID: dummy camera 10"
);
assetSearchPage.clickAssetByName("Dummy Camera 10");
assetSearchPage.clickUpdateButton();
assetSearchPage.clearAndTypeQRCode("340543-05935-04953-05234-04");
assetSearchPage.clearAndTypeSerialNumber("8989898989898");
assetSearchPage.clickAssetSubmitButton();
assetSearchPage.visitAssetsPage();
assetSearchPage.typeSearchKeyword("340543-05935-04953-05234-04");
assetSearchPage.pressEnter();
assetSearchPage.verifyAssetListContains("Dummy Camera 10");
assetSearchPage.verifyBadgeContent(
"Name/Serial No./QR ID: 340543-05935-04953-05234-04"
);
assetSearchPage.typeSearchKeyword("8989898989898");
assetSearchPage.verifyAssetListContains("Dummy Camera 10");
assetSearchPage.verifyBadgeContent("Name/Serial No./QR ID: 8989898989898");
});

// scan a asset qr code
Expand Down
47 changes: 42 additions & 5 deletions cypress/pageobject/Asset/AssetSearch.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
export class AssetSearchPage {
typeSearchKeyword(keyword: string) {
cy.get("[name='search']").type(keyword);
cy.get("#search").clear();
cy.get("#search").click().type(keyword);
}

pressEnter() {
cy.get("[name='search']").type("{enter}");
}

verifyUrlChanged(initialUrl: string) {
cy.url().should((currentUrl) => {
expect(currentUrl).not.to.equal(initialUrl);
});
clickAssetByName(assetName: string) {
cy.get("[data-testid='created-asset-list']").contains(assetName).click();
}

verifyBadgeContent(expectedText: string) {
cy.get("[data-testid='Name/Serial No./QR ID']").should(
"have.text",
expectedText
);
}

verifyAssetIsPresent(assetName: string) {
cy.get("[data-testid=created-asset-list]")
.first()
.should("contain", assetName);
}

clickUpdateButton() {
cy.get("[data-testid='asset-update-button']").contains("Update").click();
}

clearAndTypeQRCode(qrCode: string) {
cy.get("#qr_code_id").clear();
cy.get("#qr_code_id").click().type(qrCode);
}

clearAndTypeSerialNumber(serialNumber: string) {
cy.get("#serial-number").clear();
cy.get("#serial-number").click().type(serialNumber);
}

clickAssetSubmitButton() {
cy.intercept("GET", "**/api/v1/asset/**").as("getAssets");
cy.get("#submit").click();
cy.wait("@getAssets").its("response.statusCode").should("eq", 200);
}

visitAssetsPage() {
cy.visit("/assets");
}

verifyAssetListContains(dummyCameraText: string) {
cy.get("[data-testid='created-asset-list']").should(
"contain",
dummyCameraText
);
}
}

0 comments on commit 16b0bd8

Please sign in to comment.