Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
kiminus committed Jun 6, 2024
1 parent 5ff7a66 commit 4e9fd31
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: npm install --save-dev puppeteer
run: npm install --save-dev puppeteer jest
- name: '[E2E test] project cards'
run: npm test ./__tests__/ProjectCard.E2E.test.js --runInBand
- name: '[E2E test] contacts'
run: npm test ./__tests__/Contacts.E2E.test.js --runInBand
linting:
name: Linting # job name (unique id)
runs-on: ubuntu-latest # on which machine to run
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Contacts.E2E.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Unit test: contact management', () => {
});
page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.goto('http://127.0.0.1:5501/');
await page.goto('https://cse110-sp24-group31.github.io/Dev-Journal/');
// Click the "Contacts" link
await page.click('.nav-links a:nth-child(1)');
});
Expand Down
32 changes: 24 additions & 8 deletions __tests__/ProjectCard.E2E.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const puppeteer = require('puppeteer');

/**
* E2E test, focus on class interactions
* MAKE SURE USE: npm test ProjectCard.E2E.test.js --runInBand
Expand Down Expand Up @@ -48,6 +50,18 @@ describe('E2E test: create project card workflow', () => {
it('should have a submit button', async () => {
submitBtnHandle = await addProjectCardModalHandle.$('#submitButton');
expect(submitBtnHandle).not.toBe(null);

//button should be visible
const buttonVisible = await page.waitForSelector('#submitButton', {
visible: true,
});
expect(buttonVisible).not.toBe(null);

const buttonNotDisabled = await page.$eval(
'#submitButton',
el => el.getAttribute('disabled') === null
);
expect(buttonNotDisabled).toBe(true);
});

it('should not accept empty submission', async () => {
Expand Down Expand Up @@ -106,27 +120,29 @@ describe('E2E test: create project card workflow', () => {
)
).toBe(TEST_CASE[2]);

submitBtnHandle = await page.waitForSelector('#submitButton', {
visible: true,
});
await submitBtnHandle.click();
await page.click('#submitButton');

const isHidden = await page.$eval('#addCardModal', modal => {
return window.getComputedStyle(modal).display;
});
expect(isHidden).toBe('none');
}, 20000);

afterAll(async () => {
await page.waitForSelector('project-card');
});
});

//TODO: edit and update project card workflow
describe('E2E test: updateCard(title, desc, imgURL, progress)', () => {
beforeAll(async () => {
await page.goto('https://cse110-sp24-group31.github.io/Dev-Journal/'); //change this for live server
}, 20000);
let projectCardHandle;
});
it('should have a card', async () => {
projectCardHandle = await page.$('project-card');
expect(projectCardHandle).not.toBe(null);
const pcIsNull = await page.$eval('project-card', ele => {
return ele === null;
});
expect(pcIsNull).toBe(false);
});
it('should be same', async () => {
//arrange
Expand Down

0 comments on commit 4e9fd31

Please sign in to comment.