Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For detailed API documentation, please select the version of the documentation y

- 🧍 Person - Generate Names, Genders, Bios, Job titles, and more.
- 📍 Location - Generate Addresses, Zip Codes, Street Names, States, and Countries!
- Date - Past, present, future, recent, soon... whenever!
- 🗓️ Date - Past, present, future, recent, soon... whenever!
- 💸 Finance - Create stubbed out Account Details, Transactions, and Crypto Addresses.
- 👠 Commerce - Generate Prices, Product Names, Adjectives, and Descriptions.
- 👾 Hacker - “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
Expand Down
52 changes: 30 additions & 22 deletions cypress/e2e/example-refresh.cy.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
describe('example-refresh', () => {
it('should refresh the example', () => {
it('should refresh the example content on click', () => {
// given
cy.visit('/api/faker.html#constructor');
cy.get('.refresh').first().as('refresh');
cy.get('@refresh').next().find('code').as('codeBlock');
cy.get('@codeBlock').then(($el) => {
const originalCodeText = $el.text();

// Create aliases for reuse to keep selectors clean
cy.get('.refresh').first().as('refreshBtn');
cy.get('@refreshBtn').next().find('code').as('codeBlock');

cy.get('@refresh')
// Capture the initial text
cy.get('@codeBlock').invoke('text').then((text1) => {

// Act: First Click
cy.get('@refreshBtn')
.click()
.should('not.be.disabled') // stays disabled on error
.then(() => {
cy.get('@codeBlock').then(($el) => {
const newCodeText = $el.text();
expect(newCodeText).not.to.equal(originalCodeText);
.should('not.be.disabled'); // Wait for button to be interactive again

cy.get('@refresh')
.click()
.should('not.be.disabled') // stays disabled on error
.then(() => {
cy.get('@codeBlock').then(($el) => {
const newCodeText2 = $el.text();
expect(newCodeText2).not.to.equal(originalCodeText);
expect(newCodeText2).not.to.equal(newCodeText);
});
});
});
// Assert: Validate change (using .should allows Cypress to retry if update lags)
cy.get('@codeBlock').should(($el) => {
const text2 = $el.text();
expect(text2).to.not.equal(text1);
}).then(($el) => {
// Capture text2 specifically for the next comparison
const text2 = $el.text();

// Act: Second Click
cy.get('@refreshBtn')
.click()
.should('not.be.disabled');

// Assert: Validate change against BOTH previous states
cy.get('@codeBlock').should(($el) => {
const text3 = $el.text();
expect(text3).to.not.equal(text1);
expect(text3).to.not.equal(text2);
});
});
});
});
});
Loading