Some checks failed
ci / ci (22, ubuntu-latest) (push) Failing after 6m46s
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { Given, When, Then, Before } from '@cucumber/cucumber';
|
|
import { expect } from 'vitest';
|
|
import { usePageTitle } from '../../app/composables/usePageTitle';
|
|
|
|
// Store the composable instance
|
|
let pageTitleInstance: ReturnType<typeof usePageTitle>;
|
|
let userInstances: Map<string, ReturnType<typeof usePageTitle>>;
|
|
|
|
Before(function () {
|
|
// Reset before each scenario
|
|
userInstances = new Map();
|
|
});
|
|
|
|
Given('the page title system is initialized', function () {
|
|
pageTitleInstance = usePageTitle();
|
|
// Reset to default state
|
|
pageTitleInstance.setPageName('');
|
|
});
|
|
|
|
When('I first load the application', function () {
|
|
pageTitleInstance = usePageTitle();
|
|
});
|
|
|
|
When('I navigate to the {string} page', function (pageName: string) {
|
|
if (!pageTitleInstance) {
|
|
pageTitleInstance = usePageTitle();
|
|
}
|
|
pageTitleInstance.setPageName(pageName);
|
|
});
|
|
|
|
When('I clear the page name', function () {
|
|
pageTitleInstance.setPageName('');
|
|
});
|
|
|
|
Given('I am on the {string} page', function (pageName: string) {
|
|
if (!pageTitleInstance) {
|
|
pageTitleInstance = usePageTitle();
|
|
}
|
|
pageTitleInstance.setPageName(pageName);
|
|
});
|
|
|
|
Given('the page title is {string}', function (expectedTitle: string) {
|
|
expect(pageTitleInstance.title.value).toBe(expectedTitle);
|
|
});
|
|
|
|
Given('user {string} sets the page name to {string}', function (userName: string, pageName: string) {
|
|
let userInstance = userInstances.get(userName);
|
|
if (!userInstance) {
|
|
userInstance = usePageTitle();
|
|
userInstances.set(userName, userInstance);
|
|
}
|
|
userInstance.setPageName(pageName);
|
|
});
|
|
|
|
When('user {string} checks the page title', function (userName: string) {
|
|
let userInstance = userInstances.get(userName);
|
|
if (!userInstance) {
|
|
userInstance = usePageTitle();
|
|
userInstances.set(userName, userInstance);
|
|
}
|
|
// Just store the instance, we'll check in Then step
|
|
});
|
|
|
|
Then('the page title should be {string}', function (expectedTitle: string) {
|
|
expect(pageTitleInstance.title.value).toBe(expectedTitle);
|
|
});
|
|
|
|
Then('user {string} should see {string}', function (userName: string, expectedTitle: string) {
|
|
const userInstance = userInstances.get(userName);
|
|
expect(userInstance).toBeDefined();
|
|
expect(userInstance!.title.value).toBe(expectedTitle);
|
|
});
|