Pk missing fix (#2094)

* fix partition key missing not being able to load the document

* Implement E2E tests for documents with different partitionkeys

* Implement E2E tests for documents with different partitionkeys

* Implement E2E tests for documents with different partitionkeys

* Updated snapshot
This commit is contained in:
sunghyunkang1111
2025-04-07 10:45:29 -05:00
committed by GitHub
parent e3c3a8b1b7
commit af0a890516
8 changed files with 259 additions and 21 deletions

45
test/sql/document.spec.ts Normal file
View File

@@ -0,0 +1,45 @@
import { expect, test } from "@playwright/test";
import { DataExplorer, DocumentsTab, TestAccount } from "../fx";
import { documentTestCases } from "./testCases";
let explorer: DataExplorer = null!;
let documentsTab: DocumentsTab = null!;
for (const { name, databaseId, containerId, expectedDocumentIds } of documentTestCases) {
test.describe(`Test Documents with ${name}`, () => {
test.beforeEach("Open documents tab", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQLReadOnly);
const containerNode = await explorer.waitForContainerNode(databaseId, containerId);
await containerNode.expand();
const containerMenuNode = await explorer.waitForContainerItemsNode(databaseId, containerId);
await containerMenuNode.element.click();
documentsTab = explorer.documentsTab("tab0");
await documentsTab.documentsFilter.waitFor();
await documentsTab.documentsListPane.waitFor();
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
});
for (const docId of expectedDocumentIds) {
test.describe(`Document ID: ${docId}`, () => {
test(`should load and view document ${docId}`, async () => {
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 });
const resultText = await documentsTab.resultsEditor.text();
const resultData = JSON.parse(resultText!);
expect(resultText).not.toBeNull();
expect(resultData?.id).toEqual(docId);
});
});
}
});
}

88
test/sql/testCases.ts Normal file
View File

@@ -0,0 +1,88 @@
type ContainerTestCase = {
name: string;
databaseId: string;
containerId: string;
expectedDocumentIds: string[];
};
export const documentTestCases: ContainerTestCase[] = [
{
name: "System Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "systemPartitionKey",
expectedDocumentIds: ["systempartition"],
},
{
name: "Single Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "singlePartitionKey",
expectedDocumentIds: [
"singlePartitionKey",
"singlePartitionKey_empty_string",
"singlePartitionKey_null",
"singlePartitionKey_missing",
],
},
{
name: "Single Nested Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "singleNestedPartitionKey",
expectedDocumentIds: [
"singlePartitionKey_nested",
"singlePartitionKey_nested_empty_string",
"singlePartitionKey_nested_null",
"singlePartitionKey_nested_missing",
],
},
{
name: "2-Level Hierarchical Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "twoLevelPartitionKey",
expectedDocumentIds: [
"twoLevelPartitionKey_value_empty",
"twoLevelPartitionKey_value_null",
"twoLevelPartitionKey_value_missing",
"twoLevelPartitionKey_empty_null",
"twoLevelPartitionKey_null_missing",
"twoLevelPartitionKey_missing_value",
],
},
{
name: "2-Level Hierarchical Nested Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "twoLevelNestedPartitionKey",
expectedDocumentIds: [
"twoLevelNestedPartitionKey_nested_value_empty",
"twoLevelNestedPartitionKey_nested_null_missing",
"twoLevelNestedPartitionKey_nested_missing_value",
],
},
{
name: "3-Level Hierarchical Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "threeLevelPartitionKey",
expectedDocumentIds: [
"threeLevelPartitionKey_value_empty_null",
"threeLevelPartitionKey_value_null_missing",
"threeLevelPartitionKey_value_missing_null",
"threeLevelPartitionKey_null_empty_value",
"threeLevelPartitionKey_missing_value_value",
"threeLevelPartitionKey_empty_value_missing",
],
},
{
name: "3-Level Nested Hierarchical Partition Key",
databaseId: "e2etests-sql-readonly",
containerId: "threeLevelNestedPartitionKey",
expectedDocumentIds: [
"threeLevelNestedPartitionKey_nested_empty_value_null",
"threeLevelNestedPartitionKey_nested_null_value_missing",
"threeLevelNestedPartitionKey_nested_missing_value_null",
"threeLevelNestedPartitionKey_nested_null_empty_missing",
"threeLevelNestedPartitionKey_nested_value_missing_empty",
"threeLevelNestedPartitionKey_nested_missing_null_empty",
"threeLevelNestedPartitionKey_nested_empty_null_value",
"threeLevelNestedPartitionKey_nested_value_null_empty",
],
},
];