From 8e3f6a419241a4fa0925b8fe29e8de090c94a16c Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Thu, 15 Feb 2024 11:35:57 -0500 Subject: [PATCH] chore(e2e): add logging to debug failing test --- .github/workflows/e2e.yml | 9 +++++++++ test/e2e/tests/inputs/text.spec.ts | 29 +++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 77a7c6a67d9..9ecd071f0b1 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -214,6 +214,15 @@ jobs: name: playwright-report path: blob-report retention-days: 30 + + # Upload tracing reports + - uses: actions/upload-artifact@v3 + if: always() + with: + name: ${{ matrix.project }}-test-report + path: test/e2e/results + retention-days: 30 + merge-reports: if: always() needs: [playwright-test] diff --git a/test/e2e/tests/inputs/text.spec.ts b/test/e2e/tests/inputs/text.spec.ts index 20146ff2775..c6dd1547c4f 100644 --- a/test/e2e/tests/inputs/text.spec.ts +++ b/test/e2e/tests/inputs/text.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /* eslint-disable max-nested-callbacks */ /** * TODO: This need to refactored once we have a better e2e framework/setup in place. @@ -6,6 +7,8 @@ import {expect} from '@playwright/test' import {test} from '@sanity/test' +console.log('has session token:', typeof process.env.SANITY_E2E_SESSION_TOKEN) + const kanji = ` 速ヒマヤレ誌相ルなあね日諸せ変評ホ真攻同潔ク作先た員勝どそ際接レゅ自17浅ッ実情スヤ籍認ス重力務鳥の。8平はートご多乗12青國暮整ル通国うれけこ能新ロコラハ元横ミ休探ミソ梓批ざょにね薬展むい本隣ば禁抗ワアミ部真えくト提知週むすほ。査ル人形ルおじつ政謙減セヲモ読見れレぞえ録精てざ定第ぐゆとス務接産ヤ写馬エモス聞氏サヘマ有午ごね客岡ヘロ修彩枝雨父のけリド。 @@ -16,12 +19,30 @@ test.describe('inputs: text', () => { test.slow() // Because of waiting for mutations, remote values etc test('correctly applies kanji edits', async ({page, sanityClient, createDraftDocument}) => { + console.log('has session token in the test:', typeof process.env.SANITY_E2E_SESSION_TOKEN) const documentId = await createDraftDocument('/test/content/input-ci;textsTest') - function getRemoteValue() { - return sanityClient - .getDocument(`drafts.${documentId}`) - .then((doc) => (doc ? doc.simple : null)) + async function getRemoteValue() { + console.log( + 'has session token in the getRemoteValue:', + typeof process.env.SANITY_E2E_SESSION_TOKEN, + ) + try { + const docs = await sanityClient.fetch(`*[_type == $type] { _id, _type, simple }`, { + type: 'textsTest', + }) + + // eslint-disable-next-line no-console + console.log('docs', JSON.stringify(docs, null, 2)) + const doc = await sanityClient.getDocument(`drafts.${documentId}`) + + // eslint-disable-next-line no-console + console.log('doc', `drafts.${documentId}`, doc) + return doc ? doc.simple : null + } catch (err) { + console.error('Error fetching remote value', err) + return null + } } await page.waitForSelector('data-testid=field-simple', {timeout: 30000})