Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/thick-trees-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@pushkin-templates/exp-basic": patch
"@pushkin-templates/exp-grammaticality-judgment": patch
"@pushkin-templates/exp-lexical-decision": patch
"@pushkin-templates/exp-self-paced-reading": patch
---

Fix logic error that caused the post-experiment feedback page to show the "Oops! Something went wrong" message when the percentile rank and/or summary stat values was 0, which are valid values. Now it checks for null/undefined.
10 changes: 5 additions & 5 deletions .github/workflows/welcome.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Welcome new contributors

on:
on:
workflow_dispatch:
issues:
types: [opened]
pull_request:
Expand All @@ -10,11 +11,10 @@ jobs:
write-message:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/first-interaction@main
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: |
repo_token: ${{ secrets.GITHUB_TOKEN }}
issue_message: |
👋
Thanks for opening this issue! We will investigate the matter and get back to you as soon as possible. In the meantime, double check that your issue:

Expand All @@ -29,7 +29,7 @@ jobs:
- [JavaScript Tutorial](https://www.codecademy.com/learn/introduction-to-javascript)
- [JsPsych Tutorial](https://www.jspsych.org/7.3/tutorials/hello-world/#jspsych-hello-world-experiment)

pr-message: |
pr_message: |
👋
Thanks for making this pull request! We will review it as soon as possible. In the meantime, double check that your PR:

Expand Down
21 changes: 8 additions & 13 deletions templates/experiments/basic/src/e2e/experiment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,28 +238,23 @@ test.describe("Completing the experiment in simulation mode", () => {
expect(dbUserResults.user_id).toBe(userResults.user_id);
});
test("should produce the expected results page", async ({ page }) => {
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the results page displays the loading message initially
const loadingMessage = await page.locator("h1");
await expect(loadingMessage).toHaveText("Loading...");

// Mock the API response to simulate data being available
await page.route("**/api/results", (route) =>
await page.route(`**/api/${expInfo.shortName}/getPercentileRank`, (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
resData: {
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
},
}),
}),
);

// Reload the page to trigger the API call
await page.reload();
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the correct results header is displayed
const resultsHeader = await page.locator("h1");
Expand Down
9 changes: 7 additions & 2 deletions templates/experiments/basic/src/e2e/results.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ test.describe("Results page in simulation mode", () => {
);

test.beforeEach(async ({ page }) => {
// Register listener before goto to avoid missing the response
const tabulateResponsePromise = page.waitForResponse(
`/api/${expInfo.shortName}/tabulateAndPostResults`,
);
// Go to the experiment in simulation mode
await page.goto(`/quizzes/${expInfo.shortName}?simulate=true`);

// Wait for the experiment to finish
// Wait for tabulateAndPostResults to complete so data is committed to DB
await tabulateResponsePromise;
// Wait for the experiment finish screen
await page.waitForSelector("text=Click to see your results!");
});

Expand Down
2 changes: 1 addition & 1 deletion templates/experiments/basic/src/web page/src/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ExpResults = (props) => {
);
}

if (!data.percentileRank || !data.totalRows || !data.summary_stat) {
if (data.percentileRank == null || !data.totalRows || data.summary_stat == null) {
return (
<div>
<Container className="mt-5 text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,28 +234,23 @@ test.describe("Completing the experiment in simulation mode", () => {
expect(dbUserResults.user_id).toBe(userResults.user_id);
});
test("should produce the expected results page", async ({ page }) => {
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the results page displays the loading message initially
const loadingMessage = await page.locator("h1");
await expect(loadingMessage).toHaveText("Loading...");

// Mock the API response to simulate data being available
await page.route("**/api/results", (route) =>
await page.route(`**/api/${expInfo.shortName}/getPercentileRank`, (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
resData: {
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
},
}),
}),
);

// Reload the page to trigger the API call
await page.reload();
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the correct results header is displayed
const resultsHeader = await page.locator("h1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ test.describe("Results page in simulation mode", () => {
);

test.beforeEach(async ({ page }) => {
// Register listener before goto to avoid missing the response
const tabulateResponsePromise = page.waitForResponse(
`/api/${expInfo.shortName}/tabulateAndPostResults`,
);
// Go to the experiment in simulation mode
await page.goto(`/quizzes/${expInfo.shortName}?simulate=true`);

// Wait for the experiment to finish
// Wait for tabulateAndPostResults to complete so data is committed to DB
await tabulateResponsePromise;
// Wait for the experiment finish screen
await page.waitForSelector("text=Click to see your results!");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ExpResults = (props) => {
);
}

if (!data.percentileRank || !data.totalRows || !data.summary_stat) {
if (data.percentileRank == null || !data.totalRows || data.summary_stat == null) {
return (
<div>
<Container className="mt-5 text-center">
Expand Down
21 changes: 8 additions & 13 deletions templates/experiments/lexical-decision/src/e2e/experiment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,28 +234,23 @@ test.describe("Completing the experiment in simulation mode", () => {
expect(dbUserResults.user_id).toBe(userResults.user_id);
});
test("should produce the expected results page", async ({ page }) => {
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the results page displays the loading message initially
const loadingMessage = await page.locator("h1");
await expect(loadingMessage).toHaveText("Loading...");

// Mock the API response to simulate data being available
await page.route("**/api/results", (route) =>
await page.route(`**/api/${expInfo.shortName}/getPercentileRank`, (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
resData: {
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
},
}),
}),
);

// Reload the page to trigger the API call
await page.reload();
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the correct results header is displayed
const resultsHeader = await page.locator("h1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ test.describe("Results page in simulation mode", () => {
);

test.beforeEach(async ({ page }) => {
// Register listener before goto to avoid missing the response
const tabulateResponsePromise = page.waitForResponse(
`/api/${expInfo.shortName}/tabulateAndPostResults`,
);
// Go to the experiment in simulation mode
await page.goto(`/quizzes/${expInfo.shortName}?simulate=true`);

// Wait for the experiment to finish
// Wait for tabulateAndPostResults to complete so data is committed to DB
await tabulateResponsePromise;
// Wait for the experiment finish screen
await page.waitForSelector("text=Click to see your results!");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ExpResults = (props) => {
);
}

if (!data.percentileRank || !data.totalRows || !data.summary_stat) {
if (data.percentileRank == null || !data.totalRows || data.summary_stat == null) {
return (
<div>
<Container className="mt-5 text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,28 +234,23 @@ test.describe("Completing the experiment in simulation mode", () => {
expect(dbUserResults.user_id).toBe(userResults.user_id);
});
test("should produce the expected results page", async ({ page }) => {
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the results page displays the loading message initially
const loadingMessage = await page.locator("h1");
await expect(loadingMessage).toHaveText("Loading...");

// Mock the API response to simulate data being available
await page.route("**/api/results", (route) =>
await page.route(`**/api/${expInfo.shortName}/getPercentileRank`, (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
resData: {
percentileRank: 75,
totalRows: 100,
summary_stat: 5000,
},
}),
}),
);

// Reload the page to trigger the API call
await page.reload();
// Click the link to see results
await page.click("text=Click to see your results!");

// Check that the correct results header is displayed
const resultsHeader = await page.locator("h1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ test.describe("Results page in simulation mode", () => {
);

test.beforeEach(async ({ page }) => {
// Register listener before goto to avoid missing the response
const tabulateResponsePromise = page.waitForResponse(
`/api/${expInfo.shortName}/tabulateAndPostResults`,
);
// Go to the experiment in simulation mode
await page.goto(`/quizzes/${expInfo.shortName}?simulate=true`);

// Wait for the experiment to finish
// Wait for tabulateAndPostResults to complete so data is committed to DB
await tabulateResponsePromise;
// Wait for the experiment finish screen
await page.waitForSelector("text=Click to see your results!");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ExpResults = (props) => {
);
}

if (!data.percentileRank || !data.totalRows || !data.summary_stat) {
if (data.percentileRank == null || !data.totalRows || data.summary_stat == null) {
return (
<div>
<Container className="mt-5 text-center">
Expand Down
Loading