Skip to content

Commit

Permalink
Merge branch 'main' into qag-245-seperate-sources-for-cypress-and-pla…
Browse files Browse the repository at this point in the history
…ywright
  • Loading branch information
karola312 authored Jan 7, 2025
2 parents fa1ca2c + 6c723fe commit 867493e
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 114 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-toes-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Now CI workflows use updated action to upload and download artifacts
6 changes: 6 additions & 0 deletions .changeset/mean-chicken-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"saleor-dashboard": patch
---

Product data is now properly displayed in webhook dry run modal.
Add warning alert in webhook dry run modal for webhooks that don't have a valid object ids.
5 changes: 5 additions & 0 deletions .changeset/stupid-peas-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Split select link option into 2 different ones to avoid flakyness in tests
5 changes: 5 additions & 0 deletions .changeset/thin-drinks-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Add explicit waits for draft order shipping carrier button interaction
51 changes: 0 additions & 51 deletions .github/actions/combineReportsFromE2E/action.yml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/actions/merge-pw-reports/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ runs:
run: npm ci

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: all-blob-reports
path: all-blob-reports
pattern: all-blob-reports-*
merge-multiple: true

- name: Merge into HTML Report
shell: bash
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/run-pw-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ runs:
PROJECT_PARAMS+="--project=${PROJECT} "
done
npx playwright test --grep @e2e $PROJECT_PARAMS --shard "$SHARD_NUMBER"
echo "reportName=all-blob-reports-${SHARD_NUMBER%%/*}" >> $GITHUB_ENV
- name: Upload blob report to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: all-blob-reports
name: ${{ env.reportName }}
path: blob-report
retention-days: 1
37 changes: 27 additions & 10 deletions playwright/pages/dialogs/addNavigationMenuItemDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,37 @@ export class AddNavigationMenuItemDialog extends BasePage {
super(page);
}

async selectLinkOption(option: string, optionName: string) {
async selectLinkTypeOption(linkType: string) {
await this.menuLinkType.click();
await this.waitForDOMToFullyLoad();
await this.menuLinkOptions.filter({ hasText: "Categories" }).waitFor({ state: "visible" });
await this.menuLinkOptions.filter({ hasText: "Collections" }).waitFor({ state: "visible" });
await this.menuLinkOptions.filter({ hasText: "Pages" }).waitFor({ state: "visible" });
await expect(this.menuLinkOptions.filter({ hasText: option })).toBeEnabled();
await this.menuLinkOptions.filter({ hasText: option }).click({ force: true });
await this.waitForDOMToFullyLoad();

// Ensure the link type option is visible and select it
const linkTypeOption = this.menuLinkOptions.filter({ hasText: linkType });

await linkTypeOption.waitFor({ state: "visible" });
await expect(linkTypeOption).toBeEnabled();
await linkTypeOption.click({ force: true });

// Verify the correct link type is selected
const selectedLinkType = await this.menuLinkType.inputValue();

if (selectedLinkType !== linkType) {
throw new Error(`Expected link type "${linkType}" but found "${selectedLinkType}"`);
}
}

async selectLinkTypeValue(optionName: string) {
await this.menuLinkValue.click();
await this.menuLinkOptions.filter({ hasText: optionName }).waitFor({ state: "visible" });
await expect(this.menuLinkOptions.filter({ hasText: optionName })).toBeEnabled();
await this.menuLinkOptions.filter({ hasText: optionName }).click({ force: true });
await this.waitForDOMToFullyLoad();

// Ensure the option is present and select it
const option = this.menuLinkOptions.filter({ hasText: optionName });

await option.waitFor({ state: "visible" });
await expect(option).toBeEnabled();
await option.click({ force: true });

// Verify the correct option is selected
await expect(this.menuLinkValue).toHaveValue(optionName);
}

Expand Down
2 changes: 2 additions & 0 deletions playwright/pages/draftOrdersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export class DraftOrdersPage extends BasePage {
}

async clickAddShippingCarrierButton() {
await this.addShippingCarrierLink.scrollIntoViewIfNeeded();
await this.addShippingCarrierLink.click();

await this.waitForDOMToFullyLoad();
}

Expand Down
9 changes: 6 additions & 3 deletions playwright/tests/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ test("TC: SALEOR_194 Should create a new menu navigation with menu item @navigat
const menuItemName = faker.random.word();

await addNavigationMenuItemDialog.typeMenuItemName(menuItemName);
await addNavigationMenuItemDialog.selectLinkOption("Categories", "Polo Shirts");
await addNavigationMenuItemDialog.selectLinkTypeOption("Categories");
await addNavigationMenuItemDialog.selectLinkTypeValue("Polo Shirts");
await addNavigationMenuItemDialog.clickSaveButton();
await expect(navigationDetailsPage.addMenuItemDialog).not.toBeVisible();
await navigation.expectSuccessBanner();
Expand All @@ -59,7 +60,8 @@ test("TC: SALEOR_198 Should update existing menu @navigation @e2e", async () =>

await navigationDetailsPage.clickEditMenuItemButton(menuItemToBeUpdated.name);
await addNavigationMenuItemDialog.typeMenuItemName(newItemName);
await addNavigationMenuItemDialog.selectLinkOption("Categories", "Polo Shirts");
await addNavigationMenuItemDialog.selectLinkTypeOption("Categories");
await addNavigationMenuItemDialog.selectLinkTypeValue("Polo Shirts");
await addNavigationMenuItemDialog.clickSaveButton();
await expect(navigationDetailsPage.addMenuItemDialog).not.toBeVisible();
await navigationDetailsPage.clickDeleteMenuItemButton(menuItemToBeDeleted.name);
Expand All @@ -69,7 +71,8 @@ test("TC: SALEOR_198 Should update existing menu @navigation @e2e", async () =>
const menuItemName = faker.random.word();

await addNavigationMenuItemDialog.typeMenuItemName(menuItemName);
await addNavigationMenuItemDialog.selectLinkOption("Categories", "Polo Shirts");
await addNavigationMenuItemDialog.selectLinkTypeOption("Categories");
await addNavigationMenuItemDialog.selectLinkTypeValue("Polo Shirts");
await addNavigationMenuItemDialog.clickSaveButton();
await expect(navigationDetailsPage.menuItemList).toContainText(menuItemName);
await navigationDetailsPage.clickDeleteMenuItemButton(menuItemName);
Expand Down
8 changes: 7 additions & 1 deletion playwright/tests/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,15 @@ test("TC: SALEOR_84 Create draft order @e2e @draft", async () => {
await draftOrdersPage.expectSuccessBanner();
await draftOrdersPage.addressDialog.clickConfirmButton();
await draftOrdersPage.expectSuccessBanner();

await draftOrdersPage.addShippingCarrierLink.waitFor({ state: "visible" });
// Ensure the button is in viewport before clicking
await draftOrdersPage.addShippingCarrierLink.scrollIntoViewIfNeeded();

await expect(draftOrdersPage.addShippingCarrierLink).toBeVisible();
await draftOrdersPage.clickAddShippingCarrierButton();

await draftOrdersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod();
//await draftOrdersPage.expectSuccessBanner();
await draftOrdersPage.clickFinalizeButton();
await draftOrdersPage.expectSuccessBanner({ message: "finalized" });
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/DryRun/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getWebhookTypes } from "@dashboard/custom-apps/components/WebhookEvents
import { WebhookEventTypeAsyncEnum } from "@dashboard/graphql";
import { InlineFragmentNode, ObjectFieldNode, parse, visit } from "graphql";

import { DocumentMap, ExcludedDocumentMap } from "../DryRunItemsList/utils";
import { DocumentMap, ExcludedDocumentKeys } from "../DryRunItemsList/utils";

const getEventsFromQuery = (query: string) => {
if (query.length === 0) {
Expand Down Expand Up @@ -56,7 +56,7 @@ const checkEventPresence = (event: string) => {
object => !availableObjects.includes(object),
);

Object.keys(ExcludedDocumentMap).forEach(
ExcludedDocumentKeys.forEach(
object => !excludedObjects.includes(object) && excludedObjects.push(object),
);

Expand Down
69 changes: 27 additions & 42 deletions src/components/DryRunItemsList/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import {
AttributeListQueryVariables,
CategoryDetailsQuery,
CategoryDetailsQueryVariables,
ChannelListDocument,
CheckoutListDocument,
CheckoutListQuery,
CheckoutListQueryVariables,
CollectionListDocument,
CollectionListQuery,
CollectionListQueryVariables,
CustomerAddressesDocument,
CustomerAddressesQuery,
CustomerAddressesQueryVariables,
CustomerDetailsQuery,
Expand All @@ -29,7 +27,6 @@ import {
MenuListDocument,
MenuListQuery,
MenuListQueryVariables,
OrderFulfillDataDocument,
OrderFulfillDataQuery,
OrderFulfillDataQueryVariables,
OrderListDocument,
Expand All @@ -41,7 +38,6 @@ import {
ProductListDocument,
ProductListQuery,
ProductListQueryVariables,
ProductVariantListDocument,
ProductVariantListQuery,
ProductVariantListQueryVariables,
RootCategoriesDocument,
Expand Down Expand Up @@ -162,13 +158,6 @@ export const DocumentMap: Record<string, Document> = {
displayedAttribute: "email",
// TODO inverted name
},

INVOICE: {
document: OrderListDocument,
variables: DefaultVariables,
collection: "orders",
displayedAttribute: "number",
},
MENU: {
document: MenuListDocument,
variables: DefaultVariables,
Expand All @@ -189,6 +178,8 @@ export const DocumentMap: Record<string, Document> = {
variables: {
first: 100,
hasChannel: true,
includeCategories: false,
includeCollections: false,
},
displayedAttribute: "name",
},
Expand Down Expand Up @@ -228,35 +219,29 @@ export const DocumentMap: Record<string, Document> = {

// Documents which require parent object or can't be handled ATM
//
export const ExcludedDocumentMap: Record<string, Document> = {
ADDRESS: {
document: CustomerAddressesDocument,
variables: {
// USER ID REQUIRED
first: 100,
},
},
export const ExcludedDocumentKeys = [
// USER ID REQUIRED
"ADDRESS",
// it's not a countable collection
CHANNEL: {
document: ChannelListDocument,
variables: {},
},
FULFILLMENT: {
document: OrderFulfillDataDocument,
variables: {
// ORDER ID REQUIRED
first: 100,
},
},
PRODUCT_VARIANT: {
document: ProductVariantListDocument,
variables: {
// PRODUCT ID REQUIRED
first: 100,
},
},
TRANSLATION: {
document: null,
variables: {},
},
};
"CHANNEL",
// ORDER ID REQUIRED
"FULFILLMENT",
// PRODUCT ID REQUIRED
"PRODUCT_VARIANT",
"PRODUCT_EXPORT_COMPLETED",
"PRODUCT_MEDIA_CREATED",
"PRODUCT_MEDIA_DELETED",
"PRODUCT_MEDIA_UPDATED",
"PRODUCT_VARIANT_BACK_IN_STOCK",
"PRODUCT_VARIANT_CREATED",
"PRODUCT_VARIANT_DELETED",
"PRODUCT_VARIANT_METADATA_UPDATED",
"PRODUCT_VARIANT_OUT_OF_STOCK",
"PRODUCT_VARIANT_STOCK_UPDATED",
"PRODUCT_VARIANT_UPDATED",
"VOUCHER_CODES_CREATED",
"VOUCHER_CODES_DELETED",
"VOUCHER_CODE_EXPORT_COMPLETED",
"ORDER_BULK_CREATED",
"TRANSLATION",
];

0 comments on commit 867493e

Please sign in to comment.