2024-06-05 20:46:32 +01:00
|
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
|
2024-08-15 21:29:57 +01:00
|
|
|
import { DataExplorer, TestAccount, generateUniqueName } from "../fx";
|
2024-06-05 20:46:32 +01:00
|
|
|
|
|
|
|
(
|
|
|
|
[
|
|
|
|
["latest API version", TestAccount.Mongo],
|
|
|
|
["3.2 API", TestAccount.Mongo32],
|
|
|
|
] as [string, TestAccount][]
|
|
|
|
).forEach(([apiVersionDescription, accountType]) => {
|
|
|
|
test(`Mongo CRUD using ${apiVersionDescription}`, async ({ page }) => {
|
2024-08-15 21:29:57 +01:00
|
|
|
const databaseId = generateUniqueName("db");
|
|
|
|
const collectionId = "testcollection"; // A unique collection name isn't needed because the database is unique
|
2024-06-05 20:46:32 +01:00
|
|
|
|
|
|
|
const explorer = await DataExplorer.open(page, accountType);
|
|
|
|
|
2024-08-01 18:02:36 +01:00
|
|
|
await explorer.globalCommandButton("New Collection").click();
|
2024-08-15 21:29:57 +01:00
|
|
|
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 okButton.click();
|
|
|
|
},
|
|
|
|
{ closeTimeout: 5 * 60 * 1000 },
|
|
|
|
);
|
|
|
|
|
|
|
|
const databaseNode = await explorer.waitForNode(databaseId);
|
|
|
|
const collectionNode = await explorer.waitForContainerNode(databaseId, collectionId);
|
2024-06-05 20:46:32 +01:00
|
|
|
|
|
|
|
await collectionNode.openContextMenu();
|
|
|
|
await collectionNode.contextMenuItem("Delete Collection").click();
|
2024-08-15 21:29:57 +01:00
|
|
|
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 },
|
|
|
|
);
|
2024-06-05 20:46:32 +01:00
|
|
|
await expect(collectionNode.element).not.toBeAttached();
|
|
|
|
|
|
|
|
await databaseNode.openContextMenu();
|
|
|
|
await databaseNode.contextMenuItem("Delete Database").click();
|
2024-08-15 21:29:57 +01:00
|
|
|
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 },
|
|
|
|
);
|
2024-06-05 20:46:32 +01:00
|
|
|
|
|
|
|
await expect(databaseNode.element).not.toBeAttached();
|
|
|
|
});
|
2021-04-20 04:08:25 +01:00
|
|
|
});
|