Skip to content

Commit

Permalink
(chocolatey#410) Update paths for Playwright Imports
Browse files Browse the repository at this point in the history
This updates the paths to imports done in
Playwright tests to reflect the correct location.
  • Loading branch information
st3phhays committed Jun 17, 2024
1 parent 368fc0f commit 295222d
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 40 deletions.
23 changes: 23 additions & 0 deletions build/choco-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const init = async () => {

// Playwright
if (repository.playwright) {
// General
parallelTasksInitial.push(
{
task: 'Playwright tests - general',
Expand All @@ -155,6 +156,7 @@ const init = async () => {
}
);

// Pricing Calculator
if (repository.name === repositoryConfig.org.name) {
parallelTasksInitial.push(
{
Expand Down Expand Up @@ -235,6 +237,27 @@ const init = async () => {
await Promise.all(parallelTasksInitial.map(({ task, source, destination, isFolder }) => {
return copyTheme({ task, source, destination, isFolder });
}));

// Playwright - Pricing Calculator types
// This must be done at the end to ensure the files are copied
if (repository.playwright) {
copyTheme({
task: 'Playwright base config',
source: `${repositoryConfig.theme.root}/build/data/playwright-config.ts`,
destination: `${repository.playwright}/playwright-config.ts`,
isFolder: false
});

if (repository.name === repositoryConfig.org.name) {
copyTheme({
task: 'Playwright tests - pricing calculator types',
source: `${repositoryConfig.theme.root}/js/src/ts/util/pricing-calculator.ts`,
destination: `${repository.playwright}/pricing-calculator/pricing-calculator.ts`,
isFolder: false
});
}
}

console.log('✅ Copying of choco-theme complete');

// If blog repository, update Program.cs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { c4bAddOnPrice } from 'choco-theme/js/src/ts/util/pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { c4bAddOnPrice } from './pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { addOnContainer, packageCounts, packagingSelect } from './util';

test('test-add-on-packaging', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { c4bSupportNodes, c4bAddOnPrice } from 'choco-theme/js/src/ts/util/pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { c4bSupportNodes, c4bAddOnPrice } from './pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { addOnContainer, communitySupportCheckboxBtn, numberInput, standardSupportCheckboxBtn } from './util';

test('test-add-on-standard-support', async ({ page }) => {
Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/pricing-calculator/included-items.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { c4bIncludedItems } from 'choco-theme/js/src/ts/util/pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { c4bIncludedItems } from './pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { addOnContainer, numberInput, premiumSupportCheckboxBtn } from './util';

test('test-included-items', async ({ page }) => {
Expand Down
64 changes: 39 additions & 25 deletions playwright/tests/pricing-calculator/modals.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
import { test, expect } from '@playwright/test';
import { test, expect, Page } from '@playwright/test';

test('test-modals', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto('./');
});

const testModal = async (page: Page, locator: string, showContactLink: boolean) => {
await page.click(`[data-bs-target="${locator}"]`);

await page.locator('body.modal-open').waitFor();

await expect(page.locator(locator)).toBeVisible();

if (showContactLink) {
await expect(page.locator(`${locator} .modal-footer a`)).toContainText('Contact Us');
}

await page.locator(`${locator} .modal-footer button[data-bs-dismiss="modal"]`).click();

await page.locator(locator).waitFor({ state: 'hidden' });

await expect(page.locator(locator)).toBeHidden();
};

test('test-modals - #c4bModalPerpetualPricing', async ({ page }) => {
await testModal(page, '#c4bModalPerpetualPricing', true);
});

test('test-modals - #c4bModalNonProfitPricing', async ({ page }) => {
await testModal(page, '#c4bModalNonProfitPricing', true);
});

test('test-modals - #c4bModalPackaging', async ({ page }) => {
await testModal(page, '#c4bModalPackaging', false);
});

test('test-modals - #c4bModalResponseTimes', async ({ page }) => {
await testModal(page, '#c4bModalResponseTimes', false);
});

const perpetualModal = '#c4bModalPerpetualPricing';
const nonProfitModal = '#c4bModalNonProfitPricing';
const packagingModal = '#c4bModalPackaging';
const responseTimesModal = '#c4bModalResponseTimes';
const supportTypeModal = '#c4bModalSupportType';

const testModal = async (locator: string, showContactLink: boolean) => {
await page.click(`[data-bs-target="${locator}"]`);
await expect(page.locator(locator)).toBeVisible();

if (showContactLink) {
await expect(page.locator(`${locator} .modal-footer a`)).toContainText('Contact Us');
}

await page.locator(`${locator} .modal-footer button[data-bs-dismiss="modal"]`).click();
await expect(page.locator(locator)).toBeHidden();
};

await testModal(perpetualModal, true);
await testModal(nonProfitModal, true);
await testModal(packagingModal, false);
await testModal(responseTimesModal, false);
await testModal(supportTypeModal, false);
test('test-modals - #c4bModalSupportType', async ({ page }) => {
await testModal(page, '#c4bModalSupportType', false);
});
2 changes: 1 addition & 1 deletion playwright/tests/pricing-calculator/price.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { c4bStandardSubscription, c4bPremiumSubscription, c4bAddOnPrice, C4bSubscription } from 'choco-theme/js/src/ts/util/pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { c4bStandardSubscription, c4bPremiumSubscription, c4bAddOnPrice, C4bSubscription } from './pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { numberInput, packageCounts, packagingSelect, premiumSupportCheckboxBtn, standardSupportCheckboxBtn } from './util';

test('test-price', async ({ page }) => {
Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/pricing-calculator/support-types.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { c4bSupportNodes } from 'choco-theme/js/src/ts/util/pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { c4bSupportNodes } from './pricing-calculator'; // This is ignored since this is the correct location after it is imported into the repository by gulp
import { numberInput } from './util';

test('test-support-types', async ({ page }) => {
Expand Down
10 changes: 0 additions & 10 deletions playwright/tsconfig.json

This file was deleted.

0 comments on commit 295222d

Please sign in to comment.