Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test to verify template updated data
  • Loading branch information
BrunoQuaresma committed Apr 30, 2024
commit 65a2a2d00ab4cc4f6e63aaee2c4bee8e2f2344e8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from "@playwright/test";
import { beforeCoderTest } from "../hooks";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(({ page }) => beforeCoderTest(page));

Expand Down
45 changes: 45 additions & 0 deletions site/e2e/tests/templates/updateTemplateSchedule.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { expect, test } from "@playwright/test";
import { createTemplate, createTemplateVersion, getTemplate } from "api/api";
import { getCurrentOrgId, setupApiCalls } from "../../api";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(({ page }) => beforeCoderTest(page));

test("update template schedule settings without override other settings", async ({
page,
baseURL,
}) => {
await setupApiCalls(page);
const orgId = await getCurrentOrgId();
const templateVersion = await createTemplateVersion(orgId, {
storage_method: "file" as const,
provisioner: "echo",
user_variable_values: [],
example_id: "docker",
tags: {},
});
const template = await createTemplate(orgId, {
name: "test-template",
display_name: "Test Template",
template_version_id: templateVersion.id,
disable_everyone_group_access: false,
require_active_version: true,
});

await page.goto(`${baseURL}/templates/${template.name}/settings/schedule`, {
waitUntil: "domcontentloaded",
});
await page.getByLabel("Default autostop (hours)").fill("48");
await page.getByRole("button", { name: "Submit" }).click();
await expect(page.getByText("Template updated successfully")).toBeVisible();

const updatedTemplate = await getTemplate(template.id);
// Validate that the template data remains consistent, with the exception of
// the 'default_ttl_ms' field (updated during the test) and the 'updated at'
// field (automatically updated by the backend).
expect({
...template,
default_ttl_ms: 48 * 60 * 60 * 1000,
updated_at: updatedTemplate.updated_at,
}).toStrictEqual(updatedTemplate);
});