This commit is contained in:
38
cypress/e2e/spec.cy.ts
Normal file
38
cypress/e2e/spec.cy.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
describe('WeChat Moments Generator', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
it('should render the home page', () => {
|
||||
cy.contains('朋友圈神器');
|
||||
cy.get('input[placeholder*="名字"]').should('be.visible');
|
||||
cy.contains('立即生成').should('be.visible');
|
||||
});
|
||||
|
||||
it('should require name input', () => {
|
||||
cy.contains('立即生成').click();
|
||||
cy.contains('请输入姓名').should('be.visible');
|
||||
});
|
||||
|
||||
// Mock API for full test
|
||||
it('should generate copy (mocked)', () => {
|
||||
cy.intercept('POST', '**/chat/completions', {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
choices: [{ message: { content: 'Mocked Result' } }]
|
||||
}
|
||||
}).as('generateAPI');
|
||||
|
||||
cy.get('input[placeholder*="名字"]').type('TestUser');
|
||||
cy.contains('立即生成').click();
|
||||
|
||||
cy.wait('@generateAPI');
|
||||
cy.contains('Mocked Result').should('be.visible');
|
||||
});
|
||||
|
||||
it('should navigate to admin login', () => {
|
||||
cy.contains('Admin Login').click();
|
||||
cy.url().should('include', '/login');
|
||||
cy.contains('管理员登录').should('be.visible');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user