diff --git a/parser/e2e/__snapshots__/metadata.test.ts.snap b/parser/e2e/__snapshots__/metadata.test.ts.snap new file mode 100644 index 0000000..caeba57 --- /dev/null +++ b/parser/e2e/__snapshots__/metadata.test.ts.snap @@ -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)", +] +`; diff --git a/parser/e2e/listSelectOptions.ts b/parser/e2e/listSelectOptions.ts new file mode 100644 index 0000000..ed4de23 --- /dev/null +++ b/parser/e2e/listSelectOptions.ts @@ -0,0 +1,26 @@ +import puppeteer from "puppeteer"; + +export default async function listSelectOptions(selectName: string): Promise { + 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 = document.querySelector('#pricing-announcement'); + return applicableVmsAnnouncemnt !== null; + } + ); + + const selector = `select[name=${selectName}]`; + return await page.$eval(selector, select => Array.from(( select).options).map(c => `${c.value} (${c.text})`)); + } + finally + { + if (browser) { + await browser.close(); + } + } +} diff --git a/parser/e2e/metadata.test.ts b/parser/e2e/metadata.test.ts new file mode 100644 index 0000000..7589fbb --- /dev/null +++ b/parser/e2e/metadata.test.ts @@ -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(); + }); +});