mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-07-21 21:07:23 +01:00
Comment out most tests.
This commit is contained in:
@@ -1,60 +1,60 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
// import { expect, test } from "@playwright/test";
|
||||
|
||||
import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx";
|
||||
// import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx";
|
||||
|
||||
(
|
||||
[
|
||||
["latest API version", TestAccount.Mongo],
|
||||
["3.2 API", TestAccount.Mongo32],
|
||||
] as [string, TestAccount][]
|
||||
).forEach(([apiVersionDescription, accountType]) => {
|
||||
test(`Mongo CRUD using ${apiVersionDescription}`, async ({ page }) => {
|
||||
test.skip();
|
||||
const databaseId = generateUniqueName("db");
|
||||
const collectionId = "testcollection"; // A unique collection name isn't needed because the database is unique
|
||||
// (
|
||||
// [
|
||||
// ["latest API version", TestAccount.Mongo],
|
||||
// ["3.2 API", TestAccount.Mongo32],
|
||||
// ] as [string, TestAccount][]
|
||||
// ).forEach(([apiVersionDescription, accountType]) => {
|
||||
// test(`Mongo CRUD using ${apiVersionDescription}`, async ({ page }) => {
|
||||
// test.skip();
|
||||
// const databaseId = generateUniqueName("db");
|
||||
// const collectionId = "testcollection"; // A unique collection name isn't needed because the database is unique
|
||||
|
||||
const explorer = await DataExplorer.open(page, accountType);
|
||||
// const explorer = await DataExplorer.open(page, accountType);
|
||||
|
||||
const newCollectionButton = await explorer.globalCommandButton("New Collection");
|
||||
await newCollectionButton.click();
|
||||
await explorer.whilePanelOpen(
|
||||
"New Collection",
|
||||
async (panel, okButton) => {
|
||||
await panel.getByPlaceholder("Type a new database id").fill(databaseId);
|
||||
await panel.getByRole("textbox", { name: "Collection id, Example Collection1" }).fill(collectionId);
|
||||
await panel.getByRole("textbox", { name: "Shard key" }).fill("pk");
|
||||
await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
|
||||
await okButton.click();
|
||||
},
|
||||
{ closeTimeout: 5 * 60 * 1000 },
|
||||
);
|
||||
// const newCollectionButton = await explorer.globalCommandButton("New Collection");
|
||||
// await newCollectionButton.click();
|
||||
// await explorer.whilePanelOpen(
|
||||
// "New Collection",
|
||||
// async (panel, okButton) => {
|
||||
// await panel.getByPlaceholder("Type a new database id").fill(databaseId);
|
||||
// await panel.getByRole("textbox", { name: "Collection id, Example Collection1" }).fill(collectionId);
|
||||
// await panel.getByRole("textbox", { name: "Shard key" }).fill("pk");
|
||||
// await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
|
||||
// await okButton.click();
|
||||
// },
|
||||
// { closeTimeout: 5 * 60 * 1000 },
|
||||
// );
|
||||
|
||||
const databaseNode = await explorer.waitForNode(databaseId);
|
||||
const collectionNode = await explorer.waitForContainerNode(databaseId, collectionId);
|
||||
// const databaseNode = await explorer.waitForNode(databaseId);
|
||||
// const collectionNode = await explorer.waitForContainerNode(databaseId, collectionId);
|
||||
|
||||
await collectionNode.openContextMenu();
|
||||
await collectionNode.contextMenuItem("Delete Collection").click();
|
||||
await explorer.whilePanelOpen(
|
||||
"Delete Collection",
|
||||
async (panel, okButton) => {
|
||||
await panel.getByRole("textbox", { name: "Confirm by typing the collection id" }).fill(collectionId);
|
||||
await okButton.click();
|
||||
},
|
||||
{ closeTimeout: 5 * 60 * 1000 },
|
||||
);
|
||||
await expect(collectionNode.element).not.toBeAttached();
|
||||
// await collectionNode.openContextMenu();
|
||||
// await collectionNode.contextMenuItem("Delete Collection").click();
|
||||
// await explorer.whilePanelOpen(
|
||||
// "Delete Collection",
|
||||
// async (panel, okButton) => {
|
||||
// await panel.getByRole("textbox", { name: "Confirm by typing the collection id" }).fill(collectionId);
|
||||
// await okButton.click();
|
||||
// },
|
||||
// { closeTimeout: 5 * 60 * 1000 },
|
||||
// );
|
||||
// await expect(collectionNode.element).not.toBeAttached();
|
||||
|
||||
await databaseNode.openContextMenu();
|
||||
await databaseNode.contextMenuItem("Delete Database").click();
|
||||
await explorer.whilePanelOpen(
|
||||
"Delete Database",
|
||||
async (panel, okButton) => {
|
||||
await panel.getByRole("textbox", { name: "Confirm by typing the Database id" }).fill(databaseId);
|
||||
await okButton.click();
|
||||
},
|
||||
{ closeTimeout: 5 * 60 * 1000 },
|
||||
);
|
||||
// await databaseNode.openContextMenu();
|
||||
// await databaseNode.contextMenuItem("Delete Database").click();
|
||||
// await explorer.whilePanelOpen(
|
||||
// "Delete Database",
|
||||
// async (panel, okButton) => {
|
||||
// await panel.getByRole("textbox", { name: "Confirm by typing the Database id" }).fill(databaseId);
|
||||
// await okButton.click();
|
||||
// },
|
||||
// { closeTimeout: 5 * 60 * 1000 },
|
||||
// );
|
||||
|
||||
await expect(databaseNode.element).not.toBeAttached();
|
||||
});
|
||||
});
|
||||
// await expect(databaseNode.element).not.toBeAttached();
|
||||
// });
|
||||
// });
|
||||
|
||||
+82
-82
@@ -1,103 +1,103 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
// import { expect, test } from "@playwright/test";
|
||||
|
||||
import { setupCORSBypass } from "../CORSBypass";
|
||||
import { CommandBarButton, DataExplorer, DocumentsTab, TestAccount } from "../fx";
|
||||
import { retry, serializeMongoToJson, setPartitionKeys } from "../testData";
|
||||
import { documentTestCases } from "./testCases";
|
||||
// import { setupCORSBypass } from "../CORSBypass";
|
||||
// import { CommandBarButton, DataExplorer, DocumentsTab, TestAccount } from "../fx";
|
||||
// import { retry, serializeMongoToJson, setPartitionKeys } from "../testData";
|
||||
// import { documentTestCases } from "./testCases";
|
||||
|
||||
let explorer: DataExplorer = null!;
|
||||
let documentsTab: DocumentsTab = null!;
|
||||
// let explorer: DataExplorer = null!;
|
||||
// let documentsTab: DocumentsTab = null!;
|
||||
|
||||
for (const { name, databaseId, containerId, documents } of documentTestCases) {
|
||||
test.describe(`Test MongoRU Documents with ${name}`, () => {
|
||||
// test.skip(true, "Temporarily disabling all tests in this spec file");
|
||||
test.beforeEach("Open documents tab", async ({ page }) => {
|
||||
await setupCORSBypass(page);
|
||||
explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
|
||||
// for (const { name, databaseId, containerId, documents } of documentTestCases) {
|
||||
// test.describe(`Test MongoRU Documents with ${name}`, () => {
|
||||
// // test.skip(true, "Temporarily disabling all tests in this spec file");
|
||||
// test.beforeEach("Open documents tab", async ({ page }) => {
|
||||
// await setupCORSBypass(page);
|
||||
// explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
|
||||
|
||||
const containerNode = await explorer.waitForContainerNode(databaseId, containerId);
|
||||
await containerNode.expand();
|
||||
// const containerNode = await explorer.waitForContainerNode(databaseId, containerId);
|
||||
// await containerNode.expand();
|
||||
|
||||
const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, containerId);
|
||||
await containerMenuNode.element.click();
|
||||
// const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, containerId);
|
||||
// await containerMenuNode.element.click();
|
||||
|
||||
documentsTab = explorer.documentsTab("tab0");
|
||||
// documentsTab = explorer.documentsTab("tab0");
|
||||
|
||||
await documentsTab.documentsFilter.waitFor();
|
||||
await documentsTab.documentsListPane.waitFor();
|
||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
});
|
||||
test.afterEach(async ({ page }) => {
|
||||
await page.unrouteAll({ behavior: "ignoreErrors" });
|
||||
});
|
||||
// await documentsTab.documentsFilter.waitFor();
|
||||
// await documentsTab.documentsListPane.waitFor();
|
||||
// await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
// });
|
||||
// test.afterEach(async ({ page }) => {
|
||||
// await page.unrouteAll({ behavior: "ignoreErrors" });
|
||||
// });
|
||||
|
||||
for (const document of documents) {
|
||||
const { documentId: docId, partitionKeys } = document;
|
||||
test.describe(`Document ID: ${docId}`, () => {
|
||||
test(`should load and view document ${docId}`, async () => {
|
||||
test.skip();
|
||||
const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
|
||||
await span.waitFor();
|
||||
await expect(span).toBeVisible();
|
||||
// for (const document of documents) {
|
||||
// const { documentId: docId, partitionKeys } = document;
|
||||
// test.describe(`Document ID: ${docId}`, () => {
|
||||
// test(`should load and view document ${docId}`, async () => {
|
||||
// test.skip();
|
||||
// const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
|
||||
// await span.waitFor();
|
||||
// await expect(span).toBeVisible();
|
||||
|
||||
await span.click();
|
||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
// await span.click();
|
||||
// await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
|
||||
const resultText = await documentsTab.resultsEditor.text();
|
||||
const resultData = serializeMongoToJson(resultText!);
|
||||
expect(resultText).not.toBeNull();
|
||||
expect(resultData?._id).not.toBeNull();
|
||||
expect(resultData?._id).toEqual(docId);
|
||||
});
|
||||
test(`should be able to create and delete new document from ${docId}`, async ({ page }) => {
|
||||
test.skip();
|
||||
const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
|
||||
await span.waitFor();
|
||||
await expect(span).toBeVisible();
|
||||
// const resultText = await documentsTab.resultsEditor.text();
|
||||
// const resultData = serializeMongoToJson(resultText!);
|
||||
// expect(resultText).not.toBeNull();
|
||||
// expect(resultData?._id).not.toBeNull();
|
||||
// expect(resultData?._id).toEqual(docId);
|
||||
// });
|
||||
// test(`should be able to create and delete new document from ${docId}`, async ({ page }) => {
|
||||
// test.skip();
|
||||
// const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
|
||||
// await span.waitFor();
|
||||
// await expect(span).toBeVisible();
|
||||
|
||||
await span.click();
|
||||
await page.waitForTimeout(5000); // wait for 5 seconds to ensure document is fully loaded. waitforTimeout is not recommended generally but here we are working around flakiness in the test env
|
||||
// await span.click();
|
||||
// await page.waitForTimeout(5000); // wait for 5 seconds to ensure document is fully loaded. waitforTimeout is not recommended generally but here we are working around flakiness in the test env
|
||||
|
||||
let newDocumentId;
|
||||
await retry(async () => {
|
||||
const newDocumentButton = await explorer.waitForCommandBarButton(CommandBarButton.NewDocument, 5000);
|
||||
await expect(newDocumentButton).toBeVisible();
|
||||
await expect(newDocumentButton).toBeEnabled();
|
||||
await newDocumentButton.click();
|
||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
// let newDocumentId;
|
||||
// await retry(async () => {
|
||||
// const newDocumentButton = await explorer.waitForCommandBarButton(CommandBarButton.NewDocument, 5000);
|
||||
// await expect(newDocumentButton).toBeVisible();
|
||||
// await expect(newDocumentButton).toBeEnabled();
|
||||
// await newDocumentButton.click();
|
||||
// await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
|
||||
newDocumentId = `${Date.now().toString()}-delete`;
|
||||
// newDocumentId = `${Date.now().toString()}-delete`;
|
||||
|
||||
const newDocument = {
|
||||
_id: newDocumentId,
|
||||
...setPartitionKeys(partitionKeys || []),
|
||||
};
|
||||
// const newDocument = {
|
||||
// _id: newDocumentId,
|
||||
// ...setPartitionKeys(partitionKeys || []),
|
||||
// };
|
||||
|
||||
await documentsTab.resultsEditor.setText(JSON.stringify(newDocument));
|
||||
const saveButton = await explorer.waitForCommandBarButton(CommandBarButton.Save, 5000);
|
||||
await saveButton.click({ timeout: 5000 });
|
||||
// await documentsTab.resultsEditor.setText(JSON.stringify(newDocument));
|
||||
// const saveButton = await explorer.waitForCommandBarButton(CommandBarButton.Save, 5000);
|
||||
// await saveButton.click({ timeout: 5000 });
|
||||
|
||||
await expect(saveButton).toBeHidden({ timeout: 5000 });
|
||||
}, 3);
|
||||
// await expect(saveButton).toBeHidden({ timeout: 5000 });
|
||||
// }, 3);
|
||||
|
||||
await documentsTab.setFilter(`{_id: "${newDocumentId}"}`);
|
||||
await documentsTab.filterButton.click();
|
||||
// await documentsTab.setFilter(`{_id: "${newDocumentId}"}`);
|
||||
// await documentsTab.filterButton.click();
|
||||
|
||||
const newSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
|
||||
await newSpan.waitFor();
|
||||
await newSpan.click();
|
||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
// const newSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
|
||||
// await newSpan.waitFor();
|
||||
// await newSpan.click();
|
||||
// await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||
|
||||
const deleteButton = await explorer.waitForCommandBarButton(CommandBarButton.Delete, 5000);
|
||||
await deleteButton.click();
|
||||
// const deleteButton = await explorer.waitForCommandBarButton(CommandBarButton.Delete, 5000);
|
||||
// await deleteButton.click();
|
||||
|
||||
const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000);
|
||||
await deleteDialogButton.click();
|
||||
// const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000);
|
||||
// await deleteDialogButton.click();
|
||||
|
||||
const deletedSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
|
||||
await expect(deletedSpan).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// const deletedSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
|
||||
// await expect(deletedSpan).toHaveCount(0);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
+104
-104
@@ -1,133 +1,133 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { setupCORSBypass } from "../CORSBypass";
|
||||
import { CommandBarButton, DataExplorer, Editor, QueryTab, TestAccount } from "../fx";
|
||||
import { serializeMongoToJson } from "../testData";
|
||||
// import { expect, test } from "@playwright/test";
|
||||
// import { setupCORSBypass } from "../CORSBypass";
|
||||
// import { CommandBarButton, DataExplorer, Editor, QueryTab, TestAccount } from "../fx";
|
||||
// import { serializeMongoToJson } from "../testData";
|
||||
|
||||
const databaseId = "test-e2etests-mongo-pagination";
|
||||
const collectionId = "test-coll-mongo-pagination";
|
||||
let explorer: DataExplorer = null!;
|
||||
// const databaseId = "test-e2etests-mongo-pagination";
|
||||
// const collectionId = "test-coll-mongo-pagination";
|
||||
// let explorer: DataExplorer = null!;
|
||||
|
||||
test.setTimeout(5 * 60 * 1000);
|
||||
// test.setTimeout(5 * 60 * 1000);
|
||||
|
||||
test.describe("Test Mongo Pagination", () => {
|
||||
let queryTab: QueryTab;
|
||||
let queryEditor: Editor;
|
||||
// test.describe("Test Mongo Pagination", () => {
|
||||
// let queryTab: QueryTab;
|
||||
// let queryEditor: Editor;
|
||||
|
||||
test.beforeEach("Open query tab", async ({ page }) => {
|
||||
await setupCORSBypass(page);
|
||||
explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
|
||||
// test.beforeEach("Open query tab", async ({ page }) => {
|
||||
// await setupCORSBypass(page);
|
||||
// explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
|
||||
|
||||
const containerNode = await explorer.waitForContainerNode(databaseId, collectionId);
|
||||
await containerNode.expand();
|
||||
// const containerNode = await explorer.waitForContainerNode(databaseId, collectionId);
|
||||
// await containerNode.expand();
|
||||
|
||||
const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, collectionId);
|
||||
await containerMenuNode.openContextMenu();
|
||||
await containerMenuNode.contextMenuItem("New Query").click();
|
||||
// const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, collectionId);
|
||||
// await containerMenuNode.openContextMenu();
|
||||
// await containerMenuNode.contextMenuItem("New Query").click();
|
||||
|
||||
queryTab = explorer.queryTab("tab0");
|
||||
queryEditor = queryTab.editor();
|
||||
await queryEditor.locator.waitFor({ timeout: 30 * 1000 });
|
||||
await queryTab.executeCTA.waitFor();
|
||||
await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click();
|
||||
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
||||
});
|
||||
// queryTab = explorer.queryTab("tab0");
|
||||
// queryEditor = queryTab.editor();
|
||||
// await queryEditor.locator.waitFor({ timeout: 30 * 1000 });
|
||||
// await queryTab.executeCTA.waitFor();
|
||||
// await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click();
|
||||
// await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
||||
// });
|
||||
|
||||
test("should execute a query and load more results", async ({ page }) => {
|
||||
test.skip();
|
||||
const query = "{}";
|
||||
// test("should execute a query and load more results", async ({ page }) => {
|
||||
// test.skip();
|
||||
// const query = "{}";
|
||||
|
||||
await queryEditor.locator.click();
|
||||
await queryEditor.setText(query);
|
||||
// await queryEditor.locator.click();
|
||||
// await queryEditor.setText(query);
|
||||
|
||||
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
|
||||
await executeQueryButton.click();
|
||||
// const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
|
||||
// await executeQueryButton.click();
|
||||
|
||||
// Wait for query execution to complete
|
||||
await expect(queryTab.resultsView).toBeVisible({ timeout: 60000 });
|
||||
await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 30000 });
|
||||
// // Wait for query execution to complete
|
||||
// await expect(queryTab.resultsView).toBeVisible({ timeout: 60000 });
|
||||
// await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 30000 });
|
||||
|
||||
// Get initial results
|
||||
const resultText = await queryTab.resultsEditor.text();
|
||||
// // Get initial results
|
||||
// const resultText = await queryTab.resultsEditor.text();
|
||||
|
||||
if (!resultText || resultText.trim() === "" || resultText.trim() === "[]") {
|
||||
throw new Error("Query returned no results - the collection appears to be empty");
|
||||
}
|
||||
// if (!resultText || resultText.trim() === "" || resultText.trim() === "[]") {
|
||||
// throw new Error("Query returned no results - the collection appears to be empty");
|
||||
// }
|
||||
|
||||
const resultData = serializeMongoToJson(resultText);
|
||||
// const resultData = serializeMongoToJson(resultText);
|
||||
|
||||
if (resultData.length === 0) {
|
||||
throw new Error("Parsed results contain 0 documents - collection is empty");
|
||||
}
|
||||
// if (resultData.length === 0) {
|
||||
// throw new Error("Parsed results contain 0 documents - collection is empty");
|
||||
// }
|
||||
|
||||
if (resultData.length < 100) {
|
||||
expect(resultData.length).toBeGreaterThan(0);
|
||||
return;
|
||||
}
|
||||
// if (resultData.length < 100) {
|
||||
// expect(resultData.length).toBeGreaterThan(0);
|
||||
// return;
|
||||
// }
|
||||
|
||||
expect(resultData.length).toBe(100);
|
||||
// expect(resultData.length).toBe(100);
|
||||
|
||||
// Pagination test
|
||||
let totalPagesLoaded = 1;
|
||||
const maxLoadMoreAttempts = 10;
|
||||
// // Pagination test
|
||||
// let totalPagesLoaded = 1;
|
||||
// const maxLoadMoreAttempts = 10;
|
||||
|
||||
for (let loadMoreAttempts = 0; loadMoreAttempts < maxLoadMoreAttempts; loadMoreAttempts++) {
|
||||
const loadMoreButton = queryTab.resultsView.getByText("Load more");
|
||||
// for (let loadMoreAttempts = 0; loadMoreAttempts < maxLoadMoreAttempts; loadMoreAttempts++) {
|
||||
// const loadMoreButton = queryTab.resultsView.getByText("Load more");
|
||||
|
||||
try {
|
||||
await expect(loadMoreButton).toBeVisible({ timeout: 5000 });
|
||||
} catch {
|
||||
// Load more button not visible - pagination complete
|
||||
break;
|
||||
}
|
||||
// try {
|
||||
// await expect(loadMoreButton).toBeVisible({ timeout: 5000 });
|
||||
// } catch {
|
||||
// // Load more button not visible - pagination complete
|
||||
// break;
|
||||
// }
|
||||
|
||||
const beforeClickText = await queryTab.resultsEditor.text();
|
||||
const beforeClickHash = Buffer.from(beforeClickText || "")
|
||||
.toString("base64")
|
||||
.substring(0, 50);
|
||||
// const beforeClickText = await queryTab.resultsEditor.text();
|
||||
// const beforeClickHash = Buffer.from(beforeClickText || "")
|
||||
// .toString("base64")
|
||||
// .substring(0, 50);
|
||||
|
||||
await loadMoreButton.click();
|
||||
// await loadMoreButton.click();
|
||||
|
||||
// Wait for content to update
|
||||
let editorContentChanged = false;
|
||||
for (let waitAttempt = 1; waitAttempt <= 3; waitAttempt++) {
|
||||
await page.waitForTimeout(2000);
|
||||
// // Wait for content to update
|
||||
// let editorContentChanged = false;
|
||||
// for (let waitAttempt = 1; waitAttempt <= 3; waitAttempt++) {
|
||||
// await page.waitForTimeout(2000);
|
||||
|
||||
const currentEditorText = await queryTab.resultsEditor.text();
|
||||
const currentHash = Buffer.from(currentEditorText || "")
|
||||
.toString("base64")
|
||||
.substring(0, 50);
|
||||
// const currentEditorText = await queryTab.resultsEditor.text();
|
||||
// const currentHash = Buffer.from(currentEditorText || "")
|
||||
// .toString("base64")
|
||||
// .substring(0, 50);
|
||||
|
||||
if (currentHash !== beforeClickHash) {
|
||||
editorContentChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if (currentHash !== beforeClickHash) {
|
||||
// editorContentChanged = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (editorContentChanged) {
|
||||
totalPagesLoaded++;
|
||||
} else {
|
||||
// No content change detected, stop pagination
|
||||
break;
|
||||
}
|
||||
// if (editorContentChanged) {
|
||||
// totalPagesLoaded++;
|
||||
// } else {
|
||||
// // No content change detected, stop pagination
|
||||
// break;
|
||||
// }
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
}
|
||||
// await page.waitForTimeout(1000);
|
||||
// }
|
||||
|
||||
// Final verification
|
||||
const finalIndicator = queryTab.resultsView.locator("text=/\\d+ - \\d+/");
|
||||
const finalIndicatorText = await finalIndicator.textContent();
|
||||
// // Final verification
|
||||
// const finalIndicator = queryTab.resultsView.locator("text=/\\d+ - \\d+/");
|
||||
// const finalIndicatorText = await finalIndicator.textContent();
|
||||
|
||||
if (finalIndicatorText) {
|
||||
const match = finalIndicatorText.match(/(\d+) - (\d+)/);
|
||||
if (match) {
|
||||
const totalDocuments = parseInt(match[2]);
|
||||
expect(totalDocuments).toBe(405);
|
||||
expect(totalPagesLoaded).toBe(5);
|
||||
} else {
|
||||
throw new Error(`Invalid results indicator format: ${finalIndicatorText}`);
|
||||
}
|
||||
} else {
|
||||
expect(totalPagesLoaded).toBe(5);
|
||||
}
|
||||
});
|
||||
});
|
||||
// if (finalIndicatorText) {
|
||||
// const match = finalIndicatorText.match(/(\d+) - (\d+)/);
|
||||
// if (match) {
|
||||
// const totalDocuments = parseInt(match[2]);
|
||||
// expect(totalDocuments).toBe(405);
|
||||
// expect(totalPagesLoaded).toBe(5);
|
||||
// } else {
|
||||
// throw new Error(`Invalid results indicator format: ${finalIndicatorText}`);
|
||||
// }
|
||||
// } else {
|
||||
// expect(totalPagesLoaded).toBe(5);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user