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

Test sm update command #1252

Merged
merged 2 commits into from
Dec 27, 2023
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
15 changes: 14 additions & 1 deletion playwright/pages/ChangelogPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,20 @@ export class ChangelogPage extends SliceMachinePage {
/**
* Dynamic locators
*/
// Handle dynamic locators here
getUpdateCommand(args: {
packageManager: string;
adapterName: string;
version: string;
}) {
const { packageManager, adapterName, version } = args;
let updateCommand;
if (packageManager == "yarn") {
updateCommand = `yarn add --dev slice-machine-ui@${version} ${adapterName}@${version}`;
} else {
updateCommand = `npm install --save-dev slice-machine-ui@${version} ${adapterName}@${version}`;
}
return this.body.getByText(updateCommand, { exact: true });
}

/**
* Actions
Expand Down
60 changes: 60 additions & 0 deletions playwright/tests/changelog/changelog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,64 @@ test.describe("Changelog", () => {
await expect(changelogPage.breakingChangesWarning).not.toBeVisible();
},
);

test.run()(
"I can see the yarn latest update command",
async ({ changelogPage, procedures }) => {
const packageManager = "yarn";
const adapterName = "@slicemachine/adapter-next";
procedures.mock("project.getAdapterName", () => adapterName, {
execute: false,
});
procedures.mock("getState", ({ data }) => ({
...(data as Record<string, unknown>),
env: {
...((data as Record<string, unknown>)["env"] as Record<
string,
unknown
>),
packageManager,
},
}));

await changelogPage.goto();
await expect(
changelogPage.getUpdateCommand({
packageManager,
adapterName,
version: "latest",
}),
).toBeVisible();
},
);

test.run()(
"I can see the npm latest update command",
async ({ changelogPage, procedures }) => {
const packageManager = "npm";
const adapterName = "@slicemachine/adapter-next";
procedures.mock("project.getAdapterName", () => adapterName, {
execute: false,
});
procedures.mock("getState", ({ data }) => ({
...(data as Record<string, unknown>),
env: {
...((data as Record<string, unknown>)["env"] as Record<
string,
unknown
>),
packageManager,
},
}));

await changelogPage.goto();
await expect(
changelogPage.getUpdateCommand({
packageManager,
adapterName,
version: "latest",
}),
).toBeVisible();
},
);
});
Loading