Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List available currency, OS/Software, and region #292

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions parser/e2e/__snapshots__/metadata.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`List metadata: Currency 1`] = `
[
"usd (United States – Dollar ($) USD)",
"aud (Australia – Dollar ($) AUD)",
"brl (Brazil – Real (R$) BRL)",
"cad (Canada – Dollar ($) CAD)",
"dkk (Denmark – Krone (kr) DKK)",
"eur (Euro Zone – Euro (€) EUR)",
"inr (India – Rupee (₹) INR)",
"jpy (Japan – Yen (¥) JPY)",
"krw (Korea – Won (₩) KRW)",
"nzd (New Zealand – Dollar ($) NZD)",
"nok (Norway – Krone (kr) NOK)",
"rub (Russia – Ruble (руб) RUB)",
"sek (Sweden – Krona (kr) SEK)",
"chf (Switzerland – Franc (chf) CHF)",
"twd (Taiwan – Dollar (NT$) TWD)",
"gbp (United Kingdom – Pound (£) GBP)",
]
`;

exports[`List metadata: OS/Software 1`] = `
[
"linux (Ubuntu)",
"red-hat (Red Hat Enterprise Linux)",
"rhel-ha (Red Hat Enterprise Linux with HA)",
"rhel-sap-ha (RHEL for SAP with HA)",
"rhel-sap-business (RHEL for SAP Business Applications)",
"sles-basic (SUSE Linux Enterprise + Patching only)",
"sles-standard (SUSE Linux Enterprise + 24x7 Support)",
"sles-hpc-standard (SUSE Linux Enterprise for HPC + 24x7 Support)",
"sles-sap (SUSE Linux Enterprise for SAP Applications + 24x7 Support)",
"ubuntu-pro (Ubuntu Pro)",
"ubuntu-advantage-essential (Ubuntu Advantage Essential (Support))",
"ubuntu-advantage-standard (Ubuntu Advantage Standard (Support))",
"ubuntu-advantage-advanced (Ubuntu Advantage Advanced (Support))",
"ml-server-rhel (Machine Learning Server on Red Hat Enterprise Linux)",
"ml-server-ubuntu (Machine Learning Server on Ubuntu or Centos Linux)",
"sql-server-enterprise-linux (SQL Server Enterprise Ubuntu Linux)",
"sql-server-standard-linux (SQL Server Standard Ubuntu Linux)",
"sql-server-web-linux (SQL Server Web Ubuntu Linux)",
"sql-server-enterprise-redhat (SQL Server Enterprise Red Hat Enterprise Linux)",
"sql-server-standard-redhat (SQL Server Standard Red Hat Enterprise Linux)",
"sql-server-web-redhat (SQL Server Web Red Hat Enterprise Linux)",
"sql-server-enterprise-sles (SQL Server Enterprise SUSE Priority)",
"sql-server-standard-sles (SQL Server Standard SUSE Priority)",
"sql-server-web-sles (SQL Server Web SUSE Priority)",
"windows (Windows OS)",
"biztalk-enterprise (BizTalk Enterprise)",
"biztalk-standard (BizTalk Standard)",
"ml-server-windows (Machine Learning Server)",
"sharepoint (SharePoint)",
"sql-server-enterprise (SQL Server Enterprise)",
"sql-server-standard (SQL Server Standard)",
"sql-server-web (SQL Server Web)",
]
`;

exports[`List metadata: Region 1`] = `
[
"us-central (Central US)",
"us-east (East US)",
"us-east-2 (East US 2)",
"us-north-central (North Central US)",
"us-south-central (South Central US)",
"us-west-central (West Central US)",
"us-west (West US)",
"us-west-2 (West US 2)",
"us-west-3 (West US 3)",
"united-kingdom-south (UK South)",
"united-kingdom-west (UK West)",
"uae-central (UAE Central)",
"uae-north (UAE North)",
"switzerland-north (Switzerland North)",
"switzerland-west (Switzerland West)",
"sweden-central (Sweden Central)",
"sweden-south (Sweden South)",
"spain-central (Spain Central)",
"qatar-central (Qatar Central)",
"poland-central (Poland Central)",
"norway-east (Norway East)",
"norway-west (Norway West)",
"mexico-central (Mexico Central)",
"korea-central (Korea Central)",
"korea-south (Korea South)",
"japan-east (Japan East)",
"japan-west (Japan West)",
"italy-north (Italy North)",
"israel-central (Israel Central)",
"central-india (Central India)",
"south-india (South India)",
"west-india (West India)",
"germany-north (Germany North)",
"germany-west-central (Germany West Central)",
"france-central (France Central)",
"france-south (France South)",
"europe-north (North Europe)",
"europe-west (West Europe)",
"canada-central (Canada Central)",
"canada-east (Canada East)",
"brazil-south (Brazil South)",
"brazil-southeast (Brazil Southeast)",
"usgov-arizona (US Gov Arizona)",
"usgov-texas (US Gov Texas)",
"usgov-virginia (US Gov Virginia)",
"australia-central (Australia Central)",
"australia-central-2 (Australia Central 2)",
"australia-east (Australia East)",
"australia-southeast (Australia Southeast)",
"asia-pacific-east (East Asia)",
"asia-pacific-southeast (Southeast Asia)",
"south-africa-north (South Africa North)",
"south-africa-west (South Africa West)",
]
`;
26 changes: 26 additions & 0 deletions parser/e2e/listSelectOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import puppeteer from "puppeteer";

export default async function listSelectOptions(selectName: string): Promise<string[]> {
const browser = await puppeteer.launch({headless: true});
try
{
const page = await browser.newPage();
await page.goto(`https://azure.microsoft.com/en-us/pricing/details/virtual-machines/windows/`);

await page.waitForFunction(
async () => {
const applicableVmsAnnouncemnt = <HTMLSpanElement> document.querySelector('#pricing-announcement');
return applicableVmsAnnouncemnt !== null;
}
);

const selector = `select[name=${selectName}]`;
return await page.$eval(selector, select => Array.from((<HTMLSelectElement> select).options).map(c => `${c.value} (${c.text})`));
}
finally
{
if (browser) {
await browser.close();
}
}
}
18 changes: 18 additions & 0 deletions parser/e2e/metadata.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import listSelectOptions from "./listSelectOptions";

describe('List metadata:', () => {
test('Currency', async () => {
const currencies = await listSelectOptions('currency');
expect(currencies).toMatchSnapshot();
});

test('OS/Software', async () => {
const currencies = await listSelectOptions('softwareOSType');
expect(currencies).toMatchSnapshot();
});

test('Region', async () => {
const currencies = await listSelectOptions('region');
expect(currencies).toMatchSnapshot();
});
});