mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-18 16:31:31 +00:00
Fix E2E tests. Add Playwright (#698)
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
const { AxePuppeteer } = require("axe-puppeteer");
|
||||
const puppeteer = require("puppeteer");
|
||||
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch({ ignoreHTTPSErrors: true });
|
||||
const page = await browser.newPage();
|
||||
await page.setBypassCSP(true);
|
||||
await page.goto("https://localhost:1234/hostedExplorer.html");
|
||||
|
||||
const results = await new AxePuppeteer(page).withTags(["wcag2a", "wcag2aa"]).analyze();
|
||||
if (results.violations && results.violations.length && results.violations.length > 0) {
|
||||
throw results.violations;
|
||||
}
|
||||
|
||||
await page.close();
|
||||
await browser.close();
|
||||
console.log(`Accessibility Check Passed!`);
|
||||
})().catch(err => {
|
||||
console.error(`Accessibility Check Failed: ${err.length} Errors`);
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -18,7 +18,6 @@ function friendlyTime(date) {
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes all SQL and Mongo databases created more than 20 minutes ago in the test runner accounts
|
||||
async function main() {
|
||||
const credentials = await msRestNodeAuth.loginWithServicePrincipalSecret(clientId, secret, tenantId);
|
||||
const client = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
@@ -27,6 +26,7 @@ async function main() {
|
||||
if (account.kind === "MongoDB") {
|
||||
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
||||
for (const database of mongoDatabases) {
|
||||
// Unfortunately Mongo does not provide a timestamp in ARM. There is no way to tell how old the DB is other thn encoding it in the ID :(
|
||||
const timestamp = Number(database.name.split("-")[1]);
|
||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
||||
await client.mongoDBResources.deleteMongoDBDatabase(resourceGroupName, account.name, database.name);
|
||||
@@ -35,10 +35,46 @@ async function main() {
|
||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
}
|
||||
}
|
||||
} else if (account.capabilities.find((c) => c.name === "EnableCassandra")) {
|
||||
const cassandraDatabases = await client.cassandraResources.listCassandraKeyspaces(
|
||||
resourceGroupName,
|
||||
account.name
|
||||
);
|
||||
for (const database of cassandraDatabases) {
|
||||
const timestamp = Number(database.resource._ts) * 1000;
|
||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
||||
await client.cassandraResources.deleteCassandraKeyspace(resourceGroupName, account.name, database.name);
|
||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
} else {
|
||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
}
|
||||
}
|
||||
} else if (account.capabilities.find((c) => c.name === "EnableTable")) {
|
||||
const tablesDatabase = await client.tableResources.listTables(resourceGroupName, account.name);
|
||||
for (const database of tablesDatabase) {
|
||||
const timestamp = Number(database.resource._ts) * 1000;
|
||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
||||
await client.tableResources.deleteTable(resourceGroupName, account.name, database.name);
|
||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
} else {
|
||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
}
|
||||
}
|
||||
} else if (account.capabilities.find((c) => c.name === "EnableGremlin")) {
|
||||
const graphDatabases = await client.gremlinResources.listGremlinDatabases(resourceGroupName, account.name);
|
||||
for (const database of graphDatabases) {
|
||||
const timestamp = Number(database.resource._ts) * 1000;
|
||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
||||
await client.gremlinResources.deleteGremlinDatabase(resourceGroupName, account.name, database.name);
|
||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
} else {
|
||||
console.log(`SKIPPED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
}
|
||||
}
|
||||
} else if (account.kind === "GlobalDocumentDB") {
|
||||
const sqlDatabases = await client.sqlResources.listSqlDatabases(resourceGroupName, account.name);
|
||||
for (const database of sqlDatabases) {
|
||||
const timestamp = Number(database.name.split("-")[1]);
|
||||
const timestamp = Number(database.resource._ts) * 1000;
|
||||
if (timestamp && timestamp < thirtyMinutesAgo) {
|
||||
await client.sqlResources.deleteSqlDatabase(resourceGroupName, account.name, database.name);
|
||||
console.log(`DELETED: ${account.name} | ${database.name} | Age: ${friendlyTime(Date.now() - timestamp)}`);
|
||||
|
||||
Reference in New Issue
Block a user