import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';

import { describe, expect, it } from 'vitest';

function readViewSource(relativePath: string) {
  return readFileSync(resolve('app/src/views', relativePath), 'utf8');
}

describe('detail return navigation', () => {
  it.each([
    ['execHistory/details/index.vue', '/execHistory'],
    ['assistantMarket/assistant/index.vue', '/assistantMarket'],
  ])('returns %s to its fixed parent list', (relativePath, parentPath) => {
    const source = readViewSource(relativePath);

    expect(source).not.toMatch(/router\.(?:back|go)\s*\(/);
    expect(source).toContain(`path: '${parentPath}'`);
  });
});
