Skip to content
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
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: Continuous Integration

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
environment: ["AI", "MAIN"]

steps:
- uses: actions/checkout@v4
- name: Set up Node.js
Expand All @@ -20,11 +25,23 @@ jobs:
run: |
cd packages/ui
npm install
- name: Set environment variables
run: |
if [ "${{ matrix.environment }}" == "AI" ]; then
echo "SERVER_HOST=${{ vars.SERVER_HOST_AI }}" >> $GITHUB_ENV
echo "SERVER_PID=${{ vars.SERVER_PID_AI }}" >> $GITHUB_ENV
echo "SERVER_TOKEN=${{ secrets.SERVER_TOKEN_AI }}" >> $GITHUB_ENV
elif [ "${{ matrix.environment }}" == "MAIN" ]; then
echo "SERVER_HOST=${{ vars.SERVER_HOST_MAIN }}" >> $GITHUB_ENV
echo "SERVER_PID=${{ vars.SERVER_PID_MAIN }}" >> $GITHUB_ENV
echo "SERVER_TOKEN=${{ secrets.SERVER_TOKEN_MAIN }}" >> $GITHUB_ENV
fi
echo "SERVER_UID=${{ vars.SERVER_UID }}" >> $GITHUB_ENV
- name: Start server
run: |
cd packages/ui/test/plugin
npm install
node server.js -sh https://eye.projectalita.ai -spid 1396 -muid 596884aa-fc90-4e19-8de0-8ef90fa5a9b6 -st eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ1dWlkIjoiOTJkNmRjM2MtNTRmNi00NWI0LWFhM2MtNGNiZjM0MjkzMWFlIiwiZXhwaXJlcyI6IjIwMjUtMDEtMTVUMTQ6NTAifQ.N-wISbLTwvd89-mvqqdxlbNrFJj9CvM3KgmH58idf44OIe9wl1xt_7GzWCpgpOgjKlASdsjLKiQy4gIHCVVvMg &
node server.js -sh $SERVER_HOST -spid $SERVER_PID -muid $SERVER_UID -st $SERVER_TOKEN &
- name: Start chat/webpack run
run: |
cd packages/ui
Expand Down
52 changes: 50 additions & 2 deletions packages/ui/test/ui_test/po/chat.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default class ChatPage {
this.messageField = page.locator('textarea#standard-multiline-static');
this.sendButton = page.locator('button[data-testid="SendButton"]');
this.chatArea = page.locator('.MuiList-root');
this.chatAreaUserMessage = page.locator('ul li:nth-child(1)>div:nth-child(2)');
this.chatAreaAnswer = page.locator('.MuiList-root > li:nth-child(2) > div:nth-child(2) span');
this.chatAreaPromptResult = page.locator('ul li div>p[style="margin-block-start: 0px;"]:nth-child(1)');
this.chatAreaPromptResult = page.locator('ul li:nth-child(2)>div:nth-child(2)');
this.refreshButton = page.locator('[data-testid="RefreshOutlinedIcon"]');
this.scrollDownArrow = page.locator('[data-testid="KeyboardDoubleArrowDownOutlinedIcon"]');
this.cleanChatButton = page.locator('[data-testid="ClearTheChatButton"]');
Expand All @@ -21,6 +22,14 @@ export default class ChatPage {
this.chosenPromptName = page.locator('//button[@data-testid="SettingsButton"]/preceding-sibling::span');
this.serverError = page.locator('#webpack-dev-server-client-overlay');
this.alertError = page.locator('svg[data-testid="ErrorOutlineIcon"]');
this.alertMessageIsCopied = page.locator('div.MuiAlert-root');
this.tooltip = page.locator('.MuiTooltip-tooltip');
this.alertToDeleteMsgTitle = page.locator('#alert-dialog-title');
this.alertToDeleteMsgContent = page.locator('#alert-dialog-description');
this.alertToDeleteMsgBtnCancel = page.locator('div[aria-describedby="alert-dialog-description"] button:nth-child(1)');
this.alertToDeleteMsgBtnConfirm = page.locator('div[aria-describedby="alert-dialog-description"] button:nth-child(2)');
this.copyMsgBtn = page.locator('[aria-label="Copy to clipboard"]');
this.deleteMsgBtn = page.locator('[aria-label="Delete"]');
}

async openChat() {
Expand Down Expand Up @@ -54,7 +63,8 @@ export default class ChatPage {
}

async changePromptModalVariable(index, inputText) {
await this.promptModalVariable.nth(index).type(inputText);
await this.promptModalVariable.nth(index).fill('');
await this.promptModalVariable.nth(index).fill(inputText);
}

async applyPrompt() {
Expand All @@ -72,6 +82,10 @@ export default class ChatPage {
await expect(this.promptModalHeader).toBeVisible();
}

async verifyPromptModalClosed() {
await expect(this.promptModalHeader).not.toBeVisible();
}

async sendMessage() {
await this.sendButton.click();
await this.page.waitForTimeout(500)
Expand Down Expand Up @@ -108,4 +122,38 @@ export default class ChatPage {
throw new Error('Error alert is displayed.');
}
}

async verifyDeleteMessageBtnAndClick(tooltipText) {
await this.chatAreaPromptResult.waitFor();
await this.chatAreaPromptResult.hover();
await this.deleteMsgBtn.hover();
await expect(this.tooltip).toHaveText(tooltipText);
await this.deleteMsgBtn.click();
}

async checkDeleteMessageAlertComponents(alertText) {
await this.alertToDeleteMsgTitle.waitFor();
await expect(this.alertToDeleteMsgTitle).toHaveText('Warning');
await expect(this.alertToDeleteMsgContent).toHaveText(alertText);
await expect(this.alertToDeleteMsgBtnCancel).toHaveText('Cancel');
await expect(this.alertToDeleteMsgBtnConfirm).toHaveText('Confirm');
}

async confirmDeleteMessage() {
await this.alertToDeleteMsgBtnConfirm.click();
}

async verifyMessageIsDeleted() {
await expect(this.chatAreaPromptResult).not.toBeVisible();
}

async verifyChatIsCleaned() {
await expect(this.chatAreaUserMessage).not.toBeVisible();
await expect(this.chatAreaPromptResult).not.toBeVisible();
}

async clickCleanChatBtn() {
await this.chatAreaAnswer.waitFor();
await this.cleanChatButton.click();
}
}
26 changes: 26 additions & 0 deletions packages/ui/test/ui_test/tests/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ test.describe('UI tests', () => {
await chatPage.applyPrompt();
await chatPage.verifyChosenPrompt('Test Cases Generator');
await chatPage.verifySettingsOpenPromptModal();
await chatPage.changePromptModalVariable(0,'The project is an online learning platform aimed at delivering interactive courses to users.' +
'It features user registration, course management, progress tracking, and certificate generation.');
await chatPage.applyPrompt();
await chatPage.verifyPromptModalClosed();
await chatPage.verifyChosenPrompt('Test Cases Generator');
});

test('Verify user can choose prompt and receive result', async ({ page }) => {
Expand All @@ -85,4 +89,26 @@ test.describe('UI tests', () => {
await chatPage.sendMessage();
await chatPage.verifyChatPromptResultExists();
});

test('Verify user can delete one answer', async ({ page }) => {
const chatPage = new ChatPage(page);
await chatPage.openChat();
await chatPage.typeInMessageField('start');
await chatPage.sendMessage();
await chatPage.verifyDeleteMessageBtnAndClick('Delete');
await chatPage.checkDeleteMessageAlertComponents(`The deleted message can't be restored. Are you sure to delete the message?`);
await chatPage.confirmDeleteMessage();
await chatPage.verifyMessageIsDeleted();
});

test('Verify user can clean the chat', async ({ page }) => {
const chatPage = new ChatPage(page);
await chatPage.openChat();
await chatPage.typeInMessageField('start');
await chatPage.sendMessage();
await chatPage.clickCleanChatBtn();
await chatPage.checkDeleteMessageAlertComponents(`The deleted messages can't be restored. Are you sure to delete all the messages?`);
await chatPage.confirmDeleteMessage();
await chatPage.verifyChatIsCleaned();
});
});
Loading