Skip to content

Commit

Permalink
test: add play function to item-show-correct-response story for inter…
Browse files Browse the repository at this point in the history
…action validation
  • Loading branch information
Marcelh1983 committed Feb 12, 2025
1 parent 351e6f8 commit a8928ba
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,32 @@ export const GraphicOrder: Story = {
</item-container>
<item-show-correct-response></item-show-correct-response>
</div>
</qti-item>`
</qti-item>`,
play: async ({ canvasElement, step }) => {
// wait for qti-simple-choices to be rendered
const canvas = within(canvasElement);
await waitFor(
() => {
const interaction = canvasElement
.querySelector('item-container')
.shadowRoot.querySelector('qti-graphic-order-interaction');
if (!interaction) {
throw new Error('interaction not loaded yet');
}
},
{ timeout: 5000 }
);
const itemContainer = canvasElement.querySelector('item-container');
const interaction = itemContainer.shadowRoot.querySelector('qti-graphic-order-interaction');
const showCorrectButton = canvas.getAllByShadowText(/Show correct/i)[0];
await step('Click on the Show Correct button', async () => {
await showCorrectButton.click();
const hotspotChoice = interaction.querySelectorAll('qti-hotspot-choice');
// const get after content
expect(window.getComputedStyle(hotspotChoice[0], ':after').content).toBe('"C=1"');
expect(window.getComputedStyle(hotspotChoice[1], ':after').content).toBe('"C=4"');
expect(window.getComputedStyle(hotspotChoice[2], ':after').content).toBe('"C=2"');
expect(window.getComputedStyle(hotspotChoice[3], ':after').content).toBe('"C=3"');
});
}
};

0 comments on commit a8928ba

Please sign in to comment.