Skip to content

Commit

Permalink
e2e test and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Oct 11, 2023
1 parent b336ac6 commit ae6b549
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/static/src/app/localStorageManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UserPreferences} from "./store/appState/state";
import { UserPreferences } from "./store/appState/state";

class LocalStorageManager {
static _sessionIdsKey = (appName: string, basePath: string) => {
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/store/appState/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppConfig } from "../../types/responseTypes";
import { CodeMutation } from "../code/mutations";
import { RunMutation } from "../run/mutations";
import { ModelAction } from "../model/actions";
import {AppState, AppType, UserPreferences} from "./state";
import { AppState, AppType, UserPreferences } from "./state";
import { AppStateMutation } from "./mutations";
import { serialiseState } from "../../serialise";
import { FitState } from "../fit/state";
Expand Down
21 changes: 14 additions & 7 deletions app/static/tests/e2e/sessions.etest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Page
} from "@playwright/test";
import * as os from "os";
import * as fs from "fs";
import {
writeCode,
newFitCode,
Expand All @@ -29,10 +30,9 @@ test.describe("Sessions tests", () => {
test("can use Sessions page", async () => {
// We need to use a browser with persistent context instead of the default incognito browser so that
// we can use the session ids in local storage
const userDataDir = os.tmpdir();
const userDataDir = fs.mkdtempSync(`${os.tmpdir()}/`);
const browser = await chromium.launchPersistentContext(userDataDir);
const page = await browser.newPage();

await page.goto(appUrl);

// change code in this session, which we will later reload and check that we can see the code changes
Expand Down Expand Up @@ -95,7 +95,7 @@ test.describe("Sessions tests", () => {
await expect(await page.innerText(":nth-match(.session-col-header, 5)")).toBe("Delete");
await expect(await page.innerText(":nth-match(.session-col-header, 6)")).toBe("Shareable Link");

await expect(await page.innerText(".session-label")).toBe("--no label--");
await expect(await page.locator(".session-label")).toHaveText("--no label--");

// Can copy code and link for a session
await page.click(":nth-match(.session-copy-code, 2)");
Expand All @@ -116,15 +116,22 @@ test.describe("Sessions tests", () => {
await enterSessionLabel(page, "header-edit-session-label", "current session label");
await expect(await page.innerText("#sessions-menu")).toBe("Session: current session label");

// Toggle 'Show unlabelled sessions' - all historic sessions should be filtered out
const unlabelledCount = await page.locator(".previous-session-row").count();
await expect(unlabelledCount).toBeGreaterThan(0);
await page.click("input#show-unlabelled-check");
await expect(await page.locator(".previous-session-row")).toHaveCount(0);
await page.click("input#show-unlabelled-check");
await expect(await page.locator(".previous-session-row")).toHaveCount(unlabelledCount);

// Set the current session label on a previous session
await page.click(":nth-match(.session-edit-label i, 2)");
await page.click(":nth-match(.session-edit-label i, 1)");
await enterSessionLabel(page, "page-edit-session-label", "previous session label");
await expect(await page.locator(":nth-match(.session-label, 2)")).toHaveText(
await expect(await page.locator(":nth-match(.session-label, 1)")).toHaveText(
"previous session label", { timeout }
);

// NB this will load the second load link, i.e. the older session, not the current one
await page.click(":nth-match(.session-load a, 3)"); // 3rd because there are two of these on the current
await page.click(":nth-match(.session-load a, 1)");

// Check all session values have been rehydrated:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("SessionsPage", () => {
const currentSessionId = "abc";

const getWrapper = (sessionsMetadata: SessionMetadata[] | null, sessionId: string | undefined,
showUnlabelledSessions = true) => {
showUnlabelledSessions = true) => {
const store = new Vuex.Store<BasicState>({
state: mockBasicState({
appName: "testApp",
Expand Down Expand Up @@ -390,4 +390,3 @@ describe("SessionsPage", () => {
expect((wrapper.find("input#show-unlabelled-check").element as HTMLInputElement).checked).toBe(false);
});
});

0 comments on commit ae6b549

Please sign in to comment.