-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<main> | ||
<div> | ||
<div class="prompt-card json"> | ||
<div> | ||
<div>Json</div> | ||
<div>https://www.adobe.com/dc-shared/promptcard.json</div> | ||
</div> | ||
<div> | ||
<div>Prefix</div> | ||
<div>Analyze</div> | ||
</div> | ||
<div> | ||
<div>Rows</div> | ||
<div>1</div> | ||
</div> | ||
</div> | ||
<div class="section-metadata"> | ||
<div> | ||
<div>style</div> | ||
<div>Four up, xl-spacing</div> | ||
</div> | ||
<div> | ||
<div>background</div> | ||
<div>#f8f8f8</div> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<main> | ||
<div> | ||
<div class="prompt-card json"> | ||
<div> | ||
<div>Json</div> | ||
<div>https://www.adobe.com/dc-shared/promptcard.json</div> | ||
</div> | ||
<div> | ||
<div>Rows</div> | ||
<div>1</div> | ||
</div> | ||
</div> | ||
<div class="section-metadata"> | ||
<div> | ||
<div>style</div> | ||
<div>Four up, xl-spacing</div> | ||
</div> | ||
<div> | ||
<div>background</div> | ||
<div>#f8f8f8</div> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
|
30 changes: 30 additions & 0 deletions
30
test/blocks/prompt-card/prompt-card-json-more-less.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable compat/compat */ | ||
import { readFile } from '@web/test-runner-commands'; | ||
import { expect } from '@esm-bundle/chai'; | ||
import sinon from 'sinon'; | ||
import { waitForElement, delay } from '../../helpers/waitfor.js'; | ||
|
||
describe('prompt-cards view all feature', () => { | ||
before(async () => { | ||
const promptcards = await readFile({ path: './mocks/promptcards.json' }); | ||
sinon.stub(window, 'fetch'); | ||
const res = new window.Response(promptcards, { status: 200 }); | ||
window.fetch.returns(Promise.resolve(res)); | ||
document.head.innerHTML = await readFile({ path: './mocks/head.html' }); | ||
document.body.innerHTML = await readFile({ path: './mocks/body-json-more-less.html' }); | ||
await import('../../../acrobat/scripts/scripts.js'); | ||
await delay(500); | ||
await new Promise((resolve) => requestAnimationFrame(resolve)); | ||
}); | ||
|
||
after(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
it('has no a view-all button if no more items', () => { | ||
const promptcards = document.querySelectorAll('.prompt-card:not(.hidden)'); | ||
expect([...promptcards].length).to.equal(2); | ||
const button = document.querySelector('.view-all .con-button'); | ||
expect(button).to.not.exist; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable compat/compat */ | ||
import { readFile } from '@web/test-runner-commands'; | ||
import { expect } from '@esm-bundle/chai'; | ||
import sinon from 'sinon'; | ||
import { waitForElement, delay } from '../../helpers/waitfor.js'; | ||
|
||
describe('prompt-cards view all feature', () => { | ||
before(async () => { | ||
const promptcards = await readFile({ path: './mocks/promptcards.json' }); | ||
sinon.stub(window, 'fetch'); | ||
const res = new window.Response(promptcards, { status: 200 }); | ||
window.fetch.returns(Promise.resolve(res)); | ||
document.head.innerHTML = await readFile({ path: './mocks/head.html' }); | ||
document.body.innerHTML = await readFile({ path: './mocks/body-json-more.html' }); | ||
await import('../../../acrobat/scripts/scripts.js'); | ||
await delay(500); | ||
await new Promise((resolve) => requestAnimationFrame(resolve)); | ||
}); | ||
|
||
after(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
it('creates prompt cards on rows 1 with a view-all button', async () => { | ||
const promptcards = document.querySelectorAll('.prompt-card:not(.hidden)'); | ||
expect([...promptcards].length).to.equal(2); | ||
}); | ||
|
||
it('click the view-all button', () => { | ||
const button = document.querySelector('.view-all .con-button'); | ||
button.click(); | ||
const promptcards = document.querySelectorAll('.prompt-card:not(.hidden)'); | ||
expect([...promptcards].length).to.equal(6); | ||
const hiddencards = document.querySelectorAll('.hidden'); | ||
expect([...hiddencards].length).to.equal(0); | ||
expect(document.querySelector('.view-all .con-button')).to.not.exist; | ||
}); | ||
}); |