Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/canary'
Browse files Browse the repository at this point in the history
  • Loading branch information
typeofweb committed Nov 14, 2023
2 parents a059bb1 + 9a863a5 commit 50e9725
Show file tree
Hide file tree
Showing 68 changed files with 1,220 additions and 780 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: Build, TypeScripts, tests
on:
push:
branches: [canary]
pull_request:
branches: [canary]
on: deployment_status

concurrency:
group: tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build_and_test:
if: ${{ github.event.deployment_status.state == 'success' }}

runs-on: ubuntu-latest
env:
NEXT_PUBLIC_SALEOR_API_URL: https://storefront1.saleor.cloud/graphql/
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/update_types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Check Saleor release and update types

on:
workflow_dispatch:
schedule:
- cron: "0 18 * * 1-5" # workdays at 18:00

jobs:
check_saleor_release:
name: Check Saleor release and update types
runs-on: ubuntu-latest
steps:
- name: Get latest release info
id: release
run: |
echo "Fetching latest release info..."
latest_release=$(curl -s https://api.github.com/repos/saleor/saleor/releases/latest)
echo "tag=$(echo $latest_release | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
echo "schema_url=$(echo $latest_release | jq -r '.assets[] | select(.name == "schema.graphql") | .url')" >> "$GITHUB_OUTPUT"
echo "has_schema=$(echo $latest_release | jq -e '.assets[] | select(.name == "schema.graphql") | length > 0')" >> "$GITHUB_OUTPUT"
- name: Download schema.graphql
run: |
if [[ "${{ steps.release.outputs.has_schema }}" == "true" ]]; then
echo "schema.graphql is attached to the ${{ steps.release.outputs.tag }} release, updating..."
curl --output schema.graphql \
--url ${{ steps.release.outputs.schema_url }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header "Accept: application/octet-stream" \
--location
else
echo "schema.graphql is not attached to the ${{ steps.release.outputs.tag }} release, exiting..."
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4

- name: Get PNPM version from package.json
id: pnpm-version
run: echo "pnpm_version=$(cat package.json | jq '.engines.pnpm' | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT

- name: Install PNPM
uses: pnpm/action-setup@v2
with:
version: ${{ steps.pnpm-version.outputs.pnpm_version }}

- uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: "pnpm"

- name: Install dependencies
run: pnpm --version && pnpm install --frozen-lockfile

- name: Run `pnpm generate`
id: generate-schema-from-file
run: pnpm generate

- name: Remove schema
run: rm -f schema.graphql

- name: Show changed files
run: git status

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
branch: update-schema
commit-message: "Update schema to Saleor ${{ steps.release.outputs.tag }}"
title: "Update schema to Saleor ${{ steps.release.outputs.tag }}"
body: |
Pull request auto-generated by bot
labels: |
:robot: bot
6 changes: 5 additions & 1 deletion .graphqlrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import type { CodegenConfig } from "@graphql-codegen/cli";

loadEnvConfig(process.cwd());

const schemaUrl = process.env.NEXT_PUBLIC_SALEOR_API_URL;
let schemaUrl = process.env.NEXT_PUBLIC_SALEOR_API_URL;

if (process.env.GITHUB_ACTION === "generate-schema-from-file") {
schemaUrl = "schema.graphql";
}

if (!schemaUrl) {
console.error(
Expand Down
47 changes: 47 additions & 0 deletions __tests__/STF_05.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { expect, test } from "@playwright/test";
import {
addCurrentProductToCart,
clickOnNthProductElement,
openCart,
selectRandomAvailableVariant,
} from "./utils";

test("STF_05: Checkout as a unlogged user", async ({ page }) => {
await page.goto("/");

const product = await clickOnNthProductElement({ page, nth: 0 });
await selectRandomAvailableVariant({ page });
await addCurrentProductToCart({ page });
await openCart({ page });

await page.getByTestId("CheckoutLink").click();
await page.getByTestId("shippingAddressSection").waitFor();

await page.getByLabel("Email").pressSequentially("[email protected]", { delay: 50 });
await page.getByLabel("Country").selectOption("Poland");

await page.getByTestId("shippingAddressSection").waitFor();
await page.getByLabel("First name").pressSequentially("Jan", { delay: 50 });
await page.getByLabel("Last name").pressSequentially("Kowalski", { delay: 50 });
await page.getByLabel("Street address").first().pressSequentially("Ojcowska 23", { delay: 50 });
await page.getByRole("textbox", { name: "City" }).pressSequentially("Gdańsk", { delay: 50 });
await page.getByLabel("Postal code").pressSequentially("80-146", { delay: 50 });
await page.getByLabel("Postal code").blur();

await page.getByTestId("deliveryMethods").waitFor();
await page.getByLabel("DHL").click();
await page.getByLabel("DHL").blur();

await page.getByTestId("paymentMethods").waitFor();
const stripeIframe = page.getByTestId("paymentMethods").frameLocator("iframe");
await stripeIframe.getByLabel("Card number").fill("4242424242424242");
await stripeIframe.getByLabel("Expiration").fill("03/30");
await stripeIframe.getByLabel("CVC").fill("737");
await page.getByRole("button", { name: "Pay now" }).click();

await page.getByText("Thank you for placing your order.", { exact: false }).waitFor();

const summaryProductList = page.getByTestId("SummaryProductList");
await expect(summaryProductList.getByTestId("SummaryItem")).toHaveCount(1);
await expect(summaryProductList).toContainText(product.name);
});
13 changes: 11 additions & 2 deletions __tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ export async function clickOnRandomProductElement({ page }: { page: Page }) {
const productLinks = page.getByTestId("ProductElement");
await productLinks.first().waitFor();
const count = await productLinks.count();
const randomProductLink = productLinks.nth(Math.floor(Math.random() * count));
const nth = Math.floor(Math.random() * count);
return clickOnNthProductElement({ page, nth });
}

export async function clickOnNthProductElement({ page, nth }: { page: Page; nth: number }) {
const productLinks = page.getByTestId("ProductElement");
await productLinks.first().waitFor();
const randomProductLink = productLinks.nth(nth);

const name = await randomProductLink.getByRole("heading").textContent();
const priceRange = await randomProductLink.getByTestId("ProductElement_PriceRange").textContent();
Expand Down Expand Up @@ -43,7 +50,9 @@ export async function selectRandomAvailableVariant({ page }: { page: Page }) {
export async function addCurrentProductToCart({ page }: { page: Page }) {
expect(page.url()).toContain("/products/");
expect(page.url()).toContain("?variant=");
await page.getByRole("button", { name: "Add to cart" }).click();
const checkoutButton = page.getByRole("button", { name: "Add to cart" });
await checkoutButton.click();
await checkoutButton.isEnabled();
}

export async function openCart({ page }: { page: Page }) {
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@adyen/adyen-web": "5.53.2",
"@adyen/api-library": "14.3.0",
"@adyen/api-library": "14.4.0",
"@headlessui/react": "1.7.17",
"@saleor/auth-sdk": "0.14.0",
"@stripe/react-stripe-js": "2.3.1",
Expand All @@ -27,7 +27,7 @@
"libphonenumber-js": "1.10.49",
"lodash-es": "4.17.21",
"lucide-react": "0.292.0",
"next": "14.0.1",
"next": "14.0.2",
"query-string": "8.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -46,21 +46,21 @@
"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/client-preset": "4.1.0",
"@graphql-typed-document-node/core": "3.2.0",
"@next/env": "14.0.1",
"@next/env": "14.0.2",
"@parcel/watcher": "2.3.0",
"@playwright/test": "1.39.0",
"@tailwindcss/forms": "0.5.6",
"@tailwindcss/forms": "0.5.7",
"@tailwindcss/typography": "0.5.10",
"@types/lodash-es": "4.17.11",
"@types/node": "20.8.10",
"@types/react": "18.2.36",
"@types/react-dom": "18.2.14",
"@types/url-join": "4.0.2",
"@types/node": "20.9.0",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@types/url-join": "4.0.3",
"@typescript-eslint/eslint-plugin": "6.10.0",
"@typescript-eslint/parser": "6.10.0",
"autoprefixer": "10.4.16",
"eslint": "8.53.0",
"eslint-config-next": "14.0.1",
"eslint-config-next": "14.0.2",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-playwright": "0.18.0",
Expand All @@ -69,7 +69,8 @@
"lint-staged": "15.0.2",
"postcss": "8.4.31",
"prettier": "3.0.3",
"prettier-plugin-tailwindcss": "0.5.6",
"prettier-plugin-tailwindcss": "0.5.7",
"schema-dts": "1.1.2",
"tailwindcss": "3.3.5",
"typescript": "5.2.2",
"wonka": "6.3.4"
Expand Down
Loading

0 comments on commit 50e9725

Please sign in to comment.