Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make run button functional #25

Merged
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7d9c378
WIP 2: things related to post-form-submit, ie api and store
david-mears-2 Sep 3, 2024
02be36f
WIP. We dont have unit tests on the wip api endpoint + handler
david-mears-2 Sep 3, 2024
d1d4f9c
Remove store-related code
david-mears-2 Sep 4, 2024
7b146ba
test playwright ci
david-mears-2 Sep 4, 2024
52b12eb
Switch to using query params instead of body
david-mears-2 Sep 4, 2024
bcb53f2
Tests
david-mears-2 Sep 5, 2024
7434c9d
Refactor: Use pinia store for largeScreen refs
david-mears-2 Sep 5, 2024
782a8db
Update e2e test
david-mears-2 Sep 6, 2024
f45d8e9
remove comment
david-mears-2 Sep 6, 2024
12b7581
Try to improve playwright test
david-mears-2 Sep 6, 2024
8c0c4f5
Address PR comments
david-mears-2 Sep 10, 2024
0906bca
Use body instead of query for req's to run scenario
david-mears-2 Sep 10, 2024
0966d2b
Temporary change to allow web app to be compatible with latest r api
david-mears-2 Sep 10, 2024
143063c
Update e2e test to match latest R API build
david-mears-2 Sep 10, 2024
fbb2a05
Address PR comments
david-mears-2 Sep 10, 2024
2a03920
Use JSON data for request bodies instead of FormData
david-mears-2 Sep 12, 2024
67ba34d
fix integration tests
M-Kusumgar Sep 12, 2024
c3a4d8e
Merge pull request #30 from jameel-institute/jidea-57-non-country-inp…
david-mears-2 Sep 12, 2024
fbc712e
test changes
EmmaLRussell Sep 13, 2024
93ca120
parse body in test
EmmaLRussell Sep 13, 2024
501d92a
Merge pull request #33 from jameel-institute/jidea-57-mock-navigateTo-2
david-mears-2 Sep 13, 2024
d84c44c
Merge branch 'main' into jidea-57-non-country-inputs-rebasing-onto-fr…
david-mears-2 Sep 13, 2024
3e43583
Update e2e test to use real test run ids
david-mears-2 Sep 13, 2024
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
Prev Previous commit
Next Next commit
Update e2e test to match latest R API build
david-mears-2 committed Sep 10, 2024
commit 143063c5b4399dfb8df22556febe1654f15e7d93
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ export default defineConfig({
webServer: {
command: "npm run build && cd .output && node ./server/index.mjs",
url: "http://127.0.0.1:3000",
timeout: 120 * 1000,
timeout: 30 * 1000,
reuseExistingServer: true,
stdout: "pipe", // Debugging
},
4 changes: 2 additions & 2 deletions tests/e2e/runAnalysis.spec.ts
Original file line number Diff line number Diff line change
@@ -10,12 +10,12 @@ test("Can request a scenario analysis run", async ({ page, baseURL }) => {
await page.waitForURL(`${baseURL}/scenarios/new`);

await expect(page.getByText("Simulate a new scenario")).toBeVisible();
await expect(page.getByRole("form")).toBeVisible({ timeout: 30000 });
await expect(page.getByRole("form")).toBeVisible();

await page.selectOption('select[id="pathogen"]', { label: "Influenza 1957" });
await page.selectOption('select[id="response"]', { label: "Elimination" });
await page.selectOption('select[id="country"]', { label: "United States" });
await page.click('div[aria-label="Advance vaccine investment"] label[for="low"]');
await page.click('div[aria-label="Global vaccine investment"] label[for="low"]');

await expect(page.getByRole("form")).toHaveAttribute("data-test-form-data", "{\"country\":\"United States\",\"pathogen\":\"influenza-1957\",\"response\":\"elimination\",\"vaccine\":\"low\"}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be resorting to hidden attribute tests in e2e tests of forms - we should just be able to look at the values of the inputs.

Copy link
Contributor Author

@david-mears-2 david-mears-2 Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can be confident that the values of the inputs are what we just selected. I think the test to do for the e2e would be to wait until the result page is implemented, and test that the displayed parameters are correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hang on, that doesn't look like the line (I thought) this was a comment for anymore, I'm pretty sure this was about the stringified JSON - or I thought it was!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks like it's commenting on the stringified JSON to me!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm just blind as a 🦇



Unchanged files with check annotations Beta

formSubmitting.value = true;
const response = await $fetch<NewScenarioData>("/api/scenarios", {
method: "POST",
body: formDataObject,

Check warning on line 147 in components/ParameterForm.vue

Codecov / codecov/patch

components/ParameterForm.vue#L147

Added line #L147 was not covered by tests
}).catch((error: FetchError) => {
console.error(error);
});
};
onMounted(() => {
pageMounted.value = true;

Check warning on line 160 in components/ParameterForm.vue

Codecov / codecov/patch

components/ParameterForm.vue#L160

Added line #L160 was not covered by tests
});
</script>
}
};
onMounted(() => {
setScreenSize();

Check warning on line 42 in layouts/default.vue

Codecov / codecov/patch

layouts/default.vue#L41-L42

Added lines #L41 - L42 were not covered by tests
window.addEventListener("resize", setScreenSize);
});
onBeforeUnmount(() => {
import { runScenario } from "@/server/handlers/scenarios";
import { defineRApiEventHandler } from "@/server/utils/defineRApiEventHandler";
import { formDataToObject } from "@/server/utils/helpers";

Check warning on line 3 in server/api/scenarios.post.ts

Codecov / codecov/patch

server/api/scenarios.post.ts#L2-L3

Added lines #L2 - L3 were not covered by tests
import type { NewScenarioResponse } from "@/types/apiResponseTypes";
export default defineRApiEventHandler(
async (event): Promise<NewScenarioResponse> => {
const formDataBody = await readFormData(event);
const newScenarioResponse = await runScenario(formDataToObject(formDataBody), event);
return newScenarioResponse;
},
);

Check warning on line 12 in server/api/scenarios.post.ts

Codecov / codecov/patch

server/api/scenarios.post.ts#L6-L12

Added lines #L6 - L12 were not covered by tests
export interface AppState {
largeScreen: boolean
};

Check warning on line 3 in types/storeTypes.ts

Codecov / codecov/patch

types/storeTypes.ts#L3

Added line #L3 was not covered by tests