-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from MarcusT96/cypress-jonte
Cypress jonte
- Loading branch information
Showing
9 changed files
with
4,625 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Test and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
cypress_tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Start the server | ||
run: nohup npm run start & | ||
|
||
- name: Wait for server to be ready | ||
run: sleep 30 # Adjust the sleep time as needed | ||
|
||
- name: Install Cypress dependencies | ||
run: npm install cypress | ||
|
||
- name: Run Cypress | ||
uses: cypress-io/github-action@v4 | ||
with: | ||
build: npm run build # If you have a build step | ||
start: npm start # Your start command | ||
wait-on: http://localhost:3000 # Adjust to your server URL | ||
|
||
deploy: | ||
needs: cypress_tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Doing a deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USER }} | ||
password: ${{ secrets.PASSWORD }} | ||
port: ${{ secrets.PORT }} | ||
script: | | ||
cd /var/www/MystyrIncAuctions | ||
git pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Feature: Flip order of auctionboxes | ||
|
||
Scenario: Flip the order of auctionboxes | ||
Given that I am on the auctionpage | ||
When I click on Sortera Sjunkande | ||
Then the boxes should be in descending order | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Go to Auctionboxes | ||
|
||
Scenario: Go from Homepage to Auctionboxes | ||
Given that I am on the "/" page | ||
When I click on Auktioner | ||
Then I am on the Auctionboxes page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: Search function | ||
Scenario: Search for auctionboxes | ||
Given that I am on the auctionpage | ||
When I search for "<searchTerm>" | ||
Then I should see "<searchTerm>" in aktiva Auktioner | ||
|
||
|
||
Examples: | ||
| searchTerm | | ||
| poke | | ||
| indossa | | ||
| mystery | | ||
| bergen | | ||
| destination | | ||
| okänd | | ||
| Guld | | ||
| Smak | | ||
| skatt | | ||
| Bergens | | ||
| Box | | ||
| Gåva | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Given, When, Then } from "@badeball/cypress-cucumber-preprocessor"; | ||
|
||
|
||
|
||
|
||
When('I click on Sortera Sjunkande', () => { | ||
// Simulate user clicking the sorting button several times | ||
// This assumes that clicking the button cycles through different sort orders or criteria | ||
const clicks = 6; // Number of times to click the button, adjust as necessary | ||
for (let i = 0; i < clicks; i++) { | ||
cy.get('button.sorting').click(); | ||
} | ||
|
||
// Selecting sorting criteria from a dropdown | ||
// Ensure the text matches exactly with the options available in the dropdown | ||
cy.get('select.sorting').select('Tid kvar'); // Assumes 'Tid kvar' sorts by remaining time | ||
cy.get('button.sorting').click(); | ||
cy.get('select.sorting').select('Namn'); // Assumes 'Namn' sorts by name in descending order | ||
cy.get('button.sorting').click(); | ||
}); | ||
|
||
Then('the boxes should be in descending order', () => { | ||
// Check that the auction titles are in descending order | ||
cy.get('.auction-title') | ||
.then($titles => { | ||
const titles = $titles.map((i, el) => Cypress.$(el).text().trim()).get(); | ||
|
||
// Ensure the titles are sorted descending by comparing each title with the next | ||
const isSortedDescending = titles.every((val, i, arr) => i === 0 || arr[i - 1] >= val); | ||
expect(isSortedDescending).to.be.false; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Given, When, Then } from "@badeball/cypress-cucumber-preprocessor"; | ||
|
||
Given('that I am on the {string} page', (url) => { | ||
cy.visit(url, {headers: { "Accept-Encoding":'gzip, deflate' }}) | ||
cy.wait(1000) | ||
|
||
}); | ||
|
||
When('I click on Auktioner', () => { | ||
cy.get('.app__navbar-links > .p__opensans').contains('Auktioner').click(); | ||
}); | ||
|
||
Then('I am on the Auctionboxes page', () => { | ||
cy.url().should('include', '/auctions') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Given, When, Then } from "@badeball/cypress-cucumber-preprocessor"; | ||
|
||
Given('that I am on the auctionpage', () => { | ||
cy.visit("/auctions", { headers: { "Accept-Encoding": 'gzip, deflate' } }) | ||
cy.wait(1000) | ||
}); | ||
|
||
When('I search for {string}', (searchTerm) => { | ||
cy.get('.auction-search').type(searchTerm); | ||
cy.log(`Searching for: ${searchTerm}`); | ||
}); | ||
|
||
Then('I should see {string} in aktiva Auktioner', (searchTerm) => { | ||
cy.get('.Auction-list').should('be.visible') | ||
cy.get('h3.auction-title').should('be.visible'); | ||
cy.log(`Expected to see: ${searchTerm}`); | ||
}); |
Oops, something went wrong.