Skip to content

Commit

Permalink
chore(e2e): add logging to debug failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Feb 15, 2024
1 parent 656bec2 commit 8e3f6a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
29 changes: 25 additions & 4 deletions test/e2e/tests/inputs/text.spec.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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青國暮整ル通国うれけこ能新ロコラハ元横ミ休探ミソ梓批ざょにね薬展むい本隣ば禁抗ワアミ部真えくト提知週むすほ。査ル人形ルおじつ政謙減セヲモ読見れレぞえ録精てざ定第ぐゆとス務接産ヤ写馬エモス聞氏サヘマ有午ごね客岡ヘロ修彩枝雨父のけリド。
Expand All @@ -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})
Expand Down

0 comments on commit 8e3f6a4

Please sign in to comment.